feat(character): 添加用户人设接口及排序管理

新增 /character/addUserCharacter 端点,支持用户将人设加入个人列表并自动维护排序数组。引入 KeyboardUserCharacterAddDTO、KeyboardUserSortMapper 及相关错误码,实现事务级插入与排序更新。
This commit is contained in:
2025-12-04 16:17:29 +08:00
parent 4e6a5a6e18
commit fe19fb8ca2
10 changed files with 151 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ 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.dto.userCharacter.KeyboardUserCharacterAddDTO;
import com.yolo.keyborad.model.dto.userCharacter.KeyboardUserCharacterDTO;
import com.yolo.keyborad.model.dto.userCharacter.KeyboardUserCharacterSortUpdateDTO;
import com.yolo.keyborad.model.entity.KeyboardCharacter;
@@ -49,7 +50,7 @@ public class CharacterController {
@Operation(summary = "人设详情", description = "人设详情接口")
public BaseResponse<KeyboardCharacterRespVO> detail(@RequestParam("id") Long id) {
KeyboardCharacter character = characterService.getById(id);
return ResultUtils.success(BeanUtil.copyProperties(character ,KeyboardCharacterRespVO.class));
return ResultUtils.success(BeanUtil.copyProperties(character, KeyboardCharacterRespVO.class));
}
@GetMapping("/listByTag")
@@ -67,10 +68,16 @@ public class CharacterController {
@PostMapping("/updateUserCharacterSort")
@Operation(summary = "更新用户人设排序",description = "更新用户人设排序接口")
@Operation(summary = "更新用户人设排序", description = "更新用户人设排序接口")
public BaseResponse<Boolean> updateUserCharacterSort(@RequestBody KeyboardUserCharacterSortUpdateDTO sortUpdateDTO) {
characterService.updateSort(sortUpdateDTO);
return ResultUtils.success(true);
}
}
@PostMapping("/addUserCharacter")
@Operation(summary = "添加用户人设", description = "添加用户人设接口")
public BaseResponse<Boolean> addUserCharacter(@RequestBody KeyboardUserCharacterAddDTO addDTO) {
characterService.addUserCharacter(addDTO);
return ResultUtils.success(true);
}
}