会员
This commit is contained in:
@@ -169,4 +169,58 @@ public class ShopUserController extends BaseController
|
||||
return AjaxResult.error("更新在线时长异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户标签
|
||||
* 根据用户历史记录中的音乐标签来返回用户的标签列表
|
||||
*/
|
||||
@GetMapping("/tags/{userId}")
|
||||
public AjaxResult getUserTags(@PathVariable("userId") String userId)
|
||||
{
|
||||
if (userId == null || userId.isEmpty()) {
|
||||
return AjaxResult.error("用户ID不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用服务获取用户标签
|
||||
String tags = shopUserService.getUserTags(userId);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
return AjaxResult.success("获取用户标签成功", tags);
|
||||
} else {
|
||||
return AjaxResult.success("用户暂无标签", "");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户[{}]标签异常", userId, e);
|
||||
return AjaxResult.error("获取用户标签异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的标签
|
||||
*/
|
||||
@GetMapping("/myTags")
|
||||
public AjaxResult getMyTags()
|
||||
{
|
||||
try {
|
||||
// 获取当前登录用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null || loginUser.getUserId() == null) {
|
||||
return AjaxResult.error("用户未登录或用户ID为空");
|
||||
}
|
||||
ShopUser shopUser = loginUser.getShopUser();
|
||||
|
||||
// 调用服务获取用户标签
|
||||
String tags = shopUserService.getUserTags(shopUser.getUserId().toString());
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
return AjaxResult.success("获取用户标签成功", tags);
|
||||
} else {
|
||||
return AjaxResult.success("用户暂无标签", "");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户标签异常", e);
|
||||
return AjaxResult.error("获取用户标签异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user