fix 校验参数

V0.5.x
jay 2024-06-14 14:26:10 +08:00
parent 4f9a91712d
commit 2d71b0126b
10 changed files with 71 additions and 13 deletions

View File

@ -29,6 +29,7 @@ import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup; import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.common.validate.QueryGroup;
import cc.iotkit.manager.dto.bo.category.CategoryBo; import cc.iotkit.manager.dto.bo.category.CategoryBo;
import cc.iotkit.manager.dto.bo.product.IconBo; import cc.iotkit.manager.dto.bo.product.IconBo;
import cc.iotkit.manager.dto.bo.product.IconTypeBo; import cc.iotkit.manager.dto.bo.product.IconTypeBo;
@ -67,7 +68,7 @@ public class ProductController {
@ApiOperation("列表") @ApiOperation("列表")
@SaCheckPermission("iot:product:query") @SaCheckPermission("iot:product:query")
@PostMapping("/list") @PostMapping("/list")
public Paging<ProductVo> getProducts(@Validated @RequestBody public Paging<ProductVo> getProducts(@Validated(QueryGroup.class) @RequestBody
PageRequest<ProductBo> request) { PageRequest<ProductBo> request) {
return productService.selectPageList(request); return productService.selectPageList(request);
} }

View File

@ -69,7 +69,6 @@ public class DeviceQueryBo extends BaseDto {
@ApiModelProperty(value="设备状态") @ApiModelProperty(value="设备状态")
@Size(max = 255, message = "设备状态长度不正确")
@AutoMapping(ignore = true) @AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true) @ReverseAutoMapping(ignore = true)
private Boolean online; private Boolean online;

View File

@ -43,15 +43,12 @@ public class DeviceGroupBo extends BaseDto {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@ApiModelProperty(value = "分组id") @ApiModelProperty(value = "分组id")
@NotNull(message = "分组id不能为空")
private String id; private String id;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@NotNull(message = "创建时间不能为空")
private Long createAt; private Long createAt;
@ApiModelProperty(value = "设备数量") @ApiModelProperty(value = "设备数量")
@NotNull(message = "设备数量不能为空")
private Integer deviceQty; private Integer deviceQty;
@ApiModelProperty(value = "设备组名称") @ApiModelProperty(value = "设备组名称")

View File

@ -24,12 +24,16 @@
package cc.iotkit.manager.dto.bo.product; package cc.iotkit.manager.dto.bo.product;
import cc.iotkit.common.api.BaseDto; import cc.iotkit.common.api.BaseDto;
import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.model.product.Product; import cc.iotkit.model.product.Product;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -70,7 +74,6 @@ public class ProductBo extends BaseDto {
private Integer nodeType; private Integer nodeType;
@ApiModelProperty(value = "是否透传,true/false") @ApiModelProperty(value = "是否透传,true/false")
@Size(max = 255, message = "是否透传,true/false长度不正确")
private Boolean transparent; private Boolean transparent;
@ApiModelProperty(value = "是否开启设备定位,true/false") @ApiModelProperty(value = "是否开启设备定位,true/false")
@ -88,7 +91,7 @@ public class ProductBo extends BaseDto {
private String productSecret; private String productSecret;
@ApiModelProperty(value = "保活时长") @ApiModelProperty(value = "保活时长")
@NotBlank(message = "保活时长不能为空") @NotNull(message = "保活时长不能为空",groups = { AddGroup.class, EditGroup.class })
@Min(value = 10, message = "保活时长(秒)必须大于10") @Min(value = 10, message = "保活时长(秒)必须大于10")
private Long keepAliveTime; private Long keepAliveTime;

View File

@ -0,0 +1,52 @@
/*
*
* * | Licensed OPENIITA
* * +----------------------------------------------------------------------
* * | Author: xw2sy@163.com
* * +----------------------------------------------------------------------
*
* Copyright [2024] [OPENIITA]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/
package cc.iotkit.manager.dto.bo.product;
import cc.iotkit.common.api.BaseDto;
import cc.iotkit.model.product.Product;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Size;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ProductBo.class, reverseConvertGenerate = false)
public class ProductListReqBo extends BaseDto {
private static final long serialVersionUID = -1L;
@ApiModelProperty(value = "productKey")
private String productKey;
@ApiModelProperty(value = "产品名称")
@Size(max = 255, message = "产品名称长度不正确")
private String name;
}

View File

@ -30,6 +30,8 @@ import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping; import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -49,7 +51,7 @@ public class ThingModelBo extends BaseDto {
private String model; private String model;
@ApiModelProperty(value = "产品key") @ApiModelProperty(value = "产品key")
@Size(min = 16, max = 16, message = "产品key长度不正确") @NotBlank(message = "产品Key不许为空")
private String productKey; private String productKey;
} }

View File

@ -29,6 +29,7 @@ import cc.iotkit.common.constant.UserConstants;
import cc.iotkit.common.log.annotation.Log; import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.validate.QueryGroup;
import cc.iotkit.common.web.core.BaseController; import cc.iotkit.common.web.core.BaseController;
import cc.iotkit.system.dto.bo.SysDeptBo; import cc.iotkit.system.dto.bo.SysDeptBo;
import cc.iotkit.system.dto.vo.SysDeptVo; import cc.iotkit.system.dto.vo.SysDeptVo;
@ -64,7 +65,7 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:list") @SaCheckPermission("system:dept:list")
@ApiOperation("获取部门列表") @ApiOperation("获取部门列表")
@PostMapping("/list") @PostMapping("/list")
public List<SysDeptVo> list(@RequestBody @Validated PageRequest<SysDeptBo> dept) { public List<SysDeptVo> list(@RequestBody @Validated(QueryGroup.class) PageRequest<SysDeptBo> dept) {
return deptService.selectDeptList(dept.getData()); return deptService.selectDeptList(dept.getData());
} }

View File

@ -67,7 +67,7 @@ public class SysDeptBo extends BaseDto {
/** /**
* *
*/ */
@NotNull(message = "显示顺序不能为空") @NotNull(message = "显示顺序不能为空", groups = { AddGroup.class, EditGroup.class })
private Integer orderNum; private Integer orderNum;
/** /**
@ -84,7 +84,7 @@ public class SysDeptBo extends BaseDto {
/** /**
* *
*/ */
@Email(message = "邮箱格式不正确") // @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符")
private String email; private String email;

View File

@ -83,7 +83,7 @@ public class SysUserBo extends BaseDto {
/** /**
* *
*/ */
@Email(message = "邮箱格式不正确") // @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符")
private String email; private String email;

View File

@ -26,6 +26,9 @@ package cc.iotkit.system.dto.bo;
import cc.iotkit.common.api.BaseDto; import cc.iotkit.common.api.BaseDto;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -55,7 +58,7 @@ public class SysUserProfileBo extends BaseDto {
/** /**
* *
*/ */
@Email(message = "邮箱格式不正确") // @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符")
private String email; private String email;