diff --git a/.gitignore b/.gitignore index 956f4e305..6915694fa 100644 --- a/.gitignore +++ b/.gitignore @@ -37,10 +37,10 @@ target/ *.tar.gz ### logs #### -logs +/logs/ +*.log ### temp ignore ### -*.log *.cache *.diff *.patch diff --git a/pigx-auth/pom.xml b/pigx-auth/pom.xml index f56777e51..84db1e3dd 100644 --- a/pigx-auth/pom.xml +++ b/pigx-auth/pom.xml @@ -30,7 +30,6 @@ pigx-auth jar - pigx-auth pigx 认证授权中心,基于 spring security oAuth2 @@ -101,28 +100,10 @@ org.springframework.boot spring-boot-maven-plugin - - ${project.name} - com.spotify docker-maven-plugin - 0.4.12 - - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ - diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java index 142b71fe6..5199aa653 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.auth.endpoint; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; import com.pig4cloud.pigx.common.core.util.R; import com.pig4cloud.pigx.common.security.service.PigxUser; import lombok.AllArgsConstructor; @@ -53,7 +54,7 @@ import java.util.Map; @AllArgsConstructor @RequestMapping("/oauth") public class PigxTokenEndpoint { - private static final String PIGX_OAUTH_ACCESS = "pigx_oauth:access:"; + private static final String PIGX_OAUTH_ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "access:"; private final TokenStore tokenStore; private final RedisTemplate redisTemplate; diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml index a74dc9f6d..d95b0daec 100644 --- a/pigx-common/pigx-common-core/pom.xml +++ b/pigx-common/pigx-common-core/pom.xml @@ -29,7 +29,7 @@ pigx-common-core jar - pigx-common-core + pigx 公共工具类核心包 diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java index 5b0e0c472..909f70ba7 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java @@ -24,20 +24,6 @@ package com.pig4cloud.pigx.common.core.constant; * @date 2017/10/29 */ public interface CommonConstant { - /** - * token请求头名称 - */ - String REQ_HEADER = "Authorization"; - - /** - * token分割符 - */ - String TOKEN_SPLIT = "Bearer "; - - /** - * jwt签名 - */ - String SIGN_KEY = "PIG"; /** * 删除 */ @@ -57,16 +43,6 @@ public interface CommonConstant { */ String MENU = "0"; - /** - * 按钮 - */ - String BUTTON = "1"; - - /** - * 删除标记 - */ - String DEL_FLAG = "del_flag"; - /** * 编码 */ @@ -78,12 +54,12 @@ public interface CommonConstant { String CONTENT_TYPE = "application/json; charset=utf-8"; /** - * 阿里大鱼 + * 前端工程名 */ - String ALIYUN_SMS = "aliyun_sms"; + String FRONT_END_PROJECT = "pigx-ui"; /** - * 路由信息Redis保存的key + * 后端工程名 */ - String ROUTE_KEY = "_ROUTE_KEY"; + String BACK_END_PROJECT = "pigx"; } diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java index 758fb6a66..f5a5461a6 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.common.core.datascope; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.HashMap; import java.util.List; @@ -28,6 +29,7 @@ import java.util.List; * 数据权限查询参数 */ @Data +@EqualsAndHashCode(callSuper = true) public class DataScope extends HashMap { /** * 限制范围的字段名称 diff --git a/pigx-common/pigx-common-core/src/main/resources/logback-spring.xml b/pigx-common/pigx-common-core/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..578b8c92e --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/resources/logback-spring.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + diff --git a/pigx-common/pigx-common-job/pom.xml b/pigx-common/pigx-common-job/pom.xml index 5b8c1c582..f9650cb69 100644 --- a/pigx-common/pigx-common-job/pom.xml +++ b/pigx-common/pigx-common-job/pom.xml @@ -29,7 +29,7 @@ pigx-common-job jar - pigx-common-job + pigx 定时任务 diff --git a/pigx-common/pigx-common-log/pom.xml b/pigx-common/pigx-common-log/pom.xml index 152a9cdee..eca18bad8 100644 --- a/pigx-common/pigx-common-log/pom.xml +++ b/pigx-common/pigx-common-log/pom.xml @@ -29,7 +29,7 @@ pigx-common-log jar - pigx-common-log + pigx 日志服务 diff --git a/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties index 76296deab..db34a0283 100644 --- a/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties +++ b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties @@ -1 +1 @@ -restart.include.pigx-common-security=/pigx-common-log[\\w-]+\.jar +restart.include.pigx-common-log=/pigx-common-log[\\w-]+\.jar diff --git a/pigx-common/pigx-common-security/pom.xml b/pigx-common/pigx-common-security/pom.xml index 5d60b469a..89154956b 100644 --- a/pigx-common/pigx-common-security/pom.xml +++ b/pigx-common/pigx-common-security/pom.xml @@ -29,7 +29,7 @@ pigx-common-security jar - pigx-common-security + pigx 安全工具类 diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignClientInterceptor.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignClientInterceptor.java index b93c3a925..1c011f0ab 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignClientInterceptor.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignClientInterceptor.java @@ -53,6 +53,10 @@ public class PigxFeignClientInterceptor extends OAuth2FeignRequestInterceptor { */ @Override public void apply(RequestTemplate template) { + if (template.headers().isEmpty()) { + return; + } + if (oAuth2ClientContext != null && oAuth2ClientContext.getAccessToken() != null) { super.apply(template); diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java index db6f18550..376de0158 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java @@ -98,10 +98,9 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService { Collection authorities = AuthorityUtils.createAuthorityList(dbAuthsSet.toArray(new String[0])); SysUser user = info.getSysUser(); - boolean enabled = StrUtil.equals(user.getDelFlag(), CommonConstant.STATUS_NORMAL); - // 构造security用户 - return new PigxUser(user.getUserId(), user.getDeptId(), user.getUsername(), SecurityConstants.BCRYPT + user.getPassword(), enabled, - true, true, true, authorities); + // 构造security用户 + return new PigxUser(user.getUserId(), user.getDeptId(), user.getUsername(), SecurityConstants.BCRYPT + user.getPassword(), + StrUtil.equals(user.getDelFlag(), CommonConstant.STATUS_NORMAL),true, true, true, authorities); } } diff --git a/pigx-common/pigx-common-swagger/pom.xml b/pigx-common/pigx-common-swagger/pom.xml index 968243246..597c7bb98 100644 --- a/pigx-common/pigx-common-swagger/pom.xml +++ b/pigx-common/pigx-common-swagger/pom.xml @@ -29,7 +29,7 @@ pigx-common-swagger jar - pigx-common-swagger + pigx 接口文档 diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java index b7e404104..84ee6db98 100644 --- a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java @@ -17,7 +17,6 @@ package com.pig4cloud.pigx.common.swagger.config; -import cn.hutool.core.collection.CollUtil; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -34,6 +33,7 @@ import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -46,7 +46,10 @@ import java.util.List; @EnableAutoConfiguration public class SwaggerAutoConfiguration { - private static final String DEFAULT_EXCLUDE_PATH = "/error"; + /** + * 默认的排除路径,排除Spring Boot默认的错误处理路径和端点 + */ + private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error","/actuator/**"); private static final String BASE_PATH = "/**"; @Bean @@ -58,7 +61,7 @@ public class SwaggerAutoConfiguration { @Bean public Docket api(SwaggerProperties swaggerProperties) { // base-path处理 - if (CollUtil.isEmpty(swaggerProperties.getBasePath())) { + if (swaggerProperties.getBasePath().isEmpty()) { swaggerProperties.getBasePath().add(BASE_PATH); } //noinspection unchecked @@ -66,8 +69,8 @@ public class SwaggerAutoConfiguration { swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); // exclude-path处理 - if (CollUtil.isEmpty(swaggerProperties.getExcludePath())) { - swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH); + if (swaggerProperties.getExcludePath().isEmpty()) { + swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); } List> excludePath = new ArrayList<>(); swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); diff --git a/pigx-common/pigx-common-transaction/pom.xml b/pigx-common/pigx-common-transaction/pom.xml index 4c8b915d1..9062d1adb 100644 --- a/pigx-common/pigx-common-transaction/pom.xml +++ b/pigx-common/pigx-common-transaction/pom.xml @@ -10,7 +10,7 @@ pigx-common-transaction jar - pigx-common-transaction + pigx lcn transaction diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml index 3712e08ba..99bc4a584 100644 --- a/pigx-common/pom.xml +++ b/pigx-common/pom.xml @@ -29,7 +29,7 @@ pigx-common pom - pigx-common + pigx 公共聚合模块 diff --git a/pigx-config/pom.xml b/pigx-config/pom.xml index 9c0fd73ea..c40548009 100644 --- a/pigx-config/pom.xml +++ b/pigx-config/pom.xml @@ -30,7 +30,6 @@ pigx-config jar - pigx-config pigx 配置中心,基于spring cloud config @@ -64,28 +63,10 @@ org.springframework.boot spring-boot-maven-plugin - - ${project.name} - com.spotify docker-maven-plugin - 0.4.12 - - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ - diff --git a/pigx-config/src/main/resources/config/application-dev.yml b/pigx-config/src/main/resources/config/application-dev.yml index 468da6722..f0d60ca6d 100644 --- a/pigx-config/src/main/resources/config/application-dev.yml +++ b/pigx-config/src/main/resources/config/application-dev.yml @@ -72,25 +72,22 @@ mybatis-plus: #swagger公共信息 swagger: - title: 'PigX Swagger API' - description: '全宇宙最牛逼的Spring Cloud微服务开发脚手架' - version: '1.4.0' - license: 'Powered By PigX' - licenseUrl: 'https://gitee.com/log4j/pig/wikis' - terms-of-service-url: 'https://gitee.wang/pig/pigx' - exclude-path: - - /actuator/** - - /error + title: PigX Swagger API + description: 全宇宙最牛逼的Spring Cloud微服务开发脚手架 + version: 1.6.2 + license: Powered By PigX + licenseUrl: https://pig4cloud.com/ + terms-of-service-url: https://pig4cloud.com/ contact: - name: '冷冷' - email: 'wangiegie@gmail.com' - url: 'https://gitee.wang/pig/pigx' + name: 冷冷 + email: wangiegie@gmail.com + url: https://pig4cloud.com/about.html authorization: - name: 'pigX OAuth' - auth-regex: '^.*$' + name: pigX OAuth + auth-regex: ^.*$ authorization-scope-list: - - scope: 'server' - description: 'server all' + - scope: server + description: server all token-url-list: - ${security.auth.server}/token diff --git a/pigx-config/src/main/resources/logback-spring.xml b/pigx-config/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..578b8c92e --- /dev/null +++ b/pigx-config/src/main/resources/logback-spring.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + diff --git a/pigx-eureka/pom.xml b/pigx-eureka/pom.xml index 468bce4aa..f4253b057 100644 --- a/pigx-eureka/pom.xml +++ b/pigx-eureka/pom.xml @@ -30,7 +30,6 @@ pigx-eureka jar - pigx-eureka pigx 服务中心,基于eureka @@ -73,28 +72,10 @@ org.springframework.boot spring-boot-maven-plugin - - ${project.name} - com.spotify docker-maven-plugin - 0.4.12 - - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ - diff --git a/pigx-eureka/src/main/resources/logback-spring.xml b/pigx-eureka/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..578b8c92e --- /dev/null +++ b/pigx-eureka/src/main/resources/logback-spring.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml index 7e14aa5cf..1e518691f 100644 --- a/pigx-gateway/pom.xml +++ b/pigx-gateway/pom.xml @@ -29,7 +29,7 @@ pigx-gateway jar - pigx-gateway + pigx 服务网关,基于 spring cloud gateway @@ -77,28 +77,10 @@ org.springframework.boot spring-boot-maven-plugin - - ${project.name} - com.spotify docker-maven-plugin - 0.4.12 - - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ - diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml index a12866ec3..1e421ba1d 100644 --- a/pigx-upms/pigx-upms-api/pom.xml +++ b/pigx-upms/pigx-upms-api/pom.xml @@ -29,7 +29,7 @@ pigx-upms-api jar - pigx-upms-api + pigx 通用用户权限管理系统公共api模块 diff --git a/pigx-upms/pigx-upms-biz/pom.xml b/pigx-upms/pigx-upms-biz/pom.xml index 1ca23796c..939ffbf1e 100644 --- a/pigx-upms/pigx-upms-biz/pom.xml +++ b/pigx-upms/pigx-upms-biz/pom.xml @@ -30,7 +30,6 @@ pigx-upms-biz jar - pigx-upms-biz pigx 通用用户权限管理系统业务处理模块 @@ -67,12 +66,6 @@ org.springframework.cloud spring-cloud-starter-security - - - de.codecentric - spring-boot-admin-starter-client - ${monitor.version} - com.baomidou @@ -108,28 +101,10 @@ org.springframework.boot spring-boot-maven-plugin - - ${project.name} - com.spotify docker-maven-plugin - 0.4.12 - - ${registry.url}/${project.name}:0.0.1 - ${docker.url} - ${project.basedir} - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - docker-hub - https://index.docker.io/v1/ - diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java index b0a0953af..bc930fb1e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java @@ -71,7 +71,6 @@ public class DictController { */ @GetMapping("/dictPage") public Page dictPage(@RequestParam Map params) { - params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); return sysDictService.selectPage(new Query<>(params), new EntityWrapper<>()); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java index 52b1629bc..ed79c6f20 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java @@ -25,7 +25,6 @@ import com.baomidou.mybatisplus.plugins.Page; import com.pig4cloud.pigx.admin.api.entity.SysLog; import com.pig4cloud.pigx.admin.api.vo.PreLogVo; import com.pig4cloud.pigx.admin.service.SysLogService; -import com.pig4cloud.pigx.common.core.constant.CommonConstant; import com.pig4cloud.pigx.common.core.util.Query; import com.pig4cloud.pigx.common.core.util.R; import lombok.AllArgsConstructor; @@ -58,7 +57,6 @@ public class LogController { */ @GetMapping("/logPage") public Page logPage(@RequestParam Map params) { - params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); return sysLogService.selectPage(new Query<>(params), new EntityWrapper<>()); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java index 1684abc8e..28f5e584d 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java @@ -110,7 +110,6 @@ public class RoleController { */ @GetMapping("/rolePage") public Page rolePage(@RequestParam Map params) { - params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); return sysRoleService.selectwithDeptPage(new Query<>(params), new EntityWrapper<>()); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java index 9f7b12ff4..4ac7d3b8e 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java @@ -41,11 +41,4 @@ public interface SysDeptMapper extends BaseMapper { * @return 数据列表 */ List selectDeptDtoList(String delFlag); - - /** - * 删除部门关系表数据 - * - * @param id 部门ID - */ - void deleteDeptRealtion(Integer id); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java index 069c66bc4..cdbfb3bcd 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java @@ -31,5 +31,17 @@ import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; * @since 2018-02-12 */ public interface SysDeptRelationMapper extends BaseMapper { + /** + * 删除部门关系表数据 + * + * @param id 部门ID + */ + void deleteAllDeptRealtion(Integer id); + /** + * 更改部分关系表数据 + * + * @param deptRelation + */ + void updateDeptRealtion(SysDeptRelation deptRelation); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java index 62159c7a1..7f6ba9e81 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java @@ -100,7 +100,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl sysDept.setUpdateTime(LocalDateTime.now()); sysDept.setDelFlag(CommonConstant.STATUS_DEL); this.deleteById(sysDept); - sysDeptMapper.deleteDeptRealtion(id); + sysDeptRelationMapper.deleteAllDeptRealtion(id); return Boolean.TRUE; } @@ -114,10 +114,11 @@ public class SysDeptServiceImpl extends ServiceImpl impl public Boolean updateDeptById(SysDept sysDept) { //更新部门状态 this.updateById(sysDept); - //删除部门关系 - sysDeptMapper.deleteDeptRealtion(sysDept.getDeptId()); - //新建部门关系 - this.insertDeptRelation(sysDept); + //更新部门关系 + SysDeptRelation relation = new SysDeptRelation(); + relation.setAncestor(sysDept.getParentId()); + relation.setDescendant(sysDept.getDeptId()); + sysDeptRelationMapper.updateDeptRealtion(relation); return Boolean.TRUE; } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml index fdd683274..ecda851c6 100644 --- a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml @@ -35,25 +35,6 @@ dept_id AS deptId, parent_id AS parentId, name, order_num AS orderNum, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag - - DELETE - FROM - sys_dept_relation - WHERE - descendant IN ( - SELECT - temp.descendant - FROM - ( - SELECT - descendant - FROM - sys_dept_relation - WHERE - ancestor = #{id} - ) temp - ) -