fix(ops): 取消工单接口改用 @RequestBody 接收 JSON 参数
前端以 JSON body 传参,@RequestParam 无法读取导致 400 "请求参数缺失"。 新增 OpsOrderCancelReqDTO,Controller 改为 @RequestBody 风格, 与 create/assign/complete 等接口保持一致。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.viewsh.module.ops.dal.dataobject.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 工单取消请求 DTO
|
||||
*
|
||||
* @author lzh
|
||||
*/
|
||||
@Schema(description = "管理后台 - 工单取消 Request DTO")
|
||||
@Data
|
||||
public class OpsOrderCancelReqDTO {
|
||||
|
||||
@Schema(description = "工单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
|
||||
@NotNull(message = "工单ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "取消原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "客户要求取消")
|
||||
@NotBlank(message = "取消原因不能为空")
|
||||
private String reason;
|
||||
|
||||
}
|
||||
@@ -132,12 +132,9 @@ public class OpsOrderController {
|
||||
|
||||
@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);
|
||||
public CommonResult<Boolean> cancelOrder(@Valid @RequestBody OpsOrderCancelReqDTO cancelReq) {
|
||||
opsOrderService.cancelOrder(cancelReq.getId(), cancelReq.getReason(), OperatorTypeEnum.ADMIN, null);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user