|
@@ -1,57 +1,33 @@
|
|
|
package com.zanxiang.manage.service.Impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.zanxiang.common.enums.GameCategoryEnum;
|
|
|
-import com.zanxiang.common.exception.BaseException;
|
|
|
-import com.zanxiang.common.utils.StringUtils;
|
|
|
import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
-import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.manage.domain.dto.GameCategoryDTO;
|
|
|
-import com.zanxiang.manage.domain.params.GameCategoryAddUpdateParam;
|
|
|
-import com.zanxiang.manage.domain.params.GameCategoryListParam;
|
|
|
-import com.zanxiang.manage.domain.vo.GameCategoryParentVO;
|
|
|
+import com.zanxiang.manage.domain.vo.GameCategoryChoiceVO;
|
|
|
import com.zanxiang.manage.domain.vo.GameCategoryVO;
|
|
|
import com.zanxiang.manage.service.GameCategoryService;
|
|
|
import com.zanxiang.mybatis.entity.GameCategory;
|
|
|
import com.zanxiang.mybatis.mapper.GameCategoryMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author : lingfeng
|
|
|
* @time : 2022-06-23
|
|
|
- * @description : 游戏分类标签管理
|
|
|
+ * @description : 游戏应用类型
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class GameCategoryServiceImpl extends ServiceImpl<GameCategoryMapper, GameCategory> implements GameCategoryService {
|
|
|
|
|
|
- /**
|
|
|
- * 根据主键id查询分类以及子分类
|
|
|
- *
|
|
|
- * @param idList : 主键id列表
|
|
|
- * @param type : 类型
|
|
|
- * @return : 返回游戏分类信息
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<GameCategoryVO> listByIdList(List<Long> idList, Integer type) {
|
|
|
- List<GameCategory> gameCategoryList = super.list(new LambdaQueryWrapper<GameCategory>()
|
|
|
- .eq(GameCategory::getType, type)
|
|
|
- .in(GameCategory::getId, idList));
|
|
|
- return BeanUtils.copyList(gameCategoryList, GameCategoryVO.class);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 根据主键id查询
|
|
|
*
|
|
@@ -64,24 +40,13 @@ public class GameCategoryServiceImpl extends ServiceImpl<GameCategoryMapper, Gam
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查询所有父标签列表
|
|
|
+ * 查询所有应用类型列表
|
|
|
*
|
|
|
- * @param type : 标签分类
|
|
|
- * @return : 返回所有父游戏标签
|
|
|
+ * @return : 返回所有应用类型
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<GameCategoryParentVO> getGameCategoryParent(Integer type) {
|
|
|
- List<GameCategory> gameCategoryList = list(new LambdaQueryWrapper<GameCategory>()
|
|
|
- .eq(GameCategory::getType, type)
|
|
|
- .eq(Objects.equals(type, GameCategoryEnum.GAME_TYPE.getCategoryType()), GameCategory::getParentId, 0));
|
|
|
- List<GameCategoryParentVO> voList = BeanUtils.copyList(gameCategoryList, GameCategoryParentVO.class);
|
|
|
- for (GameCategoryParentVO vo : voList) {
|
|
|
- if (Objects.equals(vo.getParentId(), 0L)) {
|
|
|
- vo.setIsParent(Boolean.TRUE);
|
|
|
- vo.setParentId(vo.getParentId());
|
|
|
- }
|
|
|
- }
|
|
|
- return voList;
|
|
|
+ public List<GameCategoryChoiceVO> gameCategoryChoiceList() {
|
|
|
+ return BeanUtils.copyList(super.list(), GameCategoryChoiceVO.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,114 +65,4 @@ public class GameCategoryServiceImpl extends ServiceImpl<GameCategoryMapper, Gam
|
|
|
return gameCategoryDTOList.stream().collect(Collectors.toMap(GameCategoryDTO::getId, Function.identity()));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询游戏标签列表
|
|
|
- *
|
|
|
- * @param param : 游戏标签列表查询呢参数
|
|
|
- * @return : 返回分页信息
|
|
|
- */
|
|
|
- @Override
|
|
|
- public IPage<GameCategoryVO> list(GameCategoryListParam param) {
|
|
|
- //模糊查询父标签列表
|
|
|
- List<GameCategory> categoryList = new ArrayList<>();
|
|
|
- if (Strings.isNotBlank(param.getLabelName()) && Objects.equals(param.getIsParent(), Boolean.TRUE)) {
|
|
|
- categoryList = super.list(new LambdaQueryWrapper<GameCategory>()
|
|
|
- .like(GameCategory::getName, param.getLabelName())
|
|
|
- .eq(GameCategory::getParentId, 0)
|
|
|
- .eq(GameCategory::getType, GameCategoryEnum.GAME_LABEL.getCategoryType()));
|
|
|
- //查询父标签, 但是却查不到, 直接返回空
|
|
|
- if (categoryList.isEmpty()) {
|
|
|
- return new Page<>(param.getPageNum(), param.getPageSize());
|
|
|
- }
|
|
|
- }
|
|
|
- List<Long> parentIdList = categoryList.stream().map(GameCategory::getId).collect(Collectors.toList());
|
|
|
- return page(param.toPage(), new QueryWrapper<GameCategory>().lambda()
|
|
|
- //条件不为空没勾选父标签
|
|
|
- .like(StringUtils.isNotBlank(param.getLabelName()) && !Objects.equals(param.getIsParent(), Boolean.TRUE),
|
|
|
- GameCategory::getName, param.getLabelName())
|
|
|
- //条件为空查询所有父标签
|
|
|
- .eq(StringUtils.isBlank(param.getLabelName()) && Objects.equals(param.getIsParent(), Boolean.TRUE),
|
|
|
- GameCategory::getParentId, 0)
|
|
|
- //条件不为空查询父标签
|
|
|
- .and(StringUtils.isNotBlank(param.getLabelName()) && Objects.equals(param.getIsParent(), Boolean.TRUE),
|
|
|
- qw -> qw.in(GameCategory::getParentId, parentIdList).or().like(GameCategory::getName, param.getLabelName()))
|
|
|
- .eq(GameCategory::getType, GameCategoryEnum.GAME_LABEL.getCategoryType())
|
|
|
- .orderByDesc(GameCategory::getCreateTime))
|
|
|
- .convert(this::toVo);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 游戏标签对象转换
|
|
|
- *
|
|
|
- * @param gameCategory : 游戏标签信息
|
|
|
- * @return : 返回游戏标签vo
|
|
|
- */
|
|
|
- private GameCategoryVO toVo(GameCategory gameCategory) {
|
|
|
- if (Objects.isNull(gameCategory)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- GameCategoryVO categoryVO = BeanUtils.copy(gameCategory, GameCategoryVO.class);
|
|
|
- if (Objects.equals(categoryVO.getParentId(), 0L)) {
|
|
|
- categoryVO.setParentName(categoryVO.getName());
|
|
|
- } else {
|
|
|
- GameCategory category = super.getById(categoryVO.getParentId());
|
|
|
- if (category != null) {
|
|
|
- categoryVO.setParentName(category.getName());
|
|
|
- }
|
|
|
- }
|
|
|
- return categoryVO;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 游戏标签分类添加或修改
|
|
|
- *
|
|
|
- * @param param : 参数
|
|
|
- * @return : 返回结果
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Boolean addOrUpdate(GameCategoryAddUpdateParam param) {
|
|
|
- Long id = param.getId();
|
|
|
- Long parentId = param.getParentId() == null ? 0 : param.getParentId();
|
|
|
- //更新
|
|
|
- if (id != null) {
|
|
|
- GameCategory gameCategory = super.getById(id);
|
|
|
- if (gameCategory == null) {
|
|
|
- throw new BaseException("参数错误, 游戏分类标签信息不存在");
|
|
|
- }
|
|
|
- gameCategory.setParentId(parentId);
|
|
|
- gameCategory.setName(param.getName());
|
|
|
- gameCategory.setRemark(param.getRemark());
|
|
|
- gameCategory.setUpdateTime(LocalDateTime.now());
|
|
|
- return super.updateById(gameCategory);
|
|
|
- }
|
|
|
- //判断cp名称是否已经存在
|
|
|
- int count = super.count(new LambdaQueryWrapper<GameCategory>()
|
|
|
- .eq(GameCategory::getName, param.getName()));
|
|
|
- if (count > 0) {
|
|
|
- throw new BaseException("游戏分类标签名称已经存在");
|
|
|
- }
|
|
|
- //创建
|
|
|
- return super.save(GameCategory.builder()
|
|
|
- .type(GameCategoryEnum.GAME_LABEL.getCategoryType())
|
|
|
- .name(param.getName())
|
|
|
- .remark(param.getRemark())
|
|
|
- .parentId(parentId)
|
|
|
- .operatorId(SecurityUtil.getUserId())
|
|
|
- .operatorName(SecurityUtil.getTokenInfo().getNickname())
|
|
|
- .createTime(LocalDateTime.now())
|
|
|
- .updateTime(LocalDateTime.now())
|
|
|
- .build());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据主键id删除
|
|
|
- *
|
|
|
- * @param id : 主键id
|
|
|
- * @return : 删除结果
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Boolean deleteById(Long id) {
|
|
|
- return super.removeById(id);
|
|
|
- }
|
|
|
-
|
|
|
}
|