Browse Source

角色管理添加项目处理类型授权

feature/dangjian
尹作梅 6 years ago
parent
commit
10418b5a77
  1. 5
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java
  2. 6
      esua-epdc/epdc-admin/epdc-admin-server/pom.xml
  3. 4
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysRoleController.java
  4. 42
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java
  5. 30
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java
  6. 1
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysRoleService.java
  7. 33
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java
  8. 30
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/handlecategory/HandleCategoryTreeDTO.java
  9. 81
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/HandleRoleCategoryDTO.java
  10. 29
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/rulecategory/form/HandleRoleCategoryFormDTO.java
  11. 12
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/controller/HandleCategoryController.java
  12. 11
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/dao/HandleCategoryDao.java
  13. 10
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/HandleCategoryService.java
  14. 14
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/handlecategory/service/impl/HandleCategoryServiceImpl.java
  15. 104
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/controller/HandleRoleCategoryController.java
  16. 38
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/dao/HandleRoleCategoryDao.java
  17. 51
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/entity/HandleRoleCategoryEntity.java
  18. 62
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/excel/HandleRoleCategoryExcel.java
  19. 47
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/redis/HandleRoleCategoryRedis.java
  20. 116
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/HandleRoleCategoryService.java
  21. 161
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/rolecategory/service/impl/HandleRoleCategoryServiceImpl.java
  22. 8
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml
  23. 33
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/rolecategory/HandleRoleCategoryDao.xml

5
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<Long> appMenuIdList;
/**
* 项目处理类型授权id列表
*/
private List<String> categoryIdList;
}

6
esua-epdc/epdc-admin/epdc-admin-server/pom.xml

@ -62,6 +62,12 @@
<artifactId>feign-httpclient</artifactId>
<version>10.3.0</version>
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-events-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

4
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<Long> appMenuIdList = appRoleMenuService.getAppMenuIdList(id);
data.setAppMenuIdList(appMenuIdList);
//查询角色对应的项目处理类型权限
List<String> categoryIdList = sysRoleService.getCategoryIdList(id);
data.setCategoryIdList(categoryIdList);
return new Result<SysRoleDTO>().ok(data);
}

42
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<java.util.List<java.lang.String>>
* @Author yinzuomei
* @Description 查询角色对应的项目处理类型权限
* @Date 2019/12/24 17:17
**/
@GetMapping(value = "events/handlerolecategory/queryCategoryIdList/{ruleId}")
Result<List<String>> queryCategoryIdList(@PathVariable("ruleId")Long ruleId);
}

30
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<List<String>> queryCategoryIdList(Long ruleId) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "queryCategoryIdList", ruleId);
}
}

1
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<SysRoleEntity> {
void delete(Long[] ids);
List<String> getCategoryIdList(Long id);
}

33
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<SysRoleDao, SysRoleEntit
@Autowired
private AppRoleMenuService appRoleMenuService;
@Autowired
private EventFeignClient eventFeignClient;
@Override
public PageData<SysRoleDTO> page(Map<String, Object> params) {
IPage<SysRoleEntity> page = baseDao.selectPage(
@ -108,6 +114,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
//保存角色与app菜单关系
appRoleMenuService.saveOrUpdate(entity.getId(), dto.getAppMenuIdList());
//保存角色与项目处理类型关系
HandleRoleCategoryFormDTO categoryFormDTO=new HandleRoleCategoryFormDTO();
categoryFormDTO.setRoleId(entity.getId());
categoryFormDTO.setCategoryIdList(dto.getCategoryIdList());
eventFeignClient.saveOrUpdateHandleCategory(categoryFormDTO);
}
@Override
@ -126,6 +139,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
//更新角色与app菜单关系
appRoleMenuService.saveOrUpdate(entity.getId(), dto.getAppMenuIdList());
//保存角色与项目处理类型关系
HandleRoleCategoryFormDTO categoryFormDTO=new HandleRoleCategoryFormDTO();
categoryFormDTO.setRoleId(entity.getId());
categoryFormDTO.setCategoryIdList(dto.getCategoryIdList());
eventFeignClient.saveOrUpdateHandleCategory(categoryFormDTO);
}
@Override
@ -140,4 +160,17 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
//[角色菜单关系、角色数据权限关系、App菜单授权],需要保留,不然逻辑删除就变成物理删除了
}
/**
* @param id
* @return java.util.List<java.lang.String>
* @Author yinzuomei
* @Description 查询角色对应的项目处理类型权限
* @Date 2019/12/24 16:03
**/
@Override
public List<String> getCategoryIdList(Long id) {
Result<List<String>> result=eventFeignClient.queryCategoryIdList(id);
return result.getData();
}
}

30
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<HandleCategoryTreeDTO> children= new ArrayList<>();
}

81
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
* <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.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;
}

29
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<String> categoryIdList;
}

12
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<java.util.List<com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO>>
* @Author yinzuomei
* @Description 角色管理-项目处理类型授权
* @Date 2019/12/24 10:43
**/
@GetMapping("getCategoryList")
public Result<List<HandleCategoryTreeDTO>> getCategoryList(){
return handleCategoryService.selectListHandleCategoryDTO();
}
}

11
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<HandleCategoryEntity> {
/**
* @param
* @return java.util.List<com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO>
* @Author yinzuomei
* @Description 角色管理-项目处理类型授权 查询语句
* @Date 2019/12/24 10:45
**/
List<HandleCategoryTreeDTO> selectListHandleCategoryDTO();
}

10
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<HandleCategoryEntity>
* @date 2019-12-20
*/
void delete(String[] ids);
/**
* @param
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO>>
* @Author yinzuomei
* @Description 角色管理-项目处理类型授权
* @Date 2019/12/24 10:44
**/
Result<List<HandleCategoryTreeDTO>> selectListHandleCategoryDTO();
}

14
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<HandleCategoryDao
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @param
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO>>
* @Author yinzuomei
* @Description 角色管理-项目处理类型授权
* @Date 2019/12/24 10:44
**/
@Override
public Result<List<HandleCategoryTreeDTO>> selectListHandleCategoryDTO() {
List<HandleCategoryTreeDTO> list = baseDao.selectListHandleCategoryDTO();
return new Result<List<HandleCategoryTreeDTO>>().ok(list);
}
/**
* @param dto
* @return boolean

104
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
* <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.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<PageData<HandleRoleCategoryDTO>> page(@RequestParam Map<String, Object> params){
PageData<HandleRoleCategoryDTO> page = handleRoleCategoryService.page(params);
return new Result<PageData<HandleRoleCategoryDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<HandleRoleCategoryDTO> get(@PathVariable("id") String id){
HandleRoleCategoryDTO data = handleRoleCategoryService.get(id);
return new Result<HandleRoleCategoryDTO>().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<String, Object> params, HttpServletResponse response) throws Exception {
List<HandleRoleCategoryDTO> 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<List<String>> queryCategoryIdList(@PathVariable("ruleId") String ruleId){
return handleRoleCategoryService.listCategoryId(ruleId);
}
}

38
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
* <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.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<HandleRoleCategoryEntity> {
int deleteByRoleId(Long roleId);
List<String> selectListCategoryId(String ruleId);
}

51
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
* <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.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;
}

62
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
* <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.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;
}

47
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
* <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.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;
}
}

116
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
* <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.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<HandleRoleCategoryEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<HandleRoleCategoryDTO>
* @author generator
* @date 2019-12-20
*/
PageData<HandleRoleCategoryDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<HandleRoleCategoryDTO>
* @author generator
* @date 2019-12-20
*/
List<HandleRoleCategoryDTO> list(Map<String, Object> 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<java.util.List<java.lang.String>>
* @Author yinzuomei
* @Description
* @Date 2019/12/24 16:11
**/
Result<List<String>> listCategoryId(String ruleId);
}

161
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
* <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.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<HandleRoleCategoryDao, HandleRoleCategoryEntity> implements HandleRoleCategoryService {
@Autowired
private HandleRoleCategoryRedis handleRoleCategoryRedis;
@Override
public PageData<HandleRoleCategoryDTO> page(Map<String, Object> params) {
IPage<HandleRoleCategoryEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, HandleRoleCategoryDTO.class);
}
@Override
public List<HandleRoleCategoryDTO> list(Map<String, Object> params) {
List<HandleRoleCategoryEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, HandleRoleCategoryDTO.class);
}
private QueryWrapper<HandleRoleCategoryEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<HandleRoleCategoryEntity> 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<java.util.List < java.lang.String>>
* @Author yinzuomei
* @Description
* @Date 2019/12/24 16:11
**/
@Override
public Result<List<String>> listCategoryId(String ruleId) {
List<String> list=baseDao.selectListCategoryId(ruleId);
return new Result<List<String>>().ok(list);
}
/**
* @param roleId 角色id
* @return void
* @Author yinzuomei
* @Description
* @Date 2019/12/24 12:44
**/
private void deleteByRoleId(Long roleId) {
baseDao.deleteByRoleId(roleId);
}
}

8
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/handlecategory/HandleCategoryDao.xml

@ -17,5 +17,11 @@
<result property="categoryCode" column="CATEGORY_CODE"/>
</resultMap>
<!-- 角色管理-项目处理类型授权 查询语句 -->
<select id="selectListHandleCategoryDTO" resultType="com.elink.esua.epdc.dto.handlecategory.HandleCategoryTreeDTO">
select id,CATEGORY_LABEL as name
from epdc_handle_category
where DEL_FLAG='0'
order by SORT asc
</select>
</mapper>

33
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/rolecategory/HandleRoleCategoryDao.xml

@ -0,0 +1,33 @@
<?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.rolecategory.dao.HandleRoleCategoryDao">
<resultMap type="com.elink.esua.epdc.modules.rolecategory.entity.HandleRoleCategoryEntity" id="handleRoleCategoryMap">
<result property="id" column="ID"/>
<result property="roleId" column="ROLE_ID"/>
<result property="categoryId" column="CATEGORY_ID"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
</resultMap>
<!-- 根据角色id删除记录 -->
<delete id="deleteByRoleId">
delete from epdc_handle_role_category where ROLE_ID = #{value}
</delete>
<!-- 根据角色id查询项目处理类别id -->
<select id="selectListCategoryId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
m.CATEGORY_ID
FROM
epdc_handle_role_category m
WHERE
m.DEL_FLAG = '0'
AND m.ROLE_ID =#{ruleId}
</select>
</mapper>
Loading…
Cancel
Save