Browse Source

角色事件标签管理功能 init

feature/screenDataPush
liuchuang 4 years ago
parent
commit
429f1b90af
  1. 81
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/RoleEventsTagDTO.java
  2. 4
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java
  3. 87
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/RoleEventsTagController.java
  4. 9
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/v2/SysRoleV2Controller.java
  5. 54
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/RoleEventsTagDao.java
  6. 51
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/RoleEventsTagEntity.java
  7. 117
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/RoleEventsTagService.java
  8. 126
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/RoleEventsTagServiceImpl.java
  9. 6
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java
  10. 14
      esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/RoleEventsTagDao.xml
  11. 18
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EventTagController.java

81
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/RoleEventsTagDTO.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;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 角色和事件标签关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-07-20
*/
@Data
public class RoleEventsTagDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 角色ID
*/
private Long roleId;
/**
* 事件标签ID
*/
private String eventTagId;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除标识 0未删除1已删除
*/
private String delFlag;
}

4
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysRoleDTO.java

@ -86,4 +86,8 @@ public class SysRoleDTO implements Serializable {
* 吹哨部门id列表
*/
private List<Long> whistleDeptIdList;
/**
* 事件标签授权id列表
*/
private List<String> eventsTagsIdList;
}

87
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/RoleEventsTagController.java

@ -0,0 +1,87 @@
/**
* 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.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.RoleEventsTagDTO;
import com.elink.esua.epdc.service.RoleEventsTagService;
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 2021-07-20
*/
@RestController
@RequestMapping("roleeventstag")
public class RoleEventsTagController {
@Autowired
private RoleEventsTagService roleEventsTagService;
@GetMapping("page")
public Result<PageData<RoleEventsTagDTO>> page(@RequestParam Map<String, Object> params){
PageData<RoleEventsTagDTO> page = roleEventsTagService.page(params);
return new Result<PageData<RoleEventsTagDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<RoleEventsTagDTO> get(@PathVariable("id") String id){
RoleEventsTagDTO data = roleEventsTagService.get(id);
return new Result<RoleEventsTagDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody RoleEventsTagDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
roleEventsTagService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody RoleEventsTagDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
roleEventsTagService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
roleEventsTagService.delete(ids);
return new Result();
}
}

9
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/v2/SysRoleV2Controller.java

@ -17,10 +17,7 @@ import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.SysRoleDTO;
import com.elink.esua.epdc.enums.AppMenuCategoryEnum;
import com.elink.esua.epdc.service.AppRoleMenuService;
import com.elink.esua.epdc.service.SysRoleDataScopeService;
import com.elink.esua.epdc.service.SysRoleMenuService;
import com.elink.esua.epdc.service.SysRoleService;
import com.elink.esua.epdc.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -44,6 +41,8 @@ public class SysRoleV2Controller {
private SysRoleDataScopeService sysRoleDataScopeService;
@Autowired
private AppRoleMenuService appRoleMenuService;
@Autowired
private RoleEventsTagService roleEventsTagService;
@GetMapping("{id}")
public Result<SysRoleDTO> get(@PathVariable("id") Long id) {
@ -61,6 +60,8 @@ public class SysRoleV2Controller {
data.setCategoryIdList(sysRoleService.getCategoryIdList(id));
//查询角色对应的吹哨部门
data.setWhistleDeptIdList(sysRoleService.getWhistleDeptIdList(id));
// 查询角色对应的事件标签
data.setEventsTagsIdList(roleEventsTagService.getEventTagIdList(id));
return new Result<SysRoleDTO>().ok(data);
}

54
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/RoleEventsTagDao.java

@ -0,0 +1,54 @@
/**
* 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.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.RoleEventsTagEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 角色和事件标签关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-07-20
*/
@Mapper
public interface RoleEventsTagDao extends BaseDao<RoleEventsTagEntity> {
/**
* 删除角色对应的事件标签关系
*
* @param roleId
* @return void
* @author liuchuang
* @since 2021/7/20 14:58
*/
void updateDelFlag(Long roleId);
/**
* 根据角色获取事件标签
*
* @param roleId
* @return java.util.List<java.lang.String>
* @author liuchuang
* @since 2021/7/20 15:02
*/
List<String> selectListEventTagIdByRoleId(Long roleId);
}

51
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/RoleEventsTagEntity.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.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 2021-07-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_role_events_tag")
public class RoleEventsTagEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 角色ID
*/
private Long roleId;
/**
* 事件标签ID
*/
private String eventTagId;
}

117
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/RoleEventsTagService.java

@ -0,0 +1,117 @@
/**
* 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.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.RoleEventsTagDTO;
import com.elink.esua.epdc.entity.RoleEventsTagEntity;
import java.util.List;
import java.util.Map;
/**
* 角色和事件标签关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-07-20
*/
public interface RoleEventsTagService extends BaseService<RoleEventsTagEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<RoleEventsTagDTO>
* @author generator
* @date 2021-07-20
*/
PageData<RoleEventsTagDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<RoleEventsTagDTO>
* @author generator
* @date 2021-07-20
*/
List<RoleEventsTagDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return RoleEventsTagDTO
* @author generator
* @date 2021-07-20
*/
RoleEventsTagDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-07-20
*/
void save(RoleEventsTagDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-07-20
*/
void update(RoleEventsTagDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-07-20
*/
void delete(String[] ids);
/**
* 保存角色授权的事件标签
*
* @param roleId
* @param eventsTagIdList
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author liuchuang
* @since 2021/7/20 14:49
*/
Result saveOrUpdateRoleEventTagRelation(Long roleId, List<String> eventsTagIdList);
/**
* 根据角色获取事件标签
*
* @param roleId
* @return java.util.List<java.lang.String>
* @author liuchuang
* @since 2021/7/20 15:02
*/
List<String> getEventTagIdList(Long roleId);
}

126
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/RoleEventsTagServiceImpl.java

@ -0,0 +1,126 @@
/**
* 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.service.impl;
import cn.hutool.core.collection.CollectionUtil;
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.dao.RoleEventsTagDao;
import com.elink.esua.epdc.dto.RoleEventsTagDTO;
import com.elink.esua.epdc.entity.RoleEventsTagEntity;
import com.elink.esua.epdc.service.RoleEventsTagService;
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 2021-07-20
*/
@Service
public class RoleEventsTagServiceImpl extends BaseServiceImpl<RoleEventsTagDao, RoleEventsTagEntity> implements RoleEventsTagService {
@Override
public PageData<RoleEventsTagDTO> page(Map<String, Object> params) {
IPage<RoleEventsTagEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, RoleEventsTagDTO.class);
}
@Override
public List<RoleEventsTagDTO> list(Map<String, Object> params) {
List<RoleEventsTagEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, RoleEventsTagDTO.class);
}
private QueryWrapper<RoleEventsTagEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<RoleEventsTagEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public RoleEventsTagDTO get(String id) {
RoleEventsTagEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, RoleEventsTagDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(RoleEventsTagDTO dto) {
RoleEventsTagEntity entity = ConvertUtils.sourceToTarget(dto, RoleEventsTagEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(RoleEventsTagDTO dto) {
RoleEventsTagEntity entity = ConvertUtils.sourceToTarget(dto, RoleEventsTagEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result saveOrUpdateRoleEventTagRelation(Long roleId, List<String> eventsTagIdList) {
if (null != roleId) {
// 删除角色已关联的事件标签
baseDao.updateDelFlag(roleId);
// 插入新的关联关系
for (String eventTagId:
eventsTagIdList) {
RoleEventsTagEntity entity = new RoleEventsTagEntity();
entity.setRoleId(roleId);
entity.setEventTagId(eventTagId);
insert(entity);
}
}
return new Result();
}
@Override
public List<String> getEventTagIdList(Long roleId) {
return baseDao.selectListEventTagIdByRoleId(roleId);
}
}

6
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysRoleServiceImpl.java

@ -66,6 +66,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
private EventFeignClient eventFeignClient;
@Autowired
private SysDeptDao sysDeptDao;
@Autowired
private RoleEventsTagService roleEventsTagService;
@Override
public PageData<SysRoleDTO> page(Map<String, Object> params) {
IPage<SysRoleEntity> page = baseDao.selectPage(
@ -266,6 +269,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
List<Long> whistleDeptIdList = dto.getWhistleDeptIdList();
//保存角色对应的可吹哨部门权限
this.saveOrUpdateWhistleDeptId(entity.getId(), whistleDeptIdList);
// 保存角色授权的事件标签
roleEventsTagService.saveOrUpdateRoleEventTagRelation(entity.getId(), dto.getEventsTagsIdList());
}
/**

14
esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/RoleEventsTagDao.xml

@ -0,0 +1,14 @@
<?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.dao.RoleEventsTagDao">
<update id="updateDelFlag">
UPDATE epdc_role_events_tag SET DEL_FLAG = '1' WHERE role_id = #{roleId}
</update>
<select id="selectListEventTagIdByRoleId" resultType="string">
SELECT EVENT_TAG_ID FROM epdc_role_events_tag WHERE DEL_FLAG = '0' AND role_id = #{roleId}
</select>
</mapper>

18
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EventTagController.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.events.EventTagDTO;
import com.elink.esua.epdc.dto.events.result.EventTagsResultDTO;
import com.elink.esua.epdc.modules.events.excel.EventTagExcel;
import com.elink.esua.epdc.modules.events.service.EventTagService;
import org.springframework.beans.factory.annotation.Autowired;
@ -45,7 +46,7 @@ import java.util.Map;
@RestController
@RequestMapping("eventtag")
public class EventTagController {
@Autowired
private EventTagService eventTagService;
@ -91,4 +92,17 @@ public class EventTagController {
ExcelUtils.exportExcelToTarget(response, null, list, EventTagExcel.class);
}
}
/**
* 事件标签列表
*
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.events.result.EventTagsResultDTO>>
* @author liuchuang
* @since 2021/7/20 14:23
*/
@GetMapping("eventstags")
public Result<List<EventTagsResultDTO>> eventsTags() {
List<EventTagsResultDTO> data = eventTagService.listOfEventTags();
return new Result<List<EventTagsResultDTO>>().ok(data);
}
}

Loading…
Cancel
Save