Browse Source

我要提建议,界面开发

origin/epidemic_user
zhangyongzhangyong 4 years ago
parent
commit
d788847455
  1. 13
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionFeedbackController.java
  2. 2
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionMakeController.java
  3. 16
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionTypeController.java
  4. 21
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/dao/SuggestionMakeDao.java
  5. 29
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/dao/SuggestionTypeDao.java
  6. 28
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/entity/SuggestionTypeEntity.java
  7. 11
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/SuggestionFeedbackService.java
  8. 2
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/SuggestionTypeService.java
  9. 27
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionFeedbackServiceImpl.java
  10. 35
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionMakeServiceImpl.java
  11. 67
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionTypeServiceImpl.java
  12. 2
      epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionFeedbackDao.xml
  13. 83
      epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionMakeDao.xml
  14. 21
      epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionTypeDao.xml

13
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionFeedbackController.java

@ -25,6 +25,7 @@ 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.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.dto.FeedbackInfoDTO;
import com.elink.esua.epdc.dto.suggestion.SuggestionFeedbackDTO;
import com.elink.esua.epdc.modules.suggestion.excel.SuggestionFeedbackExcel;
import com.elink.esua.epdc.modules.suggestion.service.SuggestionFeedbackService;
@ -91,4 +92,16 @@ public class SuggestionFeedbackController {
ExcelUtils.exportExcelToTarget(response, null, list, SuggestionFeedbackExcel.class);
}
/**
* 查询 回馈信息
*
* @param suggestionMarkId
* @return java.util.List<com.elink.esua.epdc.dto.FeedbackInfoDTO>
* @Author zhangyong
* @Date 15:33 2021-09-16
**/
@GetMapping("feedbackInfo/{suggestionMarkId}")
public Result<List<FeedbackInfoDTO>> feedbackInfo(@PathVariable("suggestionMarkId") String suggestionMarkId) {
return new Result<List<FeedbackInfoDTO>>().ok(suggestionFeedbackService.getFeedbackInfo(suggestionMarkId));
}
}

2
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionMakeController.java

@ -130,7 +130,7 @@ public class SuggestionMakeController {
* @Author zhangyong
* @Date 15:58 2021-09-14
**/
@PostMapping("mySuggestion")
@GetMapping("mySuggestion")
public Result<List<MySuggestionResultDTO>> mySuggestion(@RequestBody MySuggestionFormDTO formDTO) {
return suggestionMakeService.getMySuggestion(formDTO);
}

16
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/controller/SuggestionTypeController.java

@ -25,6 +25,7 @@ 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.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.DeptOption;
import com.elink.esua.epdc.dto.TypeNode;
import com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO;
import com.elink.esua.epdc.modules.suggestion.excel.SuggestionTypeExcel;
@ -33,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -56,6 +58,12 @@ public class SuggestionTypeController {
return new Result<PageData<SuggestionTypeDTO>>().ok(page);
}
@GetMapping("list")
public Result<List<SuggestionTypeDTO>> list(@RequestParam Map<String, Object> params){
List<SuggestionTypeDTO> list = suggestionTypeService.list(params);
return new Result<List<SuggestionTypeDTO>>().ok(list);
}
@GetMapping("{id}")
public Result<SuggestionTypeDTO> get(@PathVariable("id") String id){
SuggestionTypeDTO data = suggestionTypeService.get(id);
@ -78,11 +86,11 @@ public class SuggestionTypeController {
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
@DeleteMapping("{id}")
public Result delete(@PathVariable("id") Long id){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
suggestionTypeService.delete(ids);
AssertUtils.isNull(id, "id");
suggestionTypeService.deleteBatchIds(Arrays.asList(new Long[]{id}));
return new Result();
}

21
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/dao/SuggestionMakeDao.java

@ -18,12 +18,15 @@
package com.elink.esua.epdc.modules.suggestion.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO;
import com.elink.esua.epdc.dto.suggestion.form.MySuggestionFormDTO;
import com.elink.esua.epdc.dto.suggestion.result.MySuggestionResultDTO;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionMakeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 我有建议要提
@ -43,4 +46,22 @@ public interface SuggestionMakeDao extends BaseDao<SuggestionMakeEntity> {
* @Date 16:29 2021-09-14
**/
List<MySuggestionResultDTO> selectListMySuggestion(MySuggestionFormDTO formDTO);
/**
* PC 首页查询
* @param params
* @return java.util.List<com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO>
* @Author zhangyong
* @Date 14:10 2021-09-16
**/
List<SuggestionMakeDTO> selectListPage(Map<String, Object> params);
/**
* 详情查询
* @param id
* @return com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO
* @Author zhangyong
* @Date 15:13 2021-09-16
**/
SuggestionMakeDTO selectDetailById(@Param("id") String id);
}

29
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/dao/SuggestionTypeDao.java

@ -22,6 +22,7 @@ import com.elink.esua.epdc.dto.TypeNode;
import com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
import java.util.Map;
@ -44,4 +45,32 @@ public interface SuggestionTypeDao extends BaseDao<SuggestionTypeEntity> {
* @Date 14:23 2021-09-14
**/
List<TypeNode> selectListSuggestionTypeTree();
/**
* 查询所有
*
* @param params
* @return java.util.List<com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO>
* @Author zhangyong
* @Date 15:10 2021-09-15
**/
List<SuggestionTypeDTO> getList(Map<String, Object> params);
/**
* 所有部门的idpid列表
* @param
* @return java.util.List<com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity>
* @Author zhangyong
* @Date 17:49 2021-09-15
**/
List<SuggestionTypeEntity> getIdAndPidList();
/**
* 详情查询
* @param id
* @return com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO
* @Author zhangyong
* @Date 18:05 2021-09-15
**/
SuggestionTypeDTO getById(@PathVariable("id") String id);
}

28
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/entity/SuggestionTypeEntity.java

@ -17,9 +17,11 @@
package com.elink.esua.epdc.modules.suggestion.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -34,7 +36,7 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_suggestion_type")
public class SuggestionTypeEntity extends BaseEpdcEntity {
public class SuggestionTypeEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -46,7 +48,7 @@ public class SuggestionTypeEntity extends BaseEpdcEntity {
/**
* 上级ID
*/
private String pid;
private Long pid;
/**
* 所有上级ID用逗号分开
@ -63,4 +65,22 @@ public class SuggestionTypeEntity extends BaseEpdcEntity {
*/
private String enableFlag;
/**
* 删除标识 0未删除 1删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
}

11
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/SuggestionFeedbackService.java

@ -19,6 +19,7 @@ package com.elink.esua.epdc.modules.suggestion.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.FeedbackInfoDTO;
import com.elink.esua.epdc.dto.suggestion.SuggestionFeedbackDTO;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionFeedbackEntity;
@ -92,4 +93,14 @@ public interface SuggestionFeedbackService extends BaseService<SuggestionFeedbac
* @date 2021-09-14
*/
void delete(String[] ids);
/**
* 查询回馈信息
*
* @param suggestionMarkId
* @return java.util.List<com.elink.esua.epdc.dto.FeedbackInfoDTO>
* @Author zhangyong
* @Date 15:34 2021-09-16
**/
List<FeedbackInfoDTO> getFeedbackInfo(String suggestionMarkId);
}

2
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/SuggestionTypeService.java

@ -20,6 +20,7 @@ package com.elink.esua.epdc.modules.suggestion.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.DeptOption;
import com.elink.esua.epdc.dto.TypeNode;
import com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity;
@ -104,4 +105,5 @@ public interface SuggestionTypeService extends BaseService<SuggestionTypeEntity>
* @Date 14:15 2021-09-14
**/
Result<List<TypeNode>> getSuggestionTypeTree();
}

27
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionFeedbackServiceImpl.java

@ -20,14 +20,20 @@ package com.elink.esua.epdc.modules.suggestion.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser;
import com.elink.esua.epdc.commons.tools.security.user.UserDetail;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dto.FeedbackInfoDTO;
import com.elink.esua.epdc.dto.suggestion.SuggestionFeedbackDTO;
import com.elink.esua.epdc.modules.suggestion.dao.SuggestionFeedbackDao;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionFeedbackEntity;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionMakeEntity;
import com.elink.esua.epdc.modules.suggestion.redis.SuggestionFeedbackRedis;
import com.elink.esua.epdc.modules.suggestion.service.SuggestionFeedbackService;
import com.elink.esua.epdc.modules.suggestion.service.SuggestionMakeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -48,6 +54,8 @@ public class SuggestionFeedbackServiceImpl extends BaseServiceImpl<SuggestionFee
@Autowired
private SuggestionFeedbackRedis suggestionFeedbackRedis;
@Autowired
private SuggestionMakeService suggestionMakeService;
@Override
public PageData<SuggestionFeedbackDTO> page(Map<String, Object> params) {
@ -84,16 +92,31 @@ public class SuggestionFeedbackServiceImpl extends BaseServiceImpl<SuggestionFee
@Transactional(rollbackFor = Exception.class)
public void save(SuggestionFeedbackDTO dto) {
SuggestionFeedbackEntity entity = ConvertUtils.sourceToTarget(dto, SuggestionFeedbackEntity.class);
setDeptInfo(entity);
insert(entity);
SuggestionMakeEntity makeEntity = new SuggestionMakeEntity();
makeEntity.setId(dto.getSuggestionId());
makeEntity.setIsFeedback(NumConstant.ONE_STR);
suggestionMakeService.updateById(makeEntity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(SuggestionFeedbackDTO dto) {
SuggestionFeedbackEntity entity = ConvertUtils.sourceToTarget(dto, SuggestionFeedbackEntity.class);
setDeptInfo(entity);
updateById(entity);
}
private void setDeptInfo(SuggestionFeedbackEntity entity) {
UserDetail user = SecurityUser.getUser();
if (null == user) {
throw new RuntimeException("获取当前部门信息失败,请联系管理员");
}
entity.setDeptId(user.getDeptId());
entity.setDeptName(user.getDeptName());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
@ -101,4 +124,8 @@ public class SuggestionFeedbackServiceImpl extends BaseServiceImpl<SuggestionFee
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public List<FeedbackInfoDTO> getFeedbackInfo(String suggestionMarkId) {
return baseDao.selectListMyFeedbackContent(suggestionMarkId);
}
}

35
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionMakeServiceImpl.java

@ -20,11 +20,11 @@ package com.elink.esua.epdc.modules.suggestion.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.NumConstant;
import com.elink.esua.epdc.commons.tools.constant.StrConstant;
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.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.ImageConstant;
import com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO;
@ -34,19 +34,18 @@ import com.elink.esua.epdc.dto.suggestion.result.MySuggestionResultDTO;
import com.elink.esua.epdc.modules.suggestion.dao.CustomImgDao;
import com.elink.esua.epdc.modules.suggestion.dao.SuggestionFeedbackDao;
import com.elink.esua.epdc.modules.suggestion.dao.SuggestionMakeDao;
import com.elink.esua.epdc.modules.suggestion.dao.SuggestionTypeDao;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionMakeEntity;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity;
import com.elink.esua.epdc.modules.suggestion.redis.SuggestionMakeRedis;
import com.elink.esua.epdc.modules.suggestion.service.CustomImgService;
import com.elink.esua.epdc.modules.suggestion.service.SuggestionMakeService;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 我有建议要提
@ -65,14 +64,14 @@ public class SuggestionMakeServiceImpl extends BaseServiceImpl<SuggestionMakeDao
private CustomImgDao customImgDao;
@Autowired
private SuggestionFeedbackDao suggestionFeedbackDao;
@Autowired
private SuggestionTypeDao suggestionTypeDao;
@Override
public PageData<SuggestionMakeDTO> page(Map<String, Object> params) {
IPage<SuggestionMakeEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, SuggestionMakeDTO.class);
IPage<SuggestionMakeDTO> page = getPage(params);
List<SuggestionMakeDTO> list = baseDao.selectListPage(params);
return new PageData<>(list, page.getTotal());
}
@Override
@ -93,8 +92,18 @@ public class SuggestionMakeServiceImpl extends BaseServiceImpl<SuggestionMakeDao
@Override
public SuggestionMakeDTO get(String id) {
SuggestionMakeEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, SuggestionMakeDTO.class);
SuggestionMakeDTO result = baseDao.selectDetailById(id);
// 查询建议图片URL
String[] urls = customImgDao.selectListImgUrlsByIds(result.getId());
List<Map<String, String>> suggestionPicList = new ArrayList<>();
for (int i = 0; i < urls.length; i++) {
Map<String, String> map = new HashMap<>();
map.put("name", i + "");
map.put("url", urls[i]);
suggestionPicList.add(map);
}
result.setSuggestionPicList(suggestionPicList);
return result;
}
@Override
@ -172,6 +181,8 @@ public class SuggestionMakeServiceImpl extends BaseServiceImpl<SuggestionMakeDao
SuggestionMakeEntity makeEntity = baseDao.selectById(id);
MySuggestionResultDTO result = ConvertUtils.sourceToTarget(makeEntity, MySuggestionResultDTO.class);
SuggestionTypeEntity typeEntity = suggestionTypeDao.selectById(result.getSuggestionTypeId());
result.setSuggestionTypeName(typeEntity.getSuggestionName());
result.setSuggestionTypeIds(result.getAllSuggestionTypeId().split(StrConstant.COMMA));
// 查询建议图片URL
result.setSuggestionPics(customImgDao.selectListImgUrlsByIds(result.getId()));

67
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/suggestion/service/impl/SuggestionTypeServiceImpl.java

@ -17,29 +17,33 @@
package com.elink.esua.epdc.modules.suggestion.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.Constant;
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.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.utils.TreeUtils;
import com.elink.esua.epdc.dto.DeptOption;
import com.elink.esua.epdc.dto.TypeNode;
import com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO;
import com.elink.esua.epdc.modules.suggestion.dao.SuggestionTypeDao;
import com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity;
import com.elink.esua.epdc.modules.suggestion.redis.SuggestionTypeRedis;
import com.elink.esua.epdc.modules.suggestion.service.SuggestionTypeService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -65,8 +69,9 @@ public class SuggestionTypeServiceImpl extends BaseServiceImpl<SuggestionTypeDao
@Override
public List<SuggestionTypeDTO> list(Map<String, Object> params) {
// List<SuggestionTypeDTO> result = baseDao.getList(params);
return null;//TreeUtils.build(result);
List<SuggestionTypeDTO> dtos = baseDao.getList(params);
return TreeUtils.build(dtos);
}
private QueryWrapper<SuggestionTypeEntity> getWrapper(Map<String, Object> params){
@ -80,14 +85,14 @@ public class SuggestionTypeServiceImpl extends BaseServiceImpl<SuggestionTypeDao
@Override
public SuggestionTypeDTO get(String id) {
SuggestionTypeEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, SuggestionTypeDTO.class);
return baseDao.getById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(SuggestionTypeDTO dto) {
SuggestionTypeEntity entity = ConvertUtils.sourceToTarget(dto, SuggestionTypeEntity.class);
entity.setPids(getPidList(entity.getPid()));
insert(entity);
}
@ -108,10 +113,54 @@ public class SuggestionTypeServiceImpl extends BaseServiceImpl<SuggestionTypeDao
@Override
public Result<List<TypeNode>> getSuggestionTypeTree() {
List<TypeNode> nodes = baseDao.selectListSuggestionTypeTree();
Map<String, List<TypeNode>> children = nodes.stream().filter(node -> !(node.getPid().equals(NumConstant.ZERO_STR)))
Map<String, List<TypeNode>> children = nodes.stream().filter(node -> !(node.getPid().equals(NumConstant.ZERO)))
.collect(Collectors.groupingBy(node -> node.getPid()));
nodes.forEach(node -> node.setChildren(children.get(node.getValue())));
List<TypeNode> result = nodes.stream().filter(node -> node.getPid().equals(NumConstant.ZERO_STR)).collect(Collectors.toList());
return new Result<List<TypeNode>>().ok(result);
}
/**
* 获取所有上级部门ID
*
* @param pid 上级ID
*/
private String getPidList(Long pid) {
//顶级部门,无上级部门
if (Constant.DEPT_ROOT.equals(pid)) {
return Constant.DEPT_ROOT + "";
}
//所有部门的id、pid列表
List<SuggestionTypeEntity> deptList = baseDao.getIdAndPidList();
//list转map
Map<Long, SuggestionTypeEntity> map = new HashMap<>(deptList.size());
for (SuggestionTypeEntity entity : deptList) {
map.put(entity.getId(), entity);
}
//递归查询所有上级部门ID列表
List<Long> pidList = new ArrayList<>();
getPidTree(pid, map, pidList);
return StringUtils.join(pidList, ",");
}
private void getPidTree(Long pid, Map<Long, SuggestionTypeEntity> map, List<Long> pidList) {
//顶级部门,无上级部门
if (Constant.DEPT_ROOT.equals(pid)) {
return;
}
//上级部门存在
SuggestionTypeEntity parent = map.get(pid);
if (parent != null) {
getPidTree(parent.getPid(), map, pidList);
}
pidList.add(pid);
}
}

2
epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionFeedbackDao.xml

@ -23,7 +23,7 @@
FEEDBACK_CONTENT,
DEPT_ID,
DEPT_NAME,
DATE_FORMAT(CREATED_TIME, '%Y-%m-%d') createTime
DATE_FORMAT(CREATED_TIME, '%Y.%m.%d') createdTime
FROM epdc_suggestion_feedback
WHERE DEL_FLAG ='0'
<if test="suggestionId != null and suggestionId != ''">

83
epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionMakeDao.xml

@ -43,7 +43,7 @@
m.PARTY_FLAG,
m.IS_FEEDBACK,
t.SUGGESTION_NAME suggestionTypeName,
DATE_FORMAT(m.CREATED_TIME, '%Y-%m-%d') createTime
DATE_FORMAT(m.CREATED_TIME, '%Y.%m.%d') createdTime
FROM epdc_suggestion_make m
LEFT JOIN epdc_suggestion_type t ON m.SUGGESTION_TYPE_ID = t.ID AND t.DEL_FLAG = '0'
WHERE m.DEL_FLAG = '0'
@ -53,4 +53,85 @@
ORDER BY m.IS_FEEDBACK DESC, m.CREATED_TIME DESC
LIMIT #{pageIndex},#{pageSize}
</select>
<select id="selectListPage" resultType="com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO">
SELECT
auth.ID,
auth.SUGGESTION_TYPE_ID,
auth.suggestionTypeName,
auth.ALL_SUGGESTION_TYPE_ID,
auth.SUGGESTION_TITLE,
auth.SUGGESTION_CONTENT,
auth.USER_ID,
auth.NICKNAME,
auth.FACE_IMG,
auth.MOBILE,
auth.PARTY_FLAG,
auth.DEPT_ID,
auth.DEPT_NAME,
auth.ALL_DEPT_IDS,
auth.ALL_DEPT_NAMES,
auth.IS_FEEDBACK,
DATE_FORMAT(auth.CREATED_TIME, '%Y.%m.%d') createdTimeStr
FROM (
SELECT
m.ID,
m.SUGGESTION_TYPE_ID,
t.SUGGESTION_NAME suggestionTypeName,
m.ALL_SUGGESTION_TYPE_ID,
m.SUGGESTION_TITLE,
m.SUGGESTION_CONTENT,
m.USER_ID,
m.NICKNAME,
m.FACE_IMG,
m.MOBILE,
m.PARTY_FLAG,
m.DEPT_ID,
m.DEPT_NAME,
m.ALL_DEPT_IDS,
m.ALL_DEPT_NAMES,
m.IS_FEEDBACK,
m.CREATED_TIME
FROM epdc_suggestion_make m
LEFT JOIN epdc_suggestion_type t ON m.SUGGESTION_TYPE_ID = t.ID AND t.DEL_FLAG = '0'
WHERE m.DEL_FLAG = '0'
<if test="isFeedback != null and isFeedback != ''">
AND m.IS_FEEDBACK = #{isFeedback}
</if>
<if test="suggestionTypeId != null and suggestionTypeId != ''">
AND m.SUGGESTION_TYPE_ID = #{suggestionTypeId}
</if>
<if test="suggestionTitle != null and suggestionTitle != ''">
AND m.SUGGESTION_TITLE LIKE CONCAT('%', #{suggestionTitle}, '%')
</if>
<if test="allDeptIds != null and allDeptIds != ''">
AND m.ALL_DEPT_IDS LIKE CONCAT('%', #{allDeptIds}, '%')
</if>
) auth
</select>
<select id="selectDetailById" resultType="com.elink.esua.epdc.dto.suggestion.SuggestionMakeDTO">
SELECT
m.ID,
m.SUGGESTION_TYPE_ID,
t.SUGGESTION_NAME suggestionTypeName,
m.ALL_SUGGESTION_TYPE_ID,
m.SUGGESTION_TITLE,
m.SUGGESTION_CONTENT,
m.USER_ID,
m.NICKNAME,
m.FACE_IMG,
m.MOBILE,
m.PARTY_FLAG,
m.DEPT_ID,
m.DEPT_NAME,
m.ALL_DEPT_IDS,
m.ALL_DEPT_NAMES,
m.IS_FEEDBACK,
DATE_FORMAT(m.CREATED_TIME, '%Y.%m.%d') createdTimeStr
FROM epdc_suggestion_make m
LEFT JOIN epdc_suggestion_type t ON m.SUGGESTION_TYPE_ID = t.ID AND t.DEL_FLAG = '0'
WHERE m.DEL_FLAG = '0'
AND m.ID = #{id}
</select>
</mapper>

21
epdc-cloud-custom/src/main/resources/mapper/suggestion/SuggestionTypeDao.xml

@ -29,4 +29,25 @@
AND ENABLE_FLAG ='1'
ORDER BY SORT
</select>
<select id="getList" resultType="com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO">
SELECT
t1.*,
( SELECT t2.SUGGESTION_NAME FROM epdc_suggestion_type t2 WHERE t2.id = t1.pid ) parentName
FROM
epdc_suggestion_type t1
WHERE
t1.DEL_FLAG = '0'
ORDER BY
t1.sort ASC
</select>
<select id="getIdAndPidList" resultType="com.elink.esua.epdc.modules.suggestion.entity.SuggestionTypeEntity">
select t1.id, t1.pid from epdc_suggestion_type t1 where t1.del_flag = 0
</select>
<select id="getById" resultType="com.elink.esua.epdc.dto.suggestion.SuggestionTypeDTO">
select t1.*,(select t2.SUGGESTION_NAME from epdc_suggestion_type t2 where t2.id=t1.pid)parentName from epdc_suggestion_type t1
where t1.id = #{id} and t1.del_flag = 0
</select>
</mapper>

Loading…
Cancel
Save