Commit fabf9693bfb7df995ffa466859df65af394a4cdd
1 parent
36e0ed18
code review 公众号的实现
Showing
5 changed files
with
49 additions
and
33 deletions
yudao-module-wechat-mp/yudao-module-wechat-mp-biz/src/main/java/cn/iocoder/yudao/module/wechatMp/builder/AbstractBuilder.java
| @@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | @@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||
| 6 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 8 | 8 | ||
| 9 | +// TODO @亚洲:看看是不是可以使用 convert 来做,更符合项目 | ||
| 9 | public abstract class AbstractBuilder { | 10 | public abstract class AbstractBuilder { |
| 10 | protected final Logger logger = LoggerFactory.getLogger(getClass()); | 11 | protected final Logger logger = LoggerFactory.getLogger(getClass()); |
| 11 | 12 |
yudao-module-wechat-mp/yudao-module-wechat-mp-biz/src/main/java/cn/iocoder/yudao/module/wechatMp/config/WxMpConfig.java
| @@ -24,6 +24,7 @@ import java.util.List; | @@ -24,6 +24,7 @@ import java.util.List; | ||
| 24 | import java.util.Map; | 24 | import java.util.Map; |
| 25 | import java.util.stream.Collectors; | 25 | import java.util.stream.Collectors; |
| 26 | 26 | ||
| 27 | +// TODO @芋艿:思考有没更好的处理方式 | ||
| 27 | @Component | 28 | @Component |
| 28 | @Slf4j | 29 | @Slf4j |
| 29 | public class WxMpConfig implements InitializingBean { | 30 | public class WxMpConfig implements InitializingBean { |
| @@ -49,6 +50,7 @@ public class WxMpConfig implements InitializingBean { | @@ -49,6 +50,7 @@ public class WxMpConfig implements InitializingBean { | ||
| 49 | 50 | ||
| 50 | public static void init(List<WxAccountDO> wxAccountDOS) { | 51 | public static void init(List<WxAccountDO> wxAccountDOS) { |
| 51 | mpServices = wxAccountDOS.stream().map(wxAccountDO -> { | 52 | mpServices = wxAccountDOS.stream().map(wxAccountDO -> { |
| 53 | + // TODO 亚洲:使用 WxMpInMemoryConfigStorage 的话,多节点会不会存在 accessToken 冲突 | ||
| 52 | WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); | 54 | WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); |
| 53 | configStorage.setAppId(wxAccountDO.getAppid()); | 55 | configStorage.setAppId(wxAccountDO.getAppid()); |
| 54 | configStorage.setSecret(wxAccountDO.getAppsecret()); | 56 | configStorage.setSecret(wxAccountDO.getAppsecret()); |
| @@ -60,7 +62,6 @@ public class WxMpConfig implements InitializingBean { | @@ -60,7 +62,6 @@ public class WxMpConfig implements InitializingBean { | ||
| 60 | routers.put(wxAccountDO.getAppid(), newRouter(service)); | 62 | routers.put(wxAccountDO.getAppid(), newRouter(service)); |
| 61 | return service; | 63 | return service; |
| 62 | }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); | 64 | }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); |
| 63 | - | ||
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | public static Map<String, WxMpMessageRouter> getRouters() { | 67 | public static Map<String, WxMpMessageRouter> getRouters() { |
yudao-module-wechat-mp/yudao-module-wechat-mp-biz/src/main/java/cn/iocoder/yudao/module/wechatMp/controller/admin/account/WxAccountController.java
| 1 | package cn.iocoder.yudao.module.wechatMp.controller.admin.account; | 1 | package cn.iocoder.yudao.module.wechatMp.controller.admin.account; |
| 2 | 2 | ||
| 3 | -import org.springframework.web.bind.annotation.*; | ||
| 4 | - | ||
| 5 | -import javax.annotation.Resource; | ||
| 6 | - | ||
| 7 | -import org.springframework.validation.annotation.Validated; | ||
| 8 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 9 | -import io.swagger.annotations.*; | ||
| 10 | - | ||
| 11 | -import javax.validation.*; | ||
| 12 | -import javax.servlet.http.*; | ||
| 13 | -import java.util.*; | ||
| 14 | -import java.io.IOException; | ||
| 15 | - | ||
| 16 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 18 | - | ||
| 19 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 20 | - | 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 21 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 22 | - | ||
| 23 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 24 | - | ||
| 25 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 26 | - | ||
| 27 | import cn.iocoder.yudao.module.wechatMp.controller.admin.account.vo.*; | 7 | import cn.iocoder.yudao.module.wechatMp.controller.admin.account.vo.*; |
| 28 | -import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; | ||
| 29 | import cn.iocoder.yudao.module.wechatMp.convert.account.WxAccountConvert; | 8 | import cn.iocoder.yudao.module.wechatMp.convert.account.WxAccountConvert; |
| 9 | +import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; | ||
| 30 | import cn.iocoder.yudao.module.wechatMp.service.account.WxAccountService; | 10 | import cn.iocoder.yudao.module.wechatMp.service.account.WxAccountService; |
| 11 | +import io.swagger.annotations.Api; | ||
| 12 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 13 | +import io.swagger.annotations.ApiOperation; | ||
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.web.bind.annotation.*; | ||
| 17 | + | ||
| 18 | +import javax.annotation.Resource; | ||
| 19 | +import javax.servlet.http.HttpServletResponse; | ||
| 20 | +import javax.validation.Valid; | ||
| 21 | +import java.io.IOException; | ||
| 22 | +import java.util.Collection; | ||
| 23 | +import java.util.List; | ||
| 24 | + | ||
| 25 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 26 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 31 | 27 | ||
| 28 | +// TODO @亚洲:/mp/account 即可 | ||
| 32 | @Api(tags = "管理后台 - 公众号账户") | 29 | @Api(tags = "管理后台 - 公众号账户") |
| 33 | @RestController | 30 | @RestController |
| 34 | @RequestMapping("/wechatMp/wx-account") | 31 | @RequestMapping("/wechatMp/wx-account") |
yudao-module-wechat-mp/yudao-module-wechat-mp-biz/src/main/java/cn/iocoder/yudao/module/wechatMp/dal/dataobject/account/WxAccountDO.java
| 1 | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.account; | 1 | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.account; |
| 2 | 2 | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 6 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 7 | 8 | ||
| 9 | +// TODO 亚洲:这个模块的相关类,使用 Mp 作为前缀哈 | ||
| 8 | /** | 10 | /** |
| 9 | * 公众号账户 DO | 11 | * 公众号账户 DO |
| 10 | * | 12 | * |
| @@ -33,10 +35,12 @@ public class WxAccountDO extends BaseDO { | @@ -33,10 +35,12 @@ public class WxAccountDO extends BaseDO { | ||
| 33 | * 公众号账户 | 35 | * 公众号账户 |
| 34 | */ | 36 | */ |
| 35 | private String account; | 37 | private String account; |
| 38 | + // TODO 亚洲:appId | ||
| 36 | /** | 39 | /** |
| 37 | - * 公众号appid | 40 | + * 公众号 appid |
| 38 | */ | 41 | */ |
| 39 | private String appid; | 42 | private String appid; |
| 43 | + // TODO 亚洲:appSecret | ||
| 40 | /** | 44 | /** |
| 41 | * 公众号密钥 | 45 | * 公众号密钥 |
| 42 | */ | 46 | */ |
| @@ -52,10 +56,12 @@ public class WxAccountDO extends BaseDO { | @@ -52,10 +56,12 @@ public class WxAccountDO extends BaseDO { | ||
| 52 | /** | 56 | /** |
| 53 | * 加密密钥 | 57 | * 加密密钥 |
| 54 | */ | 58 | */ |
| 59 | + // TODO 亚洲:aesKey | ||
| 55 | private String aeskey; | 60 | private String aeskey; |
| 56 | /** | 61 | /** |
| 57 | - * 二维码图片URL | 62 | + * 二维码图片 URL |
| 58 | */ | 63 | */ |
| 64 | + // TODO 亚洲:qrCodeUrl | ||
| 59 | private String qrUrl; | 65 | private String qrUrl; |
| 60 | /** | 66 | /** |
| 61 | * 备注 | 67 | * 备注 |
yudao-module-wechat-mp/yudao-module-wechat-mp-biz/src/main/java/cn/iocoder/yudao/module/wechatMp/dal/dataobject/accountfans/WxAccountFansDO.java
| 1 | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.accountfans; | 1 | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.accountfans; |
| 2 | 2 | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 6 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +import java.util.Date; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | * 微信公众号粉丝 DO | 12 | * 微信公众号粉丝 DO |
| 10 | * | 13 | * |
| 11 | * @author 芋道源码 | 14 | * @author 芋道源码 |
| 12 | */ | 15 | */ |
| 16 | +// TODO @亚洲:WxUserDO | ||
| 13 | @TableName("wx_account_fans") | 17 | @TableName("wx_account_fans") |
| 14 | @KeySequence("wx_account_fans_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | 18 | @KeySequence("wx_account_fans_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 15 | @Data | 19 | @Data |
| @@ -32,18 +36,22 @@ public class WxAccountFansDO extends BaseDO { | @@ -32,18 +36,22 @@ public class WxAccountFansDO extends BaseDO { | ||
| 32 | /** | 36 | /** |
| 33 | * 订阅状态,0未关注,1已关注 | 37 | * 订阅状态,0未关注,1已关注 |
| 34 | */ | 38 | */ |
| 39 | + // TODO @亚洲:Integer 然后写个枚举哈 | ||
| 35 | private String subscribeStatus; | 40 | private String subscribeStatus; |
| 36 | /** | 41 | /** |
| 37 | * 订阅时间 | 42 | * 订阅时间 |
| 38 | */ | 43 | */ |
| 44 | + // TODO @亚洲:增加一个取消关注的事件 | ||
| 39 | private Date subscribeTime; | 45 | private Date subscribeTime; |
| 40 | /** | 46 | /** |
| 41 | * 昵称 | 47 | * 昵称 |
| 42 | */ | 48 | */ |
| 49 | + // TODO @亚洲:String | ||
| 43 | private byte[] nickname; | 50 | private byte[] nickname; |
| 44 | /** | 51 | /** |
| 45 | * 性别,1男,2女,0未知 | 52 | * 性别,1男,2女,0未知 |
| 46 | */ | 53 | */ |
| 54 | + // TODO @亚洲:Integer | ||
| 47 | private String gender; | 55 | private String gender; |
| 48 | /** | 56 | /** |
| 49 | * 语言 | 57 | * 语言 |
| @@ -64,17 +72,20 @@ public class WxAccountFansDO extends BaseDO { | @@ -64,17 +72,20 @@ public class WxAccountFansDO extends BaseDO { | ||
| 64 | /** | 72 | /** |
| 65 | * 头像地址 | 73 | * 头像地址 |
| 66 | */ | 74 | */ |
| 75 | + // TODO @亚洲:headImageUrl | ||
| 67 | private String headimgUrl; | 76 | private String headimgUrl; |
| 68 | /** | 77 | /** |
| 69 | * 备注 | 78 | * 备注 |
| 70 | */ | 79 | */ |
| 71 | private String remark; | 80 | private String remark; |
| 81 | + | ||
| 82 | + // TODO @亚洲:是不是只要存储 WxAccountDO 的 id 呀? | ||
| 72 | /** | 83 | /** |
| 73 | - * 微信公众号ID | 84 | + * 微信公众号 ID |
| 74 | */ | 85 | */ |
| 75 | private String wxAccountId; | 86 | private String wxAccountId; |
| 76 | /** | 87 | /** |
| 77 | - * 微信公众号appid | 88 | + * 微信公众号 appid |
| 78 | */ | 89 | */ |
| 79 | private String wxAccountAppid; | 90 | private String wxAccountAppid; |
| 80 | 91 |