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 | import org.slf4j.Logger; |
| 7 | 7 | import org.slf4j.LoggerFactory; |
| 8 | 8 | |
| 9 | +// TODO @亚洲:看看是不是可以使用 convert 来做,更符合项目 | |
| 9 | 10 | public abstract class AbstractBuilder { |
| 10 | 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 | 24 | import java.util.Map; |
| 25 | 25 | import java.util.stream.Collectors; |
| 26 | 26 | |
| 27 | +// TODO @芋艿:思考有没更好的处理方式 | |
| 27 | 28 | @Component |
| 28 | 29 | @Slf4j |
| 29 | 30 | public class WxMpConfig implements InitializingBean { |
| ... | ... | @@ -49,6 +50,7 @@ public class WxMpConfig implements InitializingBean { |
| 49 | 50 | |
| 50 | 51 | public static void init(List<WxAccountDO> wxAccountDOS) { |
| 51 | 52 | mpServices = wxAccountDOS.stream().map(wxAccountDO -> { |
| 53 | + // TODO 亚洲:使用 WxMpInMemoryConfigStorage 的话,多节点会不会存在 accessToken 冲突 | |
| 52 | 54 | WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); |
| 53 | 55 | configStorage.setAppId(wxAccountDO.getAppid()); |
| 54 | 56 | configStorage.setSecret(wxAccountDO.getAppsecret()); |
| ... | ... | @@ -60,7 +62,6 @@ public class WxMpConfig implements InitializingBean { |
| 60 | 62 | routers.put(wxAccountDO.getAppid(), newRouter(service)); |
| 61 | 63 | return service; |
| 62 | 64 | }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); |
| 63 | - | |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 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 | 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 | 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 | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 22 | - | |
| 23 | 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 24 | - | |
| 25 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 26 | - | |
| 27 | 7 | import cn.iocoder.yudao.module.wechatMp.controller.admin.account.vo.*; |
| 28 | -import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; | |
| 29 | 8 | import cn.iocoder.yudao.module.wechatMp.convert.account.WxAccountConvert; |
| 9 | +import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; | |
| 30 | 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 | 29 | @Api(tags = "管理后台 - 公众号账户") |
| 33 | 30 | @RestController |
| 34 | 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 | 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 | 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 | 11 | * 公众号账户 DO |
| 10 | 12 | * |
| ... | ... | @@ -33,10 +35,12 @@ public class WxAccountDO extends BaseDO { |
| 33 | 35 | * 公众号账户 |
| 34 | 36 | */ |
| 35 | 37 | private String account; |
| 38 | + // TODO 亚洲:appId | |
| 36 | 39 | /** |
| 37 | - * 公众号appid | |
| 40 | + * 公众号 appid | |
| 38 | 41 | */ |
| 39 | 42 | private String appid; |
| 43 | + // TODO 亚洲:appSecret | |
| 40 | 44 | /** |
| 41 | 45 | * 公众号密钥 |
| 42 | 46 | */ |
| ... | ... | @@ -52,10 +56,12 @@ public class WxAccountDO extends BaseDO { |
| 52 | 56 | /** |
| 53 | 57 | * 加密密钥 |
| 54 | 58 | */ |
| 59 | + // TODO 亚洲:aesKey | |
| 55 | 60 | private String aeskey; |
| 56 | 61 | /** |
| 57 | - * 二维码图片URL | |
| 62 | + * 二维码图片 URL | |
| 58 | 63 | */ |
| 64 | + // TODO 亚洲:qrCodeUrl | |
| 59 | 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 | 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 | 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 | 12 | * 微信公众号粉丝 DO |
| 10 | 13 | * |
| 11 | 14 | * @author 芋道源码 |
| 12 | 15 | */ |
| 16 | +// TODO @亚洲:WxUserDO | |
| 13 | 17 | @TableName("wx_account_fans") |
| 14 | 18 | @KeySequence("wx_account_fans_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 15 | 19 | @Data |
| ... | ... | @@ -32,18 +36,22 @@ public class WxAccountFansDO extends BaseDO { |
| 32 | 36 | /** |
| 33 | 37 | * 订阅状态,0未关注,1已关注 |
| 34 | 38 | */ |
| 39 | + // TODO @亚洲:Integer 然后写个枚举哈 | |
| 35 | 40 | private String subscribeStatus; |
| 36 | 41 | /** |
| 37 | 42 | * 订阅时间 |
| 38 | 43 | */ |
| 44 | + // TODO @亚洲:增加一个取消关注的事件 | |
| 39 | 45 | private Date subscribeTime; |
| 40 | 46 | /** |
| 41 | 47 | * 昵称 |
| 42 | 48 | */ |
| 49 | + // TODO @亚洲:String | |
| 43 | 50 | private byte[] nickname; |
| 44 | 51 | /** |
| 45 | 52 | * 性别,1男,2女,0未知 |
| 46 | 53 | */ |
| 54 | + // TODO @亚洲:Integer | |
| 47 | 55 | private String gender; |
| 48 | 56 | /** |
| 49 | 57 | * 语言 |
| ... | ... | @@ -64,17 +72,20 @@ public class WxAccountFansDO extends BaseDO { |
| 64 | 72 | /** |
| 65 | 73 | * 头像地址 |
| 66 | 74 | */ |
| 75 | + // TODO @亚洲:headImageUrl | |
| 67 | 76 | private String headimgUrl; |
| 68 | 77 | /** |
| 69 | 78 | * 备注 |
| 70 | 79 | */ |
| 71 | 80 | private String remark; |
| 81 | + | |
| 82 | + // TODO @亚洲:是不是只要存储 WxAccountDO 的 id 呀? | |
| 72 | 83 | /** |
| 73 | - * 微信公众号ID | |
| 84 | + * 微信公众号 ID | |
| 74 | 85 | */ |
| 75 | 86 | private String wxAccountId; |
| 76 | 87 | /** |
| 77 | - * 微信公众号appid | |
| 88 | + * 微信公众号 appid | |
| 78 | 89 | */ |
| 79 | 90 | private String wxAccountAppid; |
| 80 | 91 | ... | ... |