han-note项目初始化完毕!
- 注册登录接口,开发40%
This commit is contained in:
@@ -65,6 +65,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
27
han-note-auth/src/main/resources/mapperxml/UserDOMapper.xml
Normal file
27
han-note-auth/src/main/resources/mapperxml/UserDOMapper.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hanserwei.hannote.auth.domain.mapper.UserDOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.hanserwei.hannote.auth.domain.dataobject.UserDO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table t_user-->
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="han_note_id" jdbcType="VARCHAR" property="hanNoteId" />
|
||||
<result column="password" jdbcType="VARCHAR" property="password" />
|
||||
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
|
||||
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
|
||||
<result column="birthday" jdbcType="DATE" property="birthday" />
|
||||
<result column="background_img" jdbcType="VARCHAR" property="backgroundImg" />
|
||||
<result column="email" jdbcType="VARCHAR" property="email" />
|
||||
<result column="sex" jdbcType="TINYINT" property="sex" />
|
||||
<result column="status" jdbcType="TINYINT" property="status" />
|
||||
<result column="introduction" jdbcType="VARCHAR" property="introduction" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="is_deleted" jdbcType="BIT" property="isDeleted" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, han_note_id, `password`, nickname, avatar, birthday, background_img, email, sex,
|
||||
`status`, introduction, create_time, update_time, is_deleted
|
||||
</sql>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user