Compare commits

...

3 Commits

Author SHA1 Message Date
04b891e73d feat(sql): 修改用户表唯一约束字段
- 将用户表的唯一约束从手机号(phone)更改为邮箱(email)- 更新表结构以支持邮箱唯一性校验
-保持其他字段和约束不变
2025-10-12 00:50:12 +08:00
e5c79f1abc feat(user): 更新用户表字段及认证接口
- 将用户表中的 `han_note_id` 注释更新为 "小憨书号"
- 将用户表中的 `phone` 字段改为 `email` 并更新注释
- 更新分布式ID生成器中相关SQL表名引用从 `leaf_alloc` 到 `leaf`
- 在HTTP客户端配置文件中新增认证API请求示例
- 修改Feign接口方法名以匹配邮箱查询逻辑
- 调整RPC服务调用方法名保持一致性
2025-10-12 00:49:35 +08:00
eaa5586211 feat(sql): 初始化频道、话题及关系数据
- 添加 leaf-segment 分布式ID配置表及初始数据

fix(pom):修正模块 artifactId 命名

- 将 han-note-api 模块名称更正为 han-note-note-api
2025-10-11 23:31:26 +08:00
11 changed files with 74 additions and 18 deletions

View File

@@ -15,5 +15,6 @@
</list>
</option>
</inspection_tool>
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@@ -44,7 +44,7 @@ public class UserRpcService {
FindUserByEmailReqDTO findUserByEmailReqDTO = new FindUserByEmailReqDTO();
findUserByEmailReqDTO.setEmail(email);
Response<FindUserByEmailRspDTO> response = userFeignApi.findByPhone(findUserByEmailReqDTO);
Response<FindUserByEmailRspDTO> response = userFeignApi.findByEmail(findUserByEmailReqDTO);
if (!response.isSuccess()) {
return null;

View File

@@ -13,7 +13,7 @@ import java.util.List;
@Mapper
public interface IDAllocMapper {
@Select("SELECT biz_tag, max_id, step, update_time FROM leaf_alloc")
@Select("SELECT biz_tag, max_id, step, update_time FROM leaf")
@Results(value = {
@Result(column = "biz_tag", property = "key"),
@Result(column = "max_id", property = "maxId"),
@@ -22,7 +22,7 @@ public interface IDAllocMapper {
})
List<LeafAlloc> getAllLeafAllocs();
@Select("SELECT biz_tag, max_id, step FROM leaf_alloc WHERE biz_tag = #{tag}")
@Select("SELECT biz_tag, max_id, step FROM leaf WHERE biz_tag = #{tag}")
@Results(value = {
@Result(column = "biz_tag", property = "key"),
@Result(column = "max_id", property = "maxId"),
@@ -30,12 +30,12 @@ public interface IDAllocMapper {
})
LeafAlloc getLeafAlloc(@Param("tag") String tag);
@Update("UPDATE leaf_alloc SET max_id = max_id + step WHERE biz_tag = #{tag}")
@Update("UPDATE leaf SET max_id = max_id + step WHERE biz_tag = #{tag}")
void updateMaxId(@Param("tag") String tag);
@Update("UPDATE leaf_alloc SET max_id = max_id + #{leafAlloc.step} WHERE biz_tag = #{leafAlloc.key}")
@Update("UPDATE leaf SET max_id = max_id + #{leafAlloc.step} WHERE biz_tag = #{leafAlloc.key}")
void updateMaxIdByCustomStep(@Param("leafAlloc") LeafAlloc leafAlloc);
@Select("SELECT biz_tag FROM leaf_alloc")
@Select("SELECT biz_tag FROM leaf")
List<String> getAllTags();
}

View File

@@ -11,7 +11,7 @@
<!-- 打包方式 -->
<packaging>jar</packaging>
<artifactId>han-note-api</artifactId>
<artifactId>han-note-note-api</artifactId>
<name>${project.artifactId}</name>
<description>RPC层, 供其他服务调用</description>

View File

@@ -27,13 +27,13 @@ public interface UserFeignApi {
Response<Long> registerUser(@RequestBody RegisterUserReqDTO registerUserReqDTO);
/**
* 根据手机号查询用户信息
* 根据邮箱号查询用户信息
*
* @param findUserByEmailReqDTO 查询信息请求
* @return 响应
*/
@PostMapping(value = PREFIX + "/findByEmail")
Response<FindUserByEmailRspDTO> findByPhone(@RequestBody FindUserByEmailReqDTO findUserByEmailReqDTO);
Response<FindUserByEmailRspDTO> findByEmail(@RequestBody FindUserByEmailReqDTO findUserByEmailReqDTO);
/**
* 更新密码

27
http-client/gateApi.http Normal file
View File

@@ -0,0 +1,27 @@
### 获取验证码
POST http://localhost:8000/auth/verification/code/send
Content-Type: application/json
{
"email": "ssw010723@gmail.com"
}
### 登录/注册
POST http://localhost:8000/auth/login
Content-Type: application/json
{
"email": "ssw010723@gmail.com",
"code": "135466",
"type": 1
}
### 修改密码
POST http://localhost:8000/auth/password/update
Content-Type: application/json
Authorization: Bearer {{token}}
{
"newPassword": "wwgb1314"
}

View File

View File

@@ -0,0 +1,5 @@
{
"dev": {
"token": "4bXpiBbjXEDFE4ZpqjCOHu1rP81qepl2ROOygrxRGb61K536ckLuyAwfyQHSMcyRdUzf8CxntLEMfbU2ynbYx9nJKlx4vpWZrHqv2mI4iMhnShQ4mPBi7OPPgZi22O2f"
}
}

View File

@@ -16,11 +16,17 @@ 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');
INSERT INTO `han_note`.`t_channel` (`name`, `create_time`, `update_time`, `is_deleted`) VALUES ('美食', now(), now(), 0);
INSERT INTO `han_note`.`t_channel` (`name`, `create_time`, `update_time`, `is_deleted`) VALUES ('娱乐', now(), now(), 0);
INSERT INTO `han_note`.`t_channel` (`name`, `create_time`, `update_time`, `is_deleted`)
VALUES ('美食', now(), now(), 0);
INSERT INTO `han_note`.`t_channel` (`name`, `create_time`, `update_time`, `is_deleted`)
VALUES ('娱乐', now(), now(), 0);
INSERT INTO `han_note`.`t_topic` (`name`, `create_time`, `update_time`, `is_deleted`) VALUES ('高分美剧推荐', now(), now(), 0);
INSERT INTO `han_note`.`t_topic` (`name`, `create_time`, `update_time`, `is_deleted`) VALUES ('下饭综艺推荐', now(), now(), 0);
INSERT INTO `han_note`.`t_topic` (`name`, `create_time`, `update_time`, `is_deleted`)
VALUES ('高分美剧推荐', now(), now(), 0);
INSERT INTO `han_note`.`t_topic` (`name`, `create_time`, `update_time`, `is_deleted`)
VALUES ('下饭综艺推荐', now(), now(), 0);
INSERT INTO `han_note`.`t_channel_topic_rel` (`channel_id`, `topic_id`, `create_time`, `update_time`) VALUES (2, 1, now(), now());
INSERT INTO `han_note`.`t_channel_topic_rel` (`channel_id`, `topic_id`, `create_time`, `update_time`) VALUES (2, 2, now(), now());
INSERT INTO `han_note`.`t_channel_topic_rel` (`channel_id`, `topic_id`, `create_time`, `update_time`)
VALUES (2, 1, now(), now());
INSERT INTO `han_note`.`t_channel_topic_rel` (`channel_id`, `topic_id`, `create_time`, `update_time`)
VALUES (2, 2, now(), now());

View File

@@ -1,13 +1,13 @@
CREATE TABLE `t_user`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`han_note_id` varchar(15) NOT NULL COMMENT '书号(唯一凭证)',
`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 '手机',
`email` varchar(32) 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 '个人简介',
@@ -16,7 +16,7 @@ CREATE TABLE `t_user`
`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`)
UNIQUE KEY `uk_email` (`email`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT ='用户表';

17
sql/leafcreatetable.sql Normal file
View File

@@ -0,0 +1,17 @@
INSERT INTO `leaf`.`leaf` (`biz_tag`, `max_id`, `step`, `description`, `update_time`)
VALUES ('leaf-segment-hannote-id', 10100, 2000, '小憨书 ID', now());
INSERT INTO `leaf`.`leaf` (`biz_tag`, `max_id`, `step`, `description`, `update_time`)
VALUES ('leaf-segment-user-id', 100, 2000, '用户 ID', now());
CREATE TABLE `leaf`
(
`biz_tag` varchar(128) NOT NULL DEFAULT '',
`max_id` bigint(20) NOT NULL DEFAULT '1',
`step` int(11) NOT NULL,
`description` varchar(256) DEFAULT NULL,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`biz_tag`)
) ENGINE = InnoDB;