+ * 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;
+
+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;
+
+}
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 c73087fc..d47fd749 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
@@ -86,4 +86,8 @@ public class SysRoleDTO implements Serializable {
* 吹哨部门id列表
*/
private List whistleDeptIdList;
+ /**
+ * 事件标签授权id列表
+ */
+ private List eventsTagsIdList;
}
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/RoleEventsTagController.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/RoleEventsTagController.java
new file mode 100644
index 00000000..a14695e7
--- /dev/null
+++ b/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
+ *
+ * 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.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> page(@RequestParam Map params){
+ PageData page = roleEventsTagService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id){
+ RoleEventsTagDTO data = roleEventsTagService.get(id);
+ return new Result().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();
+ }
+
+}
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/v2/SysRoleV2Controller.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/v2/SysRoleV2Controller.java
index 6aceee10..9bf2e6f8 100644
--- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/v2/SysRoleV2Controller.java
+++ b/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 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().ok(data);
}
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/RoleEventsTagDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/RoleEventsTagDao.java
new file mode 100644
index 00000000..571c5341
--- /dev/null
+++ b/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
+ *
+ * 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.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 {
+
+ /**
+ * 删除角色对应的事件标签关系
+ *
+ * @param roleId
+ * @return void
+ * @author liuchuang
+ * @since 2021/7/20 14:58
+ */
+ void updateDelFlag(Long roleId);
+
+ /**
+ * 根据角色获取事件标签
+ *
+ * @param roleId
+ * @return java.util.List
+ * @author liuchuang
+ * @since 2021/7/20 15:02
+ */
+ List selectListEventTagIdByRoleId(Long roleId);
+}
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/RoleEventsTagEntity.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/RoleEventsTagEntity.java
new file mode 100644
index 00000000..a1dc312f
--- /dev/null
+++ b/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
+ *
+ * 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.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;
+
+}
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/RoleEventsTagService.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/RoleEventsTagService.java
new file mode 100644
index 00000000..1e90f842
--- /dev/null
+++ b/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
+ *
+ * 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.
+ *
+ * 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.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 implements RoleEventsTagService {
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, RoleEventsTagDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, RoleEventsTagDTO.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 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 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 getEventTagIdList(Long roleId) {
+ return baseDao.selectListEventTagIdByRoleId(roleId);
+ }
+
+}
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 e5bcbdc3..0ca524af 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
@@ -66,6 +66,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl page(Map params) {
IPage page = baseDao.selectPage(
@@ -266,6 +269,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl whistleDeptIdList = dto.getWhistleDeptIdList();
//保存角色对应的可吹哨部门权限
this.saveOrUpdateWhistleDeptId(entity.getId(), whistleDeptIdList);
+
+ // 保存角色授权的事件标签
+ roleEventsTagService.saveOrUpdateRoleEventTagRelation(entity.getId(), dto.getEventsTagsIdList());
}
/**
diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/RoleEventsTagDao.xml b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/RoleEventsTagDao.xml
new file mode 100644
index 00000000..59e447b1
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/RoleEventsTagDao.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ UPDATE epdc_role_events_tag SET DEL_FLAG = '1' WHERE role_id = #{roleId}
+
+
+
+
+
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EventTagController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EventTagController.java
index ebd1ca27..af0ab873 100644
--- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EventTagController.java
+++ b/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);
}
-}
\ No newline at end of file
+ /**
+ * 事件标签列表
+ *
+ * @return com.elink.esua.epdc.commons.tools.utils.Result>
+ * @author liuchuang
+ * @since 2021/7/20 14:23
+ */
+ @GetMapping("eventstags")
+ public Result> eventsTags() {
+ List data = eventTagService.listOfEventTags();
+ return new Result>().ok(data);
+ }
+
+}