|
@@ -9,7 +9,6 @@ import com.yonge.cooleshow.biz.dal.dao.MusicTagDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.MusicTagSaveDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.MusicTagSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.MusicTag;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.MusicTagService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MusicTagVo;
|
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
@@ -35,15 +34,13 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
|
|
|
@Autowired
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
- private MusicSheetService musicSheetService;
|
|
|
-
|
|
|
@Override
|
|
|
public MusicTagVo detail(Long id) {
|
|
|
return baseMapper.detail(id);
|
|
|
}
|
|
|
|
|
|
@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 +53,22 @@ 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.getId().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());
|
|
|
+ musicTagVo.setMusicPlatformAlbumNum(musicTagVo.getMusicPlatformAlbumNum() + children.getMusicPlatformAlbumNum());
|
|
|
+ musicTagVo.setEnablePlatformAlbumNum(musicTagVo.getEnablePlatformAlbumNum() + children.getEnablePlatformAlbumNum());
|
|
|
+ });
|
|
|
+ });
|
|
|
return musicTagVoIPage;
|
|
|
}
|
|
|
|
|
@@ -113,19 +98,10 @@ 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;
|
|
|
-
|
|
|
- return false;
|
|
|
+ if (baseMapper.checkTagBeUsedMusicAlbum(longs) >0) return true;
|
|
|
+ return baseMapper.checkTagBeUsedMusicSheet(longs) > 0;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -138,29 +114,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(tag.getState().equals(YesOrNoEnum.YES)?YesOrNoEnum.NO: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,11 +131,13 @@ 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 {
|
|
|
musicTag.setParentTagId(musicTagSaveDto.getParentTagId());
|
|
|
}
|
|
|
+ musicTag.setSortNumber(musicTagSaveDto.getSortNumber());
|
|
|
musicTag.setName(musicTagSaveDto.getName());
|
|
|
musicTag.setCreateTime(new Date());
|
|
|
musicTag.setUpdateTime(new Date());
|
|
@@ -186,12 +151,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 +169,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 +181,8 @@ public class MusicTagServiceImpl extends ServiceImpl<MusicTagDao, MusicTag> impl
|
|
|
MusicTag musicTag = new MusicTag();
|
|
|
musicTag.setDelFlag(false);
|
|
|
musicTag.setId(musicTagSaveDto.getId());
|
|
|
+ musicTag.setSortNumber(musicTagSaveDto.getSortNumber());
|
|
|
+ musicTag.setType(musicTagSaveDto.getType());
|
|
|
if (musicTagSaveDto.getParentTagId() == null) {
|
|
|
musicTag.setParentTagId(0L);
|
|
|
} else {
|
|
@@ -226,36 +195,25 @@ 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)
|
|
|
+ .orderByDesc(MusicTag::getSortNumber)
|
|
|
.list();
|
|
|
if (list == null) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- List<MusicTagVo> musicTagVoList = list.stream().map(musicTag -> {
|
|
|
+
|
|
|
+ return list.stream().map(musicTag -> {
|
|
|
MusicTagVo musicTagVo = new MusicTagVo();
|
|
|
BeanUtils.copyProperties(musicTag, musicTagVo);
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
@Override
|