diff --git a/han-note-auth/pom.xml b/han-note-auth/pom.xml
index fbd9110..4c67c15 100755
--- a/han-note-auth/pom.xml
+++ b/han-note-auth/pom.xml
@@ -65,6 +65,10 @@
org.springframework.boot
spring-boot-starter-thymeleaf
+
+ cn.dev33
+ sa-token-redis-jackson
+
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/controller/VerificationCodeController.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/controller/VerificationCodeController.java
index d892372..3a668cd 100644
--- a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/controller/VerificationCodeController.java
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/controller/VerificationCodeController.java
@@ -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;
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/dataobject/UserDO.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/dataobject/UserDO.java
new file mode 100644
index 0000000..6e8cfd0
--- /dev/null
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/dataobject/UserDO.java
@@ -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;
+}
\ No newline at end of file
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/mapper/UserDOMapper.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/mapper/UserDOMapper.java
new file mode 100644
index 0000000..c5d844b
--- /dev/null
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/domain/mapper/UserDOMapper.java
@@ -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 {
+}
\ No newline at end of file
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/LoginTypeEnum.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/LoginTypeEnum.java
new file mode 100644
index 0000000..4892bf7
--- /dev/null
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/LoginTypeEnum.java
@@ -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;
+ }
+
+}
\ No newline at end of file
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/ResponseCodeEnum.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/ResponseCodeEnum.java
index f04237f..34e0240 100644
--- a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/ResponseCodeEnum.java
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/enums/ResponseCodeEnum.java
@@ -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", "用户不存在"),
;
// 异常码
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/user/UserLoginReqVO.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/user/UserLoginReqVO.java
new file mode 100644
index 0000000..2312467
--- /dev/null
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/user/UserLoginReqVO.java
@@ -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;
+}
\ No newline at end of file
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/SendVerificationCodeReqVO.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/verificationcode/SendVerificationCodeReqVO.java
similarity index 86%
rename from han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/SendVerificationCodeReqVO.java
rename to han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/verificationcode/SendVerificationCodeReqVO.java
index 2c49dce..d7c9ef8 100644
--- a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/SendVerificationCodeReqVO.java
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/model/vo/verificationcode/SendVerificationCodeReqVO.java
@@ -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;
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/VerificationCodeService.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/VerificationCodeService.java
index d88ef7d..351bd35 100644
--- a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/VerificationCodeService.java
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/VerificationCodeService.java
@@ -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 {
diff --git a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/impl/VerificationCodeServiceImpl.java b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/impl/VerificationCodeServiceImpl.java
index 7258df3..ed7b5e4 100644
--- a/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/impl/VerificationCodeServiceImpl.java
+++ b/han-note-auth/src/main/java/com/hanserwei/hannote/auth/service/impl/VerificationCodeServiceImpl.java
@@ -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;
diff --git a/han-note-auth/src/main/resources/mapperxml/UserDOMapper.xml b/han-note-auth/src/main/resources/mapperxml/UserDOMapper.xml
new file mode 100644
index 0000000..490a8a1
--- /dev/null
+++ b/han-note-auth/src/main/resources/mapperxml/UserDOMapper.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, han_note_id, `password`, nickname, avatar, birthday, background_img, email, sex,
+ `status`, introduction, create_time, update_time, is_deleted
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0b414d9..7753f30 100755
--- a/pom.xml
+++ b/pom.xml
@@ -139,6 +139,11 @@
commons-lang3
${commons-lang3.version}
+
+ cn.dev33
+ sa-token-redis-jackson
+ ${sa-token.version}
+
diff --git a/sql/createData.sql b/sql/createData.sql
new file mode 100644
index 0000000..35a249b
--- /dev/null
+++ b/sql/createData.sql
@@ -0,0 +1,17 @@
+INSERT INTO `t_permission` (`id`, `parent_id`, `name`, `type`, `menu_url`, `menu_icon`, `sort`, `permission_key`,
+ `status`, `create_time`, `update_time`, `is_deleted`)
+VALUES (1, 0, '发布笔记', 3, '', '', 1, 'app:note:publish', 0, now(), now(), b'0');
+
+INSERT INTO `t_permission` (`id`, `parent_id`, `name`, `type`, `menu_url`, `menu_icon`, `sort`, `permission_key`,
+ `status`, `create_time`, `update_time`, `is_deleted`)
+VALUES (2, 0, '发布评论', 3, '', '', 2, 'app:comment:publish', 0, now(), now(), b'0');
+
+INSERT INTO `t_role` (`id`, `role_name`, `role_key`, `status`, `sort`, `remark`, `create_time`, `update_time`,
+ `is_deleted`)
+VALUES (1, '普通用户', 'common_user', 0, 1, '', now(), now(), b'0');
+
+INSERT INTO `t_role_permission_rel` (`id`, `role_id`, `permission_id`, `create_time`, `update_time`, `is_deleted`)
+VALUES (1, 1, 1, now(), now(), b'0');
+
+INSERT INTO `t_role_permission_rel` (`id`, `role_id`, `permission_id`, `create_time`, `update_time`, `is_deleted`)
+VALUES (2, 1, 2, now(), now(), b'0');
diff --git a/sql/createTable.sql b/sql/createTable.sql
index 9368679..806d452 100644
--- a/sql/createTable.sql
+++ b/sql/createTable.sql
@@ -1,20 +1,86 @@
CREATE TABLE `t_user`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `han_note_id` varchar(15) NOT NULL COMMENT '小哈书号(唯一凭证)',
- `password` varchar(64) DEFAULT NULL COMMENT '密码',
- `nickname` varchar(24) NOT NULL COMMENT '昵称',
- `avatar` varchar(120) DEFAULT NULL COMMENT '头像',
- `birthday` date DEFAULT NULL COMMENT '生日',
- `background_img` varchar(120) DEFAULT NULL COMMENT '背景图',
- `phone` varchar(11) NOT NULL COMMENT '手机号',
- `sex` tinyint DEFAULT '0' COMMENT '性别(0:女 1:男)',
- `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态(0:启用 1:禁用)',
- `introduction` varchar(100) DEFAULT NULL COMMENT '个人简介',
- `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
- `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
+ `han_note_id` varchar(15) NOT NULL COMMENT '小哈书号(唯一凭证)',
+ `password` varchar(64) DEFAULT NULL COMMENT '密码',
+ `nickname` varchar(24) NOT NULL COMMENT '昵称',
+ `avatar` varchar(120) DEFAULT NULL COMMENT '头像',
+ `birthday` date DEFAULT NULL COMMENT '生日',
+ `background_img` varchar(120) DEFAULT NULL COMMENT '背景图',
+ `phone` varchar(11) NOT NULL COMMENT '手机号',
+ `sex` tinyint DEFAULT '0' COMMENT '性别(0:女 1:男)',
+ `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态(0:启用 1:禁用)',
+ `introduction` varchar(100) DEFAULT NULL COMMENT '个人简介',
+ `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+ `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_han_note_id` (`han_note_id`),
UNIQUE KEY `uk_phone` (`phone`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='用户表';
+
+CREATE TABLE `t_role`
+(
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+ `role_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色名',
+ `role_key` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色唯一标识',
+ `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态(0:启用 1:禁用)',
+ `sort` int unsigned NOT NULL DEFAULT 0 COMMENT '管理系统中的显示顺序',
+ `remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
+ `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
+ `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `uk_role_key` (`role_key`)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='角色表';
+
+CREATE TABLE `t_permission`
+(
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+ `parent_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '父ID',
+ `name` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限名称',
+ `type` tinyint unsigned NOT NULL COMMENT '类型(1:目录 2:菜单 3:按钮)',
+ `menu_url` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '菜单路由',
+ `menu_icon` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '菜单图标',
+ `sort` int unsigned NOT NULL DEFAULT 0 COMMENT '管理系统中的显示顺序',
+ `permission_key` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限标识',
+ `status` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '状态(0:启用;1:禁用)',
+ `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+ `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='权限表';
+
+CREATE TABLE `t_user_role_rel`
+(
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+ `user_id` bigint unsigned NOT NULL COMMENT '用户ID',
+ `role_id` bigint unsigned NOT NULL COMMENT '角色ID',
+ `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+ `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='用户角色表';
+
+CREATE TABLE `t_role_permission_rel`
+(
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+ `role_id` bigint unsigned NOT NULL COMMENT '角色ID',
+ `permission_id` bigint unsigned NOT NULL COMMENT '权限ID',
+ `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+ `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除(0:未删除 1:已删除)',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='用户权限表';
+
+