mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-30 01:38:43 +08:00 
			
		
		
		
	code review 公众号的实现
This commit is contained in:
		| @@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | |||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
|  | // TODO @亚洲:看看是不是可以使用 convert 来做,更符合项目 | ||||||
| public abstract class AbstractBuilder { | public abstract class AbstractBuilder { | ||||||
|     protected final Logger logger = LoggerFactory.getLogger(getClass()); |     protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ import java.util.List; | |||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||||
|  |  | ||||||
|  | // TODO @芋艿:思考有没更好的处理方式 | ||||||
| @Component | @Component | ||||||
| @Slf4j | @Slf4j | ||||||
| public class WxMpConfig implements InitializingBean { | public class WxMpConfig implements InitializingBean { | ||||||
| @@ -49,6 +50,7 @@ public class WxMpConfig implements InitializingBean { | |||||||
|  |  | ||||||
|     public static void init(List<WxAccountDO> wxAccountDOS) { |     public static void init(List<WxAccountDO> wxAccountDOS) { | ||||||
|         mpServices = wxAccountDOS.stream().map(wxAccountDO -> { |         mpServices = wxAccountDOS.stream().map(wxAccountDO -> { | ||||||
|  |             // TODO 亚洲:使用 WxMpInMemoryConfigStorage 的话,多节点会不会存在 accessToken 冲突 | ||||||
|             WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); |             WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); | ||||||
|             configStorage.setAppId(wxAccountDO.getAppid()); |             configStorage.setAppId(wxAccountDO.getAppid()); | ||||||
|             configStorage.setSecret(wxAccountDO.getAppsecret()); |             configStorage.setSecret(wxAccountDO.getAppsecret()); | ||||||
| @@ -60,7 +62,6 @@ public class WxMpConfig implements InitializingBean { | |||||||
|             routers.put(wxAccountDO.getAppid(), newRouter(service)); |             routers.put(wxAccountDO.getAppid(), newRouter(service)); | ||||||
|             return service; |             return service; | ||||||
|         }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); |         }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Map<String, WxMpMessageRouter> getRouters() { |     public static Map<String, WxMpMessageRouter> getRouters() { | ||||||
|   | |||||||
| @@ -1,34 +1,31 @@ | |||||||
| package cn.iocoder.yudao.module.wechatMp.controller.admin.account; | package cn.iocoder.yudao.module.wechatMp.controller.admin.account; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||||
|  | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||||
|  | import cn.iocoder.yudao.module.wechatMp.controller.admin.account.vo.*; | ||||||
|  | import cn.iocoder.yudao.module.wechatMp.convert.account.WxAccountConvert; | ||||||
|  | import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; | ||||||
|  | import cn.iocoder.yudao.module.wechatMp.service.account.WxAccountService; | ||||||
|  | import io.swagger.annotations.Api; | ||||||
|  | import io.swagger.annotations.ApiImplicitParam; | ||||||
|  | import io.swagger.annotations.ApiOperation; | ||||||
|  | import org.springframework.security.access.prepost.PreAuthorize; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||||
|  |  | ||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
|  | import javax.servlet.http.HttpServletResponse; | ||||||
| import org.springframework.validation.annotation.Validated; | import javax.validation.Valid; | ||||||
| import org.springframework.security.access.prepost.PreAuthorize; |  | ||||||
| import io.swagger.annotations.*; |  | ||||||
|  |  | ||||||
| import javax.validation.*; |  | ||||||
| import javax.servlet.http.*; |  | ||||||
| import java.util.*; |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.util.Collection; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import java.util.List; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
|  | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | // TODO @亚洲:/mp/account 即可 | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.module.wechatMp.controller.admin.account.vo.*; |  | ||||||
| import cn.iocoder.yudao.module.wechatMp.dal.dataobject.account.WxAccountDO; |  | ||||||
| import cn.iocoder.yudao.module.wechatMp.convert.account.WxAccountConvert; |  | ||||||
| import cn.iocoder.yudao.module.wechatMp.service.account.WxAccountService; |  | ||||||
|  |  | ||||||
| @Api(tags = "管理后台 - 公众号账户") | @Api(tags = "管理后台 - 公众号账户") | ||||||
| @RestController | @RestController | ||||||
| @RequestMapping("/wechatMp/wx-account") | @RequestMapping("/wechatMp/wx-account") | ||||||
|   | |||||||
| @@ -1,10 +1,12 @@ | |||||||
| package cn.iocoder.yudao.module.wechatMp.dal.dataobject.account; | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.account; | ||||||
|  |  | ||||||
| import lombok.*; |  | ||||||
| import java.util.*; |  | ||||||
| import com.baomidou.mybatisplus.annotation.*; |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||||
|  | import com.baomidou.mybatisplus.annotation.KeySequence; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
|  | import lombok.*; | ||||||
|  |  | ||||||
|  | // TODO 亚洲:这个模块的相关类,使用 Mp 作为前缀哈 | ||||||
| /** | /** | ||||||
|  * 公众号账户 DO |  * 公众号账户 DO | ||||||
|  * |  * | ||||||
| @@ -33,10 +35,12 @@ public class WxAccountDO extends BaseDO { | |||||||
|      * 公众号账户 |      * 公众号账户 | ||||||
|      */ |      */ | ||||||
|     private String account; |     private String account; | ||||||
|  |     // TODO 亚洲:appId | ||||||
|     /** |     /** | ||||||
|      * 公众号 appid |      * 公众号 appid | ||||||
|      */ |      */ | ||||||
|     private String appid; |     private String appid; | ||||||
|  |     // TODO 亚洲:appSecret | ||||||
|     /** |     /** | ||||||
|      * 公众号密钥 |      * 公众号密钥 | ||||||
|      */ |      */ | ||||||
| @@ -52,10 +56,12 @@ public class WxAccountDO extends BaseDO { | |||||||
|     /** |     /** | ||||||
|      * 加密密钥 |      * 加密密钥 | ||||||
|      */ |      */ | ||||||
|  |     // TODO 亚洲:aesKey | ||||||
|     private String aeskey; |     private String aeskey; | ||||||
|     /** |     /** | ||||||
|      * 二维码图片 URL |      * 二维码图片 URL | ||||||
|      */ |      */ | ||||||
|  |     // TODO 亚洲:qrCodeUrl | ||||||
|     private String qrUrl; |     private String qrUrl; | ||||||
|     /** |     /** | ||||||
|      * 备注 |      * 备注 | ||||||
|   | |||||||
| @@ -1,15 +1,19 @@ | |||||||
| package cn.iocoder.yudao.module.wechatMp.dal.dataobject.accountfans; | package cn.iocoder.yudao.module.wechatMp.dal.dataobject.accountfans; | ||||||
|  |  | ||||||
| import lombok.*; |  | ||||||
| import java.util.*; |  | ||||||
| import com.baomidou.mybatisplus.annotation.*; |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||||
|  | import com.baomidou.mybatisplus.annotation.KeySequence; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
|  | import lombok.*; | ||||||
|  |  | ||||||
|  | import java.util.Date; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 微信公众号粉丝 DO |  * 微信公众号粉丝 DO | ||||||
|  * |  * | ||||||
|  * @author 芋道源码 |  * @author 芋道源码 | ||||||
|  */ |  */ | ||||||
|  | // TODO @亚洲:WxUserDO | ||||||
| @TableName("wx_account_fans") | @TableName("wx_account_fans") | ||||||
| @KeySequence("wx_account_fans_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | @KeySequence("wx_account_fans_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||||
| @Data | @Data | ||||||
| @@ -32,18 +36,22 @@ public class WxAccountFansDO extends BaseDO { | |||||||
|     /** |     /** | ||||||
|      * 订阅状态,0未关注,1已关注 |      * 订阅状态,0未关注,1已关注 | ||||||
|      */ |      */ | ||||||
|  |     // TODO @亚洲:Integer 然后写个枚举哈 | ||||||
|     private String subscribeStatus; |     private String subscribeStatus; | ||||||
|     /** |     /** | ||||||
|      * 订阅时间 |      * 订阅时间 | ||||||
|      */ |      */ | ||||||
|  |     // TODO @亚洲:增加一个取消关注的事件 | ||||||
|     private Date subscribeTime; |     private Date subscribeTime; | ||||||
|     /** |     /** | ||||||
|      * 昵称 |      * 昵称 | ||||||
|      */ |      */ | ||||||
|  |     // TODO @亚洲:String | ||||||
|     private byte[] nickname; |     private byte[] nickname; | ||||||
|     /** |     /** | ||||||
|      * 性别,1男,2女,0未知 |      * 性别,1男,2女,0未知 | ||||||
|      */ |      */ | ||||||
|  |     // TODO @亚洲:Integer | ||||||
|     private String gender; |     private String gender; | ||||||
|     /** |     /** | ||||||
|      * 语言 |      * 语言 | ||||||
| @@ -64,11 +72,14 @@ public class WxAccountFansDO extends BaseDO { | |||||||
|     /** |     /** | ||||||
|      * 头像地址 |      * 头像地址 | ||||||
|      */ |      */ | ||||||
|  |     // TODO @亚洲:headImageUrl | ||||||
|     private String headimgUrl; |     private String headimgUrl; | ||||||
|     /** |     /** | ||||||
|      * 备注 |      * 备注 | ||||||
|      */ |      */ | ||||||
|     private String remark; |     private String remark; | ||||||
|  |  | ||||||
|  |     // TODO @亚洲:是不是只要存储 WxAccountDO 的 id 呀? | ||||||
|     /** |     /** | ||||||
|      * 微信公众号 ID |      * 微信公众号 ID | ||||||
|      */ |      */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV