From 9c8ddd93e75bd9e095e880c9f4e0f190d06e393b Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Thu, 9 Feb 2023 17:49:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=20test=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/ding/task/OrganizationBatchGetTask.java | 2 +- pmapi/src/main/resources/integration/zwdd-dev.yml | 29 ++-- pmapi/src/main/resources/integration/zwdd-prod.yml | 11 ++ .../pmapi/organization/OrganizationTest.java | 7 +- pmapi/src/test/resources/application-dev.yml | 168 +++++++++++++++++++++ pmapi/src/test/resources/application-prod.yml | 0 pmapi/src/test/resources/application.yml | 3 + pmapi/src/test/resources/integration/zwdd-dev.yml | 14 ++ pmapi/src/test/resources/integration/zwdd-prod.yml | 11 ++ pmapi/src/test/resources/logback-spring.xml | 68 +++++++++ pmapi/src/test/resources/security/auth-dev.yml | 52 +++++++ pmapi/src/test/resources/security/auth-prod.yml | 41 +++++ 12 files changed, 392 insertions(+), 14 deletions(-) create mode 100644 pmapi/src/main/resources/integration/zwdd-prod.yml create mode 100644 pmapi/src/test/resources/application-dev.yml create mode 100644 pmapi/src/test/resources/application-prod.yml create mode 100644 pmapi/src/test/resources/application.yml create mode 100644 pmapi/src/test/resources/integration/zwdd-dev.yml create mode 100644 pmapi/src/test/resources/integration/zwdd-prod.yml create mode 100644 pmapi/src/test/resources/logback-spring.xml create mode 100644 pmapi/src/test/resources/security/auth-dev.yml create mode 100644 pmapi/src/test/resources/security/auth-prod.yml diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java index 3888c2c..d5ef0f1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java @@ -46,7 +46,7 @@ public class OrganizationBatchGetTask { * 获取浙政钉组织架构 */ @Transactional(rollbackFor = Exception.class) - public void OrganizationBatchGetTask() { + public void batchGetOrganizationTask() { // List allList = iDingOrganizationService.list(); // List currentAllOrganizationCodeList = allList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList()); // 全量删除 diff --git a/pmapi/src/main/resources/integration/zwdd-dev.yml b/pmapi/src/main/resources/integration/zwdd-dev.yml index 0073994..2acb0d9 100644 --- a/pmapi/src/main/resources/integration/zwdd-dev.yml +++ b/pmapi/src/main/resources/integration/zwdd-dev.yml @@ -1,11 +1,20 @@ #专有钉钉 -ding: - #扫码 - app-auth-key: expert-base_dingoa-c5nnefYVnie - app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L - # #免登/获取信息 - app-key: file-manage-4Mjx9358wuxjyYFjY3 - app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O - #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 - tenantId: 31141 - domain: openplatform.dg-work.cn \ No newline at end of file +integration: + zzd: + #扫码 + app-auth-key: expert-base_dingoa-c5nnefYVnie + app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L + # #免登/获取信息 + # app-key: file-manage-4Mjx9358wuxjyYFjY3 + # app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O + app-key: ls_rebuild-10c8n5X0707yFV7jURr + app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6 + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn + +# integration.zzd.enabled=true +# #扫码 +# integration.zzd.app-auth-key=file-manage_dingoa-zte2LbiAfIj +# integration.zzd.app-auth-secret=H794aFZf271QbfUr50pbBpBTlXSrWIP71q9RTR34 +# integration.zzd.domain=openplatform.dg-work.cn \ No newline at end of file diff --git a/pmapi/src/main/resources/integration/zwdd-prod.yml b/pmapi/src/main/resources/integration/zwdd-prod.yml new file mode 100644 index 0000000..0073994 --- /dev/null +++ b/pmapi/src/main/resources/integration/zwdd-prod.yml @@ -0,0 +1,11 @@ +#专有钉钉 +ding: + #扫码 + app-auth-key: expert-base_dingoa-c5nnefYVnie + app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L + # #免登/获取信息 + app-key: file-manage-4Mjx9358wuxjyYFjY3 + app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java index 1f08428..0fd3585 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java @@ -4,6 +4,7 @@ import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; import com.ningdatech.zwdd.client.ZwddAuthClient; import com.ningdatech.zwdd.client.ZwddClient; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; /** @@ -11,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; * @date 2023/2/9 下午3:54 */ -public class OrganizationTest extends AppTests { +class OrganizationTest extends AppTests { @Autowired private ZwddClient zwddClient; @@ -22,9 +23,9 @@ public class OrganizationTest extends AppTests { @Autowired private OrganizationBatchGetTask organizationBatchGetTask; + @Test public void testBatchGetOrganization() { - - + organizationBatchGetTask.batchGetOrganizationTask(); } } diff --git a/pmapi/src/test/resources/application-dev.yml b/pmapi/src/test/resources/application-dev.yml new file mode 100644 index 0000000..7727198 --- /dev/null +++ b/pmapi/src/test/resources/application-dev.yml @@ -0,0 +1,168 @@ +server: + port: 28888 + servlet: + context-path: /pm + +spring: + mvc: + pathmatch: + matching-strategy: ant_path_matcher + session: + store-type: redis + redis: + namespace: "spring:session" + redis: + timeout: 5000 + host: 47.98.125.47 + port: 26379 + database: 0 + password: Ndkj1234 + jedis: + pool: + max-active: 200 + max-idle: 500 + min-idle: 8 + max-wait: 10000 + application: + name: pm + jackson: + default-property-inclusion: non_null + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + jpa: + properties: + hibernate: + default_schema: PUBLIC + hbm2ddl: + auto: update + show_sql: true + show-sql: true + hibernate: + ddl-auto: update + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.kingbase8.Driver + # 数据源 + druid: + url: jdbc:kingbase8://120.26.44.207:54321/nd_project_management?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 + username: SYSTEM + password: Ndkj1234 + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + #mysql使用:SELECT 1 FROM DUAL + validationQuery: SELECT 1 + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: admin + login-password: admin + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-value: true + logic-not-delete-value: false +logging: + config: classpath:logback-spring.xml +#日志配置 + level: + root: info + file: + path: logs +nd: + log: + enabled: true + type: DB +# 日志文件配置 +log: + path: ./logs + info: + file-size: 50MB + max-size: 5 + total-size: 200MB + error: + file-size: 10MB + max-size: 5 + total-size: 50MB + +swagger: + enabled: true + +flowable: + async-executor-activate: true + #关闭一些不需要的功能服务 + rest-api-enabled: false + idm: + enabled: false + common: + enabled: false + dmn: + enabled: false + form: + enabled: false + app: + enabled: false + +wflow: + file: + max-size: 20 #最大文件上传大小,MB + +sa-token: + # token 名称 (同时也是cookie名称) + token-name: wflowToken + # token 有效期,单位s 默认30天, -1代表永不过期 + timeout: 172800 + # token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 + activity-timeout: -1 + # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token) + is-share: false + # token风格 + token-style: uuid + # 是否输出操作日志 + is-log: false + +#专有钉钉 +ding: + #扫码 + app-auth-key: expert-base_dingoa-c5nnefYVnie + app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L + # #免登/获取信息 + app-key: file-manage-4Mjx9358wuxjyYFjY3 + app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/pmapi/src/test/resources/application-prod.yml b/pmapi/src/test/resources/application-prod.yml new file mode 100644 index 0000000..e69de29 diff --git a/pmapi/src/test/resources/application.yml b/pmapi/src/test/resources/application.yml new file mode 100644 index 0000000..3d7808a --- /dev/null +++ b/pmapi/src/test/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: dev diff --git a/pmapi/src/test/resources/integration/zwdd-dev.yml b/pmapi/src/test/resources/integration/zwdd-dev.yml new file mode 100644 index 0000000..b2bbff9 --- /dev/null +++ b/pmapi/src/test/resources/integration/zwdd-dev.yml @@ -0,0 +1,14 @@ +#专有钉钉 +integration: + zwdd: + #扫码 + app-auth-key: expert-base_dingoa-c5nnefYVnie + app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L + # #免登/获取信息 +# app-key: file-manage-4Mjx9358wuxjyYFjY3 +# app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O + app-key: ls_rebuild-10c8n5X0707yFV7jURr + app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6 + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/pmapi/src/test/resources/integration/zwdd-prod.yml b/pmapi/src/test/resources/integration/zwdd-prod.yml new file mode 100644 index 0000000..0073994 --- /dev/null +++ b/pmapi/src/test/resources/integration/zwdd-prod.yml @@ -0,0 +1,11 @@ +#专有钉钉 +ding: + #扫码 + app-auth-key: expert-base_dingoa-c5nnefYVnie + app-auth-secret: nm8qtST8uK431HYrjr7srcE23sT4889QgMcYFM3L + # #免登/获取信息 + app-key: file-manage-4Mjx9358wuxjyYFjY3 + app-secret: hE41938wqyQ5LOpc1QDRA9e7gb5YugoClWD3nY4O + #专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729 + tenantId: 31141 + domain: openplatform.dg-work.cn \ No newline at end of file diff --git a/pmapi/src/test/resources/logback-spring.xml b/pmapi/src/test/resources/logback-spring.xml new file mode 100644 index 0000000..75f5472 --- /dev/null +++ b/pmapi/src/test/resources/logback-spring.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + ${logPath}/info.log + + ${logPath}/info-%d{yyyyMMdd}-%i.log + + ${infoFileSize} + + ${infoMaxSize} + ${infoTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + ERROR + + ${logPath}/error.log + + ${logPath}/error-%d{yyyyMMdd}-%i.log + + ${errorFileSize} + + ${errorMaxSize} + ${errorTotalSize} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + + UTF-8 + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n + + UTF-8 + + + DEBUG + + + + + + + + + diff --git a/pmapi/src/test/resources/security/auth-dev.yml b/pmapi/src/test/resources/security/auth-dev.yml new file mode 100644 index 0000000..448ffa2 --- /dev/null +++ b/pmapi/src/test/resources/security/auth-dev.yml @@ -0,0 +1,52 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login/password + logout-url: /api/v1/user/auth/logout + ignore-auth-urls: + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/auth-require + - /api/v1/user/auth/invalid-session + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /api/v1/** + - /doc.html + - /ok.html + - /open/api/** + - /oa/** + - /wflow/** + - /sys/** + ignore-csrf-urls: + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** + - /oa/** + - /wflow/** + - /sys/** + role-map: + "engineer": + "project_manager": + - /api/v1/user-info/kick-off/** + "enterprise_admin": + "regional_general_manager": + "driver": + "super_admin": + - /api/v1/user-info/save + - /api/v1/user-info/del + - /api/v1/user-info/kick-off/** + - /api/v1/user-info/password/mod \ No newline at end of file diff --git a/pmapi/src/test/resources/security/auth-prod.yml b/pmapi/src/test/resources/security/auth-prod.yml new file mode 100644 index 0000000..37e3281 --- /dev/null +++ b/pmapi/src/test/resources/security/auth-prod.yml @@ -0,0 +1,41 @@ +security: + auth: + auth-require-url: /api/v1/user/auth/auth-require + invalid-session-url: /api/v1/user/auth/invalid-session + password-login-url: /api/v1/user/auth/login/password + logout-url: /api/v1/user/auth/logout + ignore-auth-urls: + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /api/v1/user/auth/register + - /api/v1/user/auth/login/password + - /api/v1/user/auth/forget-password + - /doc.html + - /ok.html + ignore-csrf-urls: + - /api/v1/user/auth/** + - /v2/api-docs + - /swagger-ui.html + - /webjars/** + - /swagger-resources/** + - /webjars/ + - /doc.html + - /ok.html + - /api/v1/** + - /file/** + - /optLog/** + - /dict/** + role-map: + "engineer": + "project_manager": + "enterprise_admin": + "regional_general_manager": + "driver": + "super_admin": + - /api/v1/user-info/save + - /api/v1/user-info/del + - /api/v1/user-info/kick-off/** + - /api/v1/user-info/password/mod \ No newline at end of file From d2845adb104f8c7f8c80c00410223abadfac1806 Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Thu, 9 Feb 2023 18:03:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=B5=99=E6=94=BF=E9=92=89=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/ding/task/OrganizationBatchGetTask.java | 48 +++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java index d5ef0f1..9f45951 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.ding.task; +import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.google.common.collect.Lists; @@ -134,33 +135,34 @@ public class OrganizationBatchGetTask { GenericResult pageSubOrganizationCodeDTOGenericResult = zwddClient.pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode); PageSubOrganizationCodeDTO pageSubOrganizationCodeDTO = pageSubOrganizationCodeDTOGenericResult.getData(); - List subOrganizationCodeList = new ArrayList<>(pageSubOrganizationCodeDTO.getSubOrganizationCodeList()); - Long totalSize = pageSubOrganizationCodeDTO.getTotalSize(); + if (CollUtil.isNotEmpty(pageSubOrganizationCodeDTO.getSubOrganizationCodeList())) { + List subOrganizationCodeList = new ArrayList<>(pageSubOrganizationCodeDTO.getSubOrganizationCodeList()); + Long totalSize = pageSubOrganizationCodeDTO.getTotalSize(); - while (totalSize > (long) currentPage * pageSize) { - GenericResult subPageSubOrganizationCodeDTOGenericResult = zwddClient - .pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode); - PageSubOrganizationCodeDTO subOrganizationCodeDTO = subPageSubOrganizationCodeDTOGenericResult.getData(); - if (CollectionUtils.isNotEmpty(subOrganizationCodeDTO.getSubOrganizationCodeList())) { - subOrganizationCodeList.addAll(subOrganizationCodeDTO.getSubOrganizationCodeList()); + while (totalSize > (long) currentPage * pageSize) { + GenericResult subPageSubOrganizationCodeDTOGenericResult = zwddClient + .pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode); + PageSubOrganizationCodeDTO subOrganizationCodeDTO = subPageSubOrganizationCodeDTOGenericResult.getData(); + if (CollectionUtils.isNotEmpty(subOrganizationCodeDTO.getSubOrganizationCodeList())) { + subOrganizationCodeList.addAll(subOrganizationCodeDTO.getSubOrganizationCodeList()); + } } - } - if (CollectionUtils.isNotEmpty(subOrganizationCodeList)) { - GenericResult> listGenericResult = zwddClient - .listOrganizationsByCodes(subOrganizationCodeList); - List dingOrgInfoDtos = listGenericResult.getData(); - List dingOrgInfoTreeDTOList = dingOrgInfoDtos.stream().map(r -> { - DingOrgInfoTreeDTO dingOrgInfoTreeDTO = new DingOrgInfoTreeDTO(); - dingOrgInfoTreeDTO.setCode(r.getOrganizationCode()); - dingOrgInfoTreeDTO.setDingOrgInfoDTO(r); - dingOrgInfoTreeDTO.setChildCodes(new ArrayList<>()); - getDingOrgChild(dingOrgInfoTreeDTO); - return dingOrgInfoTreeDTO; - }).collect(Collectors.toList()); - parentDingOrgInfoTreeDTO.setChildCodes(dingOrgInfoTreeDTOList); + if (CollectionUtils.isNotEmpty(subOrganizationCodeList)) { + GenericResult> listGenericResult = zwddClient + .listOrganizationsByCodes(subOrganizationCodeList); + List dingOrgInfoDtos = listGenericResult.getData(); + List dingOrgInfoTreeDTOList = dingOrgInfoDtos.stream().map(r -> { + DingOrgInfoTreeDTO dingOrgInfoTreeDTO = new DingOrgInfoTreeDTO(); + dingOrgInfoTreeDTO.setCode(r.getOrganizationCode()); + dingOrgInfoTreeDTO.setDingOrgInfoDTO(r); + dingOrgInfoTreeDTO.setChildCodes(new ArrayList<>()); + getDingOrgChild(dingOrgInfoTreeDTO); + return dingOrgInfoTreeDTO; + }).collect(Collectors.toList()); + parentDingOrgInfoTreeDTO.setChildCodes(dingOrgInfoTreeDTOList); + } } - } }