From ca3d8924a0c9ca27557c24c915686d5adb8d46d4 Mon Sep 17 00:00:00 2001 From: Echo <4759156@qq.com> Date: Fri, 23 Feb 2024 18:47:49 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8Fopenid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/admin/auth/AuthController.java | 7 +++++++ .../module/system/service/auth/AdminAuthService.java | 9 +++++++++ .../module/system/service/auth/AdminAuthServiceImpl.java | 8 +++++++- .../system/service/social/SocialClientService.java | 8 ++++++++ .../system/service/social/SocialClientServiceImpl.java | 8 ++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java index 01132f10..29e06743 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.controller.admin.auth; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; @@ -170,4 +171,10 @@ public class AuthController { return success(authService.miniAppQuickLogin(reqVO)) ; } + @PostMapping("/miniapp_code2Session") + @PermitAll + @Operation(summary = "微信小程序openid", description = "获取微信小程序的openid" ) + public CommonResult miniAppCode2Session(@RequestBody AuthSocialLoginReqVO reqVO) { + return success(authService.miniAppCode2Session(reqVO)) ; + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java index b95e83c0..041f208b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.system.service.auth; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; @@ -77,4 +79,11 @@ public interface AdminAuthService { * @return 登陆结果 */ AuthLoginRespVO miniAppQuickLogin(AuthSocialLoginReqVO reqVO) ; + + /** + * 获取微信 获取微信小程序的用户唯一标识 openId + * @param reqVO jscode + * @return 用户唯一标识 + */ + WxMaJscode2SessionResult miniAppCode2Session(AuthSocialLoginReqVO reqVO) ; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index 5a61df73..e2a038ee 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.system.service.auth; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; @@ -256,7 +258,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { //获取微信小程序授权手机号 WxMaPhoneNumberInfo wxMaPhoneNumberInfo = socialClientService.getWxMaPhoneNumberInfo(2,reqVO.getCode()) ; String phoneNumber = wxMaPhoneNumberInfo.getPhoneNumber() ; //授权手机号 - phoneNumber = "18611845857" ; String appId = wxMaPhoneNumberInfo.getWatermark().getAppid() ; //小程序的appId final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME; @@ -285,4 +286,9 @@ public class AdminAuthServiceImpl implements AdminAuthService { return AuthConvert.INSTANCE.convert(accessTokenDO); // return createTokenAfterLoginSuccess(user.getId(), phoneNumber, LoginLogTypeEnum.LOGIN_SOCIAL); } + + @Override + public WxMaJscode2SessionResult miniAppCode2Session(AuthSocialLoginReqVO reqVO) { + return socialClientService.getWxMaJscode2SessionResult(reqVO.getCode()) ; + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java index ea64e049..513e2546 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.service.social; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; @@ -61,6 +62,13 @@ public interface SocialClientService { */ WxMaPhoneNumberInfo getWxMaPhoneNumberInfo(Integer userType, String phoneCode); + /** + * 获取微信小程序的用户唯一标识 openId + * @param jsCode 登录时获取的 code,可通过wx.login获取 + * @return + */ + WxMaJscode2SessionResult getWxMaJscode2SessionResult(String jsCode) ; + // =================== 客户端管理 =================== /** diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java index 8ee90920..36df66ad 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.social; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import cn.hutool.core.bean.BeanUtil; @@ -336,4 +337,11 @@ public class SocialClientServiceImpl implements SocialClientService { return socialClientMapper.selectPage(pageReqVO); } + @SneakyThrows + @Override + public WxMaJscode2SessionResult getWxMaJscode2SessionResult(String jsCode) { + WxMaService wxMaService = getWxMaService(2) ; + WxMaJscode2SessionResult result = wxMaService.jsCode2SessionInfo(jsCode) ; + return result ; + } } From 960d7d4901bb70f45af29f540aa4388602768426 Mon Sep 17 00:00:00 2001 From: Echo <4759156@qq.com> Date: Sat, 24 Feb 2024 16:06:53 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8Fopenid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/auth/vo/AuthLoginReqVO.java | 3 +++ .../admin/auth/vo/AuthSocialLoginReqVO.java | 4 ++++ .../system/dal/dataobject/user/AdminUserDO.java | 4 ++++ .../system/dal/mysql/user/AdminUserMapper.java | 2 ++ .../system/service/auth/AdminAuthServiceImpl.java | 12 +++++++++++- .../system/service/user/AdminUserService.java | 14 ++++++++++++++ .../system/service/user/AdminUserServiceImpl.java | 14 ++++++++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java index 6fa2bc2e..f2018fe3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java @@ -51,6 +51,9 @@ public class AuthLoginReqVO { @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") private String socialState; + @Schema(description = "openId", requiredMode = Schema.RequiredMode.REQUIRED, example = "o3bwX6Yw1bvbMAV-jUNjHrbrJu0I") + private String openId; + /** * 开启验证码的 Group */ diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java index 1bbb67ed..d3b65548 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java @@ -31,4 +31,8 @@ public class AuthSocialLoginReqVO { @NotEmpty(message = "state 不能为空") private String state; + @Schema(description = "openId", requiredMode = Schema.RequiredMode.REQUIRED, example = "o3bwX6Yw1bvbMAV-jUNjHrbrJu0I") + @NotEmpty(message = "openId 不能为空") + private String openId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java index 1e239371..490d66d2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java @@ -93,4 +93,8 @@ public class AdminUserDO extends TenantBaseDO { */ private LocalDateTime loginDate; + /** + * 微信小程序openId + */ + private String openId ; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 75bf3fa4..0d713279 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -13,6 +13,8 @@ import java.util.List; @Mapper public interface AdminUserMapper extends BaseMapperX { + default AdminUserDO sgetByOpenId(String openId) { return selectOne(AdminUserDO::getOpenId, openId); } + default AdminUserDO selectByUsername(String username) { return selectOne(AdminUserDO::getUsername, username); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index e2a038ee..e3dc7e5c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -109,6 +109,12 @@ public class AdminAuthServiceImpl implements AdminAuthService { socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); } + + if (reqVO.getOpenId() != null) { + //绑定用户openId + userService.updateUserOpenId(user.getId(),reqVO.getOpenId()); + } + // 创建 Token 令牌,记录登录日志 return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); } @@ -258,9 +264,10 @@ public class AdminAuthServiceImpl implements AdminAuthService { //获取微信小程序授权手机号 WxMaPhoneNumberInfo wxMaPhoneNumberInfo = socialClientService.getWxMaPhoneNumberInfo(2,reqVO.getCode()) ; String phoneNumber = wxMaPhoneNumberInfo.getPhoneNumber() ; //授权手机号 + phoneNumber = "18611845857" ; String appId = wxMaPhoneNumberInfo.getWatermark().getAppid() ; //小程序的appId - final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME; + final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_MOBILE; //因为账号就是保存用户的手机号, 所以userName就是手机号 // 校验账号是否存在 @@ -275,6 +282,9 @@ public class AdminAuthServiceImpl implements AdminAuthService { throw exception(AUTH_LOGIN_USER_DISABLED); } + //绑定用户openId + userService.updateUserOpenId(user.getId(),reqVO.getOpenId()); + /** 创建 Token 令牌,记录登录日志 */ Long userId = user.getId() ; // 插入登陆日志 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java index f46b32d0..3939d761 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java @@ -33,6 +33,12 @@ public interface AdminUserService { */ Long createUser(@Valid UserSaveReqVO createReqVO); + /** + * 绑定用户微信小程序openId + * @param openId + */ + void updateUserOpenId(Long id, String openId); + /** * 修改用户 * @@ -111,6 +117,14 @@ public interface AdminUserService { */ AdminUserDO getUserByMobile(String mobile); + /** + * 根据opneId获取用户 + * + * @param openId 微信小程序用户唯一id + * @return 用户对象信息 + */ + AdminUserDO getUserByOpenId(String openId) ; + /** * 获得用户分页列表 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 51fa7158..cde360d0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -77,6 +77,20 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private FileApi fileApi; + @Override + @Transactional(rollbackFor = Exception.class) + public void updateUserOpenId(Long id,String openId) { + userMapper.updateById(new AdminUserDO().setId(id).setOpenId(openId)); + } + + @Override + public AdminUserDO getUserByOpenId(String openId) { + if (openId == null) { + return null ; + } + return userMapper.sgetByOpenId(openId); + } + @Override @Transactional(rollbackFor = Exception.class) public Long createUser(UserSaveReqVO createReqVO) { From 261f5654698b32d535e06c03108ad8fcdf788d79 Mon Sep 17 00:00:00 2001 From: Echo <4759156@qq.com> Date: Sat, 24 Feb 2024 16:17:17 +0800 Subject: [PATCH 3/5] =?UTF-8?q?yudao.web.admin-ui.url:=20http://sys.znkjfw?= =?UTF-8?q?.com=20=E5=8F=98=E6=9B=B4=E6=88=90=E4=B8=AD=E9=BC=90=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-module-bpm-biz/src/main/resources/application.yaml | 2 +- .../yudao-module-infra-biz/src/main/resources/application.yaml | 2 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../yudao-module-mp-biz/src/main/resources/application.yaml | 2 +- .../yudao-module-pay-biz/src/main/resources/application.yaml | 2 +- .../yudao-module-report-biz/src/main/resources/application.yaml | 2 +- .../yudao-module-system-biz/src/main/resources/application.yaml | 2 +- .../src/main/resources/application.yaml | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml index f0f5bd88..d99cc3e0 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml @@ -102,7 +102,7 @@ yudao: base-package: cn.iocoder.yudao.module.bpm web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 swagger: title: 管理后台 description: 提供管理员管理的所有功能 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml index dea79c8b..5c8f6bf4 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml @@ -115,7 +115,7 @@ yudao: base-package: cn.iocoder.yudao.module.infra web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 websocket: enable: true # websocket的开关 path: /infra/ws # 路径 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml index da8ae23c..b2ff8239 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml @@ -102,5 +102,5 @@ yudao: enable: false web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml index d935b65d..9cc962db 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml @@ -121,7 +121,7 @@ yudao: tag: ${HOSTNAME} web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: mock-enable: true xss: diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml index da8ae23c..b2ff8239 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml @@ -102,5 +102,5 @@ yudao: enable: false web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml index d935b65d..9cc962db 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml @@ -121,7 +121,7 @@ yudao: tag: ${HOSTNAME} web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: mock-enable: true xss: diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml index da8ae23c..b2ff8239 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml @@ -102,5 +102,5 @@ yudao: enable: false web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml index d935b65d..9cc962db 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml @@ -121,7 +121,7 @@ yudao: tag: ${HOSTNAME} web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: mock-enable: true xss: diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml index 5e1c117e..51572d3b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml @@ -102,6 +102,6 @@ yudao: enable: false web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 demo: true # 开启演示模式 tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml index 4dde1611..9838e46a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml @@ -121,7 +121,7 @@ yudao: tag: ${HOSTNAME} web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: mock-enable: true xss: diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml index da8ae23c..b2ff8239 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml @@ -102,5 +102,5 @@ yudao: enable: false web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 demo: true # 开启演示模式 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml index d935b65d..9cc962db 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml +++ b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml @@ -121,7 +121,7 @@ yudao: tag: ${HOSTNAME} web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: mock-enable: true xss: diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml index d66716b3..aa0c58cc 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml @@ -92,7 +92,7 @@ yudao: base-package: cn.iocoder.yudao.module.mp web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 security: permit-all_urls: - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml index 599e71d1..3e4fa019 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml @@ -89,7 +89,7 @@ yudao: base-package: cn.iocoder.yudao.module.pay web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 swagger: title: 管理后台 description: 提供管理员管理的所有功能 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml index dbc2279a..5de49ca8 100644 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml +++ b/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml @@ -89,7 +89,7 @@ yudao: base-package: cn.iocoder.yudao.module.report web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 swagger: title: 管理后台 description: 提供管理员管理的所有功能 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml b/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml index 8d0c7910..e0f19b7f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml @@ -134,7 +134,7 @@ yudao: base-package: cn.iocoder.yudao.module.system web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 swagger: title: 管理后台 description: 提供管理员管理的所有功能 diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/application.yaml b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/application.yaml index 8d66f27d..1d256e8a 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/application.yaml +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/application.yaml @@ -84,7 +84,7 @@ yudao: base-package: cn.iocoder.yudao.module.smartfactory web: admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 + url: http://sys.znkjfw.com # Admin 管理后台 UI 的地址 swagger: title: 管理后台 description: 提供管理员管理的所有功能 From 6aeb2f87197040214f250c54f871dd373da95b07 Mon Sep 17 00:00:00 2001 From: Echo <4759156@qq.com> Date: Sun, 25 Feb 2024 16:24:47 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB-=E6=B7=BB=E5=8A=A0Date=E6=97=A5=E6=9C=9F=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=88=90=E6=8C=87=E5=AE=9A=E6=A0=BC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/util/date/DateUtils.java | 13 ++++++++++ .../subscribe/SubscribeMessageSendApi.java | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApi.java diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java index a473518c..2a473ad3 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.common.util.date; import cn.hutool.core.date.LocalDateTimeUtil; +import java.text.SimpleDateFormat; import java.time.*; import java.util.Calendar; import java.util.Date; @@ -29,6 +30,18 @@ public class DateUtils { public static final String FORMAT_HOUR_MINUTE_SECOND = "HH:mm:ss"; + /** + * 根据传入的时间格式,将Date对象,转换成对应的时间格式 + * @param date + * @param format + * @return + */ + public static String dateFormat(Date date, String format) { + SimpleDateFormat formatter = new SimpleDateFormat(format); + String formattedDate = formatter.format(date); + return formattedDate ; + } + /** * 将 LocalDateTime 转换成 Date * diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApi.java new file mode 100644 index 00000000..dbb92056 --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApi.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.system.api.subscribe; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.system.api.subscribe.dto.SubscribeMessageReqDTO; +import cn.iocoder.yudao.module.system.enums.ApiConstants; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = +@Tag(name = "RPC 服务 - 微信小程序订阅消息发送") +public interface SubscribeMessageSendApi { + + String PREFIX = ApiConstants.PREFIX + "/subscribe/send"; + + @PostMapping(PREFIX + "/send-approval-result-notification") + @Operation(summary = "发送审批结果通知") + CommonResult sendApprovalResultNotification(SubscribeMessageReqDTO reqDTO); + + @PostMapping(PREFIX + "/send-process-todo-reminder") + @Operation(summary = "发送OA流程待办提醒") + CommonResult sendProcessToDoReminder(SubscribeMessageReqDTO reqDTO); +} From e78e8531bc401a4d37a1a28bdf8732e9d9bbb4df Mon Sep 17 00:00:00 2001 From: Echo <4759156@qq.com> Date: Sun, 25 Feb 2024 17:14:41 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/web/config/WebProperties.java | 2 + yudao-module-bpm/yudao-module-bpm-biz/pom.xml | 6 ++ .../convert/message/BpmMessageConvert.java | 97 +++++++++++++++++++ .../rpc/config/RpcConfiguration.java | 5 +- .../message/BpmMessageServiceImpl.java | 58 ++++++++++- .../system/api/subscribe/dto/MsgData.java | 24 +++++ .../subscribe/dto/SubscribeMessageReqDTO.java | 37 +++++++ .../system/api/user/dto/AdminUserRespDTO.java | 2 + .../SubscribeMessageSendApiImpl.java | 59 +++++++++++ 9 files changed, 287 insertions(+), 3 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/MsgData.java create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/SubscribeMessageReqDTO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApiImpl.java diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java index 03f4d70b..eae07e71 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; @@ -14,6 +15,7 @@ import javax.validation.constraints.NotNull; @ConfigurationProperties(prefix = "yudao.web") @Validated @Data +@Component public class WebProperties { @NotNull(message = "APP API 不能为空") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml index 0626d000..7578e4ef 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml +++ b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml @@ -114,6 +114,12 @@ cn.iocoder.cloud yudao-spring-boot-starter-flowable + + + com.github.binarywang + wx-java-miniapp-spring-boot-starter + + diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java index 3cba2395..e18db91e 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java @@ -1,11 +1,17 @@ package cn.iocoder.yudao.module.bpm.convert.message; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.binarywang.wx.miniapp.constant.WxMaConstants; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO; +import org.flowable.bpmn.model.UserTask; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import java.util.Date; +import java.util.List; import java.util.Map; @Mapper @@ -23,4 +29,95 @@ public interface BpmMessageConvert { @Mapping(source = "templateCode", target = "templateCode") @Mapping(source = "templateParams", target = "templateParams") NotifySendSingleToUserReqDTO convert1(Long userId, String templateCode, Map templateParams); + + + /** + * + * @param openId 微信小程序唯一id + * @param processInstanceName 流程名称 + * @param result 审批结果 + * @param reason 审批原因 + * @param miniProgramState 小程序的状态 + * @return + */ + default WxMaSubscribeMessage convertApprovalResultNotification(String openId, String processInstanceName, String time, String result, String reason, String miniProgramState) { + WxMaSubscribeMessage message = new WxMaSubscribeMessage() ; + message.setToUser(openId) ; + message.setTemplateId("OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk") ; + //审批类型 + WxMaSubscribeMessage.MsgData processType = new WxMaSubscribeMessage.MsgData(); + processType.setName("thing1") ; + processType.setValue(processInstanceName) ; + message.addData(processType); + + //发起时间 + WxMaSubscribeMessage.MsgData createTime = new WxMaSubscribeMessage.MsgData(); + createTime.setName("time2") ; + createTime.setValue(time) ; + message.addData(createTime); + + //审批时间 + WxMaSubscribeMessage.MsgData approvalTime = new WxMaSubscribeMessage.MsgData(); + approvalTime.setName("time7") ; + approvalTime.setValue(DateUtils.dateFormat(new Date(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)) ; + message.addData(approvalTime); + + //审批结果 + WxMaSubscribeMessage.MsgData approvalResult = new WxMaSubscribeMessage.MsgData(); + approvalResult.setName("phrase3") ; + approvalResult.setValue(result) ; + message.addData(approvalResult); + + if(reason != null ) { + WxMaSubscribeMessage.MsgData approvalReason = new WxMaSubscribeMessage.MsgData(); + approvalReason.setName("thing12") ; + approvalReason.setValue(reason) ; + message.addData(approvalReason); + } + + message.setMiniprogramState(miniProgramState) ; + return message; + } + + /** + * + * @param openId 微信小程序唯一id + * @param processInstanceName 流程名称 + * @param startUserNickname 申请人 + * @param time 申请时间 + * @param schedule 流程进度 + * @param miniProgramState 小程序的状态 + * @return + */ + default WxMaSubscribeMessage convertProcessToDoReminder(String openId, String processInstanceName,String startUserNickname, String time, String schedule, String miniProgramState) { + WxMaSubscribeMessage message = new WxMaSubscribeMessage() ; + message.setToUser(openId) ; + message.setTemplateId("3cP4btlFSSiZk65qVewN_WoT_bh0OfUkYzzTsADOrR4") ; + //待办标题 + WxMaSubscribeMessage.MsgData processType = new WxMaSubscribeMessage.MsgData(); + processType.setName("thing1") ; + processType.setValue("您收到了一条新的待办任务:"+processInstanceName) ; + message.addData(processType); + + //申请人 + WxMaSubscribeMessage.MsgData applicant = new WxMaSubscribeMessage.MsgData(); + applicant.setName("thing4") ; + applicant.setValue(startUserNickname) ; + message.addData(applicant); + + //申请时间 + WxMaSubscribeMessage.MsgData createTime = new WxMaSubscribeMessage.MsgData(); + createTime.setName("time5") ; + createTime.setValue(time) ; + message.addData(createTime); + + //当前进度 + WxMaSubscribeMessage.MsgData currentSchedule = new WxMaSubscribeMessage.MsgData(); + currentSchedule.setName("thing6") ; + currentSchedule.setValue(schedule) ; + message.addData(currentSchedule); + + message.setMiniprogramState(miniProgramState) ; + return message; + } } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java index 8cad627e..1166db35 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java @@ -7,11 +7,14 @@ import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; +import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {FileApi.class,RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class}) +@EnableFeignClients(clients = {FileApi.class,RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class, +// SubscribeMessageSendApi.class +}) public class RpcConfiguration { } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java index 1e72cb54..a5680750 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.module.bpm.service.message; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.binarywang.wx.miniapp.constant.WxMaConstants; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; @@ -11,13 +14,15 @@ import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCre import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; +import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * BPM 消息 Service 实现类 @@ -35,11 +40,15 @@ public class BpmMessageServiceImpl implements BpmMessageService { @Resource private NotifyMessageSendApi notifyMessageSendApi; + @Resource + private SubscribeMessageSendApi subscribeMessageSendApi ; + @Resource private WebProperties webProperties; @Override public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { + //审批通过 Map templateParams = new HashMap<>(); templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); @@ -47,10 +56,23 @@ public class BpmMessageServiceImpl implements BpmMessageService { // BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(reqDTO.getStartUserId(), BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); + + //发送审批结果通知 + String openId = getUserOpenId(reqDTO.getStartUserId()) ; + if(openId != null ) { +// subscribeMessageSendApi.sendApprovalResultNotification( +// BpmMessageConvert.INSTANCE.convertApprovalResultNotification( +// openId,reqDTO.getProcessInstanceName(), "","通过", null, +// /** +// * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 +// */ +// WxMaConstants.MiniProgramState.DEVELOPER) ) ; + } } @Override public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { + //审批不通过 Map templateParams = new HashMap<>(); templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); templateParams.put("reason", reqDTO.getReason()); @@ -59,10 +81,24 @@ public class BpmMessageServiceImpl implements BpmMessageService { // BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1( reqDTO.getStartUserId(), BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); + + //发送审批结果通知 + String openId = getUserOpenId(reqDTO.getStartUserId()) ; + if(openId != null ) { +// subscribeMessageSendApi.sendApprovalResultNotification( +// BpmMessageConvert.INSTANCE.convertApprovalResultNotification( +// openId,reqDTO.getProcessInstanceName(),"","不通过", reqDTO.getReason(), +// /** +// * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 +// */ +// WxMaConstants.MiniProgramState.DEVELOPER) ) ; + } + } @Override public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { + //任务分配 Long loginUserId = SecurityFrameworkUtils.getLoginUserId() ; Long startUserId = reqDTO.getStartUserId(); //如果发起人和接受人是同一个人,那么不发送站内信,否则就发送 @@ -76,6 +112,17 @@ public class BpmMessageServiceImpl implements BpmMessageService { // BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1( reqDTO.getAssigneeUserId(), BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); + + //发送OA流程待办提醒 + String openId = getUserOpenId(reqDTO.getStartUserId()) ; + if(openId != null ) { + +// subscribeMessageSendApi.sendProcessToDoReminder( BpmMessageConvert.INSTANCE.convertProcessToDoReminder( +// openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(),"","", +// WxMaConstants.MiniProgramState.DEVELOPER ) ) ; + + } + } } @@ -84,4 +131,11 @@ public class BpmMessageServiceImpl implements BpmMessageService { return webProperties.getAdminUi().getUrl() + "/process-instance/detail?id=" + taskId; } + @Resource + private AdminUserApi adminUserApi ; + private String getUserOpenId(Long userId) { + AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(userId).getData(); + String openId = adminUserRespDTO.getOpenId() ; + return openId ; + } } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/MsgData.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/MsgData.java new file mode 100644 index 00000000..b1677bb3 --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/MsgData.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.system.api.subscribe.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 功能描述 + * + * @author: yj + * @date: 2024年02月25日 15:58 + */ +@Data +public class MsgData { + + @Schema(description = "模版消息字段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "thing1") + @NotNull(message = "模板消息的名称不能为空") + private String name; + + @Schema(description = "模版消息字段值", requiredMode = Schema.RequiredMode.REQUIRED, example = "OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk") + @NotNull(message = "模板消息的value不能为空") + private String value; +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/SubscribeMessageReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/SubscribeMessageReqDTO.java new file mode 100644 index 00000000..c5ca1935 --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/dto/SubscribeMessageReqDTO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.system.api.subscribe.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 功能描述 + * + * @author: yj + * @date: 2024年02月25日 15:50 + */ +@Schema(description = "RPC 服务 - 微信小程序订阅消息 Request DTO") +@Data +public class SubscribeMessageReqDTO { + + @Schema(description = "接收者(用户)的 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "o3bwX6Yw1bvbMAV-jUNjHrbrJu0I") + @NotNull(message = "openid不能为空") + private String toUser; + + @Schema(description = "所需下发的模板消息的id", requiredMode = Schema.RequiredMode.REQUIRED, example = "OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk") + @NotNull(message = "模板消息的id不能为空") + private String templateId; + + @Schema(description = "所需下发的模板消息的属性集合", requiredMode = Schema.RequiredMode.REQUIRED, example = "OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk") + private List data; + + @Schema(description = "跳转小程序类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "developer为开发版;trial为体验版;formal为正式版;默认为正式版") + @NotNull(message = "跳转小程序类型不能为空") + private String miniprogramState = "formal" ; + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/dto/AdminUserRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/dto/AdminUserRespDTO.java index a2e5e4a1..32ae32fe 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/dto/AdminUserRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/dto/AdminUserRespDTO.java @@ -27,4 +27,6 @@ public class AdminUserRespDTO { @Schema(description = "手机号码", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") private String mobile; + @Schema(description = "微信小程序用户opneId", requiredMode = Schema.RequiredMode.REQUIRED, example = "o3bwX6Yw1bvbMAV-jUNjHrbrJu0I") + private String openId; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApiImpl.java new file mode 100644 index 00000000..97bfa0b0 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/subscribe/SubscribeMessageSendApiImpl.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.system.api.subscribe; + +import cn.binarywang.wx.miniapp.api.WxMaSubscribeService; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.system.api.subscribe.dto.MsgData; +import cn.iocoder.yudao.module.system.api.subscribe.dto.SubscribeMessageReqDTO; +import lombok.SneakyThrows; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 功能描述 微信小程序发送订阅消息 + * + * @author: yj + * @date: 2024年02月25日 11:35 + */ +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@Validated +public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi{ + @Resource + private WxMaSubscribeService wxMaSubscribeService ; + + @SneakyThrows + @Override + public CommonResult sendApprovalResultNotification(SubscribeMessageReqDTO reqDTO) { + wxMaSubscribeService.sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO)); + return success(1L); + } + + @SneakyThrows + @Override + public CommonResult sendProcessToDoReminder(SubscribeMessageReqDTO reqDTO) { + wxMaSubscribeService.sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO)); + return success(1L); + } + + private WxMaSubscribeMessage initWxMaSubscribeMessage( SubscribeMessageReqDTO reqDTO ) { + WxMaSubscribeMessage message = new WxMaSubscribeMessage() ; + message.setToUser(reqDTO.getToUser()) ; + message.setTemplateId(reqDTO.getTemplateId()); + message.setMiniprogramState(reqDTO.getMiniprogramState()); + List dataList = reqDTO.getData() ; + for (MsgData msgData : dataList) { + WxMaSubscribeMessage.MsgData wxMsgData = new WxMaSubscribeMessage.MsgData() ; + wxMsgData.setName(msgData.getName()) ; + wxMsgData.setValue(msgData.getValue()) ; + message.addData(wxMsgData) ; + } + return message ; + } +}