+ * 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.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.OperationScopeDefaultEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 默认操作范围表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-06-17
+ */
+@Mapper
+public interface OperationScopeDefaultDao extends BaseDao {
+ List listAllValid();
+}
\ No newline at end of file
diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java
new file mode 100755
index 0000000000..04d8f7baf9
--- /dev/null
+++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.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.epmet.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 默认操作范围表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-06-17
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("operation_scope_default")
+public class OperationScopeDefaultEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 操作key
+ */
+ private String operationKey;
+
+ /**
+ * 范围key
+ */
+ private String scopeKey;
+
+}
diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java
index a1320faf7b..e3c4d16d5d 100644
--- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java
+++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java
@@ -23,13 +23,17 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.dao.OperationScopeDefaultDao;
import com.epmet.dao.RoleOperationDao;
import com.epmet.dao.RoleOperationDefaultDao;
+import com.epmet.dao.RoleScopeDao;
import com.epmet.dto.RoleOperationDTO;
import com.epmet.dto.form.InitDefaultOperationsFormDTO;
import com.epmet.dto.result.RoleOperationDefaultResultDTO;
import com.epmet.dto.result.RoleOperationResultDTO;
+import com.epmet.entity.OperationScopeDefaultEntity;
import com.epmet.entity.RoleOperationEntity;
+import com.epmet.entity.RoleScopeEntity;
import com.epmet.service.RoleOperationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,9 +41,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* 角色能进行那些操作
@@ -56,6 +58,12 @@ public class RoleOperationServiceImpl extends BaseServiceImpl page(Map params) {
IPage page = baseDao.selectPage(
@@ -116,7 +124,9 @@ public class RoleOperationServiceImpl extends BaseServiceImpl roles) {
- //roleOperationDefaultDao.listAllValid();
+ List validScopeDefaults = operationScopeDefaultDao.listAllValid();
+ HashMap> opeScopeMap = convertScopeDefaultEntity2Map(validScopeDefaults);
+
for (InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO role : roles) {
String roleId = role.getRoleId();
String roleKey = role.getRoleKey();
@@ -124,6 +134,7 @@ public class RoleOperationServiceImpl extends BaseServiceImpl operations, HashMap> opeScopeMap) {
+ for (RoleOperationDefaultResultDTO operation : operations) {
+ Set scopeKeys4ThisOpe = opeScopeMap.get(operation.getOperationKey());
+ if (!CollectionUtils.isEmpty(scopeKeys4ThisOpe)) {
+ for (String scopeKey : scopeKeys4ThisOpe) {
+ RoleScopeEntity roleScopeEntity = new RoleScopeEntity();
+ roleScopeEntity.setOperationKey(operation.getOperationKey());
+ roleScopeEntity.setRoleId(roleId);
+ roleScopeEntity.setScopeKey(scopeKey);
+ roleScopeDao.insert(roleScopeEntity);
+ }
+ }
+ }
+ }
+
+ /**
+ * 将默认范围entity转换为map
+ * @param entities
+ * @return
+ */
+ private HashMap> convertScopeDefaultEntity2Map(List entities) {
+ HashMap> map = new HashMap<>();
+ for (OperationScopeDefaultEntity entity : entities) {
+ Set scopes = map.get(entity.getOperationKey());
+ if (scopes == null) {
+ scopes = new HashSet<>();
+ map.put(entity.getOperationKey(), scopes);
+ }
+ scopes.add(entity.getScopeKey());
+ }
+ return map;
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml
index c1772b7c54..0591776c96 100644
--- a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml
+++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml
@@ -32,6 +32,16 @@
+
+
+