From 796241ade79506de58c98aee506fac2fc4e6c83f Mon Sep 17 00:00:00 2001 From: liuchuang Date: Wed, 27 Nov 2019 10:49:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=85=9A=E7=BE=A4=E8=AE=AE=E4=BA=8B?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=B7=BB=E5=8A=A0=E6=9D=A5=E6=BA=90=E5=8F=8B?= =?UTF-8?q?=E9=82=BB=E7=A4=BE=E7=BE=A4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../esua/epdc/dto/events/EpdcEventsDetailDTO.java | 7 ++++++- .../epdc/dto/events/EpdcRejectEventDetailDTO.java | 7 ++++++- .../esua/epdc/dto/issue/IssueContentDetailDTO.java | 7 ++++++- .../epdc/dto/issue/IssueWaitHandleDetailDTO.java | 7 ++++++- .../item/result/ItemContentForPCEndResultDTO.java | 5 +++++ .../dto/item/result/ItemDetailForPCEndResultDTO.java | 5 +++++ .../main/resources/mapper/events/EpdcEventsDao.xml | 12 ++++++++---- .../src/main/resources/mapper/issue/IssueDao.xml | 12 ++++++++---- .../src/main/resources/mapper/item/ItemDao.xml | 6 +++++- 9 files changed, 55 insertions(+), 13 deletions(-) diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java index 5c87441d8..ee80242e1 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcRejectEventDetailDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcRejectEventDetailDTO.java index edc82e604..202d25705 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcRejectEventDetailDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueContentDetailDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueContentDetailDTO.java index 719515a6c..fc5a1a2cf 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueContentDetailDTO.java +++ b/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 handleProgressResultDTOS; + + /** + * 友邻社群 + */ + private String groupName; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueWaitHandleDetailDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueWaitHandleDetailDTO.java index 859c2b4b9..e9c04bff3 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/issue/IssueWaitHandleDetailDTO.java +++ b/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 issueProgressResultDTOS; + + /** + * 友邻社群 + */ + private String groupName; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemContentForPCEndResultDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemContentForPCEndResultDTO.java index f57147327..c5bdc31f4 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemContentForPCEndResultDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemDetailForPCEndResultDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemDetailForPCEndResultDTO.java index 6c191096c..a228b389c 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/item/result/ItemDetailForPCEndResultDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml index 3f2f93a6a..4c64cdc66 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml @@ -14,7 +14,8 @@ - + + @@ -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 @@ - + + @@ -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 diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml index c689246b5..af567a471 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml @@ -45,7 +45,8 @@ - + + @@ -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 @@ - + + @@ -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 diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml index 0ea4775a1..cd23d1337 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml @@ -429,6 +429,7 @@ + @@ -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 @@ + @@ -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, From 2d907f6951bacfb99562f836ca9bf2f07a41e96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=87=91=E9=B9=8F?= Date: Wed, 27 Nov 2019 13:27:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/commons/tools/constant/Constant.java | 4 + .../esua/epdc/dto/category/CategoryDTO.java | 89 ++++++++ .../controller/CategoryController.java | 91 ++++++++ .../modules/category/dao/CategoryDao.java | 47 ++++ .../category/entity/CategoryEntity.java | 108 +++++++++ .../modules/category/excel/CategoryExcel.java | 68 ++++++ .../modules/category/redis/CategoryRedis.java | 47 ++++ .../category/service/CategoryService.java | 97 ++++++++ .../service/impl/CategoryServiceImpl.java | 207 ++++++++++++++++++ .../resources/mapper/category/CategoryDao.xml | 37 ++++ 10 files changed, 795 insertions(+) create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/CategoryDTO.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/excel/CategoryExcel.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java index e9993322b..9ffd1d4aa 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/Constant.java +++ b/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"; /** * 数据字典根节点标识 */ diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/CategoryDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/CategoryDTO.java new file mode 100644 index 000000000..9214b877c --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java new file mode 100644 index 000000000..e10396208 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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(@RequestParam Map params){ + List list = categoryService.list(params); + return new Result>().ok(list); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") Long id){ + CategoryDTO data = categoryService.get(id); + return new Result().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 params, HttpServletResponse response) throws Exception { + List list = categoryService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, CategoryExcel.class); + } + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java new file mode 100644 index 000000000..246e82610 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + List getList(Map params); + + CategoryEntity getById(Long id); + + /** + * 根据分类ID,获取所有子分类ID列表 + * + * @param id 分类ID + */ + List getSubCategoryIdList(String id); + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java new file mode 100644 index 000000000..7b485aaf4 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/excel/CategoryExcel.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/excel/CategoryExcel.java new file mode 100644 index 000000000..f4fc67da2 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java new file mode 100644 index 000000000..51bbeee86 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + } + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java new file mode 100644 index 000000000..a3024ba3d --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-11-26 + */ + List list(Map 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 getSubCategoryIdList(Long id); + + /*** + * 校验编码是否重复 + */ + Integer getCodeCount(CategoryDTO dto); + + /** + * 获取所有上级分类 + * + * @param id + */ + List getPidListById(Long id); +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java new file mode 100644 index 000000000..462c93d2d --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 implements CategoryService { + + @Autowired + private CategoryRedis categoryRedis; + + @Override + public List list(Map params) { + List 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 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 getPidListById(Long id) { + //所有的分类列表 + CategoryEntity categoryEntity = baseDao.selectById(id); + return getPidListByPid(categoryEntity.getPid()); + } + + /** + * 获取所有上级分类 + * + * @param pid 上级ID + */ + private List getPidListByPid(String pid) { + //顶级部门,无上级部门 + if (Constant.CATEGORY_ROOT.equals(pid)) { + return new ArrayList<>(); + } + + //所有的分类列表 + QueryWrapper wrapper = new QueryWrapper<>(); + List categoryEntityList = baseDao.selectList(wrapper); + + //list转map + Map map = new HashMap<>(categoryEntityList.size()); + for (CategoryEntity entity : categoryEntityList) { + map.put(entity.getId(), entity); + } + + //递归查询所有上级分类列表 + List pCategoryEntityList = new ArrayList<>(); + + getPidTree(pid, map, pCategoryEntityList); + + return pCategoryEntityList; + } + + private void getPidTree(String pid, Map map, List 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 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 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 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 getSubCategoryIdList(Long id) { + List subCategoryIdList = baseDao.getSubCategoryIdList("%" + id + "%"); + return subCategoryIdList; + } +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml new file mode 100644 index 000000000..29f1e9e85 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +