From 8ec873a2b162dddf07255a4e2dd3329a47c8314f Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Fri, 17 Nov 2023 09:06:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=93=81=E7=89=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=95=86=E5=9F=8E=E5=BC=80=E5=90=AF=E7=AE=A1=E7=90=86?= =?UTF-8?q?;=E8=B0=83=E6=95=B4=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=8C=85=E5=AD=98=E6=94=BE=E4=BD=8D=E7=BD=AE;=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=91=98=E5=B7=A5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cpop-Api/pom.xml | 11 ++ Cpop-Common/pom.xml | 11 ++ Cpop-Core/pom.xml | 11 ++ .../core/handler/LoginFailureHandler.java | 3 +- .../strategy/login/MiniLoginStrategy.java | 4 +- Cpop-Generator/pom.xml | 11 ++ Cpop-Jambox/Cpop-Jambox-Web/pom.xml | 9 +- Cpop-Jambox/pom.xml | 11 ++ Cpop-Mall/Cpop-Mall-Web/pom.xml | 10 +- .../src/main/resources/application-dev.yml | 4 + .../java/com/cpop/mall/web/CpopCbcTests.java | 151 ++++++++++++++++++ .../com/cpop/mall/web/CpopWxPayTests.java | 6 +- Cpop-Mall/pom.xml | 11 ++ Cpop-Mini/pom.xml | 11 ++ Cpop-Oam/Cpop-Oam-Web/pom.xml | 9 -- .../src/main/resources/application-test.yml | 2 +- .../src/main/resources/application.yml | 11 +- Cpop-Oam/pom.xml | 11 ++ .../business/controller/DeptController.java | 18 ++- .../business/controller/StaffController.java | 15 +- .../oam/business/service/DeptService.java | 9 ++ .../oam/business/service/StaffService.java | 8 + .../service/impl/DeptServiceImpl.java | 69 +++++++- .../service/impl/OamMallServiceImpl.java | 2 +- .../service/impl/StaffServiceImpl.java | 70 ++++++++ Cpop-System/pom.xml | 11 ++ .../cpop/system/business/vo/BrandPageVo.java | 6 +- pom.xml | 25 +++ 28 files changed, 483 insertions(+), 47 deletions(-) create mode 100644 Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopCbcTests.java diff --git a/Cpop-Api/pom.xml b/Cpop-Api/pom.xml index 6695113..ac50cba 100644 --- a/Cpop-Api/pom.xml +++ b/Cpop-Api/pom.xml @@ -20,4 +20,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Common/pom.xml b/Cpop-Common/pom.xml index 6e34fb1..b64d6b4 100644 --- a/Cpop-Common/pom.xml +++ b/Cpop-Common/pom.xml @@ -36,4 +36,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Core/pom.xml b/Cpop-Core/pom.xml index 85b663c..cb76ea5 100644 --- a/Cpop-Core/pom.xml +++ b/Cpop-Core/pom.xml @@ -114,4 +114,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java b/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java index 4786d45..e48f393 100644 --- a/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java +++ b/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java @@ -50,7 +50,8 @@ public class LoginFailureHandler implements AuthenticationFailureHandler { loginUser.setUserType((UserType) ((CpopAuthenticationException) e).getParams()); errorMessage = e.getMessage(); } - result = R.fail(errorMessage); + //TODO:暂时先这么处理 + result = R.ok(errorMessage); if (loginUser.getUserType() == UserType.OAM_USER || loginUser.getUserType() == UserType.MINI_USER) { //添加登录失败日志 coreService.insertOperationLog(Constants.FAIL, OperationLogEnum.SYSTEM_LOGIN, loginUser, errorMessage); diff --git a/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java b/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java index 364539a..2a6a3e7 100644 --- a/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java +++ b/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java @@ -90,7 +90,7 @@ public class MiniLoginStrategy implements LoginStrategy { private void changeJamboxUser(MiniUserLoginInfo loginInfo, Map credentials, SourceType sourceType) { //获取品牌表 Row brand = DbChain.table("cp_sys_brand") - .select("csb.id", "csb.is_open_sharing") + .select("csb.id", "csb.is_open_mall") .from("cp_sys_brand").as("csb") .leftJoin("cp_j_brand_extend").as("cjbe").on("cjbe.brand_id = csb.id") .and("cjbe.brand_cloud_id = ?", credentials.get("brandId")) @@ -98,7 +98,7 @@ public class MiniLoginStrategy implements LoginStrategy { if (brand == null) { throw new CpopAuthenticationException("用户登陆失败,果酱品牌暂未录入系统"); } - if (!brand.getBoolean("isOpenSharing")){ + if (!brand.getBoolean("isOpenMall")){ throw new CpopAuthenticationException("用户登陆失败,当前品牌暂未开通分账"); } //构建用户信息 diff --git a/Cpop-Generator/pom.xml b/Cpop-Generator/pom.xml index 2e67084..992113d 100644 --- a/Cpop-Generator/pom.xml +++ b/Cpop-Generator/pom.xml @@ -32,4 +32,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Jambox/Cpop-Jambox-Web/pom.xml b/Cpop-Jambox/Cpop-Jambox-Web/pom.xml index c631f71..7eb9a37 100644 --- a/Cpop-Jambox/Cpop-Jambox-Web/pom.xml +++ b/Cpop-Jambox/Cpop-Jambox-Web/pom.xml @@ -27,18 +27,11 @@ + Cpop-Oam-Web org.springframework.boot spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - diff --git a/Cpop-Jambox/pom.xml b/Cpop-Jambox/pom.xml index bb6d4e4..20628bc 100644 --- a/Cpop-Jambox/pom.xml +++ b/Cpop-Jambox/pom.xml @@ -25,4 +25,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Mall/Cpop-Mall-Web/pom.xml b/Cpop-Mall/Cpop-Mall-Web/pom.xml index 61ce281..b79800d 100644 --- a/Cpop-Mall/Cpop-Mall-Web/pom.xml +++ b/Cpop-Mall/Cpop-Mall-Web/pom.xml @@ -29,19 +29,11 @@ - Cpop-Mall-Web + Cpop-Oam-Web org.springframework.boot spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml index 0ee745f..2abd731 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml @@ -62,6 +62,10 @@ mybatis-flex: url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_test?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true username: root password: Customer0401 + cbc: + url: jdbc:mysql://192.168.3.10:3306/cbc_game_prod?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true + username: nft + password: nft # springdoc-openapi项目配置 knife4j: diff --git a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopCbcTests.java b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopCbcTests.java new file mode 100644 index 0000000..8888bc4 --- /dev/null +++ b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopCbcTests.java @@ -0,0 +1,151 @@ +package com.cpop.mall.web; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ContentLoopMerge; +import lombok.Data; +import org.springframework.boot.test.context.SpringBootTest; + +/** + * @author DB + * @createTime 2023/11/15 17:15 + * @description CBC相关测试类 + */ +@SpringBootTest +public class CpopCbcTests { + + private final String FILE_NAME = "C:/Users/Administrator/Desktop/常规赛1v1对战信息" + System.currentTimeMillis() + ".xlsx"; + + /** + * @descriptions 导出比赛结果 + * @author DB + * @date 2023/11/15 17:16 + * @return: void + */ + public void exportGameResult() { + //TODO:获取数据 + //EasyExcel.write(FILE_NAME, GameResult.class).sheet("常规赛1v1对战信息").doWrite(data()); + } + + /** + * 比赛结果 + */ + @Data + public class GameResult { + + /** + * 场次 + */ + @ContentLoopMerge(eachRow = 10) + @ExcelProperty("场次") + private String session; + + /** + * "类型", "常规/OneMore" + */ + @ExcelProperty({"类型", "常规/OneMore"}) + private String type; + + /** + * 舞种 + */ + @ExcelProperty("舞种") + private String danceType; + + /** + * 轮次 + */ + @ExcelProperty("轮次") + private String turn; + + /** + * "战队A", "战队" + */ + @ExcelProperty({"战队A", "战队"}) + private String teamA; + + /** + * "战队A", "舞者" + */ + @ExcelProperty({"战队A", "舞者"}) + private String userA; + + /** + * "战队B", "战队" + */ + @ExcelProperty({"战队B", "战队"}) + private String teamB; + + /** + * "战队B", "舞者" + */ + @ExcelProperty({"战队B", "舞者"}) + private String userB; + + /** + * 胜负 + */ + @ExcelProperty("胜负") + private String winUser; + + /** + * 主裁 + */ + @ExcelProperty({"主裁", "名称"}) + private String masterReferee; + + /** + * "主裁", "打分" + */ + @ExcelProperty({"主裁", "打分"}) + private String masterRefereeMark; + + /** + * "副裁一", "名称" + */ + @ExcelProperty({"副裁一", "名称"}) + private String slaveRefereeA; + + /** + * "副裁一", "打分" + */ + @ExcelProperty({"副裁一", "打分"}) + private String slaveRefereeAMark; + + /** + * "副裁二", "名称" + */ + @ExcelProperty({"副裁二", "名称"}) + private String slaveRefereeB; + + /** + * "副裁二", "打分" + */ + @ExcelProperty({"副裁二", "打分"}) + private String slaveRefereeBMark; + + /** + * "副裁三", "名称" + */ + @ExcelProperty({"副裁三", "名称"}) + private String slaveRefereeC; + + /** + * "副裁三", "打分" + */ + @ExcelProperty({"副裁三", "打分"}) + private String slaveRefereeCMark; + + /** + * "副裁四", "名称" + */ + @ExcelProperty({"副裁四", "名称"}) + private String slaveRefereeD; + + /** + * "副裁四", "打分" + */ + @ExcelProperty({"副裁四", "打分"}) + private String slaveRefereeDMark; + } +} diff --git a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java index 3dd5df1..1669f45 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java +++ b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java @@ -82,10 +82,10 @@ public class CpopWxPayTests { //ProfitSharing profitSharing = SpringUtils.getBean(ProfitSharingService.class).getById("77860920238751744"); //profitSharingReturnRequest.setOrderId(profitSharing.getOutProfitSharingId()); //profitSharingReturnRequest.setOutReturnNo(profitSharing.getId()); - profitSharingReturnRequest.setOrderId("30000600822023111456560002430"); - profitSharingReturnRequest.setOutReturnNo("1724352351424733184"); + profitSharingReturnRequest.setOrderId("4200002037202311160917055414"); + profitSharingReturnRequest.setOutReturnNo("1725040884229472256"); profitSharingReturnRequest.setDescription("分账退款"); - profitSharingReturnRequest.setSubMchId("1618925571"); + profitSharingReturnRequest.setSubMchId("1650816616"); profitSharingReturnRequest.setReturnMchid("1618884922"); //profitSharingReturnRequest.setAmount(profitSharing.getAmount()); profitSharingReturnRequest.setAmount(1L); diff --git a/Cpop-Mall/pom.xml b/Cpop-Mall/pom.xml index a79fb39..490f2b7 100644 --- a/Cpop-Mall/pom.xml +++ b/Cpop-Mall/pom.xml @@ -29,4 +29,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Mini/pom.xml b/Cpop-Mini/pom.xml index 7ce92eb..c0208a4 100644 --- a/Cpop-Mini/pom.xml +++ b/Cpop-Mini/pom.xml @@ -21,4 +21,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Oam/Cpop-Oam-Web/pom.xml b/Cpop-Oam/Cpop-Oam-Web/pom.xml index f6e07cf..7b7e2e9 100644 --- a/Cpop-Oam/Cpop-Oam-Web/pom.xml +++ b/Cpop-Oam/Cpop-Oam-Web/pom.xml @@ -32,16 +32,7 @@ org.springframework.boot spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml index 6280a8a..d1be89a 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml @@ -46,7 +46,7 @@ spring: database: rock-blade server: - port: 9420 + port: 8420 servlet: context-path: /Cpop-Oam diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml index d09bfc0..3f8e27a 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml @@ -130,16 +130,17 @@ logging: wx: #企业微信 cp: - corpId: 111 + corpId: ww9b83a363662f219f appConfigs: # (某一具体应用的AgentId,如果是要配置通讯录同步的应用,可以随便配置一个) - - agentId: 1000001 + - agentId: 1000024 #(该应用的Secret) - secret: 1111 + secret: VJFNBvZgK6oNEKpfrb5B9KQcm7yB0CacpWS2BfTln5Q # (应用中的 “接受消息” 部分的 “接收消息服务器配置” 里的Token值) - token: 111 + token: 1i2dz2yxD0Np2xvMYTD # (应用中的 “接受消息” 部分的 “接收消息服务器配置” 里的EncodingAESKey值) - aesKey: 111 + aesKey: DLSzfHVUZN3O9WhtL07RBXUoooqC2bjEJYwep8k8ojt + #开放平台 open: openAppid: wx6e07ba6606e912a5 diff --git a/Cpop-Oam/pom.xml b/Cpop-Oam/pom.xml index f798430..9833c32 100644 --- a/Cpop-Oam/pom.xml +++ b/Cpop-Oam/pom.xml @@ -43,4 +43,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/DeptController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/DeptController.java index 2aeffa7..027afcd 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/DeptController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/DeptController.java @@ -53,7 +53,6 @@ public class DeptController { * @Date: 2023/5/9 20:47 */ @PreAuthorize("@aps.hasPermission('system:dept:insert')") - @OperationLog(operationLogEnumType = OperationLogEnum.INSERT_OAM_DEPT) @ApiOperation("新增部门") @PostMapping("/insertDept") public R insertDept(@Validated @RequestBody DeptBo bo) { @@ -69,7 +68,6 @@ public class DeptController { * @Date: 2023/5/9 20:47 */ @PreAuthorize("@aps.hasPermission('system:dept:update')") - @OperationLog(operationLogEnumType = OperationLogEnum.UPDATE_OAM_DEPT) @ApiOperation("修改部门") @PutMapping("/updateDept") public R updateDept(@Validated @RequestBody DeptBo bo) { @@ -84,7 +82,6 @@ public class DeptController { * @Date: 2023/5/9 20:48 */ @PreAuthorize("@aps.hasPermission('system:dept:remove')") - @OperationLog(operationLogEnumType = OperationLogEnum.REMOVE_OAM_DEPT) @ApiOperation("删除部门") @DeleteMapping("/removeDept/{id}") public R removeDept(@PathVariable String id) { @@ -92,4 +89,19 @@ public class DeptController { return R.ok(); } + /** + * @return R + * @Description: 同步企业微信部门 + * @Author DB + * @Date: 2023/5/9 20:47 + */ + @Deprecated + @PreAuthorize("@aps.hasPermission('*:*:*')") + @ApiOperation("同步企业微信部门") + @PostMapping("/syncWxCpDept") + public R syncWxCpDept() { + deptService.syncWxCpDept(); + return R.ok(); + } + } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java index 078458c..1b31d63 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java @@ -192,5 +192,18 @@ public class StaffController { return R.ok(); } - + /** + * @return R + * @Description: 同步企业微信员工 + * @Author DB + * @Date: 2023/5/9 20:47 + */ + @Deprecated + @PreAuthorize("@aps.hasPermission('*:*:*')") + @ApiOperation("同步企业微信员工") + @PostMapping("/syncWxCpStaff") + public R syncWxCpStaff() { + staffService.syncWxCpStaff(); + return R.ok(); + } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DeptService.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DeptService.java index 036c4ac..6e0e253 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DeptService.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DeptService.java @@ -47,4 +47,13 @@ public interface DeptService extends IService { * @Date: 2023/5/9 20:48 */ void removeDept(String id); + + /** + * @descriptions 同步企业微信部门 + * @author DB + * @date 2023/11/15 16:56 + * @return: void + */ + void syncWxCpDept(); + } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/StaffService.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/StaffService.java index 1f44f86..e43168a 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/StaffService.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/StaffService.java @@ -119,4 +119,12 @@ public interface StaffService extends IService { * @return: void */ void createWxCpUser(WxCpXmlMessage wxMessage, WxCpService cpService); + + /** + * @descriptions 同步企业微信员工 + * @author DB + * @date 2023/11/16 17:03 + * @return: void + */ + void syncWxCpStaff(); } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DeptServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DeptServiceImpl.java index cb3307d..7fb4e2a 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DeptServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DeptServiceImpl.java @@ -12,11 +12,18 @@ import com.cpop.oam.business.mapper.DeptMapper; import com.cpop.oam.business.service.DeptService; import com.cpop.oam.business.service.StaffMidDeptService; import com.cpop.oam.business.vo.DeptVo; +import com.cpop.oam.framework.config.wxCp.WxCpConfiguration; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.row.RowUtil; import com.mybatisflex.spring.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpDepart; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -44,7 +51,7 @@ public class DeptServiceImpl extends ServiceImpl implements De return buildDeptTree(this.listAs(QueryWrapper.create() .and(DEPT.NAME.like(bo.getName())) .and(DEPT.STATUS.eq(bo.getStatus())) - .orderBy(DEPT.ORDER_NO.asc()), DeptVo.class)); + .orderBy(DEPT.ORDER_NO.desc()), DeptVo.class)); } /** @@ -204,4 +211,64 @@ public class DeptServiceImpl extends ServiceImpl implements De .collect(Collectors.toList())); }); } + + /** + * @descriptions 同步企业微信部门 + * @author DB + * @date 2023/11/15 16:56 + * @return: void + */ + @Override + public void syncWxCpDept() { + //企业微信互通应用 + WxCpService cpService = WxCpConfiguration.getCpService(1000024); + try { + //获取所有数据 + List list = cpService.getDepartmentService().list(null); + //过滤出最顶级部门 + WxCpDepart wxCpDepart = list.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList()).get(0); + //先存 + Dept dept = new Dept(); + dept.setWxCpId(wxCpDepart.getId()).setWxCpParentId(wxCpDepart.getParentId()).setOrderNo(wxCpDepart.getOrder().intValue()).setName(wxCpDepart.getName()); + if (wxCpDepart.getDepartmentLeader().length > 0) { + dept.setLeader(wxCpDepart.getDepartmentLeader()[0]); + } + this.save(dept); + //递归保存余下部门 + List filterWxDeptList = list.stream().filter(item -> item.getParentId() != 0).collect(Collectors.toList()); + recursionSonDept(filterWxDeptList, dept); + } catch (WxErrorException e) { + throw new ServiceException(e.getMessage()); + } + } + + /** + * @descriptions 递归保存子部门 + * @author DB + * @date 2023/11/16 16:06 + * @param wxCpDepartList 部门id + * @param parentDept 父部门 + * @return: void + */ + private void recursionSonDept(List wxCpDepartList, Dept parentDept) { + List deptList = new ArrayList(); + Iterator iterator = wxCpDepartList.iterator(); + while (iterator.hasNext()) { + WxCpDepart next = iterator.next(); + if (next.getParentId().equals(parentDept.getWxCpId())) { + //先存 + Dept dept = new Dept(); + dept.setWxCpId(next.getId()).setWxCpParentId(next.getParentId()).setOrderNo(next.getOrder().intValue()).setParentId(parentDept.getId()).setName(next.getName()); + deptList.add(dept); + iterator.remove(); + } + } + //当子部门不为空的时候保存部门 + if (!deptList.isEmpty()) { + this.saveBatch(deptList); + deptList.forEach(item -> { + recursionSonDept(wxCpDepartList, item); + }); + } + } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java index d046775..a7acc3b 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java @@ -54,7 +54,7 @@ public class OamMallServiceImpl implements OamMallService { PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); QueryWrapper queryWrapper = QueryWrapper.create(); if (StringUtils.isNotBlank(name)) { - queryWrapper.and("name like ?", "%" + name + "%"); + queryWrapper.and("name like ?", name + "%"); } if (StringUtils.isNotBlank(brandIds)) { queryWrapper.in("cp_mall_role_brand.brand_id", Arrays.asList(brandIds.split(","))); diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java index a738e28..c130c27 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java @@ -1,5 +1,6 @@ package com.cpop.oam.business.service.impl; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cpop.common.constant.Constants; import com.cpop.common.utils.StringUtils; @@ -10,6 +11,7 @@ import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo; import com.cpop.core.base.enums.UserType; import com.cpop.core.base.exception.ServiceException; import com.cpop.core.base.table.SysUser; +import com.cpop.core.mapper.CoreMapper; import com.cpop.core.service.CoreService; import com.cpop.core.service.RedisService; import com.cpop.core.utils.*; @@ -19,13 +21,18 @@ import com.cpop.oam.business.bo.ModifyUserPasswordBo; import com.cpop.oam.business.bo.StaffBo; import com.cpop.oam.business.bo.StaffPageBo; import com.cpop.oam.business.bo.SysUserLogBo; +import com.cpop.oam.business.entity.Dept; import com.cpop.oam.business.entity.Staff; +import com.cpop.oam.business.entity.StaffMidDept; import com.cpop.oam.business.mapper.StaffMapper; +import com.cpop.oam.business.service.DeptService; +import com.cpop.oam.business.service.StaffMidDeptService; import com.cpop.oam.business.service.StaffService; import com.cpop.oam.business.vo.StaffInfoVo; import com.cpop.oam.business.vo.StaffPageVo; import com.cpop.oam.business.vo.StaffVo; import com.cpop.oam.business.vo.SysOperationLogVo; +import com.cpop.oam.framework.config.wxCp.WxCpConfiguration; import com.cpop.oam.framework.utils.OamUtils; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; @@ -33,7 +40,10 @@ import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.DbChain; import com.mybatisflex.core.row.Row; import com.mybatisflex.spring.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage; import org.springframework.security.crypto.bcrypt.BCrypt; import org.springframework.stereotype.Service; @@ -41,10 +51,15 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static com.cpop.core.base.table.table.SysOperationLogTableDef.SYS_OPERATION_LOG; import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER; +import static com.cpop.oam.business.entity.table.DeptTableDef.DEPT; import static com.cpop.oam.business.entity.table.StaffMidDeptTableDef.STAFF_MID_DEPT; import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF; import static com.cpop.system.business.entity.table.RoleTableDef.ROLE; @@ -57,6 +72,7 @@ import static com.mybatisflex.core.query.QueryMethods.groupConcat; * @author DB * @since 2023-09-07 */ +@Slf4j @Service("oamStaffService") public class StaffServiceImpl extends ServiceImpl implements StaffService { @@ -362,4 +378,58 @@ public class StaffServiceImpl extends ServiceImpl implements //TODO:先改造部门 //insertStaff(wxCpUserToStaff(wxMessage, cpService)); } + + /** + * @descriptions 同步企业微信员工 + * @author DB + * @date 2023/11/16 17:04 + * @return: void + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void syncWxCpStaff() { + WxCpService cpService = WxCpConfiguration.getCpService(1000024); + try { + List wxCpUsers = cpService.getUserService().listByDepartment(1L, true, 0); + if (!wxCpUsers.isEmpty()){ + log.info("部门用户信息:{}", JSONArray.toJSONString(wxCpUsers)); + //批量插入用户 + Map userWxCpUserMap = new HashMap<>(); + wxCpUsers.forEach(item -> { + SysUser sysUser = new SysUser(); + sysUser.setId(IdUtils.fastSimpleUUID()) + .setStatus(item.getStatus() == 1) + .setUserType(UserType.OAM_USER.toString()) + .setCreateUserId("1"); + sysUser.setUpdateUserId("1"); + userWxCpUserMap.put(sysUser, item); + }); + Db.executeBatch(userWxCpUserMap.keySet(), CoreMapper.class, CoreMapper::insertSysUser); + List staffList = new ArrayList<>(); + //批量创建用户 + userWxCpUserMap.forEach((key, value) -> { + Staff staff = new Staff(); + staff.setName(value.getName()).setUserId(key.getId()).setWxCpUserId(value.getUserId()); + staffList.add(staff); + }); + this.saveBatch(staffList); + //获取所有部门信息 + List deptList = SpringUtils.getBean(DeptService.class).queryChain().where(DEPT.WX_CP_ID.isNotNull()).list(); + //部门id映射 + Map deptMap = deptList.stream().collect(Collectors.toMap(Dept::getWxCpId, Dept::getId)); + List staffMidDeptList = new ArrayList<>(); + //批量创建用户 + userWxCpUserMap.forEach((key, value) -> { + for (Long wxDeptId : value.getDepartIds()) { + StaffMidDept staffMidDept = new StaffMidDept(); + staffMidDept.setStaffId(key.getId()).setDeptId(deptMap.get(wxDeptId)); + staffMidDeptList.add(staffMidDept); + } + }); + SpringUtils.getBean(StaffMidDeptService.class).saveBatch(staffMidDeptList); + } + } catch (WxErrorException e) { + throw new ServiceException(e.getMessage()); + } + } } diff --git a/Cpop-System/pom.xml b/Cpop-System/pom.xml index ac1b4f4..68e70da 100644 --- a/Cpop-System/pom.xml +++ b/Cpop-System/pom.xml @@ -21,4 +21,15 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + diff --git a/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java b/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java index 947e39e..035ec04 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java @@ -66,10 +66,10 @@ public class BrandPageVo implements Serializable { private String backgroundUrl; /** - * 是否开通微信分账 + * 是否开通商城 */ - @ApiModelProperty("是否开通微信分账") - private Boolean isOpenSharing; + @ApiModelProperty("是否开通商城") + private Boolean isOpenMall; /** * 创建时间 diff --git a/pom.xml b/pom.xml index 0e64c3c..b96cd6e 100644 --- a/pom.xml +++ b/pom.xml @@ -229,4 +229,29 @@ true + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + repackage + + + + + +