han-note项目初始化完毕!
- 注册登录接口,开发40%
This commit is contained in:
@@ -2,7 +2,7 @@ package com.hanserwei.hannote.auth.controller;
|
||||
|
||||
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||
import com.hanserwei.framework.common.response.Response;
|
||||
import com.hanserwei.hannote.auth.model.vo.SendVerificationCodeReqVO;
|
||||
import com.hanserwei.hannote.auth.model.vo.verificationcode.SendVerificationCodeReqVO;
|
||||
import com.hanserwei.hannote.auth.service.VerificationCodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.hanserwei.hannote.auth.domain.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户表
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "t_user")
|
||||
public class UserDO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 小哈书号(唯一凭证)
|
||||
*/
|
||||
@TableField(value = "han_note_id")
|
||||
private String hanNoteId;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@TableField(value = "`password`")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@TableField(value = "nickname")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@TableField(value = "avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@TableField(value = "birthday")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
@TableField(value = "background_img")
|
||||
private String backgroundImg;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@TableField(value = "email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别(0:女 1:男)
|
||||
*/
|
||||
@TableField(value = "sex")
|
||||
private Byte sex;
|
||||
|
||||
/**
|
||||
* 状态(0:启用 1:禁用)
|
||||
*/
|
||||
@TableField(value = "`status`")
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 个人简介
|
||||
*/
|
||||
@TableField(value = "introduction")
|
||||
private String introduction;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除(0:未删除 1:已删除)
|
||||
*/
|
||||
@TableField(value = "is_deleted")
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.hanserwei.hannote.auth.domain.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.hanserwei.hannote.auth.domain.dataobject.UserDO;
|
||||
|
||||
public interface UserDOMapper extends BaseMapper<UserDO> {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.hanserwei.hannote.auth.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginTypeEnum {
|
||||
// 验证码
|
||||
VERIFICATION_CODE(1),
|
||||
// 密码
|
||||
PASSWORD(2);
|
||||
|
||||
private final Integer value;
|
||||
|
||||
public static LoginTypeEnum valueOf(Integer code) {
|
||||
for (LoginTypeEnum loginTypeEnum : LoginTypeEnum.values()) {
|
||||
if (Objects.equals(code, loginTypeEnum.getValue())) {
|
||||
return loginTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,8 @@ public enum ResponseCodeEnum implements BaseExceptionInterface {
|
||||
// ----------- 业务异常状态码 -----------
|
||||
VERIFICATION_CODE_SEND_FREQUENTLY("AUTH-20000", "请求太频繁,请3分钟后再试"),
|
||||
MAIL_SEND_ERROR("AUTH-20001", "邮件发送失败,请稍后再试"),
|
||||
TEMPLATE_RENDER_ERROR("AUTH-20002", "模板渲染错误")
|
||||
TEMPLATE_RENDER_ERROR("AUTH-20002", "模板渲染错误"),
|
||||
USER_NOT_EXIST("AUTH-20003", "用户不存在"),
|
||||
;
|
||||
|
||||
// 异常码
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.hanserwei.hannote.auth.model.vo.user;
|
||||
|
||||
import com.hanserwei.framework.common.validate.EmailNumber;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class UserLoginReqVO {
|
||||
|
||||
/**
|
||||
* 邮箱号
|
||||
*/
|
||||
@NotBlank(message = "邮箱不能为空")
|
||||
@EmailNumber
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 登录类型:邮箱验证码,或者是账号密码
|
||||
*/
|
||||
@NotNull(message = "登录类型不能为空")
|
||||
private Integer type;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hanserwei.hannote.auth.model.vo;
|
||||
package com.hanserwei.hannote.auth.model.vo.verificationcode;
|
||||
|
||||
import com.hanserwei.framework.common.validate.EmailNumber;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.hanserwei.hannote.auth.service;
|
||||
|
||||
import com.hanserwei.framework.common.response.Response;
|
||||
import com.hanserwei.hannote.auth.model.vo.SendVerificationCodeReqVO;
|
||||
import com.hanserwei.hannote.auth.model.vo.verificationcode.SendVerificationCodeReqVO;
|
||||
|
||||
public interface VerificationCodeService {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.hanserwei.framework.common.exception.ApiException;
|
||||
import com.hanserwei.framework.common.response.Response;
|
||||
import com.hanserwei.hannote.auth.constant.RedisKeyConstants;
|
||||
import com.hanserwei.hannote.auth.enums.ResponseCodeEnum;
|
||||
import com.hanserwei.hannote.auth.model.vo.SendVerificationCodeReqVO;
|
||||
import com.hanserwei.hannote.auth.model.vo.verificationcode.SendVerificationCodeReqVO;
|
||||
import com.hanserwei.hannote.auth.service.VerificationCodeService;
|
||||
import com.hanserwei.hannote.auth.utils.MailHelper;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
Reference in New Issue
Block a user