|
@@ -3,19 +3,19 @@ package com.citu.module.menduner.system.service.area;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
-import com.citu.module.menduner.system.controller.admin.area.vo.AreaListReqVO;
|
|
|
|
-import com.citu.module.menduner.system.controller.admin.area.vo.AreaPageReqVO;
|
|
|
|
-import com.citu.module.menduner.system.controller.admin.area.vo.AreaSaveReqVO;
|
|
|
|
|
|
+import com.citu.module.menduner.system.controller.admin.area.vo.*;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaChildrenRespVO;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaChildrenRespVO;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaListReqVO;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaListReqVO;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaSimpleRespVO;
|
|
import com.citu.module.menduner.system.controller.app.area.vo.AppAreaSimpleRespVO;
|
|
|
|
+import com.citu.module.menduner.system.controller.app.area.vo.AppHotAreaRespVO;
|
|
import com.citu.module.menduner.system.convert.AreaConvert;
|
|
import com.citu.module.menduner.system.convert.AreaConvert;
|
|
import com.citu.module.menduner.system.dal.dataobject.area.AreaDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.area.AreaDO;
|
|
|
|
+import com.citu.module.menduner.system.dal.dataobject.area.AreaHotDO;
|
|
|
|
+import com.citu.module.menduner.system.dal.mysql.area.AreaHotMapper;
|
|
import com.citu.module.menduner.system.dal.mysql.area.AreaMapper;
|
|
import com.citu.module.menduner.system.dal.mysql.area.AreaMapper;
|
|
import com.citu.module.menduner.system.dal.redis.RedisKeyConstants;
|
|
import com.citu.module.menduner.system.dal.redis.RedisKeyConstants;
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static com.citu.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static com.citu.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
+import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_AREA_HOT_EXISTS;
|
|
import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_AREA_NOT_EXISTS;
|
|
import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_AREA_NOT_EXISTS;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -39,6 +40,9 @@ public class AreaServiceImpl implements AreaService {
|
|
@Resource
|
|
@Resource
|
|
private AreaMapper areaMapper;
|
|
private AreaMapper areaMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private AreaHotMapper hotMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Long createArea(AreaSaveReqVO createReqVO) {
|
|
public Long createArea(AreaSaveReqVO createReqVO) {
|
|
// 插入
|
|
// 插入
|
|
@@ -158,7 +162,76 @@ public class AreaServiceImpl implements AreaService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<AppAreaSimpleRespVO> getHotArea() {
|
|
|
|
- return Collections.emptyList();
|
|
|
|
|
|
+ public List<AppHotAreaRespVO> getHotArea() {
|
|
|
|
+ List<AreaHotDO> hotList = hotMapper.selectList();
|
|
|
|
+ if (CollUtil.isEmpty(hotList)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<AreaDO> areaList = areaMapper.selectListByIdList(hotList.stream().map(AreaHotDO::getAreaId).collect(Collectors.toList()));
|
|
|
|
+ if (CollUtil.isEmpty(areaList)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<AppHotAreaRespVO> list = new ArrayList<>();
|
|
|
|
+ areaList.forEach(area -> {
|
|
|
|
+ AppHotAreaRespVO respVO = new AppHotAreaRespVO();
|
|
|
|
+ respVO.setId(area.getId());
|
|
|
|
+ respVO.setName(area.getName());
|
|
|
|
+ respVO.setType(area.getType());
|
|
|
|
+ respVO.setParentId(area.getParentId());
|
|
|
|
+ AreaHotDO hot = hotList.stream().filter(c -> c.getAreaId().equals(area.getId())).findFirst().orElse(null);
|
|
|
|
+ if (null != hot) {
|
|
|
|
+ respVO.setRemark(hot.getRemark());
|
|
|
|
+ respVO.setSort(hot.getSort());
|
|
|
|
+ }
|
|
|
|
+ list.add(respVO);
|
|
|
|
+ });
|
|
|
|
+ Collections.sort(list, Comparator.comparingInt(p -> p.getSort()));
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<AreaHotRespVO> getHotAreaList() {
|
|
|
|
+ List<AreaHotDO> hotList = hotMapper.selectList();
|
|
|
|
+ if (CollUtil.isEmpty(hotList)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<AreaDO> areaList = areaMapper.selectListByIdList(hotList.stream().map(AreaHotDO::getAreaId).collect(Collectors.toList()));
|
|
|
|
+ if (CollUtil.isEmpty(areaList)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<AreaHotRespVO> list = new ArrayList<>();
|
|
|
|
+ areaList.forEach(area -> {
|
|
|
|
+ AreaHotRespVO respVO = new AreaHotRespVO();
|
|
|
|
+ respVO.setId(area.getId());
|
|
|
|
+ respVO.setAreaId(area.getId());
|
|
|
|
+ respVO.setName(area.getName());
|
|
|
|
+ respVO.setType(area.getType());
|
|
|
|
+ AreaHotDO hot = hotList.stream().filter(c -> c.getAreaId().equals(area.getId())).findFirst().orElse(null);
|
|
|
|
+ if (null != hot) {
|
|
|
|
+ respVO.setRemark(hot.getRemark());
|
|
|
|
+ }
|
|
|
|
+ list.add(respVO);
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ Collections.sort(list, Comparator.comparingInt(p -> p.getSort()));
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Long createHotArea(AreaHotReqVO reqVO) {
|
|
|
|
+ AreaHotDO hot = hotMapper.selectByAreaId(reqVO.getAreaId());
|
|
|
|
+ if (null != hot) {
|
|
|
|
+ throw exception(MDE_AREA_HOT_EXISTS);
|
|
|
|
+ }
|
|
|
|
+ // 插入
|
|
|
|
+ AreaHotDO hotDO = BeanUtils.toBean(reqVO, AreaHotDO.class);
|
|
|
|
+ hotMapper.insert(hotDO);
|
|
|
|
+ // 返回
|
|
|
|
+ return hotDO.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void removeHotArea(Long id) {
|
|
|
|
+ hotMapper.deleteById(id);
|
|
}
|
|
}
|
|
}
|
|
}
|