diff --git a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java index 306b2ebc6..cdc597b5e 100644 --- a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java +++ b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java @@ -72,4 +72,9 @@ public class SysRoleDTO implements Serializable { * app菜单ID列表 */ private List appMenuIdList; + + /** + * 项目处理类型授权id列表 + */ + private List categoryIdList; } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/pom.xml b/esua-epdc/epdc-admin/epdc-admin-server/pom.xml index 452668612..a44333237 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/pom.xml +++ b/esua-epdc/epdc-admin/epdc-admin-server/pom.xml @@ -62,6 +62,12 @@ feign-httpclient 10.3.0 + + com.esua.epdc + epdc-events-client + 1.0.0 + compile + diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysRoleController.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysRoleController.java index dcf0b1f25..62b1665a9 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysRoleController.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysRoleController.java @@ -93,6 +93,10 @@ public class SysRoleController { List appMenuIdList = appRoleMenuService.getAppMenuIdList(id); data.setAppMenuIdList(appMenuIdList); + //查询角色对应的项目处理类型权限 + List categoryIdList = sysRoleService.getCategoryIdList(id); + data.setCategoryIdList(categoryIdList); + return new Result().ok(data); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java new file mode 100644 index 000000000..e68527529 --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java @@ -0,0 +1,42 @@ +package com.elink.esua.epdc.feign; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; +import com.elink.esua.epdc.feign.fallback.EventFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * @Auther: yinzuomei + * @Date: 2019/12/24 09:28 + * @Description: 事件接口 + */ +@FeignClient(name = ServiceConstant.EPDC_EVENTS_SERVER, fallback = EventFeignClientFallback.class) +public interface EventFeignClient { + + /** + * @param orgTypeFormDTO + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存项目处理类型权限 + * @Date 2019/12/24 17:17 + **/ + @PostMapping(value = "events/handlerolecategory/saveOrUpdate", consumes = MediaType.APPLICATION_JSON_VALUE) + Result saveOrUpdateHandleCategory(HandleRoleCategoryFormDTO orgTypeFormDTO); + + /** + * @param ruleId + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 查询角色对应的项目处理类型权限 + * @Date 2019/12/24 17:17 + **/ + @GetMapping(value = "events/handlerolecategory/queryCategoryIdList/{ruleId}") + Result> queryCategoryIdList(@PathVariable("ruleId")Long ruleId); +} diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java new file mode 100644 index 000000000..eccb995ab --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java @@ -0,0 +1,30 @@ +package com.elink.esua.epdc.feign.fallback; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; +import com.elink.esua.epdc.feign.EventFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description + * @Author yinzuomei + * @Date 2019/12/24 9:45 + */ +@Component +public class EventFeignClientFallback implements EventFeignClient { + + @Override + public Result saveOrUpdateHandleCategory(HandleRoleCategoryFormDTO orgTypeFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "saveOrUpdate", orgTypeFormDTO); + } + + @Override + public Result> queryCategoryIdList(Long ruleId) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "queryCategoryIdList", ruleId); + } + +} diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysRoleService.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysRoleService.java index 1e1ea15ef..f273be70a 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysRoleService.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysRoleService.java @@ -36,4 +36,5 @@ public interface SysRoleService extends BaseService { void delete(Long[] ids); + List getCategoryIdList(Long id); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java index 434a69ec2..6c2c18ee6 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java @@ -18,9 +18,12 @@ 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.utils.Result; import com.elink.esua.epdc.dao.SysRoleDao; import com.elink.esua.epdc.dto.SysRoleDTO; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; import com.elink.esua.epdc.entity.SysRoleEntity; +import com.elink.esua.epdc.feign.EventFeignClient; import com.elink.esua.epdc.service.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -49,6 +52,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -108,6 +114,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl + * @Author yinzuomei + * @Description 查询角色对应的项目处理类型权限 + * @Date 2019/12/24 16:03 + **/ + @Override + public List getCategoryIdList(Long id) { + Result> result=eventFeignClient.queryCategoryIdList(id); + return result.getData(); + } + } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/handlecategory/HandleCategoryTreeDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/handlecategory/HandleCategoryTreeDTO.java new file mode 100644 index 000000000..956d9298a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/handlecategory/HandleCategoryTreeDTO.java @@ -0,0 +1,30 @@ +package com.elink.esua.epdc.dto.handlecategory; + +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description 角色授权tree返参dto + * @Author yinzuomei + * @Date 2019/12/24 10:19 + */ +@Data +public class HandleCategoryTreeDTO implements Serializable { + + private static final long serialVersionUID = -445779738699117585L; + + /** + * 主键 + */ + private String id; + + /** + * 处理类别显示信息 + */ + private String name; + + private List children= new ArrayList<>(); +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/HandleRoleCategoryDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/HandleRoleCategoryDTO.java new file mode 100644 index 000000000..540ae4552 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/HandleRoleCategoryDTO.java @@ -0,0 +1,81 @@ +/** + * 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.rulecategory; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Data +public class HandleRoleCategoryDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 处理类别ID + */ + private String categoryId; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标识 0:未删除,1:已删除 + */ + private String delFlag; + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/form/HandleRoleCategoryFormDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/form/HandleRoleCategoryFormDTO.java new file mode 100644 index 000000000..1372b059e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/form/HandleRoleCategoryFormDTO.java @@ -0,0 +1,29 @@ +package com.elink.esua.epdc.dto.rulecategory.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 保存或修改 角色和处理类别关系 入参DTO + * @Author yinzuomei + * @Date 2019/12/24 12:12 + */ +@Data +public class HandleRoleCategoryFormDTO implements Serializable { + + private static final long serialVersionUID = -3295948468274114972L; + + /** + * 角色ID + */ + @NotBlank(message = "角色id不能为空") + private Long roleId; + + /** + * 处理类别ID + */ + private List categoryIdList; +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/controller/HandleCategoryController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/controller/HandleCategoryController.java index 1793802d5..6aee55154 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/controller/HandleCategoryController.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/controller/HandleCategoryController.java @@ -26,6 +26,7 @@ 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.handlecategory.HandleCategoryDTO; +import com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO; import com.elink.esua.epdc.modules.handlecategory.excel.HandleCategoryExcel; import com.elink.esua.epdc.modules.handlecategory.service.HandleCategoryService; import org.springframework.beans.factory.annotation.Autowired; @@ -89,4 +90,15 @@ public class HandleCategoryController { ExcelUtils.exportExcelToTarget(response, null, list, HandleCategoryExcel.class); } + /** + * @param + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 角色管理-项目处理类型授权 + * @Date 2019/12/24 10:43 + **/ + @GetMapping("getCategoryList") + public Result> getCategoryList(){ + return handleCategoryService.selectListHandleCategoryDTO(); + } } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/dao/HandleCategoryDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/dao/HandleCategoryDao.java index bc363b381..d567e2999 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/dao/HandleCategoryDao.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/dao/HandleCategoryDao.java @@ -18,9 +18,12 @@ package com.elink.esua.epdc.modules.handlecategory.dao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO; import com.elink.esua.epdc.modules.handlecategory.entity.HandleCategoryEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 处理类别表 * @@ -30,4 +33,12 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface HandleCategoryDao extends BaseDao { + /** + * @param + * @return java.util.List + * @Author yinzuomei + * @Description 角色管理-项目处理类型授权 查询语句 + * @Date 2019/12/24 10:45 + **/ + List selectListHandleCategoryDTO(); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/HandleCategoryService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/HandleCategoryService.java index d7bbe5204..1d6e4587b 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/HandleCategoryService.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/HandleCategoryService.java @@ -21,6 +21,7 @@ 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.handlecategory.HandleCategoryDTO; +import com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO; import com.elink.esua.epdc.modules.handlecategory.entity.HandleCategoryEntity; import java.util.List; @@ -93,4 +94,13 @@ public interface HandleCategoryService extends BaseService * @date 2019-12-20 */ void delete(String[] ids); + + /** + * @param + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 角色管理-项目处理类型授权 + * @Date 2019/12/24 10:44 + **/ + Result> selectListHandleCategoryDTO(); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/impl/HandleCategoryServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/impl/HandleCategoryServiceImpl.java index eb53a2700..4d8b8bb85 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/impl/HandleCategoryServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/impl/HandleCategoryServiceImpl.java @@ -25,6 +25,7 @@ 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.dto.handlecategory.HandleCategoryDTO; +import com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO; import com.elink.esua.epdc.modules.handlecategory.dao.HandleCategoryDao; import com.elink.esua.epdc.modules.handlecategory.entity.HandleCategoryEntity; import com.elink.esua.epdc.modules.handlecategory.redis.HandleCategoryRedis; @@ -115,6 +116,19 @@ public class HandleCategoryServiceImpl extends BaseServiceImpl> + * @Author yinzuomei + * @Description 角色管理-项目处理类型授权 + * @Date 2019/12/24 10:44 + **/ + @Override + public Result> selectListHandleCategoryDTO() { + List list = baseDao.selectListHandleCategoryDTO(); + return new Result>().ok(list); + } + /** * @param dto * @return boolean diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/controller/HandleRoleCategoryController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/controller/HandleRoleCategoryController.java new file mode 100644 index 000000000..bf1a3c15b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/controller/HandleRoleCategoryController.java @@ -0,0 +1,104 @@ +/** + * 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.rolecategory.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.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.rulecategory.HandleRoleCategoryDTO; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; +import com.elink.esua.epdc.modules.rolecategory.excel.HandleRoleCategoryExcel; +import com.elink.esua.epdc.modules.rolecategory.service.HandleRoleCategoryService; +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 qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@RestController +@RequestMapping("handlerolecategory") +public class HandleRoleCategoryController { + + @Autowired + private HandleRoleCategoryService handleRoleCategoryService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = handleRoleCategoryService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + HandleRoleCategoryDTO data = handleRoleCategoryService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody HandleRoleCategoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + handleRoleCategoryService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody HandleRoleCategoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + handleRoleCategoryService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + handleRoleCategoryService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = handleRoleCategoryService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, HandleRoleCategoryExcel.class); + } + + @PostMapping("saveOrUpdate") + public Result saveOrUpdate(@RequestBody HandleRoleCategoryFormDTO formDTO){ + return handleRoleCategoryService.saveOrUpdate(formDTO); + } + + @GetMapping("queryCategoryIdList/{ruleId}") + public Result> queryCategoryIdList(@PathVariable("ruleId") String ruleId){ + return handleRoleCategoryService.listCategoryId(ruleId); + } +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/dao/HandleRoleCategoryDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/dao/HandleRoleCategoryDao.java new file mode 100644 index 000000000..22fd64cce --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/dao/HandleRoleCategoryDao.java @@ -0,0 +1,38 @@ +/** + * 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.rolecategory.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Mapper +public interface HandleRoleCategoryDao extends BaseDao { + + int deleteByRoleId(Long roleId); + + List selectListCategoryId(String ruleId); +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/entity/HandleRoleCategoryEntity.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/entity/HandleRoleCategoryEntity.java new file mode 100644 index 000000000..95abed9c8 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/entity/HandleRoleCategoryEntity.java @@ -0,0 +1,51 @@ +/** + * 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.rolecategory.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_handle_role_category") +public class HandleRoleCategoryEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 处理类别ID + */ + private String categoryId; + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/excel/HandleRoleCategoryExcel.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/excel/HandleRoleCategoryExcel.java new file mode 100644 index 000000000..82a19ad9d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/excel/HandleRoleCategoryExcel.java @@ -0,0 +1,62 @@ +/** + * 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.rolecategory.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Data +public class HandleRoleCategoryExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "角色ID") + private String roleId; + + @Excel(name = "处理类别ID") + private String categoryId; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "删除标识 0:未删除,1:已删除") + private String delFlag; + + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/redis/HandleRoleCategoryRedis.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/redis/HandleRoleCategoryRedis.java new file mode 100644 index 000000000..02e19ac68 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/redis/HandleRoleCategoryRedis.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.rolecategory.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Component +public class HandleRoleCategoryRedis { + @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/rolecategory/service/HandleRoleCategoryService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/HandleRoleCategoryService.java new file mode 100644 index 000000000..f0be3f4ae --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/HandleRoleCategoryService.java @@ -0,0 +1,116 @@ +/** + * 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.rolecategory.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.rulecategory.HandleRoleCategoryDTO; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; +import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +public interface HandleRoleCategoryService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2019-12-20 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-12-20 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return HandleRoleCategoryDTO + * @author generator + * @date 2019-12-20 + */ + HandleRoleCategoryDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-20 + */ + void save(HandleRoleCategoryDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-20 + */ + void update(HandleRoleCategoryDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2019-12-20 + */ + void delete(String[] ids); + + /** + * @param formDTO + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存或修改 角色和处理类别关系 + * @Date 2019/12/24 12:46 + **/ + Result saveOrUpdate(HandleRoleCategoryFormDTO formDTO); + + /** + * @param ruleId + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @Author yinzuomei + * @Description + * @Date 2019/12/24 16:11 + **/ + Result> listCategoryId(String ruleId); +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/impl/HandleRoleCategoryServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/impl/HandleRoleCategoryServiceImpl.java new file mode 100644 index 000000000..6366b42a8 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/impl/HandleRoleCategoryServiceImpl.java @@ -0,0 +1,161 @@ +/** + * 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.rolecategory.service.impl; + +import cn.hutool.core.collection.CollUtil; +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.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.dto.rulecategory.HandleRoleCategoryDTO; +import com.elink.esua.epdc.dto.rulecategory.form.HandleRoleCategoryFormDTO; +import com.elink.esua.epdc.modules.rolecategory.dao.HandleRoleCategoryDao; +import com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity; +import com.elink.esua.epdc.modules.rolecategory.redis.HandleRoleCategoryRedis; +import com.elink.esua.epdc.modules.rolecategory.service.HandleRoleCategoryService; +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; + +/** + * 角色和处理类别关系表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-20 + */ +@Service +public class HandleRoleCategoryServiceImpl extends BaseServiceImpl implements HandleRoleCategoryService { + + @Autowired + private HandleRoleCategoryRedis handleRoleCategoryRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, HandleRoleCategoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, HandleRoleCategoryDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public HandleRoleCategoryDTO get(String id) { + HandleRoleCategoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, HandleRoleCategoryDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(HandleRoleCategoryDTO dto) { + HandleRoleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, HandleRoleCategoryEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(HandleRoleCategoryDTO dto) { + HandleRoleCategoryEntity entity = ConvertUtils.sourceToTarget(dto, HandleRoleCategoryEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @param formDTO + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存或修改 角色和处理类别关系 + * @Date 2019/12/24 12:39 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public Result saveOrUpdate(HandleRoleCategoryFormDTO formDTO) { + //先删除角色处理类别权限关系 + deleteByRoleId(formDTO.getRoleId()); + + //角色没有一个处理类别的情况 + if (CollUtil.isEmpty(formDTO.getCategoryIdList())) { + return new Result(); + } + + //保存角色和处理类别关系 + for (String categoryId : formDTO.getCategoryIdList()) { + HandleRoleCategoryEntity entity = new HandleRoleCategoryEntity(); + entity.setCategoryId(categoryId); + entity.setRoleId(formDTO.getRoleId().toString()); + //保存 + insert(entity); + } + + return new Result(); + } + + /** + * @param ruleId + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @Author yinzuomei + * @Description + * @Date 2019/12/24 16:11 + **/ + @Override + public Result> listCategoryId(String ruleId) { + List list=baseDao.selectListCategoryId(ruleId); + return new Result>().ok(list); + } + + /** + * @param roleId 角色id + * @return void + * @Author yinzuomei + * @Description + * @Date 2019/12/24 12:44 + **/ + private void deleteByRoleId(Long roleId) { + baseDao.deleteByRoleId(roleId); + } + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml index 8725dbe68..bec0b4dde 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml @@ -17,5 +17,11 @@ - + + diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/rolecategory/HandleRoleCategoryDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/rolecategory/HandleRoleCategoryDao.xml new file mode 100644 index 000000000..e271f226f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/rolecategory/HandleRoleCategoryDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + delete from epdc_handle_role_category where ROLE_ID = #{value} + + + + +