From 848490215eb32d8abe0d41883beee1cde112d9b5 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 21 Feb 2024 00:39:23 +0800 Subject: [PATCH] 1.fix tag display condition 2.enable badge for user info --- .../java/com/luoo/music/controller/SearchController.java | 2 +- luoo_music/src/main/java/com/luoo/music/dao/TagDao.java | 8 ++++---- luoo_music/src/main/java/com/luoo/music/pojo/Tag.java | 5 +++++ .../src/main/java/com/luoo/music/service/TagService.java | 4 ++-- .../main/java/com/luoo/user/controller/MyController.java | 4 ++++ .../main/java/com/luoo/user/dto/response/UserRespDTO.java | 4 ++-- luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java | 2 ++ 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java b/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java index 20a74dc..7eb0423 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java @@ -53,7 +53,7 @@ public class SearchController { @GetMapping("/category") @GlobalInterceptor public Result> getCategory() { - List tags = tagService.getLevel1Tags(); + List tags = tagService.getCategoryTags(); List searchCategoryDTOs = tags.stream().map(this::getSearchCategoryDTO) .collect(Collectors.toList()); return Result.success(searchCategoryDTOs); diff --git a/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java b/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java index 5ff9528..11d1855 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java @@ -19,14 +19,14 @@ public interface TagDao extends JpaRepository, JpaSpecificationExec @Query(value = "select * from tb_tag_info where parent_id='' order by rand() limit ?1 ", nativeQuery = true) List random(int limit); - @Query(value = "select * from tb_tag_info where parent_id=(select id from tb_tag_info where name_ch='语言' and level=1 limit 1) ", nativeQuery = true) + @Query(value = "select * from tb_tag_info where state=1 and parent_id=(select id from tb_tag_info where name_ch='语言' and level=1 limit 1) ", nativeQuery = true) List getLanguageList(); - @Query(value = "select * from tb_tag_info where level=1 and not name_ch='语言' ", nativeQuery = true) + @Query(value = "select * from tb_tag_info where state=1 and is_show=1 and not name_ch='语言' ", nativeQuery = true) List getStyleList(); - @Query(value = "select * from tb_tag_info where level=1", nativeQuery = true) - List getLevel1Tags(); + @Query(value = "select * from tb_tag_info where state=1 and is_show=1", nativeQuery = true) + List getCategoryTags(); @Query(value = "select journal_id,name_ch from tb_journal_tag,tb_tag_info where journal_id in ?1 and tb_journal_tag.tag_id =tb_tag_info.id ;", nativeQuery = true) List getJounralId2TagPairs(List journalIds); diff --git a/luoo_music/src/main/java/com/luoo/music/pojo/Tag.java b/luoo_music/src/main/java/com/luoo/music/pojo/Tag.java index 26d28e0..c560f0d 100644 --- a/luoo_music/src/main/java/com/luoo/music/pojo/Tag.java +++ b/luoo_music/src/main/java/com/luoo/music/pojo/Tag.java @@ -55,6 +55,11 @@ public class Tag implements Serializable { * 状态: 0.禁用, 1.启用 */ private Integer state; + + /** + * 是否显示 + */ + private Integer isShow; /** * 说明文案 diff --git a/luoo_music/src/main/java/com/luoo/music/service/TagService.java b/luoo_music/src/main/java/com/luoo/music/service/TagService.java index 30efb6d..15e88e7 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/TagService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/TagService.java @@ -24,8 +24,8 @@ public class TagService { return tagDao.getStyleList(); } - public List getLevel1Tags() { - return tagDao.getLevel1Tags(); + public List getCategoryTags() { + return tagDao.getCategoryTags(); } public Map> getTagMap(List journalIds) { diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 674afd8..80d5984 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -1,6 +1,7 @@ package com.luoo.user.controller; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; @@ -273,6 +274,9 @@ public class MyController extends BaseController { private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount, Set bothFollowSet) { UserRespDTO userRespDTO = new UserRespDTO(); BeanUtils.copyProperties(user, userRespDTO); + if(!StringTools.isEmpty(user.getBadges())) { + userRespDTO.setBadgeList(Arrays.stream(user.getBadges().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + } if (null != userRespDTO.getAvatar()) { userRespDTO.setAvatar(Constants.RESOURCE_PREFIX + userRespDTO.getAvatar()); } diff --git a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java index 25374f9..3c36153 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java @@ -17,8 +17,8 @@ public class UserRespDTO { private String avatar; @ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”") private String signature; - @ApiModelProperty(value = "用户标识,如“贡献者”,“音乐人”") - private List badge; + @ApiModelProperty(value = "用户标识,1为贡献者 2为音乐人") + private List badgeList; @ApiModelProperty(value = "关注数") private int followCount; @ApiModelProperty(value = "粉丝数") diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java index ac6c676..55e12df 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java @@ -134,4 +134,6 @@ public class UserInfo implements Serializable { * 0:禁用 1:正常 */ private int onlineStatus; + + private String badges; }