Skip to content

Commit

Permalink
创建管理员时,头像无法存储问题处理
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed Sep 29, 2021
1 parent 50c08c0 commit 95095f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;


/**
Expand All @@ -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 = "用户头像")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;

Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;

Expand Down Expand Up @@ -110,7 +111,7 @@ public ResultMessage<Object> editOwner(AdminUser adminUser) {
@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);
Expand Down Expand Up @@ -154,7 +155,7 @@ public ResultMessage<IPage<AdminUserVO>> getByCondition(AdminUserDTO user,

@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 {
Expand Down

0 comments on commit 95095f3

Please sign in to comment.