Skip to content

Commit a01fdb1

Browse files
committed
feat:角色新增偶像显示
1 parent ebd4c8b commit a01fdb1

File tree

7 files changed

+281
-16
lines changed

7 files changed

+281
-16
lines changed

db/2025_06_28.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE `xiaozhi`.`sys_role`
2+
ADD COLUMN `avatar` varchar(255) DEFAULT NULL COMMENT '角色头像' AFTER roleName;

src/main/java/com/xiaozhi/common/config/WebMvcConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public void addInterceptors(InterceptorRegistry registry) {
3535
"/api/device/ota",
3636
"/audio/**",
3737
"/uploads/**",
38-
"/avatar/**",
3938
"/ws/**"
4039
);
4140
}
@@ -57,10 +56,17 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
5756
// 音频文件存储在项目根目录下的audio文件夹中
5857
String audioPath = "file:" + basePath + File.separator + "audio" + File.separator;
5958

59+
// 上传文件存储在项目根目录下的uploads文件夹中
60+
String uploadsPath = "file:" + basePath + File.separator + "uploads" + File.separator;
61+
6062
// 配置资源映射
6163
registry.addResourceHandler("/audio/**")
6264
.addResourceLocations(audioPath);
6365

66+
// 为上传文件添加资源映射
67+
registry.addResourceHandler("/uploads/**")
68+
.addResourceLocations(uploadsPath);
69+
6470
super.addResourceHandlers(registry);
6571
} catch (Exception e) {
6672
log.error("添加资源失败", e);

src/main/java/com/xiaozhi/common/interceptor/AuthenticationInterceptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
3939
"/api/device/ota",
4040
"/audio/",
4141
"/uploads/",
42-
"/avatar/",
4342
"/ws/");
4443

4544
@Override

src/main/java/com/xiaozhi/controller/FileUploadController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AjaxResult uploadFile(
6363
// 如果是本地URL,需要调整格式
6464
if (!isCosUrl) {
6565
// 将本地路径转换为访问URL格式
66-
String accessUrl = relativePath + "/" + fileName;
66+
String accessUrl = "uploads/" + relativePath + "/" + fileName;
6767
result.put("url", accessUrl);
6868
}
6969

src/main/java/com/xiaozhi/entity/SysRole.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
public class SysRole extends Base {
1313
private Integer roleId;
1414

15+
private String avatar;
16+
1517
private String roleName;
1618

1719
private String roleDesc;
@@ -45,14 +47,6 @@ public class SysRole extends Base {
4547

4648
private Integer totalDevice;
4749

48-
public Integer getTtsId() {
49-
return ttsId;
50-
}
51-
52-
public SysRole setTtsId(Integer ttsId) {
53-
this.ttsId = ttsId;
54-
return this;
55-
}
5650

5751
public Integer getModelId() {
5852
return modelId;
@@ -81,6 +75,15 @@ public SysRole setSttId(Integer sttId) {
8175
return this;
8276
}
8377

78+
public Integer getTtsId() {
79+
return ttsId;
80+
}
81+
82+
public SysRole setTtsId(Integer ttsId) {
83+
this.ttsId = ttsId;
84+
return this;
85+
}
86+
8487
public Double getTemperature() {
8588
return temperature;
8689
}
@@ -162,6 +165,15 @@ public SysRole setRoleId(Integer roleId) {
162165
return this;
163166
}
164167

168+
public String getAvatar() {
169+
return avatar;
170+
}
171+
172+
public SysRole setAvatar(String avatar) {
173+
this.avatar = avatar;
174+
return this;
175+
}
176+
165177
public String getRoleName() {
166178
return roleName;
167179
}

src/main/java/com/xiaozhi/mapper/RoleMapper.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<mapper namespace="com.xiaozhi.dao.RoleMapper">
44

55
<sql id="roleSql">
6-
sys_role.roleId, sys_role.roleName, sys_role.roleDesc, sys_role.voiceName,
6+
sys_role.roleId, sys_role.avatar, sys_role.roleName, sys_role.roleDesc, sys_role.voiceName,
77
sys_role.modelId, sys_role.sttId, sys_role.ttsId,
88
sys_role.vadSpeechTh, sys_role.vadSilenceTh, sys_role.vadEnergyTh, sys_role.vadSilenceMs,
99
sys_role.userId, sys_role.state, sys_role.isDefault, sys_role.createTime
@@ -45,7 +45,7 @@
4545
UPDATE
4646
sys_role
4747
<set>
48-
<if test="roleName != null and roleName != ''">roleName = #{roleName},</if>
48+
avatar = #{avatar},
4949
<if test="roleDesc != null and roleDesc != ''">roleDesc = #{roleDesc},</if>
5050
<if test="voiceName != null and voiceName != ''">voiceName = #{voiceName},</if>
5151
<if test="isDefault != null and isDefault != ''">isDefault = #{isDefault},</if>
@@ -79,7 +79,8 @@
7979
</update>
8080

8181
<insert id="add" useGeneratedKeys="true" keyProperty="roleName" parameterType="com.xiaozhi.entity.SysRole">
82-
INSERT INTO sys_role ( roleName, roleDesc, voiceName, modelId, ttsId, sttId, userId, isDefault ) VALUES (
82+
INSERT INTO sys_role ( avatar, roleName, roleDesc, voiceName, modelId, ttsId, sttId, userId, isDefault ) VALUES (
83+
#{avatar},
8384
#{roleName},
8485
#{roleDesc},
8586
#{voiceName},

0 commit comments

Comments
 (0)