From 6b69dd74d4f4f253f7d9c67f64f209ab5b45d9e1 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Mon, 15 Jul 2024 15:32:04 +0800 Subject: [PATCH 001/182] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91ai?= =?UTF-8?q?=20image=20=E5=A2=9E=E5=8A=A0release=20=E5=88=97=E8=A1=A8(?= =?UTF-8?q?=E7=94=BB=E5=BB=8A=E3=80=81=E5=B9=BF=E5=9C=BA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/image/AiImageController.java | 11 +++++++---- .../admin/image/vo/AiImageReleaseListReqVO.java | 14 ++++++++++++++ .../module/ai/dal/mysql/image/AiImageMapper.java | 7 +++++++ .../module/ai/service/image/AiImageService.java | 11 ++++++++--- .../ai/service/image/AiImageServiceImpl.java | 9 ++++++--- 5 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java index de12ee1e0..c06842f33 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java @@ -6,10 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageRespVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageUpdateReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyActionReqVO; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyImagineReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; @@ -131,4 +128,10 @@ public class AiImageController { return success(true); } + @GetMapping("/release-list") + @Operation(summary = "发布列表") + public CommonResult> releaseList(AiImageReleaseListReqVO releaseListReqVO) { + PageResult pageResult = imageService.releaseList(releaseListReqVO); + return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); + } } \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java new file mode 100644 index 000000000..17c368fa2 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.ai.controller.admin.image.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "Ai Image 发布列表 req") +@Data +public class AiImageReleaseListReqVO extends PageParam { + + @Schema(description = "提示词") + private String prompt; + +} \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java index fd6e4b398..062196806 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageReleaseListReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; import org.apache.ibatis.annotations.Mapper; @@ -43,4 +44,10 @@ public interface AiImageMapper extends BaseMapperX { AiImageDO::getPlatform, platform); } + default PageResult selectPageOfReleaseList(AiImageReleaseListReqVO releaseListReqVO) { + return selectPage(releaseListReqVO, new LambdaQueryWrapperX() + .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) + .eqIfPresent(AiImageDO::getPrompt, releaseListReqVO.getPrompt()) + .orderByDesc(AiImageDO::getId)); + } } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java index 716c7ea8a..abd79840e 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java @@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.ai.service.image; import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageUpdateReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyActionReqVO; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyImagineReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; @@ -118,4 +116,11 @@ public interface AiImageService { */ Long midjourneyAction(Long userId, AiMidjourneyActionReqVO reqVO); + /** + * 发布列表 + * @param releaseListReqVO + * @return + */ + PageResult releaseList(AiImageReleaseListReqVO releaseListReqVO); + } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java index 3a8ff8346..81f3b61e5 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java @@ -13,9 +13,7 @@ import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageUpdateReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyActionReqVO; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyImagineReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; @@ -338,6 +336,11 @@ public class AiImageServiceImpl implements AiImageService { return newImage.getId(); } + @Override + public PageResult releaseList(AiImageReleaseListReqVO releaseListReqVO) { + return imageMapper.selectPageOfReleaseList(releaseListReqVO); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * From ef4fb7ec057ba364371cddff22aef644137e96ac Mon Sep 17 00:00:00 2001 From: cherishsince Date: Mon, 15 Jul 2024 16:15:06 +0800 Subject: [PATCH 002/182] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=20publicList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/ai/controller/admin/image/AiImageController.java | 6 +++--- ...ageReleaseListReqVO.java => AiImagePublicListReqVO.java} | 2 +- .../yudao/module/ai/dal/mysql/image/AiImageMapper.java | 4 ++-- .../yudao/module/ai/service/image/AiImageService.java | 4 ++-- .../yudao/module/ai/service/image/AiImageServiceImpl.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/{AiImageReleaseListReqVO.java => AiImagePublicListReqVO.java} (84%) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java index c06842f33..a5a975acc 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java @@ -128,10 +128,10 @@ public class AiImageController { return success(true); } - @GetMapping("/release-list") + @GetMapping("/public-list") @Operation(summary = "发布列表") - public CommonResult> releaseList(AiImageReleaseListReqVO releaseListReqVO) { - PageResult pageResult = imageService.releaseList(releaseListReqVO); + public CommonResult> publicList(AiImagePublicListReqVO publicListReqVO) { + PageResult pageResult = imageService.publicList(publicListReqVO); return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); } } \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java similarity index 84% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java index 17c368fa2..816441c49 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageReleaseListReqVO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java @@ -6,7 +6,7 @@ import lombok.Data; @Schema(description = "Ai Image 发布列表 req") @Data -public class AiImageReleaseListReqVO extends PageParam { +public class AiImagePublicListReqVO extends PageParam { @Schema(description = "提示词") private String prompt; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java index 062196806..0b8acf374 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageReleaseListReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicListReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; import org.apache.ibatis.annotations.Mapper; @@ -44,7 +44,7 @@ public interface AiImageMapper extends BaseMapperX { AiImageDO::getPlatform, platform); } - default PageResult selectPageOfReleaseList(AiImageReleaseListReqVO releaseListReqVO) { + default PageResult selectPageOfPublicList(AiImagePublicListReqVO releaseListReqVO) { return selectPage(releaseListReqVO, new LambdaQueryWrapperX() .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) .eqIfPresent(AiImageDO::getPrompt, releaseListReqVO.getPrompt()) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java index abd79840e..86c01d42d 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java @@ -118,9 +118,9 @@ public interface AiImageService { /** * 发布列表 - * @param releaseListReqVO + * @param publicListReqVO * @return */ - PageResult releaseList(AiImageReleaseListReqVO releaseListReqVO); + PageResult publicList(AiImagePublicListReqVO publicListReqVO); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java index 81f3b61e5..cb1932021 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java @@ -337,8 +337,8 @@ public class AiImageServiceImpl implements AiImageService { } @Override - public PageResult releaseList(AiImageReleaseListReqVO releaseListReqVO) { - return imageMapper.selectPageOfReleaseList(releaseListReqVO); + public PageResult publicList(AiImagePublicListReqVO publicListReqVO) { + return imageMapper.selectPageOfPublicList(publicListReqVO); } /** From cb59a61a04698d498c9f9c86bf7a136f7fdff2f9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 17 Jul 2024 08:50:30 +0800 Subject: [PATCH 003/182] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91AI=EF=BC=9A=E8=8E=B7=E5=8F=96=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E7=9A=84=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/image/AiImageController.java | 13 +++++++------ ...ListReqVO.java => AiImagePublicPageReqVO.java} | 4 ++-- .../module/ai/dal/mysql/image/AiImageMapper.java | 15 ++++++++------- .../module/ai/service/image/AiImageService.java | 15 ++++++++------- .../ai/service/image/AiImageServiceImpl.java | 10 +++++----- 5 files changed, 30 insertions(+), 27 deletions(-) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/{AiImagePublicListReqVO.java => AiImagePublicPageReqVO.java} (66%) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java index a5a975acc..4634c5cd3 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java @@ -43,6 +43,13 @@ public class AiImageController { return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); } + @GetMapping("/public-page") + @Operation(summary = "获取公开的绘图分页") + public CommonResult> getImagePagePublic(AiImagePublicPageReqVO pageReqVO) { + PageResult pageResult = imageService.getImagePagePublic(pageReqVO); + return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); + } + @GetMapping("/get-my") @Operation(summary = "获取【我的】绘图记录") @Parameter(name = "id", required = true, description = "绘画编号", example = "1024") @@ -128,10 +135,4 @@ public class AiImageController { return success(true); } - @GetMapping("/public-list") - @Operation(summary = "发布列表") - public CommonResult> publicList(AiImagePublicListReqVO publicListReqVO) { - PageResult pageResult = imageService.publicList(publicListReqVO); - return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); - } } \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicPageReqVO.java similarity index 66% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicPageReqVO.java index 816441c49..e7ff80a98 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicPageReqVO.java @@ -4,9 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -@Schema(description = "Ai Image 发布列表 req") +@Schema(description = "管理后台 - AI 绘画公开的分页 Request VO") @Data -public class AiImagePublicListReqVO extends PageParam { +public class AiImagePublicPageReqVO extends PageParam { @Schema(description = "提示词") private String prompt; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java index 0b8acf374..7ef8b30eb 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicListReqVO; +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicPageReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; import org.apache.ibatis.annotations.Mapper; @@ -39,15 +39,16 @@ public interface AiImageMapper extends BaseMapperX { .orderByDesc(AiImageDO::getId)); } + default PageResult selectPage(AiImagePublicPageReqVO pageReqVO) { + return selectPage(pageReqVO, new LambdaQueryWrapperX() + .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) + .likeIfPresent(AiImageDO::getPrompt, pageReqVO.getPrompt()) + .orderByDesc(AiImageDO::getId)); + } + default List selectListByStatusAndPlatform(Integer status, String platform) { return selectList(AiImageDO::getStatus, status, AiImageDO::getPlatform, platform); } - default PageResult selectPageOfPublicList(AiImagePublicListReqVO releaseListReqVO) { - return selectPage(releaseListReqVO, new LambdaQueryWrapperX() - .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) - .eqIfPresent(AiImageDO::getPrompt, releaseListReqVO.getPrompt()) - .orderByDesc(AiImageDO::getId)); - } } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java index 86c01d42d..3858224e4 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java @@ -27,6 +27,14 @@ public interface AiImageService { */ PageResult getImagePageMy(Long userId, PageParam pageReqVO); + /** + * 获取公开的绘图分页 + * + * @param pageReqVO 分页条件 + * @return 绘图分页 + */ + PageResult getImagePagePublic(AiImagePublicPageReqVO pageReqVO); + /** * 获得绘图记录 * @@ -116,11 +124,4 @@ public interface AiImageService { */ Long midjourneyAction(Long userId, AiMidjourneyActionReqVO reqVO); - /** - * 发布列表 - * @param publicListReqVO - * @return - */ - PageResult publicList(AiImagePublicListReqVO publicListReqVO); - } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java index cb1932021..1949ba067 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java @@ -69,6 +69,11 @@ public class AiImageServiceImpl implements AiImageService { return imageMapper.selectPage(userId, pageReqVO); } + @Override + public PageResult getImagePagePublic(AiImagePublicPageReqVO pageReqVO) { + return imageMapper.selectPage(pageReqVO); + } + @Override public AiImageDO getImage(Long id) { return imageMapper.selectById(id); @@ -336,11 +341,6 @@ public class AiImageServiceImpl implements AiImageService { return newImage.getId(); } - @Override - public PageResult publicList(AiImagePublicListReqVO publicListReqVO) { - return imageMapper.selectPageOfPublicList(publicListReqVO); - } - /** * 获得自身的代理对象,解决 AOP 生效问题 * From 1ecc50b3c94a712289f385e4d9cbae6758760a28 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 17 Jul 2024 18:36:48 +0800 Subject: [PATCH 004/182] =?UTF-8?q?mall:=20=E5=AE=8C=E5=96=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=AB=AF=E8=8E=B7=E5=BE=97=E5=95=86=E5=93=81=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E8=AE=B0=E5=BD=95=E5=88=86=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductBrowseHistoryController.java | 22 ++++++++++++++- .../vo/ProductBrowseHistoryRespVO.java | 28 +++++++++---------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java index b87e4ee44..b97c36001 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.module.product.controller.admin.history; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; +import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -17,7 +20,13 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Tag(name = "管理后台 - 商品浏览记录") @RestController @@ -27,13 +36,24 @@ public class ProductBrowseHistoryController { @Resource private ProductBrowseHistoryService browseHistoryService; + @Resource + private ProductSpuService productSpuService; @GetMapping("/page") @Operation(summary = "获得商品浏览记录分页") @PreAuthorize("@ss.hasPermission('product:browse-history:query')") public CommonResult> getBrowseHistoryPage(@Valid ProductBrowseHistoryPageReqVO pageReqVO) { PageResult pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class)); + if (CollUtil.isEmpty(pageResult.getList())) { + return success(PageResult.empty()); + } + + // 得到商品 spu 信息 + Set spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId); + Map spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); + return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class, + vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) + .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); } } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java index 0e2e0cbed..012f1602c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java @@ -7,28 +7,28 @@ import lombok.Data; import java.time.LocalDateTime; +import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; + @Schema(description = "管理后台 - 商品浏览记录 Response VO") @Data @ExcelIgnoreUnannotated public class ProductBrowseHistoryRespVO { - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26055") - @ExcelProperty("记录编号") + @Schema(description = "编号", requiredMode = REQUIRED, example = "1") private Long id; - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4314") - @ExcelProperty("用户编号") - private Long userId; - - @Schema(description = "用户是否删除", example = "false") - private Boolean userDeleted; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "42") - @ExcelProperty("商品 SPU 编号") + @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") private Long spuId; - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; + // ========== 商品相关字段 ========== + + @Schema(description = "商品 SPU 名称", example = "赵六") + private String spuName; + + @Schema(description = "商品封面图", example = "https://domain/pic.png") + private String picUrl; + + @Schema(description = "商品单价", example = "100") + private Integer price; } \ No newline at end of file From c4ab00eabbf83a5d7a3f8464a856893fe9e3ea3f Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 17 Jul 2024 18:42:45 +0800 Subject: [PATCH 005/182] =?UTF-8?q?mall:=20kefu=20=E5=8C=85=E5=90=8D?= =?UTF-8?q?=E6=9B=B4=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/{kehu => kefu}/KeFuMessageContentTypeEnum.java | 2 +- .../promotion/dal/dataobject/kefu/KeFuConversationDO.java | 2 +- .../module/promotion/dal/dataobject/kefu/KeFuMessageDO.java | 2 +- .../promotion/service/kefu/KeFuConversationServiceImpl.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/{kehu => kefu}/KeFuMessageContentTypeEnum.java (94%) diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kefu/KeFuMessageContentTypeEnum.java similarity index 94% rename from yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java rename to yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kefu/KeFuMessageContentTypeEnum.java index 51ee59332..4a058ab56 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kefu/KeFuMessageContentTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.enums.kehu; +package cn.iocoder.yudao.module.promotion.enums.kefu; import cn.iocoder.yudao.framework.common.core.IntArrayValuable; import lombok.AllArgsConstructor; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuConversationDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuConversationDO.java index e9a73284f..482b6cd82 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuConversationDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuConversationDO.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.kefu; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.kehu.KeFuMessageContentTypeEnum; +import cn.iocoder.yudao.module.promotion.enums.kefu.KeFuMessageContentTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuMessageDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuMessageDO.java index bd542f890..b36f3eeec 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuMessageDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/kefu/KeFuMessageDO.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.kefu; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.kehu.KeFuMessageContentTypeEnum; +import cn.iocoder.yudao.module.promotion.enums.kefu.KeFuMessageContentTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java index fbc658abc..48aff5b03 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.conversation.K import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuConversationDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; import cn.iocoder.yudao.module.promotion.dal.mysql.kefu.KeFuConversationMapper; -import cn.iocoder.yudao.module.promotion.enums.kehu.KeFuMessageContentTypeEnum; +import cn.iocoder.yudao.module.promotion.enums.kefu.KeFuMessageContentTypeEnum; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From 401de3034479bf8787b22fc4e9f6c6b7f9f03c73 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 17 Jul 2024 20:07:01 +0800 Subject: [PATCH 006/182] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91MALL=EF=BC=9A=E5=AE=8C=E5=96=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=AB=AF=E8=8E=B7=E5=BE=97=E5=95=86=E5=93=81=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E8=AE=B0=E5=BD=95=E5=88=86=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/ProductBrowseHistoryController.java | 6 ++---- .../product/service/spu/ProductSpuService.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java index b97c36001..0b9e6a13b 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java @@ -22,10 +22,8 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; -import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Tag(name = "管理后台 - 商品浏览记录") @@ -49,8 +47,8 @@ public class ProductBrowseHistoryController { } // 得到商品 spu 信息 - Set spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId); - Map spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); + Map spuMap = productSpuService.getSpuMap( + convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId)); return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class, vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index c288a76ca..d7403c159 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.product.service.spu; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; @@ -58,6 +59,17 @@ public interface ProductSpuService { */ List getSpuList(Collection ids); + /** + * 获得商品 SPU Map + * + * @param ids 编号数组 + * @return 商品 SPU Map + */ + default Map getSpuMap(Collection ids) { + List list = getSpuList(ids); + return CollectionUtils.convertMap(list, ProductSpuDO::getId); + } + /** * 获得指定状态的商品 SPU 列表 * From f81d56eb8836297076c790b264bc2d0a7191125a Mon Sep 17 00:00:00 2001 From: scholar <1145227973@qq.com> Date: Thu, 18 Jul 2024 21:13:36 +0800 Subject: [PATCH 007/182] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=EF=BC=8C=E5=87=8F=E5=B0=91=E4=B8=BASDK=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=9F=BA=E4=BA=8E?= =?UTF-8?q?API=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/core/client/impl/AliyunSmsClient.java | 265 ++++++++++++++---- 1 file changed, 216 insertions(+), 49 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java index 7d01e6cdf..708683b21 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java @@ -1,6 +1,14 @@ package cn.iocoder.yudao.module.system.framework.sms.core.client.impl; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.HexUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.crypto.digest.DigestUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; @@ -9,27 +17,23 @@ import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespD import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateRequest; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateResponse; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; -import com.aliyuncs.profile.DefaultProfile; -import com.aliyuncs.profile.IClientProfile; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.annotations.VisibleForTesting; import lombok.Data; import lombok.extern.slf4j.Slf4j; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.net.URLEncoder; import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; +import java.util.*; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; +import java.text.SimpleDateFormat; /** * 阿里短信客户端的实现类 @@ -40,21 +44,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DE @Slf4j public class AliyunSmsClient extends AbstractSmsClient { - /** - * 调用成功 code - */ - public static final String API_CODE_SUCCESS = "OK"; - - /** - * REGION, 使用杭州 - */ - private static final String ENDPOINT = "cn-hangzhou"; - - /** - * 阿里云客户端 - */ - private volatile IAcsClient client; - public AliyunSmsClient(SmsChannelProperties properties) { super(properties); Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空"); @@ -63,24 +52,116 @@ public class AliyunSmsClient extends AbstractSmsClient { @Override protected void doInit() { - IClientProfile profile = DefaultProfile.getProfile(ENDPOINT, properties.getApiKey(), properties.getApiSecret()); - client = new DefaultAcsClient(profile); +// IClientProfile profile = DefaultProfile.getProfile(ENDPOINT, properties.getApiKey(), properties.getApiSecret()); +// client = new DefaultAcsClient(profile); } @Override public SmsSendRespDTO sendSms(Long sendLogId, String mobile, String apiTemplateId, List> templateParams) throws Throwable { - // 构建请求 - SendSmsRequest request = new SendSmsRequest(); - request.setPhoneNumbers(mobile); - request.setSignName(properties.getSignature()); - request.setTemplateCode(apiTemplateId); - request.setTemplateParam(JsonUtils.toJsonString(MapUtils.convertMap(templateParams))); - request.setOutId(String.valueOf(sendLogId)); - // 执行请求 - SendSmsResponse response = client.getAcsResponse(request); - return new SmsSendRespDTO().setSuccess(Objects.equals(response.getCode(), API_CODE_SUCCESS)).setSerialNo(response.getBizId()) - .setApiRequestId(response.getRequestId()).setApiCode(response.getCode()).setApiMsg(response.getMessage()); + + TreeMap queryParam = new TreeMap<>(); + queryParam.put("PhoneNumbers",mobile); + queryParam.put("SignName",properties.getSignature()); + queryParam.put("TemplateCode",apiTemplateId); + queryParam.put("TemplateParam",JsonUtils.toJsonString(MapUtils.convertMap(templateParams))); + + JSONObject response = sendSmsRequest(queryParam,"sendSms"); + SmsResponse smsResponse = getSmsSendResponse(response); + + return new SmsSendRespDTO().setSuccess(smsResponse.success).setApiMsg(smsResponse.data.toString()); + } + + JSONObject sendSmsRequest(TreeMap queryParam,String apiName) throws IOException, URISyntaxException { + + // ************* 步骤 1:拼接规范请求串 ************* + String url = "https://dysmsapi.aliyuncs.com"; //APP接入地址+接口访问URI + String httpMethod = "POST"; // 请求方式 + String canonicalUri = "/"; + // 请求参数,当请求的查询字符串为空时,使用空字符串作为规范化查询字符串 + StringBuilder canonicalQueryString = new StringBuilder(); + queryParam.entrySet().stream().map(entry -> percentCode(entry.getKey()) + "=" + percentCode(String.valueOf(entry.getValue()))).forEachOrdered(queryPart -> { + // 如果canonicalQueryString已经不是空的,则在查询参数前添加"&" + if (!canonicalQueryString.isEmpty()) { + canonicalQueryString.append("&"); + } + canonicalQueryString.append(queryPart); + System.out.println("canonicalQueryString=========>\n" + canonicalQueryString); + }); + + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + SDF.setTimeZone(new SimpleTimeZone(0, "GMT")); + String SdfTime = SDF.format(new Date()); + String randomUUID = UUID.randomUUID().toString(); + + TreeMap headers = new TreeMap<>(); + headers.put("host", "dysmsapi.aliyuncs.com"); + headers.put("x-acs-action", apiName); + headers.put("x-acs-version", "2017-05-25"); + headers.put("x-acs-date", SdfTime); + headers.put("x-acs-signature-nonce", randomUUID); +// headers.put("content-type", "application/json;charset=utf-8"); + + // 构造请求头,多个规范化消息头,按照消息头名称(小写)的字符代码顺序以升序排列后拼接在一起 + StringBuilder canonicalHeaders = new StringBuilder(); + // 已签名消息头列表,多个请求头名称(小写)按首字母升序排列并以英文分号(;)分隔 + StringBuilder signedHeadersSb = new StringBuilder(); + headers.entrySet().stream().filter(entry -> entry.getKey().toLowerCase().startsWith("x-acs-") || entry.getKey().equalsIgnoreCase("host") || entry.getKey().equalsIgnoreCase("content-type")).sorted(Map.Entry.comparingByKey()).forEach(entry -> { + String lowerKey = entry.getKey().toLowerCase(); + String value = String.valueOf(entry.getValue()).trim(); + canonicalHeaders.append(lowerKey).append(":").append(value).append("\n"); + signedHeadersSb.append(lowerKey).append(";"); + }); + String signedHeaders = signedHeadersSb.substring(0, signedHeadersSb.length() - 1); + + String body = "";//短信API为RPC接口,query parameters在uri中拼接,因此request body如果没有特殊要求,设置为空。 + String hashedRequestBody = HexUtil.encodeHexStr(DigestUtil.sha256(body)); + + + String canonicalRequest = httpMethod + "\n" + canonicalUri + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" + signedHeaders + "\n" + hashedRequestBody; + System.out.println("canonicalRequest=========>\n" + canonicalRequest); + + // ************* 步骤 2:拼接待签名字符串 ************* + String hashedCanonicalRequest = HexUtil.encodeHexStr(DigestUtil.sha256(canonicalRequest)); + String stringToSign = "ACS3-HMAC-SHA256" + "\n" + hashedCanonicalRequest; + + // ************* 步骤 3:计算签名 ************* + String signature = SecureUtil.hmacSha256(properties.getApiSecret()).digestHex(stringToSign); + + // ************* 步骤 4:拼接 Authorization ************* + String authorization = "ACS3-HMAC-SHA256" + " " + "Credential=" + properties.getApiKey() + ", " + + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature; + headers.put("Authorization", authorization); + + // ************* 步骤 5:构造HttpRequest 并执行request请求,获得response ************* +// url = url + canonicalUri; + String urlWithParams = url + "?" + URLUtil.buildQuery(queryParam, null); + + HttpResponse response = HttpRequest.post(urlWithParams) + .addHeaders(headers) + .body(body) + .execute(); +// URIBuilder uriBuilder = new URIBuilder(url); +// // 添加请求参数 +// for (Map.Entry entry : queryParam.entrySet()) { +// uriBuilder.addParameter(entry.getKey(), String.valueOf(entry.getValue())); +// } +// HttpUriRequest httpRequest = new HttpPost(uriBuilder.build()); +//// HttpPost httpPost = new HttpPost(uriBuilder.build()); +//// httpRequest = httpPost; +// +// // 添加http请求头 +// for (Map.Entry entry : headers.entrySet()) { +// httpRequest.addHeader(entry.getKey(), String.valueOf(entry.getValue())); +// } +// +// // 发送请求 +// CloseableHttpClient httpClient = HttpClients.createDefault(); +// CloseableHttpResponse response = httpClient.execute(httpRequest); + System.out.println("getEntity====="+response.body()); + System.out.println("response====="+response); + + return JSONUtil.parseObj(response.body()); } @Override @@ -94,16 +175,15 @@ public class AliyunSmsClient extends AbstractSmsClient { @Override public SmsTemplateRespDTO getSmsTemplate(String apiTemplateId) throws Throwable { - // 构建请求 - QuerySmsTemplateRequest request = new QuerySmsTemplateRequest(); - request.setTemplateCode(apiTemplateId); - // 执行请求 - QuerySmsTemplateResponse response = client.getAcsResponse(request); - if (response.getTemplateStatus() == null) { - return null; - } - return new SmsTemplateRespDTO().setId(response.getTemplateCode()).setContent(response.getTemplateContent()) - .setAuditStatus(convertSmsTemplateAuditStatus(response.getTemplateStatus())).setAuditReason(response.getReason()); + + TreeMap queryParam = new TreeMap<>(); + queryParam.put("TemplateCode",apiTemplateId); + + JSONObject response = sendSmsRequest(queryParam,"QuerySmsTemplate"); + QuerySmsTemplateResponse smsTemplateResponse = getSmsTemplateResponse(response); + return new SmsTemplateRespDTO().setId(smsTemplateResponse.getTemplateCode()).setContent(smsTemplateResponse.getTemplateContent()) + .setAuditStatus(convertSmsTemplateAuditStatus(smsTemplateResponse.getTemplateStatus())).setAuditReason(smsTemplateResponse.getReason()); + } @VisibleForTesting @@ -116,12 +196,99 @@ public class AliyunSmsClient extends AbstractSmsClient { } } + + /** + * 对指定的字符串进行URL编码。 + * 使用UTF-8编码字符集对字符串进行编码,并对特定的字符进行替换,以符合URL编码规范。 + * + * @param str 需要进行URL编码的字符串。 + * @return 编码后的字符串。其中,加号"+"被替换为"%20",星号"*"被替换为"%2A",波浪号"%7E"被替换为"~"。 + */ + public static String percentCode(String str) { + if (str == null) { + throw new IllegalArgumentException("输入字符串不可为null"); + } + try { + return URLEncoder.encode(str, "UTF-8").replace("+", "%20").replace("*", "%2A").replace("%7E", "~"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8编码不被支持", e); + } + } + + private SmsResponse getSmsSendResponse(JSONObject resJson) { + SmsResponse smsResponse = new SmsResponse(); + smsResponse.setSuccess("OK".equals(resJson.getStr("Code"))); + smsResponse.setData(resJson); +// smsResponse.setConfigId(getConfigId()); + return smsResponse; + } + + private QuerySmsTemplateResponse getSmsTemplateResponse(JSONObject resJson) { + + QuerySmsTemplateResponse smsTemplateResponse = new QuerySmsTemplateResponse(); + + smsTemplateResponse.setRequestId(resJson.getStr("RequestId")); + smsTemplateResponse.setTemplateContent(resJson.getStr("TemplateContent")); + smsTemplateResponse.setReason(resJson.getStr("Reason")); + smsTemplateResponse.setTemplateStatus(resJson.getInt("TemplateStatus")); + + return smsTemplateResponse; + } + + /** + *

类名: SmsResponse + *

说明: 发送短信返回信息 + * + * @author :scholar + * 2024/07/17 0:25 + **/ + @Data + public static class SmsResponse { + + /** + * 是否成功 + */ + private boolean success; + + /** + * 厂商原返回体 + */ + private Object data; + + /** + * 配置标识名 如未配置取对应渠道名例如 Alibaba + */ + private String configId; + } + + + /** + *

类名: QuerySmsTemplateResponse + *

说明: sms模板查询返回信息 + * + * @author :scholar + * 2024/07/17 0:25 + **/ + @Data + public static class QuerySmsTemplateResponse { + private String requestId; + private String code; + private String message; + private Integer templateStatus; + private String reason; + private String templateCode; + private Integer templateType; + private String templateName; + private String templateContent; + private String createDate; + } + /** * 短信接收状态 * * 参见 文档 * - * @author 芋道源码 + * @author 润普源码 */ @Data public static class SmsReceiveStatus { From 9a263f8dab735d8b8ba3829b0ac08c2adf09e351 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 22 Jul 2024 15:40:20 +0800 Subject: [PATCH 008/182] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91SYS?= =?UTF-8?q?TEM:=20=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E6=B6=88=E6=81=AF=E6=A8=A1=E7=89=88=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/social/AppSocialUserController.java | 13 +++++-- .../AppSocialWxSubscribeTemplateRespVO.java | 25 ++++++++++++ .../system/api/social/SocialClientApi.java | 18 +++++++-- .../dto/SocialWxSubscribeTemplateRespDTO.java | 39 +++++++++++++++++++ .../system/enums/ErrorCodeConstants.java | 5 ++- .../api/social/SocialClientApiImpl.java | 11 +++++- .../service/social/SocialClientService.java | 10 +++++ .../social/SocialClientServiceImpl.java | 15 +++++++ 8 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java index de76856c3..326460fe8 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java @@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBindReqVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserRespVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialWxQrcodeReqVO; +import cn.iocoder.yudao.module.member.controller.app.social.vo.*; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.SocialUserApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; @@ -23,6 +20,8 @@ import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -72,4 +71,10 @@ public class AppSocialUserController { return success(Base64.encode(wxQrcode)); } + @GetMapping("/get-subscribe-template") + @Operation(summary = "获得微信小程订阅模板") + public CommonResult> getSubscribeTemplate() { + return success(BeanUtils.toBean(socialClientApi.getSubscribeTemplate(), AppSocialWxSubscribeTemplateRespVO.class)); + } + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java new file mode 100644 index 000000000..2aad4fdda --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.member.controller.app.social.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "用户 APP - 获得小程序订阅模版 Response VO") +@Data +public class AppSocialWxSubscribeTemplateRespVO { + + @Schema(description = "添加至账号下的模板 id,发送小程序订阅消息时所需", requiredMode = Schema.RequiredMode.REQUIRED, example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU") + private String priTmplId; + + @Schema(description = "模版标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单支付通知") + private String title; + + @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED) + private String content; + + @Schema(description = "模板内容示例", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单时间:2016年8月8日") + private String example; + + @Schema(description = "模版类型,2 为一次性订阅,3 为长期订阅", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private Integer type; + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java index cdc609b3f..1db894fb1 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java @@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.system.api.social; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeTemplateRespDTO; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import jakarta.validation.Valid; +import java.util.List; + /** * 社交应用的 API 接口 * @@ -16,8 +19,8 @@ public interface SocialClientApi { /** * 获得社交平台的授权 URL * - * @param socialType 社交平台的类型 {@link SocialTypeEnum} - * @param userType 用户类型 + * @param socialType 社交平台的类型 {@link SocialTypeEnum} + * @param userType 用户类型 * @param redirectUri 重定向 URL * @return 社交平台的授权 URL */ @@ -27,7 +30,7 @@ public interface SocialClientApi { * 创建微信公众号 JS SDK 初始化所需的签名 * * @param userType 用户类型 - * @param url 访问的 URL 地址 + * @param url 访问的 URL 地址 * @return 签名 */ SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url); @@ -35,7 +38,7 @@ public interface SocialClientApi { /** * 获得微信小程序的手机信息 * - * @param userType 用户类型 + * @param userType 用户类型 * @param phoneCode 手机授权码 * @return 手机信息 */ @@ -49,4 +52,11 @@ public interface SocialClientApi { */ byte[] getWxaQrcode(@Valid SocialWxQrcodeReqDTO reqVO); + /** + * 获得微信小程订阅模板 + * + * @return 小程序订阅消息模版 + */ + List getSubscribeTemplate(); + } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java new file mode 100644 index 000000000..5959f5b14 --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.system.api.social.dto; + +import lombok.Data; + + +/** + * 小程序订阅消息模版 Response DTO + * + * @author HUIHUI + */ +@Data +public class SocialWxSubscribeTemplateRespDTO { + + /** + * 添加至账号下的模板 id,发送小程序订阅消息时所需 + */ + private String priTmplId; + + /** + * 模版标题 + */ + private String title; + + /** + * 模版内容 + */ + private String content; + + /** + * 模板内容示例 + */ + private String example; + + /** + * 模版类型,2 为一次性订阅,3 为长期订阅 + */ + private Integer type; + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 412ac413e..c7d09823f 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -121,8 +121,9 @@ public interface ErrorCodeConstants { ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_200, "获得手机号失败"); ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR = new ErrorCode(1_002_018_201, "获得小程序码失败"); - ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_202, "社交客户端不存在"); - ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_203, "社交客户端已存在配置"); + ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR = new ErrorCode(1_002_018_202, "获得小程序订阅消息模版失败"); + ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在"); + ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_211, "社交客户端已存在配置"); // ========== OAuth2 客户端 1-002-020-000 ========= diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java index 2a7b69cfe..605907bc2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java @@ -5,12 +5,15 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeTemplateRespDTO; import cn.iocoder.yudao.module.system.service.social.SocialClientService; +import jakarta.annotation.Resource; import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; +import java.util.List; /** * 社交应用的 API 实现类 @@ -46,4 +49,10 @@ public class SocialClientApiImpl implements SocialClientApi { return socialClientService.getWxaQrcode(reqVO); } + @Override + public List getSubscribeTemplate() { + List subscribeTemplate = socialClientService.getSubscribeTemplate(); + return BeanUtils.toBean(subscribeTemplate, SocialWxSubscribeTemplateRespDTO.class); + } + } 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 7757d35d1..edfe930ce 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 @@ -10,6 +10,9 @@ import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import com.xingyuv.jushauth.model.AuthUser; import jakarta.validation.Valid; import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; + +import java.util.List; /** * 社交应用 Service 接口 @@ -109,4 +112,11 @@ public interface SocialClientService { */ PageResult getSocialClientPage(SocialClientPageReqVO pageReqVO); + /** + * 获得微信小程订阅模板 + * + * @return 微信小程订阅模板 + */ + List getSubscribeTemplate(); + } 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 b9a339223..6a8295c20 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.service.social; import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.WxMaSubscribeService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; @@ -36,6 +37,7 @@ import jakarta.annotation.Resource; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; import me.chanjar.weixin.mp.api.WxMpService; @@ -46,6 +48,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.time.Duration; +import java.util.List; import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -364,4 +367,16 @@ public class SocialClientServiceImpl implements SocialClientService { return socialClientMapper.selectPage(pageReqVO); } + @Override + public List getSubscribeTemplate() { + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); + try { + WxMaSubscribeService subscribeService = service.getSubscribeService(); + return subscribeService.getTemplateList(); + }catch (WxErrorException e) { + log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e); + throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR); + } + } + } From 878b56a7d60ea5dbaabd2d53719c36cf826353c1 Mon Sep 17 00:00:00 2001 From: yinyilong <195332105@qq.com> Date: Tue, 23 Jul 2024 14:43:57 +0800 Subject: [PATCH 009/182] =?UTF-8?q?bugfix-=E5=AF=BC=E5=85=A5=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=94=A8=E6=88=B7=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E6=A0=A1=E9=AA=8C=E8=BF=87=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E4=B8=8E=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=92=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/test/core/util/RandomUtils.java | 4 ++ .../service/user/AdminUserServiceImpl.java | 38 +++++++++++++++++-- .../user/AdminUserServiceImplTest.java | 6 +++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java index 66d15c5bf..095269751 100644 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java @@ -103,6 +103,10 @@ public class RandomUtils { return randomString() + "@qq.com"; } + public static String randomMobile() { + return "13800138" + RandomUtil.randomNumbers(3); + } + public static String randomURL() { return "https://www.iocoder.cn/" + randomString(); } 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 1f99899db..2edff89cf 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 @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils; import cn.iocoder.yudao.module.infra.api.config.ConfigApi; import cn.iocoder.yudao.module.infra.api.file.FileApi; @@ -32,6 +33,7 @@ import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.service.impl.DiffParseFunction; import com.mzt.logapi.starter.annotation.LogRecord; import jakarta.annotation.Resource; +import jakarta.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; import org.springframework.security.crypto.password.PasswordEncoder; @@ -40,13 +42,36 @@ import org.springframework.transaction.annotation.Transactional; import java.io.InputStream; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_COUNT_MAX; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_EMAIL_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IMPORT_INIT_PASSWORD; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IS_DISABLE; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_MOBILE_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_PASSWORD_FAILED; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_CREATE_SUB_TYPE; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_CREATE_SUCCESS; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_DELETE_SUB_TYPE; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_DELETE_SUCCESS; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_TYPE; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_UPDATE_PASSWORD_SUB_TYPE; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_UPDATE_PASSWORD_SUCCESS; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_UPDATE_SUB_TYPE; +import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.SYSTEM_USER_UPDATE_SUCCESS; /** * 后台用户 Service 实现类 @@ -451,6 +476,13 @@ public class AdminUserServiceImpl implements AdminUserService { respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage()); return; } + // 校验字段是否符合要求 + try { + ValidationUtils.validate(BeanUtils.toBean(importUser, UserSaveReqVO.class).setPassword(initPassword)); + }catch (ConstraintViolationException ex){ + respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage()); + return; + } // 判断如果不存在,在进行插入 AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername()); if (existUser == null) { diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java index 4d9ca7856..73f54d151 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java @@ -452,6 +452,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 + o.setEmail(randomEmail()); + o.setMobile(randomMobile()); }); // mock deptService 的方法 DeptDO dept = randomPojo(DeptDO.class, o -> { @@ -486,6 +488,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 o.setUsername(dbUser.getUsername()); + o.setEmail(randomEmail()); + o.setMobile(randomMobile()); }); // mock deptService 的方法 DeptDO dept = randomPojo(DeptDO.class, o -> { @@ -516,6 +520,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 o.setUsername(dbUser.getUsername()); + o.setEmail(randomEmail()); + o.setMobile(randomMobile()); }); // mock deptService 的方法 DeptDO dept = randomPojo(DeptDO.class, o -> { From 63e319e6639c4ac387f98fb85d5e6835b3c2af2c Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 23 Jul 2024 17:46:41 +0800 Subject: [PATCH 010/182] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91SYS?= =?UTF-8?q?TEM:=20=E5=8F=91=E9=80=81=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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/api/social/SocialClientApi.java | 12 ++-- .../dto/SocialWxSubscribeMessageReqDTO.java | 70 +++++++++++++++++++ .../system/enums/ErrorCodeConstants.java | 1 + .../api/social/SocialClientApiImpl.java | 10 +-- .../service/social/SocialClientService.java | 22 ++++-- .../social/SocialClientServiceImpl.java | 40 +++++++---- 6 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java index 1db894fb1..3a91c92a4 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java @@ -1,9 +1,6 @@ package cn.iocoder.yudao.module.system.api.social; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeTemplateRespDTO; +import cn.iocoder.yudao.module.system.api.social.dto.*; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import jakarta.validation.Valid; @@ -59,4 +56,11 @@ public interface SocialClientApi { */ List getSubscribeTemplate(); + /** + * 发送订阅消息 + * + * @param reqDTO 请求 + */ + void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO); + } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java new file mode 100644 index 000000000..6bcb6397d --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.system.api.social.dto; + +import cn.iocoder.yudao.framework.common.core.KeyValue; +import lombok.Data; + +import java.util.List; + +/** + * 微信小程序订阅消息 Request DTO + * + * @author HUIHUI + */ +@Data +public class SocialWxSubscribeMessageReqDTO { + + /** + * 接收者(用户)的 openid. + *

+     * 参数:touser
+     * 是否必填: 是
+     * 描述: 接收者(用户)的 openid
+     * 
+ */ + private String toUser; + + /** + * 所需下发的模板消息的id. + *
+     * 参数:template_id
+     * 是否必填: 是
+     * 描述: 所需下发的模板消息的id
+     * 
+ */ + private String templateId; + + /** + * 点击模板卡片后的跳转页面,仅限本小程序内的页面. + *
+     * 参数:page
+     * 是否必填: 否
+     * 描述: 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
+     * 
+ */ + private String page; + + /** + * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 + * + * 枚举 WxMaConstants.MiniProgramState + */ + private String miniprogramState; + + /** + * 进入小程序查看的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN + * + * 枚举 WxMaConstants.MiniProgramLang + */ + private String lang; + + /** + * 模板内容,不填则下发空模板. + *
+     * 参数:data
+     * 是否必填: 是
+     * 描述: 模板内容,不填则下发空模板
+     * 
+ */ + private List> data; + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index c7d09823f..d34adc7dc 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -122,6 +122,7 @@ public interface ErrorCodeConstants { ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_200, "获得手机号失败"); ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR = new ErrorCode(1_002_018_201, "获得小程序码失败"); ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR = new ErrorCode(1_002_018_202, "获得小程序订阅消息模版失败"); + ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR = new ErrorCode(1_002_018_203, "发送小程序订阅消息失败"); ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在"); ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_211, "社交客户端已存在配置"); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java index 605907bc2..1656524a7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java @@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.system.api.social; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeTemplateRespDTO; +import cn.iocoder.yudao.module.system.api.social.dto.*; import cn.iocoder.yudao.module.system.service.social.SocialClientService; import jakarta.annotation.Resource; import me.chanjar.weixin.common.bean.WxJsapiSignature; @@ -55,4 +52,9 @@ public class SocialClientApiImpl implements SocialClientApi { return BeanUtils.toBean(subscribeTemplate, SocialWxSubscribeTemplateRespDTO.class); } + @Override + public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) { + socialClientService.sendSubscribeMessage(reqDTO); + } + } 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 edfe930ce..2f58732bb 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 @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.social; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; @@ -72,6 +73,20 @@ public interface SocialClientService { */ byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO); + /** + * 获得微信小程订阅模板 + * + * @return 微信小程订阅模板 + */ + List getSubscribeTemplate(); + + /** + * 发送订阅消息 + * + * @param reqDTO 请求 + */ + void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO); + // =================== 客户端管理 =================== /** @@ -112,11 +127,4 @@ public interface SocialClientService { */ PageResult getSocialClientPage(SocialClientPageReqVO pageReqVO); - /** - * 获得微信小程订阅模板 - * - * @return 微信小程订阅模板 - */ - List getSubscribeTemplate(); - } 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 6a8295c20..9e05f3a23 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 @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaSubscribeService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Assert; @@ -16,6 +17,7 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; import cn.iocoder.yudao.framework.common.util.http.HttpUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; @@ -258,6 +260,32 @@ public class SocialClientServiceImpl implements SocialClientService { } } + @Override + public List getSubscribeTemplate() { + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); + try { + WxMaSubscribeService subscribeService = service.getSubscribeService(); + return subscribeService.getTemplateList(); + }catch (WxErrorException e) { + log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e); + throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR); + } + } + + @Override + public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) { + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); + try { + WxMaSubscribeService subscribeService = service.getSubscribeService(); + WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class); + reqDTO.getData().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue()))); + subscribeService.sendSubscribeMsg(message); + }catch (WxErrorException e) { + log.error("[sendSubscribeMessage][发送小程序订阅消息]", e); + throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR); + } + } + /** * 获得 clientId + clientSecret 对应的 WxMpService 对象 * @@ -367,16 +395,4 @@ public class SocialClientServiceImpl implements SocialClientService { return socialClientMapper.selectPage(pageReqVO); } - @Override - public List getSubscribeTemplate() { - WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); - try { - WxMaSubscribeService subscribeService = service.getSubscribeService(); - return subscribeService.getTemplateList(); - }catch (WxErrorException e) { - log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e); - throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR); - } - } - } From 8054847b05bb10f6e9fc0f934c2c257a29dd7e86 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 24 Jul 2024 17:18:48 +0800 Subject: [PATCH 011/182] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91SYS?= =?UTF-8?q?TEM:=20=E5=8F=91=E9=80=81=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=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/enums/MessageTemplateConstants.java | 5 +++++ .../dto/SocialWxSubscribeMessageReqDTO.java | 11 ++++++++++- .../admin/socail/SocialClientController.http | 5 +++++ .../admin/socail/SocialClientController.java | 18 +++++++++++++++--- .../social/SocialClientServiceImpl.java | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java index 5041139b4..727598636 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java @@ -13,4 +13,9 @@ public interface MessageTemplateConstants { String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) + //======================= 订阅消息模版 ======================= + + String ORDER_AFTERSALE_CHANGE = "售后进度通知"; + String MONEY_CHANGE = "充值成功通知"; + } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java index 6bcb6397d..4f7ecd7a0 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.social.dto; import cn.iocoder.yudao.framework.common.core.KeyValue; import lombok.Data; +import java.util.ArrayList; import java.util.List; /** @@ -65,6 +66,14 @@ public class SocialWxSubscribeMessageReqDTO { * 描述: 模板内容,不填则下发空模板 * */ - private List> data; + private List> messages; + + public SocialWxSubscribeMessageReqDTO addData(String key, String value) { + if (messages == null) { + messages = new ArrayList<>(); + } + messages.add(new KeyValue<>(key, value)); + return this; + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http new file mode 100644 index 000000000..b1390a743 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http @@ -0,0 +1,5 @@ +### 请求 /system/social-client/send-subscribe-message 接口 => 发送测试订阅消息 +POST {{baseUrl}}/system/social-client/send-subscribe-message +Authorization: Bearer {{token}} +#Authorization: Bearer test100 +tenant-id: {{adminTenentId}} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java index a029ca29b..f0fc6d836 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; @@ -11,13 +12,12 @@ import cn.iocoder.yudao.module.system.service.social.SocialClientService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 社交客户端") @@ -70,4 +70,16 @@ public class SocialClientController { return success(BeanUtils.toBean(pageResult, SocialClientRespVO.class)); } + //======================= TODO 测试发送订阅消息 ======================= + + @PostMapping("/send-subscribe-message") + public void testSendSubscribeMessage() { + SocialWxSubscribeMessageReqDTO reqDTO = new SocialWxSubscribeMessageReqDTO().setLang("zh_CN") + .setMiniprogramState("developer").setTemplateId("W4ybDTIwCfKHtMKR7fSfx83DtmVKEeXQo3Ti7GCw4_4") + .setToUser("oKNkb4xxw2H135-MVPKtEMkumK08"); + reqDTO.addData("character_string1", "11111111").addData("amount2", "6666").addData("time3", "2024-01-01 10:10:10") + .addData("phrase4", "成功"); + socialClientService.sendSubscribeMessage(reqDTO); + } + } 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 9e05f3a23..7f793f27e 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 @@ -278,7 +278,7 @@ public class SocialClientServiceImpl implements SocialClientService { try { WxMaSubscribeService subscribeService = service.getSubscribeService(); WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class); - reqDTO.getData().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue()))); + reqDTO.getMessages().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue()))); subscribeService.sendSubscribeMsg(message); }catch (WxErrorException e) { log.error("[sendSubscribeMessage][发送小程序订阅消息]", e); From 7f87f26f3a09fbcba5dfca7fa51af9362605aa13 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 24 Jul 2024 19:30:28 +0800 Subject: [PATCH 012/182] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E3=80=91SYSTEM=EF=BC=9A=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/trade/enums/MessageTemplateConstants.java | 3 +++ .../app/social/AppSocialUserController.java | 8 +++----- .../social/vo/AppSocialWxSubscribeTemplateRespVO.java | 11 +++++++---- .../module/system/api/social/SocialClientApi.java | 2 +- .../social/dto/SocialWxSubscribeMessageReqDTO.java | 3 +++ .../social/dto/SocialWxSubscribeTemplateRespDTO.java | 7 ++++++- .../admin/socail/SocialClientController.java | 1 + .../system/service/social/SocialClientService.java | 2 +- .../service/social/SocialClientServiceImpl.java | 8 ++++++-- 9 files changed, 31 insertions(+), 14 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java index 727598636..d6ab00f03 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java @@ -15,7 +15,10 @@ public interface MessageTemplateConstants { //======================= 订阅消息模版 ======================= + // TODO @puhui999:建议 TRADE_AFTER_SALE_CHANGE String ORDER_AFTERSALE_CHANGE = "售后进度通知"; + + // TODO @puhui999:是不是改成 PAY_WALLET_CHANGE 放在 PAY 模块 String MONEY_CHANGE = "充值成功通知"; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java index 326460fe8..da5536989 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java @@ -8,10 +8,7 @@ import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.module.member.controller.app.social.vo.*; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.*; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -74,7 +71,8 @@ public class AppSocialUserController { @GetMapping("/get-subscribe-template") @Operation(summary = "获得微信小程订阅模板") public CommonResult> getSubscribeTemplate() { - return success(BeanUtils.toBean(socialClientApi.getSubscribeTemplate(), AppSocialWxSubscribeTemplateRespVO.class)); + List template = socialClientApi.getSubscribeTemplate(); + return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java index 2aad4fdda..095d39d93 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java @@ -7,19 +7,22 @@ import lombok.Data; @Data public class AppSocialWxSubscribeTemplateRespVO { - @Schema(description = "添加至账号下的模板 id,发送小程序订阅消息时所需", requiredMode = Schema.RequiredMode.REQUIRED, example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU") + // TODO @puhui999:是不是使用 id 作为字段,更干净些哈; + @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, + example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU") private String priTmplId; @Schema(description = "模版标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单支付通知") private String title; - @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, + example = "{ {result.DATA} }\\n\\n领奖金额:{ {withdrawMoney.DATA} }\\n领奖时间: { {withdrawTime.DATA} }") private String content; @Schema(description = "模板内容示例", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单时间:2016年8月8日") private String example; - @Schema(description = "模版类型,2 为一次性订阅,3 为长期订阅", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer type; + @Schema(description = "模版类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private Integer type; // 2 为一次性订阅,3 为长期订阅 } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java index 3a91c92a4..ca65d0486 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java @@ -57,7 +57,7 @@ public interface SocialClientApi { List getSubscribeTemplate(); /** - * 发送订阅消息 + * 发送微信小程序订阅消息 * * @param reqDTO 请求 */ diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java index 4f7ecd7a0..5fb13b952 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import java.util.ArrayList; import java.util.List; +// TODO @puhui99:1)参考 SocialWxQrcodeReqDTO,可以 @see 文档。这样,注释会更见见一点。2)是不是少了 Send:SocialWxSubscribeMessageSendReqDTO /** * 微信小程序订阅消息 Request DTO * @@ -14,6 +15,7 @@ import java.util.List; @Data public class SocialWxSubscribeMessageReqDTO { + // TODO @puhui999:参数校验 /** * 接收者(用户)的 openid. *
@@ -58,6 +60,7 @@ public class SocialWxSubscribeMessageReqDTO {
      */
     private String lang;
 
+    // TODO @puhui999:是必须 List>,还是 Map
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java
index 5959f5b14..69cc4e62e 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java
@@ -11,6 +11,7 @@ import lombok.Data;
 @Data
 public class SocialWxSubscribeTemplateRespDTO {
 
+    // TODO @puhui999:建议搞成 id
     /**
      * 添加至账号下的模板 id,发送小程序订阅消息时所需
      */
@@ -31,8 +32,12 @@ public class SocialWxSubscribeTemplateRespDTO {
      */
     private String example;
 
+    // TODO @puhui999:这个在 wxjava 里面,有枚举字段么?
     /**
-     * 模版类型,2 为一次性订阅,3 为长期订阅
+     * 模版类型
+     *
+     * 2 为一次性订阅
+     * 3 为长期订阅
      */
     private Integer type;
 
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
index f0fc6d836..6ff6aff7c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
@@ -72,6 +72,7 @@ public class SocialClientController {
 
     //======================= TODO 测试发送订阅消息 =======================
 
+    // TODO @puhui999:这个接口,其实可以留着。然后把参数挪到 .http 文件。先直接用 SocialWxSubscribeMessageReqDTO 接参数
     @PostMapping("/send-subscribe-message")
     public void testSendSubscribeMessage() {
         SocialWxSubscribeMessageReqDTO reqDTO = new SocialWxSubscribeMessageReqDTO().setLang("zh_CN")
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 2f58732bb..0fe4adf20 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
@@ -81,7 +81,7 @@ public interface SocialClientService {
     List getSubscribeTemplate();
 
     /**
-     * 发送订阅消息
+     * 发送微信小程序订阅消息
      *
      * @param reqDTO 请求
      */
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 7f793f27e..34fd83136 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
@@ -236,6 +236,7 @@ public class SocialClientServiceImpl implements SocialClientService {
         try {
             return service.getUserService().getPhoneNoInfo(phoneCode);
         } catch (WxErrorException e) {
+            // TODO @puhui999:这里的日志,reqDTO 要打进去
             log.error("[getPhoneNoInfo][userType({}) phoneCode({}) 获得手机号失败]", userType, phoneCode, e);
             throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR);
         }
@@ -262,11 +263,12 @@ public class SocialClientServiceImpl implements SocialClientService {
 
     @Override
     public List getSubscribeTemplate() {
+        // TODO @puhui999:这个 userType 最好通过参数,传递过来;然后这个方法名,貌似叫 getSubscribeTemplateList 更合适哈;
         WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
         try {
             WxMaSubscribeService subscribeService = service.getSubscribeService();
             return subscribeService.getTemplateList();
-        }catch (WxErrorException e) {
+        } catch (WxErrorException e) {
             log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e);
             throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR);
         }
@@ -274,13 +276,15 @@ public class SocialClientServiceImpl implements SocialClientService {
 
     @Override
     public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) {
+        // TODO @puhui999:这个 userType 最好通过参数,
         WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
         try {
             WxMaSubscribeService subscribeService = service.getSubscribeService();
             WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class);
             reqDTO.getMessages().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue())));
             subscribeService.sendSubscribeMsg(message);
-        }catch (WxErrorException e) {
+        } catch (WxErrorException e) {
+            // TODO @puhui999:这里的日志,reqDTO 要打进去
             log.error("[sendSubscribeMessage][发送小程序订阅消息]", e);
             throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR);
         }

From 469610521054d9b38bc78221a5b07fd7ca1ffb75 Mon Sep 17 00:00:00 2001
From: puhui999 
Date: Thu, 25 Jul 2024 17:37:50 +0800
Subject: [PATCH 013/182] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91SYS?=
 =?UTF-8?q?TEM:=20=E6=A0=B9=E6=8D=AE=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?=
 =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E8=AE=A2?=
 =?UTF-8?q?=E9=98=85=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../trade/enums/MessageTemplateConstants.java |  8 ++---
 .../app/social/AppSocialUserController.java   |  8 ++---
 .../AppSocialWxSubscribeTemplateRespVO.java   |  3 +-
 .../pay/enums/MessageTemplateConstants.java   | 15 +++++++++
 .../system/api/social/SocialClientApi.java    |  4 +--
 ...> SocialWxSubscribeMessageSendReqDTO.java} | 26 ++++++++-------
 .../dto/SocialWxSubscribeTemplateRespDTO.java |  5 ++-
 .../api/social/SocialClientApiImpl.java       | 11 ++++---
 .../admin/socail/SocialClientController.http  | 14 ++++++++
 .../admin/socail/SocialClientController.java  | 13 +++-----
 .../convert/social/SocialUserConvert.java     | 32 +++++++++++++++++++
 .../service/social/SocialClientService.java   |  6 ++--
 .../social/SocialClientServiceImpl.java       | 26 ++++++---------
 13 files changed, 109 insertions(+), 62 deletions(-)
 create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
 rename yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/{SocialWxSubscribeMessageReqDTO.java => SocialWxSubscribeMessageSendReqDTO.java} (67%)

diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
index d6ab00f03..c9e20cbe0 100644
--- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
@@ -13,12 +13,8 @@ public interface MessageTemplateConstants {
     String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过)
     String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过)
 
-    //======================= 订阅消息模版 =======================
+    //======================= 小程序订阅消息模版 =======================
 
-    // TODO @puhui999:建议 TRADE_AFTER_SALE_CHANGE
-    String ORDER_AFTERSALE_CHANGE = "售后进度通知";
-
-    // TODO @puhui999:是不是改成 PAY_WALLET_CHANGE 放在 PAY 模块
-    String MONEY_CHANGE = "充值成功通知";
+    String TRADE_AFTER_SALE_CHANGE = "售后进度通知";
 
 }
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
index da5536989..b3b045171 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
@@ -68,10 +68,10 @@ public class AppSocialUserController {
         return success(Base64.encode(wxQrcode));
     }
 
-    @GetMapping("/get-subscribe-template")
-    @Operation(summary = "获得微信小程订阅模板")
-    public CommonResult> getSubscribeTemplate() {
-        List template = socialClientApi.getSubscribeTemplate();
+    @GetMapping("/get-subscribe-template-list")
+    @Operation(summary = "获得微信小程订阅模板列表")
+    public CommonResult> getSubscribeTemplateList() {
+        List template = socialClientApi.getSubscribeTemplateList(UserTypeEnum.MEMBER.getValue());
         return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class));
     }
 
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java
index 095d39d93..3fdc38b69 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java
@@ -7,10 +7,9 @@ import lombok.Data;
 @Data
 public class AppSocialWxSubscribeTemplateRespVO {
 
-    // TODO @puhui999:是不是使用 id 作为字段,更干净些哈;
     @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED,
             example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU")
-    private String priTmplId;
+    private String id;
 
     @Schema(description = "模版标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单支付通知")
     private String title;
diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
new file mode 100644
index 000000000..f6b727aef
--- /dev/null
+++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
@@ -0,0 +1,15 @@
+package cn.iocoder.yudao.module.pay.enums;
+
+// TODO @芋艿:枚举
+/**
+ * 通知模板枚举类
+ *
+ * @author HUIHUI
+ */
+public interface MessageTemplateConstants {
+
+    //======================= 小程序订阅消息 =======================
+
+    String PAY_WALLET_CHANGE = "充值成功通知";
+
+}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
index ca65d0486..a75c398a7 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
@@ -54,13 +54,13 @@ public interface SocialClientApi {
      *
      * @return 小程序订阅消息模版
      */
-    List getSubscribeTemplate();
+    List getSubscribeTemplateList(Integer userType);
 
     /**
      * 发送微信小程序订阅消息
      *
      * @param reqDTO 请求
      */
-    void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO);
+    void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, Integer userType);
 
 }
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageSendReqDTO.java
similarity index 67%
rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java
rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageSendReqDTO.java
index 5fb13b952..069864272 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageReqDTO.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeMessageSendReqDTO.java
@@ -1,21 +1,20 @@
 package cn.iocoder.yudao.module.system.api.social.dto;
 
-import cn.iocoder.yudao.framework.common.core.KeyValue;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 
-// TODO @puhui99:1)参考 SocialWxQrcodeReqDTO,可以 @see 文档。这样,注释会更见见一点。2)是不是少了 Send:SocialWxSubscribeMessageSendReqDTO
 /**
- * 微信小程序订阅消息 Request DTO
+ * 微信小程序订阅消息发送 Request DTO
  *
+ * @see 接口文档
  * @author HUIHUI
  */
 @Data
-public class SocialWxSubscribeMessageReqDTO {
+public class SocialWxSubscribeMessageSendReqDTO {
 
-    // TODO @puhui999:参数校验
     /**
      * 接收者(用户)的 openid.
      * 
@@ -24,6 +23,7 @@ public class SocialWxSubscribeMessageReqDTO {
      * 描述: 接收者(用户)的 openid
      * 
*/ + @NotNull(message = "接收者(用户)的 openid不能为空") private String toUser; /** @@ -34,6 +34,7 @@ public class SocialWxSubscribeMessageReqDTO { * 描述: 所需下发的模板消息的id *
*/ + @NotNull(message = "模板消息的id不能为空") private String templateId; /** @@ -51,6 +52,7 @@ public class SocialWxSubscribeMessageReqDTO { * * 枚举 WxMaConstants.MiniProgramState */ + @NotNull(message = "跳转小程序类型不能为空") private String miniprogramState; /** @@ -58,9 +60,9 @@ public class SocialWxSubscribeMessageReqDTO { * * 枚举 WxMaConstants.MiniProgramLang */ + @NotNull(message = "进入小程序查看的语言类型不能为空") private String lang; - // TODO @puhui999:是必须 List>,还是 Map @@ -69,13 +71,13 @@ public class SocialWxSubscribeMessageReqDTO { * 描述: 模板内容,不填则下发空模板 * */ - private List> messages; + private Map messages; - public SocialWxSubscribeMessageReqDTO addData(String key, String value) { + public SocialWxSubscribeMessageSendReqDTO addData(String key, String value) { if (messages == null) { - messages = new ArrayList<>(); + messages = new HashMap<>(); } - messages.add(new KeyValue<>(key, value)); + messages.put(key, value); return this; } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java index 69cc4e62e..0802ca9ac 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxSubscribeTemplateRespDTO.java @@ -11,11 +11,10 @@ import lombok.Data; @Data public class SocialWxSubscribeTemplateRespDTO { - // TODO @puhui999:建议搞成 id /** * 添加至账号下的模板 id,发送小程序订阅消息时所需 */ - private String priTmplId; + private String id; /** * 模版标题 @@ -32,7 +31,7 @@ public class SocialWxSubscribeTemplateRespDTO { */ private String example; - // TODO @puhui999:这个在 wxjava 里面,有枚举字段么? + // TODO @puhui999:这个在 wxjava 里面,有枚举字段么?没得🤣 /** * 模版类型 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java index 1656524a7..77d676d96 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.social; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.*; +import cn.iocoder.yudao.module.system.convert.social.SocialUserConvert; import cn.iocoder.yudao.module.system.service.social.SocialClientService; import jakarta.annotation.Resource; import me.chanjar.weixin.common.bean.WxJsapiSignature; @@ -47,14 +48,14 @@ public class SocialClientApiImpl implements SocialClientApi { } @Override - public List getSubscribeTemplate() { - List subscribeTemplate = socialClientService.getSubscribeTemplate(); - return BeanUtils.toBean(subscribeTemplate, SocialWxSubscribeTemplateRespDTO.class); + public List getSubscribeTemplateList(Integer userType) { + List subscribeTemplate = socialClientService.getSubscribeTemplateList(userType); + return SocialUserConvert.INSTANCE.convertList(subscribeTemplate); } @Override - public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) { - socialClientService.sendSubscribeMessage(reqDTO); + public void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, Integer userType) { + socialClientService.sendSubscribeMessage(reqDTO, userType); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http index b1390a743..b4ba43a09 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.http @@ -1,5 +1,19 @@ ### 请求 /system/social-client/send-subscribe-message 接口 => 发送测试订阅消息 POST {{baseUrl}}/system/social-client/send-subscribe-message Authorization: Bearer {{token}} +Content-Type: application/json #Authorization: Bearer test100 tenant-id: {{adminTenentId}} + +{ + "toUser": "oKNkb4xxw2H135-MVPKtEMkumK08", + "templateId": "W4ybDTIwCfKHtMKR7fSfx83DtmVKEeXQo3Ti7GCw4_4", + "miniprogramState": "developer", + "lang": "zh_CN", + "messages": { + "character_string1":"5616122165165", + "amount2":"1000.00", + "time3":"2024-01-01 10:10:10", + "phrase4":"成功" + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java index 6ff6aff7c..e7b7c5511 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java @@ -1,9 +1,10 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; @@ -72,15 +73,9 @@ public class SocialClientController { //======================= TODO 测试发送订阅消息 ======================= - // TODO @puhui999:这个接口,其实可以留着。然后把参数挪到 .http 文件。先直接用 SocialWxSubscribeMessageReqDTO 接参数 @PostMapping("/send-subscribe-message") - public void testSendSubscribeMessage() { - SocialWxSubscribeMessageReqDTO reqDTO = new SocialWxSubscribeMessageReqDTO().setLang("zh_CN") - .setMiniprogramState("developer").setTemplateId("W4ybDTIwCfKHtMKR7fSfx83DtmVKEeXQo3Ti7GCw4_4") - .setToUser("oKNkb4xxw2H135-MVPKtEMkumK08"); - reqDTO.addData("character_string1", "11111111").addData("amount2", "6666").addData("time3", "2024-01-01 10:10:10") - .addData("phrase4", "成功"); - socialClientService.sendSubscribeMessage(reqDTO); + public void testSendSubscribeMessage(@RequestBody SocialWxSubscribeMessageSendReqDTO reqDTO) { + socialClientService.sendSubscribeMessage(reqDTO, UserTypeEnum.MEMBER.getValue()); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java index 9e679a242..0eb001282 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java @@ -1,11 +1,23 @@ package cn.iocoder.yudao.module.system.convert.social; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeTemplateRespDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserBindReqVO; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + @Mapper public interface SocialUserConvert { @@ -14,4 +26,24 @@ public interface SocialUserConvert { @Mapping(source = "reqVO.type", target = "socialType") SocialUserBindReqDTO convert(Long userId, Integer userType, SocialUserBindReqVO reqVO); + default WxMaSubscribeMessage convert(SocialWxSubscribeMessageSendReqDTO reqDTO) { + WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class); + Map messages = reqDTO.getMessages(); + if (CollUtil.isNotEmpty(messages)) { + messages.keySet().forEach(key -> { + findAndThen(messages, key, value -> message.addData(new WxMaSubscribeMessage.MsgData(key, value))); + }); + } + return message; + } + + @Mapping(target = "id", source = "priTmplId") + SocialWxSubscribeTemplateRespDTO convert(TemplateInfo templateInfo); + + default List convertList(List subscribeTemplate) { + List list = new ArrayList<>(); + subscribeTemplate.forEach(templateInfo -> list.add(convert(templateInfo))); + return list; + } + } 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 0fe4adf20..5d39680ea 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 @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.service.social; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; @@ -78,14 +78,14 @@ public interface SocialClientService { * * @return 微信小程订阅模板 */ - List getSubscribeTemplate(); + List getSubscribeTemplateList(Integer userType); /** * 发送微信小程序订阅消息 * * @param reqDTO 请求 */ - void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO); + void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, Integer userType); // =================== 客户端管理 =================== 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 34fd83136..ab888b801 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 @@ -4,7 +4,6 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaSubscribeService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; -import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Assert; @@ -17,9 +16,10 @@ import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; import cn.iocoder.yudao.framework.common.util.http.HttpUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; +import cn.iocoder.yudao.module.system.convert.social.SocialUserConvert; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; @@ -236,7 +236,6 @@ public class SocialClientServiceImpl implements SocialClientService { try { return service.getUserService().getPhoneNoInfo(phoneCode); } catch (WxErrorException e) { - // TODO @puhui999:这里的日志,reqDTO 要打进去 log.error("[getPhoneNoInfo][userType({}) phoneCode({}) 获得手机号失败]", userType, phoneCode, e); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR); } @@ -256,36 +255,31 @@ public class SocialClientServiceImpl implements SocialClientService { null, ObjUtil.defaultIfNull(reqVO.getHyaline(), SocialWxQrcodeReqDTO.HYALINE)); } catch (WxErrorException e) { - log.error("[getWxQrcode][reqVO({})) 获得小程序码失败]", reqVO, e); + log.error("[getWxQrcode][reqVO({}) 获得小程序码失败]", reqVO, e); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR); } } @Override - public List getSubscribeTemplate() { - // TODO @puhui999:这个 userType 最好通过参数,传递过来;然后这个方法名,貌似叫 getSubscribeTemplateList 更合适哈; - WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); + public List getSubscribeTemplateList(Integer userType) { + WxMaService service = getWxMaService(userType); try { WxMaSubscribeService subscribeService = service.getSubscribeService(); return subscribeService.getTemplateList(); } catch (WxErrorException e) { - log.error("[getSubscribeTemplate][获得小程序订阅消息模版]", e); + log.error("[getSubscribeTemplate][userType({}) 获得小程序订阅消息模版]", userType, e); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR); } } @Override - public void sendSubscribeMessage(SocialWxSubscribeMessageReqDTO reqDTO) { - // TODO @puhui999:这个 userType 最好通过参数, - WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); + public void sendSubscribeMessage(SocialWxSubscribeMessageSendReqDTO reqDTO, Integer userType) { + WxMaService service = getWxMaService(userType); try { WxMaSubscribeService subscribeService = service.getSubscribeService(); - WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class); - reqDTO.getMessages().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue()))); - subscribeService.sendSubscribeMsg(message); + subscribeService.sendSubscribeMsg(SocialUserConvert.INSTANCE.convert(reqDTO)); } catch (WxErrorException e) { - // TODO @puhui999:这里的日志,reqDTO 要打进去 - log.error("[sendSubscribeMessage][发送小程序订阅消息]", e); + log.error("[sendSubscribeMessage][reqVO({}) userType({}) 发送小程序订阅消息]", reqDTO, userType, e); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR); } } From 6325ff1144678a996b545778c9a0851724fed1c6 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 26 Jul 2024 21:59:44 +0800 Subject: [PATCH 014/182] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=91=E5=85=A8=E5=B1=80=EF=BC=9A=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E7=9A=84=20`tenant=5Fid`=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=A2=9E=E5=8A=A0=20default=200=20=E5=80=BC?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm index b22389b0b..a073fdba1 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS "${table.tableName.toLowerCase()}" ( "${column.columnName}" ${dataType} DEFAULT '', #elseif (${column.columnName} == 'deleted') "deleted" bit NOT NULL DEFAULT FALSE, - #elseif (${column.columnName} == 'tenantId') + #elseif (${column.columnName} == 'tenant_id') "tenant_id" bigint NOT NULL DEFAULT 0, #else "${column.columnName.toLowerCase()}" ${dataType}#if (${column.nullable} == false) NOT NULL#end, From 22ff197f02fde92c7cceead31a1f06809282f2d9 Mon Sep 17 00:00:00 2001 From: scholar <1145227973@qq.com> Date: Fri, 26 Jul 2024 22:06:10 +0800 Subject: [PATCH 015/182] =?UTF-8?q?=E5=AE=8C=E6=88=90todo=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/core/client/impl/HuaweiSmsClient.java | 117 ++++++++++-------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/HuaweiSmsClient.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/HuaweiSmsClient.java index 84bc2645e..4df820861 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/HuaweiSmsClient.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/HuaweiSmsClient.java @@ -2,35 +2,29 @@ package cn.iocoder.yudao.module.system.framework.sms.core.client.impl; import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.HexUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.hutool.json.JSONArray; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.core.KeyValue; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO; import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespDTO; import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties; -import org.apache.http.client.methods.*; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; @@ -38,6 +32,7 @@ import java.util.*; import java.time.LocalDateTime; +import static cn.hutool.crypto.digest.DigestUtil.sha256Hex; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; @@ -55,88 +50,90 @@ public class HuaweiSmsClient extends AbstractSmsClient { /** * 调用成功 code */ - public static final String API_CODE_SUCCESS = "OK"; - private static final Logger LOGGER = LoggerFactory.getLogger(HuaweiSmsClient.class); + public static final String URL = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1";//APP接入地址+接口访问URI + public static final String HOST = "smsapi.cn-north-4.myhuaweicloud.com:443"; + public static final String SIGNEDHEADERS = "content-type;host;x-sdk-date"; + + @Override + protected void doInit() { + + } public HuaweiSmsClient(SmsChannelProperties properties) { super(properties); Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空"); Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空"); } - @Override - protected void doInit() { - } @Override public SmsSendRespDTO sendSms(Long sendLogId, String mobile, String apiTemplateId, List> templateParams) throws Throwable { - String url = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1"; //APP接入地址+接口访问URI // 相比较阿里短信,华为短信发送的时候需要额外的参数“通道号”,考虑到不破坏原有的的结构 // 所以将 通道号 拼接到 apiTemplateId 字段中,格式为 "apiTemplateId 通道号"。空格为分隔符。 String sender = StrUtil.subAfter(apiTemplateId, " ", true); //中国大陆短信签名通道号或全球短信通道号 String templateId = StrUtil.subBefore(apiTemplateId, " ", true); //模板ID - //必填,全局号码格式(包含国家码),示例:+86151****6789,多个号码之间用英文逗号分隔 - String receiver = mobile; //短信接收人号码 - //选填,短信状态报告接收地址,推荐使用域名,为空或者不填表示不接收状态报告 String statusCallBack = properties.getCallbackUrl(); + List templateParas = CollectionUtils.convertList(templateParams, kv -> String.valueOf(kv.getValue())); + + JSONObject JsonResponse = sendSmsRequest(sender,mobile,templateId,templateParas,statusCallBack); + SmsResponse smsResponse = getSmsSendResponse(JsonResponse); + + return new SmsSendRespDTO().setSuccess(smsResponse.success).setApiMsg(smsResponse.data.toString()); + } + + JSONObject sendSmsRequest(String sender,String mobile,String templateId,List templateParas,String statusCallBack) throws UnsupportedEncodingException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ENGLISH); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - String singerDate = sdf.format(new Date()); + String sdkDate = sdf.format(new Date()); // ************* 步骤 1:拼接规范请求串 ************* String httpRequestMethod = "POST"; String canonicalUri = "/sms/batchSendSms/v1/"; String canonicalQueryString = "";//查询参数为空 String canonicalHeaders = "content-type:application/x-www-form-urlencoded\n" - + "host:smsapi.cn-north-4.myhuaweicloud.com:443\n" - + "x-sdk-date:" + singerDate + "\n"; - String signedHeaders = "content-type;host;x-sdk-date"; - /** - * 选填,使用无变量模板时请赋空值 String templateParas = ""; - * 单变量模板示例:模板内容为"您的验证码是${NUM_6}"时,templateParas可填写为"[\"111111\"]" - * 双变量模板示例:模板内容为"您有${NUM_2}件快递请到${TXT_20}领取"时,templateParas可填写为"[\"3\",\"人民公园正门\"]" - */ - List templateParas = new ArrayList<>(); - for (KeyValue kv : templateParams) { - templateParas.add(String.valueOf(kv.getValue())); - } - + + "host:"+ HOST +"\n" + + "x-sdk-date:" + sdkDate + "\n"; //请求Body,不携带签名名称时,signature请填null - String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, null); + String body = buildRequestBody(sender, mobile, templateId, templateParas, statusCallBack, null); if (null == body || body.isEmpty()) { return null; } - String hashedRequestBody = HexUtil.encodeHexStr(DigestUtil.sha256(body)); + String hashedRequestBody = sha256Hex(body); String canonicalRequest = httpRequestMethod + "\n" + canonicalUri + "\n" + canonicalQueryString + "\n" - + canonicalHeaders + "\n" + signedHeaders + "\n" + hashedRequestBody; + + canonicalHeaders + "\n" + SIGNEDHEADERS + "\n" + hashedRequestBody; // ************* 步骤 2:拼接待签名字符串 ************* - String hashedCanonicalRequest = HexUtil.encodeHexStr(DigestUtil.sha256(canonicalRequest)); - String stringToSign = "SDK-HMAC-SHA256" + "\n" + singerDate + "\n" + hashedCanonicalRequest; + String hashedCanonicalRequest = sha256Hex(canonicalRequest); + String stringToSign = "SDK-HMAC-SHA256" + "\n" + sdkDate + "\n" + hashedCanonicalRequest; // ************* 步骤 3:计算签名 ************* String signature = SecureUtil.hmacSha256(properties.getApiSecret()).digestHex(stringToSign); // ************* 步骤 4:拼接 Authorization ************* String authorization = "SDK-HMAC-SHA256" + " " + "Access=" + properties.getApiKey() + ", " - + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature; + + "SignedHeaders=" + SIGNEDHEADERS + ", " + "Signature=" + signature; // ************* 步骤 5:构造HttpRequest 并执行request请求,获得response ************* - HttpUriRequest postMethod = RequestBuilder.post() - .setUri(url) - .setEntity(new StringEntity(body, StandardCharsets.UTF_8)) - .setHeader("Content-Type","application/x-www-form-urlencoded") - .setHeader("X-Sdk-Date",singerDate) - .setHeader("Authorization",authorization) - .build(); - CloseableHttpClient client = HttpClientBuilder.create().build(); - HttpResponse response = client.execute(postMethod); + HttpResponse response = HttpRequest.post(URL) + .header("Content-Type", "application/x-www-form-urlencoded") + .header("X-Sdk-Date", sdkDate) + .header("host",HOST) + .header("Authorization", authorization) + .body(body) + .execute(); - return new SmsSendRespDTO().setSuccess(Objects.equals(response.getStatusLine().getReasonPhrase(), API_CODE_SUCCESS)).setSerialNo(Integer.toString(response.getStatusLine().getStatusCode())) - .setApiRequestId(null).setApiCode(null).setApiMsg(null); + return JSONUtil.parseObj(response.body()); + } + + private SmsResponse getSmsSendResponse(JSONObject resJson) { + SmsResponse smsResponse = new SmsResponse(); + smsResponse.setSuccess("000000".equals(resJson.getStr("code"))); + smsResponse.setData(resJson); + return smsResponse; } static String buildRequestBody(String sender, String receiver, String templateId, List templateParas, @@ -151,7 +148,7 @@ public class HuaweiSmsClient extends AbstractSmsClient { appendToBody(body, "from=", sender); appendToBody(body, "&to=", receiver); appendToBody(body, "&templateId=", templateId); - appendToBody(body, "&templateParas=", new JSONArray(templateParas).toString()); + appendToBody(body, "&templateParas=", JsonUtils.toJsonString(templateParas)); appendToBody(body, "&statusCallback=", statusCallBack); appendToBody(body, "&signature=", signature); return body.toString(); @@ -179,6 +176,22 @@ public class HuaweiSmsClient extends AbstractSmsClient { } + @Data + public static class SmsResponse { + + /** + * 是否成功 + */ + private boolean success; + + /** + * 厂商原返回体 + */ + private Object data; + + } + + /** * 短信接收状态 * From 39c0652c433f5dd766592798f891cec2c64fc04d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 26 Jul 2024 22:08:57 +0800 Subject: [PATCH 016/182] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E5=85=A8=E5=B1=80=EF=BC=9A=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AD=97=E6=AE=B5=E8=BF=87=E5=A4=9A=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=93=8D=E4=BD=9C=E6=A0=8F=E8=AE=BE=E7=BD=AE=20min-wi?= =?UTF-8?q?dth=20=E4=BF=9D=E8=AF=81=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/codegen/vue3/views/index.vue.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index 361d379fa..399b58e34 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -74,7 +74,7 @@ start-placeholder="开始日期" end-placeholder="结束日期" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" - class="!w-240px" + class="!w-220px" /> #end @@ -181,7 +181,7 @@ #end #end #end - +