feat(singer): 添加歌手类型相关功能

- 在 pom.xml 中添加 Hutool 工具库依赖
- 优化前端 Singer.vue 中的歌手数据处理逻辑
- 在后端 SingerServiceImpl 中添加默认歌手类型设置功能
This commit is contained in:
ikmkj
2025-08-10 19:36:38 +08:00
parent a36ef7a561
commit 1546cdb3c4
3 changed files with 16 additions and 1 deletions

View File

@@ -97,6 +97,13 @@
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- Hutool工具库 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.22</version>
</dependency>
<!-- 工具类 -->
<dependency>
<groupId>org.apache.commons</groupId>

View File

@@ -1,6 +1,8 @@
package com.test.musichouduan.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.test.musichouduan.dto.PageResult;
import com.test.musichouduan.dto.SingerDTO;
import com.test.musichouduan.dto.MusicDTO;
@@ -225,6 +227,12 @@ public class SingerServiceImpl implements SingerService {
singer.setAvatar(avatarUrl);
singer.setIntroduction(singerDTO.getIntroduction());
singer.setCollectCount(0);
// 设置默认歌手类型
if (ObjectUtil.isEmpty(singerDTO.getTypeId())){
SingerType defaultType = singerTypeRepository.findById(1L)
.orElseThrow(() -> new BusinessException("默认歌手类型不存在"));
singer.setType(defaultType);
}
// 设置歌手类型
if (singerDTO.getTypeId() != null) {

View File

@@ -261,7 +261,7 @@ const submitForm = async () => {
const singerData = {
name: form.value.name,
introduction: form.value.introduction,
type: form.value.typeId ? { id: form.value.typeId } : null
typeId: form.value.typeId || null
}
let res