创建管理员时,头像无法存储问题处理

This commit is contained in:
Chopper 2021-09-29 14:52:27 +08:00
parent 50c08c0e01
commit 95095f35c0
3 changed files with 17 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
/**
@ -21,18 +22,22 @@ public class AdminUser extends BaseEntity {
private static final long serialVersionUID = 2918352800205024873L;
@ApiModelProperty(value = "用户名")
@Length(max = 20,message = "用户名长度不能超过20个字符")
private String username;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "昵称")
@Length(max = 10,message = "昵称长度不能超过10个字符")
private String nickName;
@ApiModelProperty(value = "手机")
@Length(max = 11,message = "手机号长度不能超过11")
private String mobile;
@ApiModelProperty(value = "邮件")
@Length(max = 100,message = "又想长度不能超过100")
private String email;
@ApiModelProperty(value = "用户头像")

View File

@ -4,6 +4,7 @@ import cn.lili.mybatis.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
@ -19,23 +20,29 @@ public class AdminUserDTO extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "用户名")
@NotEmpty(message = "用户名不能为空")
@Length(max = 20,message = "用户名长度不能超过20个字符")
private String username;
@NotEmpty(message = "密码不能为空")
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "昵称")
@Length(max = 10,message = "昵称长度不能超过10个字符")
private String nickName;
@ApiModelProperty(value = "手机")
@Length(max = 11,message = "手机号长度不能超过11")
private String mobile;
@ApiModelProperty(value = "邮件")
@Length(max = 100,message = "又想长度不能超过100")
private String email;
@ApiModelProperty(value = "头像")
private String avatar;
@ApiModelProperty(value = "描述/详情/备注")
private String description;

View File

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
@ -110,7 +111,7 @@ public class AdminUserManagerController {
@PutMapping(value = "/admin/edit")
@ApiOperation(value = "超级管理员修改其他管理员资料")
@DemoSite
public ResultMessage<Object> edit(AdminUser adminUser,
public ResultMessage<Object> edit(@Valid AdminUser adminUser,
@RequestParam(required = false) List<String> roles) {
if (!adminUserService.updateAdminUser(adminUser, roles)) {
throw new ServiceException(ResultCode.USER_EDIT_ERROR);
@ -154,7 +155,7 @@ public class AdminUserManagerController {
@PostMapping
@ApiOperation(value = "添加用户")
public ResultMessage<Object> register(AdminUserDTO adminUser,
public ResultMessage<Object> register(@Valid AdminUserDTO adminUser,
@RequestParam(required = false) List<String> roles) {
int rolesMaxSize=10;
try {