系统管理-标签设计、机台管理接口入参检查完善

This commit is contained in:
gaoqr
2024-10-16 11:08:31 +08:00
parent e73eca6762
commit 94908e01eb
14 changed files with 101 additions and 13 deletions
@@ -1,6 +1,5 @@
package com.cf.imes.module.system.controller.admin.auth.vo; package com.cf.imes.module.system.controller.admin.auth.vo;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.validation.InEnum; import com.cf.imes.framework.common.validation.InEnum;
import com.cf.imes.module.system.enums.social.SocialTypeEnum; import com.cf.imes.module.system.enums.social.SocialTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@@ -33,9 +32,6 @@ public class AuthLoginReqVO {
@NotEmpty(message = "密码不能为空") @NotEmpty(message = "密码不能为空")
private String password; private String password;
@Schema(description = "组织名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰科技")
private String organName;
// ========== 图片验证码相关 ========== // ========== 图片验证码相关 ==========
@Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED, @Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED,
@@ -1,22 +1,28 @@
package com.cf.imes.module.system.controller.admin.dept.vo.post; package com.cf.imes.module.system.controller.admin.dept.vo.post;
import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 岗位分页 Request VO") @Schema(description = "管理后台 - 岗位分页 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class PostPageReqVO extends PageParam { public class PostPageReqVO extends PageParam {
@Schema(description = "岗位编码,模糊匹配", example = "chenfeng") @Schema(description = "岗位编码,模糊匹配", example = "chenfeng")
@Size(max = 64, message = "岗位编码长度不能超过64个字符")
private String code; private String code;
@Schema(description = "岗位名称,模糊匹配", example = "晨丰") @Schema(description = "岗位名称,模糊匹配", example = "晨丰")
@Size(max = 50, message = "岗位名称长度不能超过50个字符")
private String name; private String name;
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1") @Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
@CommonStatus
private Integer status; private Integer status;
private Long organId; private Long organId;
@@ -1,7 +1,6 @@
package com.cf.imes.module.system.controller.admin.dept.vo.post; package com.cf.imes.module.system.controller.admin.dept.vo.post;
import com.cf.imes.framework.common.enums.CommonStatusEnum; import com.cf.imes.module.system.validation.common.CommonStatus;
import com.cf.imes.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -31,10 +30,11 @@ public class PostSaveReqVO {
private Integer sort; private Integer sort;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@InEnum(CommonStatusEnum.class) @CommonStatus
private Integer status; private Integer status;
@Schema(description = "备注", example = "快乐的备注") @Schema(description = "备注", example = "快乐的备注")
@Size(max = 256, message = "备注长度不能超过256个字符")
private String remark; private String remark;
} }
@@ -12,6 +12,7 @@ import com.cf.imes.module.system.controller.admin.label.vo.LabelRespVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO; import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO; import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
import com.cf.imes.module.system.service.lable.LabelService; import com.cf.imes.module.system.service.lable.LabelService;
import com.cf.imes.module.system.validation.label.LabelTemplateTypeValid;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -87,7 +88,7 @@ public class LabelController {
@Parameter(name = "type", description = "类型", required = false, example = "1024") @Parameter(name = "type", description = "类型", required = false, example = "1024")
//@PreAuthorize("@ss.hasPermission('system:label:query')") //@PreAuthorize("@ss.hasPermission('system:label:query')")
@OperateLog(enable = false) @OperateLog(enable = false)
public CommonResult<List<LabelRespVO>> getList(@RequestParam("type") String type) { public CommonResult<List<LabelRespVO>> getList(@RequestParam("type") @LabelTemplateTypeValid String type) {
return success(BeanUtils.toBean(labelService.list(type), LabelRespVO.class)); return success(BeanUtils.toBean(labelService.list(type), LabelRespVO.class));
} }
@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -18,12 +19,15 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
public class LabelPageReqVO extends PageParam { public class LabelPageReqVO extends PageParam {
@Schema(description = "标签类型", example = "2") @Schema(description = "标签类型", example = "2")
@Size(max = 32, message = "标签类型长度不能超过32个字符")
private String type; private String type;
@Schema(description = "标签名称", example = "王五") @Schema(description = "标签名称", example = "王五")
@Size(max = 50, message = "标签名称长度不能超过50个字符")
private String name; private String name;
@Schema(description = "备注", example = "你猜") @Schema(description = "备注", example = "你猜")
@Size(max = 255, message = "备注长度不能超过255个字符")
private String remark; private String remark;
@Schema(description = "宽度") @Schema(description = "宽度")
@@ -1,12 +1,11 @@
package com.cf.imes.module.system.controller.admin.label.vo; package com.cf.imes.module.system.controller.admin.label.vo;
import co.elastic.clients.elasticsearch.watcher.DeactivateWatchRequest;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 标签模板新增/修改 Request VO") @Schema(description = "管理后台 - 标签模板新增/修改 Request VO")
@Data @Data
@@ -17,14 +16,17 @@ public class LabelSaveReqVO {
@Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "标签类型不能为空") @NotNull(message = "标签类型不能为空")
@Size(max = 32, message = "标签类型长度不能超过32个字符")
private String type; private String type;
@Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "标签名称不能为空") @NotEmpty(message = "标签名称不能为空")
@Size(max = 50, message = "标签名称长度不能超过50个字符")
private String name; private String name;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@NotEmpty(message = "备注不能为空") @NotEmpty(message = "备注不能为空")
@Size(max = 255, message = "备注长度不能超过255个字符")
private String remark; private String remark;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -10,6 +10,7 @@ import com.cf.imes.module.system.controller.admin.machine.vo.*;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO; import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
import com.cf.imes.module.system.service.machine.MachineService; import com.cf.imes.module.system.service.machine.MachineService;
import com.cf.imes.module.system.service.machine.MachineTemplateService; import com.cf.imes.module.system.service.machine.MachineTemplateService;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@@ -119,7 +120,7 @@ public class MachineController {
@GetMapping("getBrandAndModel") @GetMapping("getBrandAndModel")
@Operation(summary = "获得机台的品牌跟型号") @Operation(summary = "获得机台的品牌跟型号")
//@PreAuthorize("@ss.hasPermission('machine::query')") //@PreAuthorize("@ss.hasPermission('machine::query')")
public CommonResult<List<MachineBrandModelRespVO>> getBrandAndModel(@RequestParam Integer type) { public CommonResult<List<MachineBrandModelRespVO>> getBrandAndModel(@RequestParam @MachineTypeValid Integer type) {
return success(machineService.getBrandAndModel(type)); return success(machineService.getBrandAndModel(type));
} }
@@ -2,11 +2,13 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.es.core.valid.UpdateGroup; import com.cf.imes.framework.es.core.valid.UpdateGroup;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/** /**
* @author there * @author there
@@ -21,10 +23,12 @@ public class CuttingSaveReqVO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "名称不能为空") @NotEmpty(message = "名称不能为空")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name; private String name;
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空") @NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType; private Integer machineType;
@Schema(description = "标签id") @Schema(description = "标签id")
@@ -2,11 +2,13 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.es.core.valid.UpdateGroup; import com.cf.imes.framework.es.core.valid.UpdateGroup;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/** /**
* @author there * @author there
@@ -19,10 +21,12 @@ public class CuttingTemplateSaveReqVO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "名称不能为空") @NotEmpty(message = "名称不能为空")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name; private String name;
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空") @NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType; private Integer machineType;
@@ -1,10 +1,12 @@
package com.cf.imes.module.system.controller.admin.machine.vo; package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import lombok.*; import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -16,9 +18,11 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
public class MachinePageReqVO extends PageParam { public class MachinePageReqVO extends PageParam {
@Schema(description = "名称", example = "王五") @Schema(description = "名称", example = "王五")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name; private String name;
@Schema(description = "1机台设备 2CNC设备", example = "2") @Schema(description = "1机台设备 2CNC设备", example = "2")
@MachineTypeValid
private Integer machineType; private Integer machineType;
@Schema(description = "创建时间") @Schema(description = "创建时间")
@@ -1,10 +1,12 @@
package com.cf.imes.module.system.controller.admin.machine.vo; package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
@Data @Data
@@ -16,6 +18,7 @@ public class MachineTemplateBrandReqVO {
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空") @NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType; private Integer machineType;
@Schema(description = "机台的品牌ID") @Schema(description = "机台的品牌ID")
@@ -24,6 +27,7 @@ public class MachineTemplateBrandReqVO {
@Schema(description = "机台的品牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "机台的品牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "品牌名称不能为空") @NotNull(message = "品牌名称不能为空")
@Size(max = 64, message = "品牌名称长度不能超过64个字符")
private String brand; private String brand;
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.controller.admin.machine.vo; package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -10,10 +11,11 @@ import lombok.Data;
@Data @Data
public class OrganMachinePage extends PageParam { public class OrganMachinePage extends PageParam {
@Schema(description = "组织名称") @Schema(description = "组织编号")
private Long organId; private Long organId;
@Schema(description = "组织状态(0正常 1停用)") @Schema(description = "组织状态(0正常 1停用)")
@CommonStatus
private Integer status; private Integer status;
} }
@@ -0,0 +1,32 @@
package com.cf.imes.module.system.validation.machine;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 机台类型校验注解
*
* @author Gqr
* @since 2024/10/16 10:20
*/
@Target({
ElementType.PARAMETER,
ElementType.FIELD,
})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(
validatedBy = {MachineTypeValidator.class}
)
public @interface MachineTypeValid {
String message() default "机台类型类型不合法";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,28 @@
package com.cf.imes.module.system.validation.machine;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.MachineTypeEnum;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 机台类型校验器
*
* @author Gqr
* @since 2024/10/16 10:21
*/
public class MachineTypeValidator implements ConstraintValidator<MachineTypeValid, Integer> {
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
if (ObjectUtil.isNull(value)) {
return true;
}
for (MachineTypeEnum typeEnum : MachineTypeEnum.values()) {
if (ObjectUtil.equal(typeEnum.getType(), value)) {
return true;
}
}
return false;
}
}