提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.auth.vo; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.StrUtil; |
|
4 |
import com.iailab.framework.common.validation.InEnum; |
|
5 |
import com.iailab.module.system.enums.social.SocialTypeEnum; |
|
6 |
import io.swagger.v3.oas.annotations.media.Schema; |
|
7 |
import lombok.AllArgsConstructor; |
|
8 |
import lombok.Builder; |
|
9 |
import lombok.Data; |
|
10 |
import lombok.NoArgsConstructor; |
|
11 |
import org.hibernate.validator.constraints.Length; |
|
12 |
|
|
13 |
import javax.validation.constraints.AssertTrue; |
|
14 |
import javax.validation.constraints.NotEmpty; |
|
15 |
import javax.validation.constraints.Pattern; |
|
16 |
|
|
17 |
@Schema(description = "管理后台 - 账号密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") |
|
18 |
@Data |
|
19 |
@NoArgsConstructor |
|
20 |
@AllArgsConstructor |
|
21 |
@Builder |
|
22 |
public class AuthLoginReqVO { |
|
23 |
|
|
24 |
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "iailabyuanma") |
|
25 |
@NotEmpty(message = "登录账号不能为空") |
|
26 |
@Length(min = 4, max = 16, message = "账号长度为 4-16 位") |
|
27 |
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") |
|
28 |
private String username; |
|
29 |
|
|
30 |
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") |
|
31 |
@NotEmpty(message = "密码不能为空") |
|
32 |
@Length(min = 4, max = 16, message = "密码长度为 4-16 位") |
|
33 |
private String password; |
|
34 |
|
|
35 |
// ========== 图片验证码相关 ========== |
|
36 |
|
|
37 |
@Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED, |
|
38 |
example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==") |
|
39 |
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class) |
|
40 |
private String captchaVerification; |
|
41 |
|
|
42 |
// ========== 绑定社交登录时,需要传递如下参数 ========== |
|
43 |
|
|
44 |
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") |
|
45 |
@InEnum(SocialTypeEnum.class) |
|
46 |
private Integer socialType; |
|
47 |
|
|
48 |
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
|
49 |
private String socialCode; |
|
50 |
|
|
51 |
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") |
|
52 |
private String socialState; |
|
53 |
|
|
54 |
/** |
|
55 |
* 开启验证码的 Group |
|
56 |
*/ |
|
57 |
public interface CodeEnableGroup {} |
|
58 |
|
|
59 |
@AssertTrue(message = "授权码不能为空") |
|
60 |
public boolean isSocialCodeValid() { |
|
61 |
return socialType == null || StrUtil.isNotEmpty(socialCode); |
|
62 |
} |
|
63 |
|
|
64 |
@AssertTrue(message = "授权 state 不能为空") |
|
65 |
public boolean isSocialState() { |
|
66 |
return socialType == null || StrUtil.isNotEmpty(socialState); |
|
67 |
} |
|
68 |
|
|
69 |
} |