feat:check userName and password (#955)

pull/956/head
WuLang 2 years ago committed by GitHub
parent fcf719ce1a
commit cf5613b80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -44,6 +44,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
</dependency>
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>

@ -19,23 +19,28 @@ package cn.hippo4j.auth.model.biz.user;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
/** /**
* User req dto. * User req dto.
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class UserReqDTO extends Page { public class UserReqDTO extends Page {
/** /**
* userName * userName
*/ */
@Length(max = 64, message = "用户名最长为64个字符")
private String userName; private String userName;
/** /**
* password * password
*/ */
@Length(min = 6, message = "密码最少为6个字符")
private String password; private String password;
/** /**

@ -29,6 +29,7 @@ import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results; import cn.hippo4j.common.web.base.Results;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -74,7 +75,7 @@ public class UserController {
} }
@PostMapping("/add") @PostMapping("/add")
public Result<Void> addUser(@RequestBody UserReqDTO reqDTO) { public Result<Void> addUser(@Validated @RequestBody UserReqDTO reqDTO) {
userService.addUser(reqDTO); userService.addUser(reqDTO);
return Results.success(); return Results.success();
} }

Loading…
Cancel
Save