Commit ed10449a authored by chenwj's avatar chenwj

对Dapp实体类的Dapp名称长度做限制

parent e603a319
package com.roo.dto; package com.roo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.roo.commons.tools.utils.DateUtils;
import com.roo.commons.tools.validator.group.DefaultGroup;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -20,6 +27,7 @@ public class DappsDTO implements Serializable { ...@@ -20,6 +27,7 @@ public class DappsDTO implements Serializable {
private Long id; private Long id;
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
@Size(min = 1, max = 10, message = "dapps.name.length must be less than or equal to 10 and greater than 0")
private String name; private String name;
@ApiModelProperty(value = "图标") @ApiModelProperty(value = "图标")
private String icon; private String icon;
...@@ -32,12 +40,15 @@ public class DappsDTO implements Serializable { ...@@ -32,12 +40,15 @@ public class DappsDTO implements Serializable {
@ApiModelProperty(value = "dapp所属链") @ApiModelProperty(value = "dapp所属链")
private String chain; private String chain;
@ApiModelProperty(value = "dapp介绍") @ApiModelProperty(value = "dapp介绍")
@Size(max = 255, message = "dapps.discription.length must be less than or equal to 255")
private String discription; private String discription;
@ApiModelProperty(value = "是否显示(show、hide)") @ApiModelProperty(value = "是否显示(show、hide)")
private String display; private String display;
@ApiModelProperty(value = "排序(排序,最小靠前)") @ApiModelProperty(value = "排序(排序,最小靠前)")
private Integer sort; private Integer sort;
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
@ApiModelProperty(value = "收录时间") @ApiModelProperty(value = "收录时间")
private Date createTime; private Date createTime;
} }
\ No newline at end of file
package com.roo.service; package com.roo.service;
import com.roo.commons.tools.page.PageData; import com.roo.commons.tools.page.PageData;
import com.roo.commons.tools.validator.ValidatorUtils;
import com.roo.commons.tools.validator.group.AddGroup;
import com.roo.commons.tools.validator.group.DefaultGroup;
import com.roo.dto.*; import com.roo.dto.*;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -124,4 +127,16 @@ public class AllServiceTest { ...@@ -124,4 +127,16 @@ public class AllServiceTest {
PageData<TokenDTO> page = tokenService.page(params); PageData<TokenDTO> page = tokenService.page(params);
logger.info("total:{}", page.getTotal()); logger.info("total:{}", page.getTotal());
} }
@Test
public void testValidate(){
DappsDTO dto = new DappsDTO();
dto.setChain("BSC");
dto.setDiscription("AAA");
dto.setDisplay("show");
dto.setHots(1);
dto.setType("DEX");
dto.setName("qq");
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment