Browse Source

Merge branch 'dev_1118' of http://121.42.41.42:7070/r/esua-epdc-cloud into dev_1118

dev
管理员 6 years ago
parent
commit
6ef58edec2
  1. 4
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java
  2. 89
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/CategoryDTO.java
  3. 7
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java
  4. 7
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcRejectEventDetailDTO.java
  5. 7
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueContentDetailDTO.java
  6. 7
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueWaitHandleDetailDTO.java
  7. 5
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemContentForPCEndResultDTO.java
  8. 5
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemDetailForPCEndResultDTO.java
  9. 91
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java
  10. 47
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java
  11. 108
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java
  12. 68
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/excel/CategoryExcel.java
  13. 47
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java
  14. 97
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java
  15. 207
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java
  16. 37
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml
  17. 12
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml
  18. 12
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml
  19. 6
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml

4
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java

@ -39,6 +39,10 @@ public interface Constant {
* 部门根节点标识
*/
Long DEPT_ROOT = 0L;
/**
* 分类根节点标识
*/
String CATEGORY_ROOT = "0";
/**
* 数据字典根节点标识
*/

89
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/CategoryDTO.java

@ -0,0 +1,89 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.category;
import java.io.Serializable;
import java.util.Date;
import com.elink.esua.epdc.commons.tools.utils.TreeNode;
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 io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Data
public class CategoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@ApiModelProperty(value = "id")
@Null(message = "{id.null}", groups = AddGroup.class)
@NotNull(message = "{id.require}", groups = UpdateGroup.class)
private String id;
/**
* 上级分类ID
*/
@ApiModelProperty(value = "上级ID")
@NotNull(message = "{sysdept.pid.require}", groups = DefaultGroup.class)
private String pid;
/**
* 分类名称
*/
@ApiModelProperty(value = "分类名称")
@NotBlank(message = "{sysdept.name.require}", groups = DefaultGroup.class)
private String categoryName;
/**
* 分类类别
*/
private String categoryType;
/**
* 分类编码
*/
private String categoryCode;
/**
* 排序
*/
@ApiModelProperty(value = "排序")
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
private Integer sort;
private String parentName;
}

7
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java

@ -73,5 +73,10 @@ public class EpdcEventsDetailDTO implements Serializable {
/**
* 所属网格详细信息
*/
private String ownGrid;
private String allDeptNames;
/**
* 友邻社群
*/
private String groupName;
}

7
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcRejectEventDetailDTO.java

@ -62,5 +62,10 @@ public class EpdcRejectEventDetailDTO implements Serializable {
/**
* 所属网格详细信息
*/
private String ownGrid;
private String allDeptNames;
/**
* 友邻社群
*/
private String groupName;
}

7
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueContentDetailDTO.java

@ -63,7 +63,7 @@ public class IssueContentDetailDTO implements Serializable {
/**
* 所属网格详细信息
*/
private String ownGrid;
private String allDeptNames;
/**
* 所属类别
*/
@ -78,4 +78,9 @@ public class IssueContentDetailDTO implements Serializable {
* 项目处理进度
*/
List<ItemHandleProgressResultDTO> handleProgressResultDTOS;
/**
* 友邻社群
*/
private String groupName;
}

7
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueWaitHandleDetailDTO.java

@ -55,7 +55,7 @@ public class IssueWaitHandleDetailDTO implements Serializable {
/**
* 所属网格详细信息
*/
private String ownGrid;
private String allDeptNames;
/**
* 类别
*/
@ -64,4 +64,9 @@ public class IssueWaitHandleDetailDTO implements Serializable {
* 议题处理进度
*/
List<IssueProgressResultDTO> issueProgressResultDTOS;
/**
* 友邻社群
*/
private String groupName;
}

5
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemContentForPCEndResultDTO.java

@ -93,4 +93,9 @@ public class ItemContentForPCEndResultDTO implements Serializable {
* 所属类别
*/
private String categoryName;
/**
* 友邻社群
*/
private String groupName;
}

5
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemDetailForPCEndResultDTO.java

@ -93,4 +93,9 @@ public class ItemDetailForPCEndResultDTO implements Serializable {
* 评论数
*/
private Integer commentNum;
/**
* 友邻社群
*/
private String groupName;
}

91
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java

@ -0,0 +1,91 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.controller;
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.validator.AssertUtils;
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.category.CategoryDTO;
import com.elink.esua.epdc.modules.category.excel.CategoryExcel;
import com.elink.esua.epdc.modules.category.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@RestController
@RequestMapping("category")
public class CategoryController {
@Autowired
private CategoryService categoryService;
@GetMapping("list")
public Result<List<CategoryDTO>> list(@RequestParam Map<String, Object> params){
List<CategoryDTO> list = categoryService.list(params);
return new Result<List<CategoryDTO>>().ok(list);
}
@GetMapping("{id}")
public Result<CategoryDTO> get(@PathVariable("id") Long id){
CategoryDTO data = categoryService.get(id);
return new Result<CategoryDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CategoryDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
categoryService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody CategoryDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
categoryService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody Long id){
categoryService.delete(id);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CategoryDTO> list = categoryService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CategoryExcel.class);
}
}

47
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Mapper
public interface CategoryDao extends BaseDao<CategoryEntity> {
List<CategoryEntity> getList(Map<String, Object> params);
CategoryEntity getById(Long id);
/**
* 根据分类ID获取所有子分类ID列表
*
* @param id 分类ID
*/
List<Long> getSubCategoryIdList(String id);
}

108
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java

@ -0,0 +1,108 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_category")
public class CategoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.UUID)
private String id;
/**
* 上级分类ID
*/
private String pid;
/**
* 所有上级分类ID用逗号分开
*/
private String pids;
/**
* 分类名称
*/
private String categoryName;
/**
* 分类编码
*/
private String categoryCode;
/**
* 分类类别
*/
private String categoryType;
/**
* 排序
*/
private Integer sort;
/**
* 删除标识 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;
/**
* 上级部门名称
*/
@TableField(exist = false)
private String parentName;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private Long creator;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
}

68
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/excel/CategoryExcel.java

@ -0,0 +1,68 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Data
public class CategoryExcel {
@Excel(name = "id")
private Long id;
@Excel(name = "上级分类ID")
private Long pid;
@Excel(name = "所有上级分类ID,用逗号分开")
private String pids;
@Excel(name = "分类名称")
private String categoryName;
@Excel(name = "分类类别")
private String categoryType;
@Excel(name = "排序")
private Integer sort;
@Excel(name = "删除标识 0:未删除 1:删除")
private Integer delFlag;
@Excel(name = "创建者")
private Long creator;
@Excel(name = "创建时间")
private Date createDate;
@Excel(name = "更新者")
private Long updater;
@Excel(name = "更新时间")
private Date updateDate;
}

47
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Component
public class CategoryRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

97
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java

@ -0,0 +1,97 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.dto.category.CategoryDTO;
import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
import java.util.List;
import java.util.Map;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
public interface CategoryService extends BaseService<CategoryEntity> {
/**
* 默认查询
*
* @param params
* @return java.util.List<CategoryDTO>
* @author generator
* @date 2019-11-26
*/
List<CategoryDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CategoryDTO
* @author generator
* @date 2019-11-26
*/
CategoryDTO get(Long id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2019-11-26
*/
void save(CategoryDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2019-11-26
*/
void update(CategoryDTO dto);
void delete(Long id);
/**
* 根据分类ID获取所有子分类ID列表
*
* @param id 分类ID
*/
List<Long> getSubCategoryIdList(Long id);
/***
* 校验编码是否重复
*/
Integer getCodeCount(CategoryDTO dto);
/**
* 获取所有上级分类
*
* @param id
*/
List<CategoryEntity> getPidListById(Long id);
}

207
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java

@ -0,0 +1,207 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.category.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
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.exception.ErrorCode;
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.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dto.category.CategoryDTO;
import com.elink.esua.epdc.modules.category.dao.CategoryDao;
import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
import com.elink.esua.epdc.modules.category.redis.CategoryRedis;
import com.elink.esua.epdc.modules.category.service.CategoryService;
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.*;
/**
* 分类管理
*
* @author wjp wjp@elink-cn.com
* @since v1.0.0 2019-11-26
*/
@Service
public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {
@Autowired
private CategoryRedis categoryRedis;
@Override
public List<CategoryDTO> list(Map<String, Object> params) {
List<CategoryEntity> entityList = baseDao.getList(params);
return ConvertUtils.sourceToTarget(entityList, CategoryDTO.class);
}
@Override
public CategoryDTO get(Long id) {
if (id == null) {
return null;
}
CategoryEntity entity = baseDao.getById(id);
return ConvertUtils.sourceToTarget(entity, CategoryDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CategoryDTO dto) {
String categoryCode = dto.getCategoryCode();
if (StringUtils.isNotBlank(categoryCode)) {
if (getCodeCount(dto) > 0) {
throw new RenException("您输入的编码已存在");
}
}
CategoryEntity entity = ConvertUtils.sourceToTarget(dto, CategoryEntity.class);
List<CategoryEntity> list = getPidListByPid(entity.getPid());
if (list.size() == 0){
entity.setPids("0");
}else {
String pids = "";
for (int i = 0; i < list.size(); i++){
if (i == list.size() -1){
pids = pids + list.get(i).getId().toString();
}else {
pids = pids + list.get(i).getId().toString() + ",";
}
}
entity.setPids(pids);
}
insert(entity);
}
@Override
public List<CategoryEntity> getPidListById(Long id) {
//所有的分类列表
CategoryEntity categoryEntity = baseDao.selectById(id);
return getPidListByPid(categoryEntity.getPid());
}
/**
* 获取所有上级分类
*
* @param pid 上级ID
*/
private List<CategoryEntity> getPidListByPid(String pid) {
//顶级部门,无上级部门
if (Constant.CATEGORY_ROOT.equals(pid)) {
return new ArrayList<>();
}
//所有的分类列表
QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<>();
List<CategoryEntity> categoryEntityList = baseDao.selectList(wrapper);
//list转map
Map<String, CategoryEntity> map = new HashMap<>(categoryEntityList.size());
for (CategoryEntity entity : categoryEntityList) {
map.put(entity.getId(), entity);
}
//递归查询所有上级分类列表
List<CategoryEntity> pCategoryEntityList = new ArrayList<>();
getPidTree(pid, map, pCategoryEntityList);
return pCategoryEntityList;
}
private void getPidTree(String pid, Map<String, CategoryEntity> map, List<CategoryEntity> pCategoryEntityList) {
//顶级,无上级
if (Constant.CATEGORY_ROOT.equals(pid)) {
return;
}
//上级存在
CategoryEntity parent = map.get(pid);
if (parent != null) {
getPidTree(parent.getPid(), map, pCategoryEntityList);
}
pCategoryEntityList.add(parent);
}
@Override
public Integer getCodeCount(CategoryDTO dto) {
QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<>();
wrapper.eq("category_code", dto.getCategoryCode());
String id = dto.getId();
wrapper.ne(id!=null, "id", dto.getId());
return baseDao.selectCount(wrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CategoryDTO dto) {
String categoryCode = dto.getCategoryCode();
if (StringUtils.isNotBlank(categoryCode)) {
if (getCodeCount(dto) > 0) {
throw new RenException("您输入的编码已存在");
}
}
CategoryEntity entity = ConvertUtils.sourceToTarget(dto, CategoryEntity.class);
//上级部门不能为自身
if (entity.getId().equals(entity.getPid())) {
throw new RenException(ErrorCode.SUPERIOR_DEPT_ERROR);
}
List<CategoryEntity> list = getPidListByPid(entity.getPid());
if (list.size() == 0){
entity.setPids("0");
}else {
String pids = "";
for (int i = 0; i < list.size(); i++){
if (i == list.size() -1){
pids = pids + list.get(i).getId().toString();
}else {
pids = pids + list.get(i).getId().toString() + ",";
}
}
entity.setPids(pids);
}
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
//判断是否有子部门
List<Long> subList = getSubCategoryIdList(id);
if (subList.size() > 1) {
throw new RenException(ErrorCode.DEPT_SUB_DELETE_ERROR);
}
// 逻辑删除(@TableLogic 注解)
logicDelete(new Long[]{id}, CategoryEntity.class);
}
@Override
public List<Long> getSubCategoryIdList(Long id) {
List<Long> subCategoryIdList = baseDao.getSubCategoryIdList("%" + id + "%");
return subCategoryIdList;
}
}

37
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.modules.category.dao.CategoryDao">
<resultMap type="com.elink.esua.epdc.modules.category.entity.CategoryEntity" id="categoryMap">
<result property="id" column="id"/>
<result property="pid" column="pid"/>
<result property="pids" column="pids"/>
<result property="categoryName" column="category_name"/>
<result property="categoryCode" column="category_code"/>
<result property="categoryType" column="category_type"/>
<result property="sort" column="sort"/>
<result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
</resultMap>
<select id="getList" resultType="com.elink.esua.epdc.modules.category.entity.CategoryEntity">
select t1.*,(select t2.category_name from epdc_category t2 where t2.id=t1.pid)parentName from epdc_category t1
where t1.del_flag = 0
order by t1.sort asc
</select>
<select id="getById" resultType="com.elink.esua.epdc.modules.category.entity.CategoryEntity">
select t1.*,(select t2.category_name from epdc_category t2 where t2.id=t1.pid)parentName from epdc_category t1
where t1.id = #{value} and t1.del_flag = 0
</select>
<select id="getSubCategoryIdList" resultType="long">
select id from epdc_category where pids like #{id} and del_flag = 0
</select>
</mapper>

12
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml

@ -14,7 +14,8 @@
<result property="issueLongitude" column="ISSUE_LONGITUDE"/>
<result property="userFace" column="USER_FACE"/>
<result property="partyFlag" column="IS_PARTY_MEMBER"/>
<result property="ownGrid" column="ownGrid"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="groupName" column="GROUP_NAME"/>
<collection property="imageArray" ofType="java.lang.String">
<result property="image" column="IMG_URL"/>
</collection>
@ -37,7 +38,8 @@
e.ISSUE_LATITUDE,
e.ISSUE_LONGITUDE,
e.ADVICE,
CONCAT(e.AREA,e.STREET,e.COMMUNITY,e.GRID) AS ownGrid
e.GROUP_NAME,
e.ALL_DEPT_NAMES
FROM
epdc_events e
LEFT JOIN epdc_img i ON e.ID = i.REFERENCE_ID
@ -116,7 +118,8 @@
<result property="advice" column="ADVICE"/>
<result property="issueLatitude" column="ISSUE_LATITUDE"/>
<result property="issueLongitude" column="ISSUE_LONGITUDE"/>
<result property="ownGrid" column="ownGrid"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="groupName" column="GROUP_NAME"/>
<collection property="images" ofType="java.lang.String">
<result property="image" column="IMG_URL"/>
</collection>
@ -134,7 +137,8 @@
img.IMG_URL,
temp.ISSUE_LATITUDE,
temp.ISSUE_LONGITUDE,
CONCAT(temp.AREA,temp.STREET,temp.COMMUNITY,temp.GRID) AS ownGrid
temp.ALL_DEPT_NAMES,
temp.GROUP_NAME
FROM
epdc_events temp
LEFT JOIN epdc_img img ON temp.ID = img.REFERENCE_ID

12
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml

@ -45,7 +45,8 @@
<result property="address" column="ISSUE_ADDRESS"/>
<result property="issueLatitude" column="ISSUE_LATITUDE"/>
<result property="issueLongitude" column="ISSUE_LONGITUDE"/>
<result property="ownGrid" column="ownGrid"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="groupName" column="GROUP_NAME"/>
<result property="categoryName" column="CATEGORY_NAME"/>
<collection property="images" ofType="java.lang.String">
<result property="image" column="IMG_URL"/>
@ -63,7 +64,8 @@
i.ISSUE_LATITUDE,
i.ISSUE_LONGITUDE,
cate.CATEGORY_NAME,
CONCAT(i.AREA,i.STREET,i.COMMUNITY,i.GRID) AS ownGrid,
i.ALL_DEPT_NAMES,
i.GROUP_NAME,
img.IMG_URL
FROM
epdc_issue i
@ -86,7 +88,8 @@
<result property="issueLatitude" column="ISSUE_LATITUDE"/>
<result property="issueLongitude" column="ISSUE_LONGITUDE"/>
<result property="categoryName" column="CATEGORY_NAME"/>
<result property="ownGrid" column="ownGrid"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="groupName" column="GROUP_NAME"/>
<result property="approveNum" column="APPROVE_NUM"/>
<result property="opposeNum" column="OPPOSE_NUM"/>
<result property="commentNum" column="COMMENT_NUM"/>
@ -108,7 +111,8 @@
i.ISSUE_LATITUDE,
i.ISSUE_LONGITUDE,
cate.CATEGORY_NAME,
CONCAT(i.AREA,i.STREET,i.COMMUNITY,i.GRID) AS ownGrid
i.ALL_DEPT_NAMES,
i.GROUP_NAME
FROM
epdc_issue i
LEFT JOIN epdc_events e ON i.EVENT_ID = e.ID

6
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml

@ -429,6 +429,7 @@
<result property="approveNum" column="APPROVE_NUM"/>
<result property="opposeNum" column="OPPOSE_NUM"/>
<result property="commentNum" column="COMMENT_NUM"/>
<result property="groupName" column="GROUP_NAME"/>
<collection property="images" ofType="java.lang.String">
<result property="image" column="IMG_URL"/>
</collection>
@ -447,7 +448,8 @@
eve.OPPOSE_NUM,
eve.COMMENT_NUM,
cate.CATEGORY_NAME,
img.IMG_URL
img.IMG_URL,
item.GROUP_NAME
FROM
epdc_item item
LEFT JOIN epdc_img img ON item.EVENT_ID = img.REFERENCE_ID
@ -595,6 +597,7 @@
<result property="issueAddress" column="ISSUE_ADDRESS"/>
<result property="issueLatitude" column="ISSUE_LATITUDE"/>
<result property="issueLongitude" column="ISSUE_LONGITUDE"/>
<result property="groupName" column="GROUP_NAME"/>
<result property="categoryName" column="CATEGORY_NAME"/>
<result property="approveNum" column="APPROVE_NUM"/>
<result property="opposeNum" column="OPPOSE_NUM"/>
@ -616,6 +619,7 @@
item.ISSUE_ADDRESS,
item.ISSUE_LATITUDE,
item.ISSUE_LONGITUDE,
item.GROUP_NAME,
cate.CATEGORY_NAME,
eve.APPROVE_NUM,
eve.OPPOSE_NUM,

Loading…
Cancel
Save