chore: 【ops】工单基础Controller
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
package com.viewsh.module.ops.controller.admin;
|
||||
|
||||
import com.viewsh.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import com.viewsh.framework.common.pojo.CommonResult;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.framework.common.util.object.BeanUtils;
|
||||
import com.viewsh.module.ops.dal.dataobject.dto.*;
|
||||
import com.viewsh.module.ops.dal.dataobject.workorder.OpsOrderDO;
|
||||
import com.viewsh.module.ops.enums.OperatorTypeEnum;
|
||||
import com.viewsh.module.ops.service.order.OpsOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static com.viewsh.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 管理后台 - 工单 Controller
|
||||
*
|
||||
* @author lzh
|
||||
*/
|
||||
@Tag(name = "管理后台 - 工单管理")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/ops/order")
|
||||
@Validated
|
||||
public class OpsOrderController {
|
||||
|
||||
@Resource
|
||||
private OpsOrderService opsOrderService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工单")
|
||||
@Parameter(name = "createReq", description = "创建请求", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:create')")
|
||||
public CommonResult<Long> createOrder(@Valid @RequestBody OpsOrderCreateReqDTO createReq) {
|
||||
Long orderId = opsOrderService.createOrder(createReq);
|
||||
return success(orderId);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新工单")
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:update')")
|
||||
public CommonResult<Boolean> updateOrder(@Valid @RequestBody OpsOrderUpdateReqDTO updateReq) {
|
||||
opsOrderService.updateOrder(updateReq);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除工单")
|
||||
@Parameter(name = "id", description = "工单ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:delete')")
|
||||
public CommonResult<Boolean> deleteOrder(@RequestParam("id") Long id) {
|
||||
opsOrderService.deleteOrder(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得工单详情")
|
||||
@Parameter(name = "id", description = "工单ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:query')")
|
||||
public CommonResult<OpsOrderRespDTO> getOrder(@RequestParam("id") Long id) {
|
||||
OpsOrderDO order = opsOrderService.getOrder(id);
|
||||
return success(BeanUtils.toBean(order, OpsOrderRespDTO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得工单分页")
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:query')")
|
||||
public CommonResult<PageResult<OpsOrderRespDTO>> getOrderPage(@Valid OpsOrderPageReqDTO pageReq) {
|
||||
PageResult<OpsOrderDO> pageResult = opsOrderService.getOrderPage(pageReq);
|
||||
return success(BeanUtils.toBean(pageResult, OpsOrderRespDTO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/assign")
|
||||
@Operation(summary = "分配工单")
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:assign')")
|
||||
public CommonResult<Boolean> assignOrder(@Valid @RequestBody OpsOrderAssignReqDTO assignReq) {
|
||||
opsOrderService.assignOrder(assignReq, OperatorTypeEnum.ADMIN, null);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/accept")
|
||||
@Operation(summary = "接单")
|
||||
@Parameter(name = "orderId", description = "工单ID", required = true)
|
||||
@Parameter(name = "userId", description = "保洁员ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:accept')")
|
||||
public CommonResult<Boolean> acceptOrder(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam("userId") Long userId) {
|
||||
opsOrderService.acceptOrder(orderId, userId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/complete")
|
||||
@Operation(summary = "完成工单")
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:complete')")
|
||||
public CommonResult<Boolean> completeOrder(@Valid @RequestBody OpsOrderCompleteReqDTO completeReq,
|
||||
@Parameter(description = "执行人ID") @RequestParam("userId") Long userId) {
|
||||
opsOrderService.completeOrder(completeReq, userId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/pause")
|
||||
@Operation(summary = "暂停工单")
|
||||
@Parameter(name = "orderId", description = "工单ID", required = true)
|
||||
@Parameter(name = "userId", description = "保洁员ID", required = true)
|
||||
@Parameter(name = "reason", description = "暂停原因", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:pause')")
|
||||
public CommonResult<Boolean> pauseOrder(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam("userId") Long userId,
|
||||
@RequestParam("reason") String reason) {
|
||||
opsOrderService.pauseOrder(orderId, userId, reason);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/resume")
|
||||
@Operation(summary = "恢复工单")
|
||||
@Parameter(name = "orderId", description = "工单ID", required = true)
|
||||
@Parameter(name = "userId", description = "保洁员ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:resume')")
|
||||
public CommonResult<Boolean> resumeOrder(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam("userId") Long userId) {
|
||||
opsOrderService.resumeOrder(orderId, userId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/cancel")
|
||||
@Operation(summary = "取消工单")
|
||||
@Parameter(name = "id", description = "工单ID", required = true)
|
||||
@Parameter(name = "reason", description = "取消原因", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ops:order:cancel')")
|
||||
public CommonResult<Boolean> cancelOrder(@RequestParam("id") Long id,
|
||||
@RequestParam("reason") String reason) {
|
||||
opsOrderService.cancelOrder(id, reason, OperatorTypeEnum.ADMIN, null);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user