Browse Source

模块分类bug修改

feature/syp_points
songyunpeng 5 years ago
parent
commit
94fc9424ac
  1. 21
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/ModuleCategoryController.java
  2. 16
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/ModuleCategoryDao.java
  3. 11
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/ModuleCategoryService.java
  4. 42
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/ModuleCategoryServiceImpl.java
  5. 13
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml

21
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/ModuleCategoryController.java

@ -20,7 +20,6 @@ package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
@ -70,6 +69,18 @@ public class ModuleCategoryController {
List<ModuleCategoryDTO> list = moduleCategoryService.list(new HashMap<>(1)); List<ModuleCategoryDTO> list = moduleCategoryService.list(new HashMap<>(1));
return new Result<List<ModuleCategoryDTO>>().ok(list); return new Result<List<ModuleCategoryDTO>>().ok(list);
} }
/**
* @Description 内容管理新增通知时使用
* @Author songyunpeng
* @Date 2020/10/28
* @Param []
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.ModuleCategoryDTO>>
**/
@GetMapping("getListToShow")
public Result<List<ModuleCategoryDTO>> getListToShow(){
List<ModuleCategoryDTO> list = moduleCategoryService.getListToShow(new HashMap<>(1));
return new Result<List<ModuleCategoryDTO>>().ok(list);
}
@GetMapping("{id}") @GetMapping("{id}")
public Result<ModuleCategoryDTO> get(@PathVariable("id") String id){ public Result<ModuleCategoryDTO> get(@PathVariable("id") String id){
@ -93,11 +104,9 @@ public class ModuleCategoryController {
return new Result(); return new Result();
} }
@DeleteMapping @DeleteMapping("{id}")
public Result delete(@RequestBody String[] ids){ public Result delete(@PathVariable("id") String id){
//效验数据 moduleCategoryService.delete(id);
AssertUtils.isArrayEmpty(ids, "id");
moduleCategoryService.delete(ids);
return new Result(); return new Result();
} }

16
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/ModuleCategoryDao.java

@ -44,6 +44,14 @@ public interface ModuleCategoryDao extends BaseDao<ModuleCategoryEntity> {
* @return java.util.List<com.elink.esua.epdc.modules.moduleCategory.entity.ModuleCategoryEntity> * @return java.util.List<com.elink.esua.epdc.modules.moduleCategory.entity.ModuleCategoryEntity>
**/ **/
List<ModuleCategoryEntity> getList(Map<String, Object> params); List<ModuleCategoryEntity> getList(Map<String, Object> params);
/**
* @Description 内容管理新增通知时使用
* @Author songyunpeng
* @Date 2020/10/29
* @Param [params]
* @return java.util.List<com.elink.esua.epdc.modules.moduleCategory.entity.ModuleCategoryEntity>
**/
List<ModuleCategoryEntity> getListToShow(Map<String, Object> params);
/** /**
* @Description 查询类别tree * @Description 查询类别tree
* @Author songyunpeng * @Author songyunpeng
@ -83,4 +91,12 @@ public interface ModuleCategoryDao extends BaseDao<ModuleCategoryEntity> {
* @return java.util.List<java.lang.String> * @return java.util.List<java.lang.String>
**/ **/
List<String> getModuleCategoryCodesHierarchy(@Param("moduleCategoryIds") List<String> moduleCategoryIds); List<String> getModuleCategoryCodesHierarchy(@Param("moduleCategoryIds") List<String> moduleCategoryIds);
/**
* @Description 根据ID查询所有下级ID列表
* @Author songyunpeng
* @Date 2020/11/2
* @Param [s]
* @return java.util.List<java.lang.String>
**/
List<String> getSubModuleCategoryIdList(String id);
} }

11
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/ModuleCategoryService.java

@ -56,6 +56,15 @@ public interface ModuleCategoryService extends BaseService<ModuleCategoryEntity>
* @date 2020-10-28 * @date 2020-10-28
*/ */
List<ModuleCategoryDTO> list(Map<String, Object> params); List<ModuleCategoryDTO> list(Map<String, Object> params);
/**
* 内容管理新增通知时使用
*
* @param params
* @return java.util.List<ModuleCategoryDTO>
* @author generator
* @date 2020-10-28
*/
List<ModuleCategoryDTO> getListToShow(Map<String, Object> params);
/** /**
* 单条查询 * 单条查询
@ -100,7 +109,7 @@ public interface ModuleCategoryService extends BaseService<ModuleCategoryEntity>
* @author generator * @author generator
* @date 2020-10-28 * @date 2020-10-28
*/ */
void delete(String[] ids); void delete(String ids);
/** /**
* @Description 查询事件类别树, 供下拉框调用 * @Description 查询事件类别树, 供下拉框调用
* @Author songyunpeng * @Author songyunpeng

42
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/ModuleCategoryServiceImpl.java

@ -24,7 +24,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.exception.ErrorCode;
import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
@ -76,6 +75,14 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao
return TreeUtils.build(dtoList); return TreeUtils.build(dtoList);
} }
@Override
public List<ModuleCategoryDTO> getListToShow(Map<String, Object> params) {
List<ModuleCategoryEntity> entityList = baseDao.getListToShow(params);
List<ModuleCategoryDTO> dtoList = ConvertUtils.sourceToTarget(entityList, ModuleCategoryDTO.class);
return TreeUtils.build(dtoList);
}
private QueryWrapper<ModuleCategoryEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<ModuleCategoryEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP); String id = (String)params.get(FieldConstant.ID_HUMP);
@ -185,7 +192,7 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao
ModuleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ModuleCategoryEntity.class); ModuleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ModuleCategoryEntity.class);
//上级部门不能为自身 //上级部门不能为自身
if (entity.getId().equals(entity.getPid())) { if (entity.getId().equals(entity.getPid())) {
throw new RenException(ErrorCode.SUPERIOR_DEPT_ERROR); throw new RenException("上级分类不能为自身");
} }
List<ModuleCategoryEntity> list = getPidListByPid(entity.getPid()); List<ModuleCategoryEntity> list = getPidListByPid(entity.getPid());
if (list.size() == 0) { if (list.size() == 0) {
@ -201,14 +208,39 @@ public class ModuleCategoryServiceImpl extends BaseServiceImpl<ModuleCategoryDao
} }
entity.setPids(pids); entity.setPids(pids);
} }
//更新启用标识 : 是,则更新上级为是 否 则下级全为否
if("1".equals(entity.getEnableFlag())){
ModuleCategoryEntity pModuleCategoryEntity = selectById(entity.getPid());
if(pModuleCategoryEntity!=null){
pModuleCategoryEntity.setEnableFlag("1");
updateById(pModuleCategoryEntity);
}
} else if("0".equals(entity.getEnableFlag())) {
List<String> subModuleCategoryIdList = baseDao.getSubModuleCategoryIdList("%"+entity.getId()+"%");
if(subModuleCategoryIdList!=null && subModuleCategoryIdList.size() > 0){
List<ModuleCategoryEntity> moduleCategoryEntities = baseDao.selectBatchIds(subModuleCategoryIdList);
moduleCategoryEntities.forEach(moduleCategoryEntity -> moduleCategoryEntity.setEnableFlag("0"));
updateBatchById(moduleCategoryEntities);
}
}
updateById(entity); updateById(entity);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) { public void delete(String id) {
// 逻辑删除(@TableLogic 注解) //判断是否有子部门
baseDao.deleteBatchIds(Arrays.asList(ids)); List<String> subList = SubModuleCategoryIdList(id);
if (subList.size() > 1) {
throw new RenException("请先删除下级分类");
}
baseDao.deleteBatchIds(Arrays.asList(new String[]{id}));
}
private List<String> SubModuleCategoryIdList(String id) {
List<String> subCategoryIdList = baseDao.getSubModuleCategoryIdList("%" + id + "%");
subCategoryIdList.add(id);
return subCategoryIdList;
} }
@Override @Override

13
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml

@ -24,8 +24,14 @@
<result property="updatedTime" column="UPDATED_TIME"/> <result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<select id="getList" resultType="com.elink.esua.epdc.entity.ModuleCategoryEntity"> <select id="getList" resultType="com.elink.esua.epdc.entity.ModuleCategoryEntity">
select t1.*,t1.id as value,t1.category_name as label,(select t2.category_name from epdc_module_category t2 where t2.id=t1.pid)parentName from epdc_module_category t1 select t1.*,t1.id as value,t1.category_name as label,(select t2.category_name from epdc_module_category t2 where t2.id=t1.pid)parentName from epdc_module_category t1
where t1.del_flag = '0' AND t1.enable_flag = '1' where t1.del_flag = '0'
order by t1.sort asc
</select>
<select id="getListToShow" resultType="com.elink.esua.epdc.entity.ModuleCategoryEntity">
select t1.*,t1.id as value,t1.category_name as label,(select t2.category_name from epdc_module_category t2 where t2.id=t1.pid)parentName from epdc_module_category t1
where t1.del_flag = '0' and t1.ENABLE_FLAG = '1'
order by t1.sort asc order by t1.sort asc
</select> </select>
<select id="selectListCategoryTreeDTO" resultType="com.elink.esua.epdc.dto.ModuleCategoryTreeDTO"> <select id="selectListCategoryTreeDTO" resultType="com.elink.esua.epdc.dto.ModuleCategoryTreeDTO">
@ -78,6 +84,9 @@
</foreach> </foreach>
order by LENGTH(PIDS) order by LENGTH(PIDS)
</select> </select>
<select id="getSubModuleCategoryIdList" resultType="java.lang.String">
select id from epdc_module_category where pids like #{id} and del_flag = 0
</select>
</mapper> </mapper>
Loading…
Cancel
Save