From 1c14c14b84a67e1c4d7fd0e93d94148a77c86c02 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 17 Jun 2020 15:54:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7=EF=BC=8C?= =?UTF-8?q?=E7=BB=99=E5=AE=A2=E6=88=B7=E5=88=9D=E5=A7=8B=E5=8C=96=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E8=A7=92=E8=89=B2=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=88=97=E8=A1=A8=E5=92=8C=E8=8C=83=E5=9B=B4=E5=88=97?= =?UTF-8?q?=E8=A1=A8=202.=E6=9F=A5=E8=AF=A2=E4=B8=80=E4=B8=AA=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E6=9D=83=E9=99=90=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=90=8C=E6=97=B6=E6=9F=A5=E8=AF=A2=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=A1=A8=E5=92=8C=E9=85=8D=E7=BD=AE=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8F=AA=E6=9F=A5=E8=AF=A2=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/feign/GovAccessFeignClient.java | 1 + .../epmet/dao/OperationScopeDefaultDao.java | 35 +++++++++++ .../entity/OperationScopeDefaultEntity.java | 51 ++++++++++++++++ .../impl/RoleOperationServiceImpl.java | 58 +++++++++++++++++-- .../resources/mapper/OperationScopeDao.xml | 12 +++- .../mapper/OperationScopeDefaultDao.xml | 24 ++++++++ .../com/epmet/feign/EpmetUserFeignClient.java | 2 +- .../epmet/feign/OperCustomizeFeignClient.java | 10 ---- 8 files changed, 177 insertions(+), 16 deletions(-) create mode 100755 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java create mode 100755 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java create mode 100755 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDefaultDao.xml diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java index c419c8a257..b4ca57f24b 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -8,6 +8,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +//@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallBack.class, url = "http://localhost:8099") @FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallBack.class) public interface GovAccessFeignClient { diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java new file mode 100755 index 0000000000..5e38a89f31 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java @@ -0,0 +1,35 @@ +/** + * 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.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 @@ + + + + SELECT * + FROM operation_scope_default WHERE DEL_FLAG=0 + + + + \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 1942525951..d67b500d59 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; -//, url = "localhost:8087" +//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class, url = "localhost:8087") @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class) public interface EpmetUserFeignClient { diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java index b3c13859b7..b59a5c7a20 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java @@ -2,22 +2,12 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerHomeDTO; -import com.epmet.dto.form.AddAgencyFormDTO; -import com.epmet.dto.form.AddRootAgencyFormDTO; -import com.epmet.dto.form.StaffSubmitFromDTO; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.feign.fallback.GovOrgFeignClientFallBack; import com.epmet.feign.fallback.OperCustomizeFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import java.util.List; -import java.util.Map; - //@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class, url = "localhost:8089") @FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class) public interface OperCustomizeFeignClient {