feat(character): 新增用户人设列表接口并支持邮箱登录

- CharacterController 增加 /listByUser 端点,返回当前用户已购人设
- KeyboardCharacterService 新增 selectListByUserId(),通过 Sa-Token 取当前用户 ID
- 引入 KeyboardUserCharacter 中间表及对应 Mapper、VO
- UserController 增加 /login 端点,支持邮箱+密码登录
- 统一将实体与 VO 的 title 字段更名为 characterName
- 补充错误码 USER_NOT_FOUND,调整 Sa-Token 白名单与 Redis 依赖
This commit is contained in:
2025-12-03 16:29:06 +08:00
parent 822fe3c76d
commit c4dbc9e475
17 changed files with 214 additions and 7 deletions

View File

@@ -1,11 +1,14 @@
package com.yolo.keyborad.controller;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.yolo.keyborad.common.BaseResponse;
import com.yolo.keyborad.common.ResultUtils;
import com.yolo.keyborad.model.entity.KeyboardCharacter;
import com.yolo.keyborad.model.entity.KeyboardTag;
import com.yolo.keyborad.model.entity.KeyboardUserCharacter;
import com.yolo.keyborad.model.vo.character.KeyboardCharacterRespVO;
import com.yolo.keyborad.model.vo.character.KeyboardUserCharacterVO;
import com.yolo.keyborad.model.vo.tags.TagsRespVO;
import com.yolo.keyborad.service.KeyboardCharacterService;
import io.swagger.v3.oas.annotations.Operation;
@@ -53,4 +56,10 @@ public class CharacterController {
return ResultUtils.success(BeanUtil.copyToList(list, KeyboardCharacterRespVO.class));
}
@GetMapping("/listByUser")
@Operation(summary = "用户人设列表", description = "用户人设列表接口")
public BaseResponse<List<KeyboardUserCharacterVO>> userList() {
List<KeyboardCharacter> keyboardCharacters = characterService.selectListByUserId();
return ResultUtils.success(BeanUtil.copyToList(keyboardCharacters, KeyboardUserCharacterVO.class));
}
}

View File

@@ -4,14 +4,17 @@ import cn.dev33.satoken.stp.StpUtil;
import com.yolo.keyborad.common.BaseResponse;
import com.yolo.keyborad.common.ResultUtils;
import com.yolo.keyborad.model.dto.AppleLoginReq;
import com.yolo.keyborad.model.dto.user.UserLoginDTO;
import com.yolo.keyborad.model.vo.user.KeyboardUserRespVO;
import com.yolo.keyborad.service.IAppleService;
import com.yolo.keyborad.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
@@ -29,6 +32,9 @@ public class UserController {
@Resource
private IAppleService appleService;
@Resource
private UserService userService;
/**
* 苹果登录
*
@@ -48,4 +54,9 @@ public class UserController {
return ResultUtils.success(true);
}
@PostMapping("/login")
@Operation(summary = "登录", description = "登录接口")
public BaseResponse<KeyboardUserRespVO> login(@RequestBody UserLoginDTO userLoginDTO) {
return ResultUtils.success(userService.login(userLoginDTO));
}
}