浏览代码

专辑标签

liujunchi 2 年之前
父节点
当前提交
494c440b27

+ 3 - 14
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/MusicTagController.java

@@ -57,8 +57,8 @@ public class MusicTagController extends BaseController {
 	 */
 	@GetMapping("/tree")
 	@ApiOperation(value = "查询标签树列表")
-	public HttpResponseResult<List<MusicTagVo>> tree() {
-		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree();
+	public HttpResponseResult<List<MusicTagVo>> tree(String type) {
+		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree(type);
 		return succeed(treeList);
 	}
 
@@ -69,12 +69,7 @@ public class MusicTagController extends BaseController {
 	@ApiOperation(value = "新增", httpMethod="POST", consumes="application/json", produces="application/json")
 	@PreAuthorize("@pcs.hasPermissions('MusicTag/save')")
 	public HttpResponseResult<Boolean> save(@Validated(MusicTagSaveDto.Create.class) @RequestBody MusicTagSaveDto musicTagSaveDto) {
-		if (musicTagSaveDto.getParentTagId() != null && musicTagSaveDto.getParentTagId() != 0) {
-			MusicTag musicTag = musicTagService.getById(musicTagSaveDto.getParentTagId());
-			if (musicTag.getParentTagId() != 0) {
-				return failed("标签只能有两级");
-			}
-		}
+
 		return succeed(musicTagService.createMusicTag(musicTagSaveDto));
 	}
 
@@ -85,12 +80,6 @@ public class MusicTagController extends BaseController {
 	@ApiOperation(value = "修改", httpMethod="POST", consumes="application/json", produces="application/json")
 	@PreAuthorize("@pcs.hasPermissions('MusicTag/update')")
 	public HttpResponseResult<Boolean> update(@Validated(MusicTagSaveDto.Update.class) @RequestBody MusicTagSaveDto musicTagSaveDto) {
-		if (musicTagSaveDto.getParentTagId() != null && musicTagSaveDto.getParentTagId() != 0) {
-			MusicTag musicTag = musicTagService.getById(musicTagSaveDto.getParentTagId());
-			if (musicTag.getParentTagId() != 0) {
-				return failed("标签只能有两级");
-			}
-		}
 		return succeed(musicTagService.updateMusicTag(musicTagSaveDto));
 	}
 

+ 13 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/MusicTagSaveDto.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.biz.dal.dto;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModelProperty;
 
 import javax.validation.constraints.NotBlank;
@@ -29,6 +30,18 @@ public class MusicTagSaveDto {
     @NotBlank(message = "标签名称不能为空")
     private String name;
 
+    @NotBlank(message = "标签类型不能为空")
+    @ApiModelProperty("标签类型 MUSIC:曲目 ALBUM:专辑")
+    private String type;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
     public Long getId() {
         return id;
     }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicTagSearch.java

@@ -19,6 +19,17 @@ public class MusicTagSearch extends QueryInfo{
 	@ApiModelProperty("标签状态(0:禁用,1:启用)")
 	private YesOrNoEnum state;
 
+	@ApiModelProperty("标签类型 MUSIC:曲目 ALBUM:专辑")
+	private String type;
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
 	public String getIdAndName() {
 		return idAndName;
 	}

+ 14 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicTag.java

@@ -35,6 +35,10 @@ public class MusicTag implements Serializable {
     @ApiModelProperty(value = "标签状态(0:禁用,1:启用)")
     private YesOrNoEnum state;
 
+    @TableField(value = "type_")
+    @ApiModelProperty("标签类型 MUSIC:曲目 ALBUM:专辑")
+    private String type;
+
 	@TableField(value = "del_flag_")
     @ApiModelProperty(value = "假删标识(0:正常,1:删除)")
     private Boolean delFlag= false;
@@ -59,7 +63,16 @@ public class MusicTag implements Serializable {
     @ApiModelProperty(value = "更新人(后台平台用户)")
     private Long updateBy;  //更新人(老师或者是后台平台用户)
 
-	public Long getId() {
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Long getId() {
         return id;
     }
 

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicTagService.java

@@ -64,8 +64,9 @@ public interface MusicTagService extends IService<MusicTag>  {
 	 * 获取标签树
 	 *
 	 * @return list
+	 * @param type
 	 */
-    List<MusicTagVo> selectMusicTagTree();
+    List<MusicTagVo> selectMusicTagTree(String type);
 
 	/**
 	 * 检查每个二级标签都在不同的一级标签下

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -1015,7 +1015,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         List<ErrMsg> errMsgList = new ArrayList<>();
         dataList.sort(Comparator.comparingInt(ExcelDataReaderProperty::getRowIndex));
         List<MusicSheetDto> musicSheetDtoList = new ArrayList<>();
-        List<MusicTagVo> musicTagVoList = musicTagService.selectMusicTagTree();
+        List<MusicTagVo> musicTagVoList = musicTagService.selectMusicTagTree("MUSIC");
         List<Subject> subjects = subjectService.subjectSelect(null, null);
         Date date = new Date();
         for (ExcelDataReaderProperty<MusicSheetExport> readerProperty : dataList) {

+ 33 - 74
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicTagServiceImpl.java

@@ -43,7 +43,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
     }
 
      @Override
-    public IPage<MusicTagVo> selectPage(IPage<MusicTagVo> page, MusicTagSearch query){
+     public IPage<MusicTagVo> selectPage(IPage<MusicTagVo> page, MusicTagSearch query){
          IPage<MusicTagVo> musicTagVoIPage = page.setRecords(baseMapper.selectPage(page, query));
          // 将父类的id 拿出来,集体查出子集
          List<Long> longList = musicTagVoIPage
@@ -56,34 +56,20 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
 
          // 根据父级id, 将子集分类
          Map<String, List<MusicTagVo>> musicTagMap = musicTagVoList.stream()
-                                                                .collect(Collectors.groupingBy( vo -> vo.getParentTagId().toString()));
+                                                                   .collect(Collectors.groupingBy( vo -> vo.getParentTagId().toString()));
          musicTagVoIPage.getRecords()
-                 .forEach(musicTagVo -> {
-                     List<MusicTagVo> childrenList = musicTagMap.get(musicTagVo.getId().toString());
-                     if (CollectionUtils.isEmpty(childrenList)) {
-                         return;
-                     }
-                     childrenList.forEach(children -> {
-                         musicTagVo.setEnablePlatformMusicSheetNum(musicTagVo.getEnablePlatformMusicSheetNum() + children.getEnablePlatformMusicSheetNum());
-                         musicTagVo.setEnableTeacherMusicSheetNum(musicTagVo.getEnableTeacherMusicSheetNum() + children.getEnableTeacherMusicSheetNum());
-                         musicTagVo.setMusicPlatformSheetNum(musicTagVo.getMusicPlatformSheetNum() + children.getMusicPlatformSheetNum());
-                         musicTagVo.setMusicTeacherSheetNum(musicTagVo.getMusicTeacherSheetNum() + children.getMusicTeacherSheetNum());
-                     });
-                     // 如果没有按名称/编号查询 或 父级标签包含了名称/编号 , 展示所有子集 标签列表子集收起
-                     if (StringUtil.isBlank(query.getIdAndName())
-                             || musicTagVo.getName().contains(query.getIdAndName())
-                             || musicTagVo.getId().toString().contains(query.getIdAndName())) {
-                         musicTagVo.setChildren(childrenList);
-                     } else {
-                         // 如果名称查询中,父级不包含名称/编号,子集包含,只展示包含的子集,并且默认展开子集列表
-                         musicTagVo.setOpen(YesOrNoEnum.YES);
-                         List<MusicTagVo> childrenNameList = childrenList.stream()
-                                                                .filter(vo -> vo.getName().contains(query.getIdAndName())
-                                                                        ||vo.getId().toString().contains(query.getIdAndName()))
-                                                                .collect(Collectors.toList());
-                         musicTagVo.setChildren(childrenNameList);
-                     }
-                 });
+                        .forEach(musicTagVo -> {
+                            List<MusicTagVo> childrenList = musicTagMap.get(musicTagVo.getId().toString());
+                            if (CollectionUtils.isEmpty(childrenList)) {
+                                return;
+                            }
+                            childrenList.forEach(children -> {
+                                musicTagVo.setEnablePlatformMusicSheetNum(musicTagVo.getEnablePlatformMusicSheetNum() + children.getEnablePlatformMusicSheetNum());
+                                musicTagVo.setEnableTeacherMusicSheetNum(musicTagVo.getEnableTeacherMusicSheetNum() + children.getEnableTeacherMusicSheetNum());
+                                musicTagVo.setMusicPlatformSheetNum(musicTagVo.getMusicPlatformSheetNum() + children.getMusicPlatformSheetNum());
+                                musicTagVo.setMusicTeacherSheetNum(musicTagVo.getMusicTeacherSheetNum() + children.getMusicTeacherSheetNum());
+                            });
+                        });
          return musicTagVoIPage;
      }
 
@@ -113,14 +99,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
      */
     private boolean checkTagBeUsed(Long musicTagId) {
 
-        List<MusicTag> list = this.lambdaQuery()
-                                  .eq(MusicTag::getParentTagId, musicTagId)
-                                  .eq(MusicTag::getDelFlag, false)
-                                  .list();
-        List<Long> longs = list.stream().map(MusicTag::getId).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(longs)) {
-            longs = new ArrayList<>();
-        }
+        List<Long> longs = new ArrayList<>();
         longs.add(musicTagId);
         if (baseMapper.checkTagBeUsedMusicAblum(longs) >0) return true;
         if (baseMapper.checkTagBeUsedMusicSheet(longs) >0) return true;
@@ -138,29 +117,16 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
         }
         MusicTag musicTag = new MusicTag();
         musicTag.setId(musicTagId);
-        if (tag.getState().getCode().equals(YesOrNoEnum.NO.getCode())) {
-            musicTag.setState(YesOrNoEnum.YES);
-            return this.updateById(musicTag);
-        } else {
-            // 一级停用,二级也停用
-            if (musicTag.getParentTagId() == null || musicTag.getParentTagId() ==0) {
-                return this.lambdaUpdate()
-                    .eq(MusicTag::getParentTagId,musicTagId)
-                    .or(wrapper -> wrapper.eq(MusicTag::getId,musicTagId))
-                    .set(MusicTag::getState,YesOrNoEnum.NO)
-                    .update();
-            } else {
-                musicTag.setState(YesOrNoEnum.NO);
-                return this.updateById(musicTag);
-            }
-        }
+        musicTag.setState(YesOrNoEnum.YES);
+        return this.updateById(musicTag);
+
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean createMusicTag(MusicTagSaveDto musicTagSaveDto) {
 
-        if (checkNameRepeat(musicTagSaveDto.getName(), musicTagSaveDto.getId())) {
+        if (checkNameRepeat(musicTagSaveDto.getName(), musicTagSaveDto.getId(),musicTagSaveDto.getType())) {
             throw new BizException("标签名称重复");
         }
 
@@ -168,6 +134,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
         MusicTag musicTag = new MusicTag();
         musicTag.setDelFlag(false);
         musicTag.setState(YesOrNoEnum.NO);
+        musicTag.setType(musicTagSaveDto.getType());
         if (musicTagSaveDto.getParentTagId() == null) {
             musicTag.setParentTagId(0L);
         } else {
@@ -186,12 +153,14 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
      *
      * @param name 名称
      * @param id 标签id, 更新
+     * @param type
      * @return boolean
      */
-    private boolean checkNameRepeat(String name,Long id) {
+    private boolean checkNameRepeat(String name, Long id, String type) {
         LambdaQueryChainWrapper<MusicTag> eq = this.lambdaQuery()
-                                                   .eq(MusicTag::getDelFlag, YesOrNoEnum.NO.getCode())
-                                                   .eq(MusicTag::getName, name);
+                .eq(MusicTag::getDelFlag, YesOrNoEnum.NO.getCode())
+                .eq(MusicTag::getName, name)
+                .eq(MusicTag::getType,type);
         if (id != null) {
             eq.ne(MusicTag::getId,id);
         }
@@ -202,7 +171,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
     @Transactional(rollbackFor = Exception.class)
     public boolean updateMusicTag(MusicTagSaveDto musicTagSaveDto) {
 
-        if (checkNameRepeat(musicTagSaveDto.getName(), musicTagSaveDto.getId())) {
+        if (checkNameRepeat(musicTagSaveDto.getName(), musicTagSaveDto.getId(), musicTagSaveDto.getType())) {
             throw new BizException("标签名称重复");
         }
         MusicTag oldTag = super.getById(musicTagSaveDto.getId());
@@ -214,6 +183,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
         MusicTag musicTag = new MusicTag();
         musicTag.setDelFlag(false);
         musicTag.setId(musicTagSaveDto.getId());
+        musicTag.setType(musicTagSaveDto.getType());
         if (musicTagSaveDto.getParentTagId() == null) {
             musicTag.setParentTagId(0L);
         } else {
@@ -226,10 +196,14 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
     }
 
     @Override
-    public List<MusicTagVo> selectMusicTagTree() {
+    public List<MusicTagVo> selectMusicTagTree(String type) {
+        if (StringUtil.isEmpty(type)) {
+            type = "MUSIC";
+        }
         List<MusicTag> list = this.lambdaQuery()
                 .eq(MusicTag::getDelFlag,YesOrNoEnum.NO.getCode())
                 .eq(MusicTag::getState,YesOrNoEnum.YES.getCode())
+                .eq(MusicTag::getType,type)
                 .list();
         if (list == null) {
             return new ArrayList<>();
@@ -240,22 +214,7 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
             return musicTagVo;
         }).collect(Collectors.toList());
 
-        List<MusicTagVo> tree = new ArrayList<>();
-        for (MusicTagVo musicTagVo : musicTagVoList) {
-            if (musicTagVo.getParentTagId() == null || musicTagVo.getParentTagId() == 0) {
-                tree.add(musicTagVo);
-            }
-            for (MusicTagVo tagVo : musicTagVoList) {
-                if (tagVo.getParentTagId() != null && tagVo.getParentTagId() != 0
-                        && tagVo.getParentTagId().equals(musicTagVo.getId())) {
-                    if (musicTagVo.getChildren() == null) {
-                        musicTagVo.setChildren(new ArrayList<>());
-                    }
-                    musicTagVo.getChildren().add(tagVo);
-                }
-            }
-        }
-        return tree;
+        return musicTagVoList;
     }
 
     @Override

+ 7 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicTagMapper.xml

@@ -6,6 +6,7 @@
         <result column="parent_tag_id_" property="parentTagId" />
         <result column="name_" property="name" />
         <result column="state_" property="state" />
+        <result column="type_" property="type" />
         <result column="del_flag_" property="delFlag" />
         <result column="create_time_" property="createTime" />
         <result column="update_time_" property="updateTime" />
@@ -19,6 +20,7 @@
         , t.parent_tag_id_ as parentTagId
         , t.name_ as name
         , t.state_ as state
+        , t.type_ as type
         , t.del_flag_ as delFlag
         , t.create_time_ as createTime
         , t.update_time_ as updateTime
@@ -40,10 +42,13 @@
 		FROM music_tag t
         left join sys_user su on t.update_by_ = su.id_
         <where>
-            t.parent_tag_id_ = 0 and t.del_flag_ = 0
+            t.del_flag_ = 0
             <if test="param.state != null">
                 and t.state_ = #{param.state}
             </if>
+            <if test="param.type != null and param.type != ''">
+                and t.type_ = #{param.type}
+            </if>
             <if test="param.idAndName != null and param.idAndName != ''">
                 and ( t.id_ like concat( '%',#{param.idAndName},'%') or
                     t.name_ like  concat ('%',#{param.idAndName},'%') or
@@ -90,7 +95,7 @@
         <where>
             t.del_flag_ = 0
             <if test="longList != null and longList.size() != 0">
-                and t.parent_tag_id_ in
+                and t.id_ in
                 <foreach collection="longList" close=")" item="item" open="(" separator=",">
                     #{item}
                 </foreach>

+ 2 - 2
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/MusicTagController.java

@@ -26,8 +26,8 @@ public class MusicTagController extends BaseController {
 	 */
 	@GetMapping("/tree")
 	@ApiOperation(value = "查询标签树列表")
-	public HttpResponseResult<List<MusicTagVo>> tree() {
-		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree();
+	public HttpResponseResult<List<MusicTagVo>> tree(String type) {
+		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree(type);
 		return succeed(treeList);
 	}
 

+ 2 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/MusicTagController.java

@@ -26,8 +26,8 @@ public class MusicTagController extends BaseController {
 	 */
 	@GetMapping("/tree")
 	@ApiOperation(value = "查询标签树列表")
-	public HttpResponseResult<List<MusicTagVo>> tree() {
-		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree();
+	public HttpResponseResult<List<MusicTagVo>> tree(String type) {
+		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree(type);
 		return succeed(treeList);
 	}
 

+ 2 - 2
cooleshow-user/user-website/src/main/java/com/yonge/cooleshow/website/controller/open/OpenMusicTagController.java

@@ -26,8 +26,8 @@ public class OpenMusicTagController extends BaseController {
 	 */
 	@GetMapping("/tree")
 	@ApiOperation(value = "查询标签树列表")
-	public HttpResponseResult<List<MusicTagVo>> tree() {
-		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree();
+	public HttpResponseResult<List<MusicTagVo>> tree(String type) {
+		List<MusicTagVo> treeList = musicTagService.selectMusicTagTree(type);
 		return succeed(treeList);
 	}