!204 微信模块:公众号账号管理、粉丝标签管理(前端页面待优化)

Merge pull request !204 from fengdan/wechat-mp-fengdan
This commit is contained in:
芋道源码 2022-06-24 13:41:15 +00:00 committed by Gitee
commit 3f68c25540
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
52 changed files with 9442 additions and 9239 deletions

View File

@ -2,10 +2,10 @@
"local": { "local": {
"baseUrl": "http://127.0.0.1:48080/admin-api", "baseUrl": "http://127.0.0.1:48080/admin-api",
"token": "test1", "token": "test1",
"adminTenentId": "1", "appTenantId": "1",
"appApi": "http://127.0.0.1:48080/app-api", "appApi": "http://127.0.0.1:48080/app-api",
"appToken": "test1", "appToken": "test1",
"appTenentId": "1" "appTenantId": "1"
} }
} }

View File

@ -64,7 +64,7 @@
<tencentcloud-sdk-java.version>3.1.471</tencentcloud-sdk-java.version> <tencentcloud-sdk-java.version>3.1.471</tencentcloud-sdk-java.version>
<yunpian-java-sdk.version>1.2.7</yunpian-java-sdk.version> <yunpian-java-sdk.version>1.2.7</yunpian-java-sdk.version>
<justauth.version>1.4.0</justauth.version> <justauth.version>1.4.0</justauth.version>
<weixin-java-mp.version>4.3.0</weixin-java-mp.version> <wx-java-mp.version>4.3.0</wx-java-mp.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -570,8 +570,8 @@
<dependency> <dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId> <artifactId>wx-java-mp-spring-boot-starter</artifactId>
<version>${weixin-java-mp.version}</version> <version>${wx-java-mp.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -33,9 +33,7 @@
<!-- 三方云服务相关 --> <!-- 三方云服务相关 -->
<dependency> <dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<!-- <artifactId>weixin-java-mp</artifactId>-->
<artifactId>wx-java-mp-spring-boot-starter</artifactId> <artifactId>wx-java-mp-spring-boot-starter</artifactId>
<version>4.1.9.B</version>
</dependency> </dependency>
<!-- TODO 芋艿:清理 --> <!-- TODO 芋艿:清理 -->
</dependencies> </dependencies>

View File

@ -2,18 +2,16 @@ package cn.iocoder.yudao.module.mp.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.exception.ErrorCode;
// TODO @亚洲错误码要避免和别人的模块分段重叠
/** /**
* MP 错误码枚举类 * Member 错误码枚举类
* *
* mp 系统使用 1-004-000-000 * wechatMp 系统使用 1-004-000-000
*/ */
public interface ErrorCodeConstants { public interface ErrorCodeConstants {
// ========== 用户相关 1004001000============ // ========== 用户相关 1004001000============
ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在"); ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1004001000, "公众号账户不存在");
ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在"); ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1004001001, "粉丝账号不存在");
// TODO @亚洲需要前缀哈错误码分段不要重复 ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1004001002, "用户不存在");
ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在");
} }

View File

@ -79,11 +79,6 @@
</dependency> </dependency>
<!-- 工具类相关 --> <!-- 工具类相关 -->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>

View File

@ -1,165 +0,0 @@
package cn.iocoder.yudao.module.mp.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import cn.iocoder.yudao.module.mp.handler.*;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
import me.chanjar.weixin.mp.constant.WxMpEventConstants;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
// TODO @芋艿思考有没更好的处理方式
@Component
@EnableConfigurationProperties(WxMpProperties.class)
@Slf4j
public class WxMpConfig implements InitializingBean {
private static Map<String, WxMpMessageRouter> routers = Maps.newHashMap();
private static Map<String, WxMpService> mpServices = Maps.newHashMap();
@Autowired
private WxAccountService wxAccountService;
@Autowired
private WxMpProperties wxMpProperties;
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
/**
* 初始化公众号配置
*/
public synchronized void initWxConfig() {
WxAccountExportReqVO req = new WxAccountExportReqVO();
List<WxAccountDO> wxAccountList = wxAccountService.getWxAccountList(req);
if (CollectionUtils.isEmpty(wxAccountList)) {
return;
}
WxMpConfig.init(wxAccountList, wxMpProperties);
log.info("加载公众号配置成功");
}
@Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
public void schedulePeriodicRefresh() {
initWxConfig();
}
public static void init(List<WxAccountDO> wxAccountDOS, WxMpProperties properties) {
mpServices = wxAccountDOS.stream().map(wxAccountDO -> {
// TODO 亚洲使用 WxMpInMemoryConfigStorage 的话多节点会不会存在 accessToken 冲突
WxMpDefaultConfigImpl configStorage;
if (properties.isUseRedis()) {
final WxMpProperties.RedisConfig redisConfig = properties.getRedisConfig();
JedisPoolConfig poolConfig = new JedisPoolConfig();
JedisPool jedisPool = new JedisPool(poolConfig, redisConfig.getHost(), redisConfig.getPort(),
redisConfig.getTimeout(), redisConfig.getPassword());
configStorage = new WxMpRedisConfigImpl(new JedisWxRedisOps(jedisPool), wxAccountDO.getAppId());
} else {
configStorage = new WxMpDefaultConfigImpl();
}
configStorage.setAppId(wxAccountDO.getAppId());
configStorage.setSecret(wxAccountDO.getAppSecret());
configStorage.setToken(wxAccountDO.getToken());
configStorage.setAesKey(wxAccountDO.getAesKey());
WxMpService service = new WxMpServiceImpl();
service.setWxMpConfigStorage(configStorage);
routers.put(wxAccountDO.getAppId(), newRouter(service));
return service;
}).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o));
}
public static Map<String, WxMpMessageRouter> getRouters() {
return routers;
}
public static Map<String, WxMpService> getMpServices() {
return mpServices;
}
private static WxMpMessageRouter newRouter(WxMpService wxMpService) {
final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
// 记录所有事件的日志 异步执行
newRouter.rule().handler(SpringUtil.getBean(LogHandler.class)).next();
// 接收客服会话管理事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION)
.handler(SpringUtil.getBean(KfSessionHandler.class)).end();
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION)
.handler(SpringUtil.getBean(KfSessionHandler.class))
.end();
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION)
.handler(SpringUtil.getBean(KfSessionHandler.class)).end();
// 门店审核事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.POI_CHECK_NOTIFY)
.handler(SpringUtil.getBean(StoreCheckNotifyHandler.class)).end();
// 自定义菜单事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.MenuButtonType.CLICK).handler(SpringUtil.getBean(MenuHandler.class)).end();
// 点击菜单连接事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.MenuButtonType.VIEW).handler(SpringUtil.getBean(NullHandler.class)).end();
// 关注事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.SUBSCRIBE).handler(SpringUtil.getBean(SubscribeHandler.class))
.end();
// 取消关注事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.UNSUBSCRIBE)
.handler(SpringUtil.getBean(UnsubscribeHandler.class)).end();
// 上报地理位置事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.LOCATION).handler(SpringUtil.getBean(LocationHandler.class))
.end();
// 接收地理位置消息
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION)
.handler(SpringUtil.getBean(LocationHandler.class)).end();
// 扫码事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.SCAN).handler(SpringUtil.getBean(ScanHandler.class)).end();
// 默认
newRouter.rule().async(false).handler(SpringUtil.getBean(MsgHandler.class)).end();
return newRouter;
}
@Override
public void afterPropertiesSet() throws Exception {
initWxConfig();
}
}

View File

@ -1,47 +0,0 @@
package cn.iocoder.yudao.module.mp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* wechat mp properties
*/
@Data
@ConfigurationProperties(prefix = "wx.mp")
public class WxMpProperties {
/**
* 是否使用redis存储access token
*/
private boolean useRedis;
private String defaultContent;
/**
* redis 配置
*/
private RedisConfig redisConfig;
@Data
public static class RedisConfig {
/**
* redis服务器 主机地址
*/
private String host;
/**
* redis服务器 端口号
*/
private Integer port;
/**
* redis服务器 密码
*/
private String password;
/**
* redis 服务连接超时时间
*/
private Integer timeout;
}
}

View File

@ -25,10 +25,12 @@ import java.util.List;
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 static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO @亚洲/mp/account 即可 /**
* @author fengdan
*/
@Api(tags = "管理后台 - 公众号账户") @Api(tags = "管理后台 - 公众号账户")
@RestController @RestController
@RequestMapping("/wechatMp/wx-account") @RequestMapping("/wechatMp/account")
@Validated @Validated
public class WxAccountController { public class WxAccountController {
@ -37,14 +39,14 @@ public class WxAccountController {
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建公众号账户") @ApiOperation("创建公众号账户")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:create')") @PreAuthorize("@ss.hasPermission('wechatMp:account:create')")
public CommonResult<Long> createWxAccount(@Valid @RequestBody WxAccountCreateReqVO createReqVO) { public CommonResult<Long> createWxAccount(@Valid @RequestBody WxAccountCreateReqVO createReqVO) {
return success(wxAccountService.createWxAccount(createReqVO)); return success(wxAccountService.createWxAccount(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("更新公众号账户") @ApiOperation("更新公众号账户")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:update')") @PreAuthorize("@ss.hasPermission('wechatMp:account:update')")
public CommonResult<Boolean> updateWxAccount(@Valid @RequestBody WxAccountUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateWxAccount(@Valid @RequestBody WxAccountUpdateReqVO updateReqVO) {
wxAccountService.updateWxAccount(updateReqVO); wxAccountService.updateWxAccount(updateReqVO);
return success(true); return success(true);
@ -53,7 +55,7 @@ public class WxAccountController {
@DeleteMapping("/delete") @DeleteMapping("/delete")
@ApiOperation("删除公众号账户") @ApiOperation("删除公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:delete')") @PreAuthorize("@ss.hasPermission('wechatMp:account:delete')")
public CommonResult<Boolean> deleteWxAccount(@RequestParam("id") Long id) { public CommonResult<Boolean> deleteWxAccount(@RequestParam("id") Long id) {
wxAccountService.deleteWxAccount(id); wxAccountService.deleteWxAccount(id);
return success(true); return success(true);
@ -62,7 +64,7 @@ public class WxAccountController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得公众号账户") @ApiOperation("获得公众号账户")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:query')") @PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<WxAccountRespVO> getWxAccount(@RequestParam("id") Long id) { public CommonResult<WxAccountRespVO> getWxAccount(@RequestParam("id") Long id) {
WxAccountDO wxAccount = wxAccountService.getWxAccount(id); WxAccountDO wxAccount = wxAccountService.getWxAccount(id);
return success(WxAccountConvert.INSTANCE.convert(wxAccount)); return success(WxAccountConvert.INSTANCE.convert(wxAccount));
@ -71,7 +73,7 @@ public class WxAccountController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得公众号账户列表") @ApiOperation("获得公众号账户列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:query')") @PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<List<WxAccountRespVO>> getWxAccountList(@RequestParam("ids") Collection<Long> ids) { public CommonResult<List<WxAccountRespVO>> getWxAccountList(@RequestParam("ids") Collection<Long> ids) {
List<WxAccountDO> list = wxAccountService.getWxAccountList(ids); List<WxAccountDO> list = wxAccountService.getWxAccountList(ids);
return success(WxAccountConvert.INSTANCE.convertList(list)); return success(WxAccountConvert.INSTANCE.convertList(list));
@ -79,7 +81,7 @@ public class WxAccountController {
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得公众号账户分页") @ApiOperation("获得公众号账户分页")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:query')") @PreAuthorize("@ss.hasPermission('wechatMp:account:query')")
public CommonResult<PageResult<WxAccountRespVO>> getWxAccountPage(@Valid WxAccountPageReqVO pageVO) { public CommonResult<PageResult<WxAccountRespVO>> getWxAccountPage(@Valid WxAccountPageReqVO pageVO) {
PageResult<WxAccountDO> pageResult = wxAccountService.getWxAccountPage(pageVO); PageResult<WxAccountDO> pageResult = wxAccountService.getWxAccountPage(pageVO);
return success(WxAccountConvert.INSTANCE.convertPage(pageResult)); return success(WxAccountConvert.INSTANCE.convertPage(pageResult));
@ -87,7 +89,7 @@ public class WxAccountController {
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ApiOperation("导出公众号账户 Excel") @ApiOperation("导出公众号账户 Excel")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-account:export')") @PreAuthorize("@ss.hasPermission('wechatMp:account:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportWxAccountExcel(@Valid WxAccountExportReqVO exportReqVO, public void exportWxAccountExcel(@Valid WxAccountExportReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {

View File

@ -1,32 +1,40 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo; package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.*; import lombok.Data;
import javax.validation.constraints.NotNull;
/** /**
* 公众号账户 Base VO提供给添加修改详细的子 VO 使用 * 公众号账户 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成 * 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @author fengdan
*/ */
@Data @Data
public class WxAccountBaseVO { public class WxAccountBaseVO {
@ApiModelProperty(value = "公众号名称") @ApiModelProperty(value = "公众号名称", required = true)
@NotNull(message = "公众号名称不能为空")
private String name; private String name;
@ApiModelProperty(value = "公众号账户") @ApiModelProperty(value = "公众号账户", required = true)
@NotNull(message = "公众号账户不能为空")
private String account; private String account;
@ApiModelProperty(value = "公众号appid") @ApiModelProperty(value = "公众号appid", required = true)
private String appid; @NotNull(message = "公众号appid不能为空")
private String appId;
@ApiModelProperty(value = "公众号密钥") @ApiModelProperty(value = "公众号密钥", required = true)
private String appsecret; @NotNull(message = "公众号密钥不能为空")
private String appSecret;
@ApiModelProperty(value = "公众号token") @ApiModelProperty(value = "公众号token")
private String token; private String token;
@ApiModelProperty(value = "加密密钥") @ApiModelProperty(value = "加密密钥")
private String aeskey; private String aesKey;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;

View File

@ -1,8 +1,13 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo; package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户创建 Request VO") @ApiModel("管理后台 - 公众号账户创建 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)

View File

@ -1,9 +1,10 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo; package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/** /**
* 公众号账户 Excel VO * 公众号账户 Excel VO
@ -23,10 +24,7 @@ public class WxAccountExcelVO {
private String account; private String account;
@ExcelProperty("公众号appid") @ExcelProperty("公众号appid")
private String appid; private String appId;
@ExcelProperty("公众号密钥")
private String appsecret;
@ExcelProperty("公众号url") @ExcelProperty("公众号url")
private String url; private String url;
@ -35,7 +33,7 @@ public class WxAccountExcelVO {
private String token; private String token;
@ExcelProperty("加密密钥") @ExcelProperty("加密密钥")
private String aeskey; private String aesKey;
@ExcelProperty("二维码图片URL") @ExcelProperty("二维码图片URL")
private String qrCodeUrl; private String qrCodeUrl;
@ -45,5 +43,4 @@ public class WxAccountExcelVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private Date createTime; private Date createTime;
} }

View File

@ -7,6 +7,9 @@ import org.springframework.format.annotation.DateTimeFormat;
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.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author fengdan
*/
@ApiModel(value = "管理后台 - 公众号账户 Excel 导出 Request VO", description = "参数和 WxAccountPageReqVO 是一致的") @ApiModel(value = "管理后台 - 公众号账户 Excel 导出 Request VO", description = "参数和 WxAccountPageReqVO 是一致的")
@Data @Data
public class WxAccountExportReqVO { public class WxAccountExportReqVO {
@ -18,7 +21,7 @@ public class WxAccountExportReqVO {
private String account; private String account;
@ApiModelProperty(value = "公众号appid") @ApiModelProperty(value = "公众号appid")
private String appid; private String appId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间") @ApiModelProperty(value = "开始创建时间")

View File

@ -8,12 +8,14 @@ import org.springframework.format.annotation.DateTimeFormat;
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.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户分页 Request VO") @ApiModel("管理后台 - 公众号账户分页 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxAccountPageReqVO extends PageParam { public class WxAccountPageReqVO extends PageParam {
@ApiModelProperty(value = "公众号名称") @ApiModelProperty(value = "公众号名称")
private String name; private String name;
@ -21,7 +23,7 @@ public class WxAccountPageReqVO extends PageParam {
private String account; private String account;
@ApiModelProperty(value = "公众号appid") @ApiModelProperty(value = "公众号appid")
private String appid; private String appId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间") @ApiModelProperty(value = "开始创建时间")
@ -30,5 +32,4 @@ public class WxAccountPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间") @ApiModelProperty(value = "结束创建时间")
private Date endCreateTime; private Date endCreateTime;
} }

View File

@ -1,9 +1,16 @@
package cn.iocoder.yudao.module.mp.controller.admin.account.vo; package cn.iocoder.yudao.module.mp.controller.admin.account.vo;
import lombok.*; import io.swagger.annotations.ApiModel;
import java.util.*; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.*; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.Date;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户 Response VO") @ApiModel("管理后台 - 公众号账户 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -22,4 +29,6 @@ public class WxAccountRespVO extends WxAccountBaseVO {
@ApiModelProperty(value = "创建时间", required = true) @ApiModelProperty(value = "创建时间", required = true)
private Date createTime; private Date createTime;
@ApiModelProperty(value = "公众号密钥", required = true)
private String appSecret;
} }

View File

@ -4,6 +4,9 @@ import lombok.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 公众号账户更新 Request VO") @ApiModel("管理后台 - 公众号账户更新 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)

View File

@ -0,0 +1,98 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag;
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.mp.controller.admin.fanstag.vo.*;
import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert;
import cn.iocoder.yudao.module.mp.service.tag.FansTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
/**
* @author fengdan
*/
@Api(tags = "管理后台 - 粉丝标签")
@RestController
@RequestMapping("/wechatMp/fans-tag")
@Validated
public class FansTagController {
@Resource
private FansTagService fansTagService;
@PostMapping("/create")
@ApiOperation("创建粉丝标签")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:create')")
public CommonResult<WxUserTag> createWxFansTag(@Valid @RequestBody FansTagCreateReqVO createReqVO) throws WxErrorException {
return success(fansTagService.createWxFansTag(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新粉丝标签")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:update')")
public CommonResult<Boolean> updateWxFansTag(@Valid @RequestBody FansTagUpdateReqVO updateReqVO) throws WxErrorException {
return success(fansTagService.updateWxFansTag(updateReqVO));
}
@DeleteMapping("/delete")
@ApiOperation("删除粉丝标签")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:delete')")
public CommonResult<Boolean> deleteWxFansTag(@RequestParam("id") Long id,
@RequestParam("appId") String appId) throws WxErrorException {
return success(fansTagService.deleteWxFansTag(id, appId));
}
@GetMapping("/list")
@ApiOperation("获取公众号已创建的标签")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
public CommonResult<List<FansTagRespVO>> getWxFansTagList(@NotEmpty(message = "公众号appId不能为空")
@RequestParam("appId") String appId) throws WxErrorException {
List<WxUserTag> list = fansTagService.getWxFansTagList(appId);
return success(WxFansTagConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获取公众号已创建的标签")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
public CommonResult<PageResult<FansTagRespVO>> page() throws WxErrorException {
PageResult<WxUserTag> page = new PageResult<>();
return success(WxFansTagConvert.INSTANCE.convertPage(page));
}
@GetMapping("/tagListUser")
@ApiOperation("获取标签下粉丝列表")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
public CommonResult<String> tagListUser(@Valid FansTagPageReqVO pageVO) {
return success("");
}
@GetMapping("/export-excel")
@ApiOperation("导出粉丝标签 Excel")
@PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:export')")
@OperateLog(type = EXPORT)
public void exportWxFansTagExcel(@Valid FansTagExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<WxUserTag> list = fansTagService.getWxFansTagList(exportReqVO);
// 导出 Excel
List<FansTagExcelVO> datas = WxFansTagConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "粉丝标签.xls", "数据", FansTagExcelVO.class, datas);
}
}

View File

@ -1,103 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
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 cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.fanstag.WxFansTagDO;
import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert;
import cn.iocoder.yudao.module.mp.service.fanstag.WxFansTagService;
@Api(tags = "管理后台 - 粉丝标签")
@RestController
@RequestMapping("/wechatMp/wx-fans-tag")
@Validated
public class WxFansTagController {
@Resource
private WxFansTagService wxFansTagService;
@PostMapping("/create")
@ApiOperation("创建粉丝标签")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:create')")
public CommonResult<Integer> createWxFansTag(@Valid @RequestBody WxFansTagCreateReqVO createReqVO) {
return success(wxFansTagService.createWxFansTag(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新粉丝标签")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:update')")
public CommonResult<Boolean> updateWxFansTag(@Valid @RequestBody WxFansTagUpdateReqVO updateReqVO) {
wxFansTagService.updateWxFansTag(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除粉丝标签")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:delete')")
public CommonResult<Boolean> deleteWxFansTag(@RequestParam("id") Integer id) {
wxFansTagService.deleteWxFansTag(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得粉丝标签")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")
public CommonResult<WxFansTagRespVO> getWxFansTag(@RequestParam("id") Integer id) {
WxFansTagDO wxFansTag = wxFansTagService.getWxFansTag(id);
return success(WxFansTagConvert.INSTANCE.convert(wxFansTag));
}
@GetMapping("/list")
@ApiOperation("获得粉丝标签列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")
public CommonResult<List<WxFansTagRespVO>> getWxFansTagList(@RequestParam("ids") Collection<Integer> ids) {
List<WxFansTagDO> list = wxFansTagService.getWxFansTagList(ids);
return success(WxFansTagConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得粉丝标签分页")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")
public CommonResult<PageResult<WxFansTagRespVO>> getWxFansTagPage(@Valid WxFansTagPageReqVO pageVO) {
PageResult<WxFansTagDO> pageResult = wxFansTagService.getWxFansTagPage(pageVO);
return success(WxFansTagConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出粉丝标签 Excel")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:export')")
@OperateLog(type = EXPORT)
public void exportWxFansTagExcel(@Valid WxFansTagExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<WxFansTagDO> list = wxFansTagService.getWxFansTagList(exportReqVO);
// 导出 Excel
List<WxFansTagExcelVO> datas = WxFansTagConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "粉丝标签.xls", "数据", WxFansTagExcelVO.class, datas);
}
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 粉丝标签 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @author fengdan
*/
@Data
public class FansTagBaseVO {
@NotBlank(message = "标签名不能为空")
@ApiModelProperty(value = "标签名UTF8编码")
private String name;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 粉丝标签创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class FansTagCreateReqVO extends FansTagBaseVO {
@NotBlank(message = "公众号appId不能为空")
@ApiModelProperty("微信公众号appId")
private String appId;
}

View File

@ -12,7 +12,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
* @author 芋道源码 * @author 芋道源码
*/ */
@Data @Data
public class WxFansTagExcelVO { public class FansTagExcelVO {
@ExcelProperty("主键") @ExcelProperty("主键")
private Integer id; private Integer id;
@ -23,9 +23,6 @@ public class WxFansTagExcelVO {
@ExcelProperty("粉丝数量") @ExcelProperty("粉丝数量")
private Integer count; private Integer count;
@ExcelProperty("微信账号ID")
private String wxAccountId;
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private Date createTime; private Date createTime;

View File

@ -11,7 +11,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ApiModel(value = "管理后台 - 粉丝标签 Excel 导出 Request VO", description = "参数和 WxFansTagPageReqVO 是一致的") @ApiModel(value = "管理后台 - 粉丝标签 Excel 导出 Request VO", description = "参数和 WxFansTagPageReqVO 是一致的")
@Data @Data
public class WxFansTagExportReqVO { public class FansTagExportReqVO {
@ApiModelProperty(value = "标签名称") @ApiModelProperty(value = "标签名称")
private String name; private String name;

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 粉丝标签分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class FansTagPageReqVO extends PageParam {
@NotEmpty(message = "公众号appId不能为空")
@ApiModelProperty("微信公众号appId")
private String appId;
}

View File

@ -10,10 +10,10 @@ import io.swagger.annotations.*;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxFansTagRespVO extends WxFansTagBaseVO { public class FansTagRespVO extends FansTagBaseVO {
@ApiModelProperty(value = "主键", required = true) @ApiModelProperty(value = "标签id由微信分配.")
private Integer id; private Long id;
@ApiModelProperty(value = "创建时间", required = true) @ApiModelProperty(value = "创建时间", required = true)
private Date createTime; private Date createTime;

View File

@ -5,14 +5,21 @@ import io.swagger.annotations.*;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/**
* @author fengdan
*/
@ApiModel("管理后台 - 粉丝标签更新 Request VO") @ApiModel("管理后台 - 粉丝标签更新 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WxFansTagUpdateReqVO extends WxFansTagBaseVO { public class FansTagUpdateReqVO extends FansTagBaseVO {
@ApiModelProperty(value = "主键", required = true) @ApiModelProperty(value = "标签id由微信分配", required = true)
@NotNull(message = "主键不能为空") @NotNull(message = "主键不能为空")
private Integer id; private Long id;
@NotBlank(message = "公众号appId不能为空")
@ApiModelProperty("微信公众号appId")
private String appId;
} }

View File

@ -1,22 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import lombok.*;
import io.swagger.annotations.*;
/**
* 粉丝标签 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class WxFansTagBaseVO {
@ApiModelProperty(value = "标签名称")
private String name;
@ApiModelProperty(value = "粉丝数量")
private Integer count;
@ApiModelProperty(value = "微信账号ID")
private String wxAccountId;
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import lombok.*;
import io.swagger.annotations.*;
@ApiModel("管理后台 - 粉丝标签创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WxFansTagCreateReqVO extends WxFansTagBaseVO {
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 粉丝标签分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WxFansTagPageReqVO extends PageParam {
@ApiModelProperty(value = "标签名称")
private String name;
@ApiModelProperty(value = "粉丝数量")
private Integer count;
@ApiModelProperty(value = "微信账号ID")
private String wxAccountId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -4,31 +4,31 @@ import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*; import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.fanstag.WxFansTagDO;
/** /**
* 粉丝标签 Convert * 粉丝标签 Convert
* *
* @author 芋道源码 * @author fengdan
*/ */
@Mapper @Mapper
public interface WxFansTagConvert { public interface WxFansTagConvert {
WxFansTagConvert INSTANCE = Mappers.getMapper(WxFansTagConvert.class); WxFansTagConvert INSTANCE = Mappers.getMapper(WxFansTagConvert.class);
WxFansTagDO convert(WxFansTagCreateReqVO bean); WxUserTag convert(FansTagCreateReqVO bean);
WxFansTagDO convert(WxFansTagUpdateReqVO bean); WxUserTag convert(FansTagUpdateReqVO bean);
WxFansTagRespVO convert(WxFansTagDO bean); FansTagRespVO convert(WxUserTag bean);
List<WxFansTagRespVO> convertList(List<WxFansTagDO> list); List<FansTagRespVO> convertList(List<WxUserTag> list);
PageResult<WxFansTagRespVO> convertPage(PageResult<WxFansTagDO> page); PageResult<FansTagRespVO> convertPage(PageResult<WxUserTag> page);
List<WxFansTagExcelVO> convertList02(List<WxFansTagDO> list); List<FansTagExcelVO> convertList02(List<WxUserTag> list);
} }

View File

@ -4,7 +4,11 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
import lombok.*; import lombok.*;
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
// TODO 亚洲这个模块的相关类使用 Mp 作为前缀哈 // TODO 亚洲这个模块的相关类使用 Mp 作为前缀哈
/** /**
@ -64,4 +68,12 @@ public class WxAccountDO extends BaseDO {
*/ */
private String remark; private String remark;
public WxMpConfigStorage toWxMpConfigStorage(RedisTemplateWxRedisOps redisTemplateWxRedisOps, WxMpProperties wxMpProperties) {
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisTemplateWxRedisOps, wxMpProperties.getConfigStorage().getKeyPrefix());
wxMpRedisConfig.setAppId(appId);
wxMpRedisConfig.setSecret(appSecret);
wxMpRedisConfig.setToken(token);
wxMpRedisConfig.setAesKey(aesKey);
return wxMpRedisConfig;
}
} }

View File

@ -1,43 +0,0 @@
package cn.iocoder.yudao.module.mp.dal.dataobject.fanstag;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 粉丝标签 DO
*
* @author 芋道源码
*/
@TableName("wx_fans_tag")
@KeySequence("wx_fans_tag_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxFansTagDO extends BaseDO {
/**
* 主键
*/
@TableId
private Integer id;
/**
* 标签名称
*/
private String name;
/**
* 粉丝数量
*/
private Integer count;
/**
* 微信账号ID
*/
private String wxAccountId;
}

View File

@ -1,12 +1,12 @@
package cn.iocoder.yudao.module.mp.dal.dataobject.texttemplate; package cn.iocoder.yudao.module.mp.dal.dataobject.texttemplate;
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 lombok.*;
// TODO @亚洲消息使用统一的表存储思考下咋做哈 import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/** /**
* 文本模板 DO * 文本模板 DO
* *

View File

@ -22,7 +22,7 @@ public interface WxAccountMapper extends BaseMapperX<WxAccountDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<WxAccountDO>() return selectPage(reqVO, new LambdaQueryWrapperX<WxAccountDO>()
.likeIfPresent(WxAccountDO::getName, reqVO.getName()) .likeIfPresent(WxAccountDO::getName, reqVO.getName())
.eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount()) .eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount())
.eqIfPresent(WxAccountDO::getAppId, reqVO.getAppid()) .eqIfPresent(WxAccountDO::getAppId, reqVO.getAppId())
.betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) .betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxAccountDO::getId)); .orderByDesc(WxAccountDO::getId));
} }
@ -31,7 +31,7 @@ public interface WxAccountMapper extends BaseMapperX<WxAccountDO> {
return selectList(new LambdaQueryWrapperX<WxAccountDO>() return selectList(new LambdaQueryWrapperX<WxAccountDO>()
.likeIfPresent(WxAccountDO::getName, reqVO.getName()) .likeIfPresent(WxAccountDO::getName, reqVO.getName())
.eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount()) .eqIfPresent(WxAccountDO::getAccount, reqVO.getAccount())
.eqIfPresent(WxAccountDO::getAppId, reqVO.getAppid()) .eqIfPresent(WxAccountDO::getAppId, reqVO.getAppId())
.betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) .betweenIfPresent(WxAccountDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxAccountDO::getId)); .orderByDesc(WxAccountDO::getId));
} }

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.mp.dal.mysql.fanstag;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mp.dal.dataobject.fanstag.WxFansTagDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
/**
* 粉丝标签 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface WxFansTagMapper extends BaseMapperX<WxFansTagDO> {
default PageResult<WxFansTagDO> selectPage(WxFansTagPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WxFansTagDO>()
.likeIfPresent(WxFansTagDO::getName, reqVO.getName())
.eqIfPresent(WxFansTagDO::getCount, reqVO.getCount())
.eqIfPresent(WxFansTagDO::getWxAccountId, reqVO.getWxAccountId())
.betweenIfPresent(WxFansTagDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxFansTagDO::getId));
}
default List<WxFansTagDO> selectList(WxFansTagExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<WxFansTagDO>()
.likeIfPresent(WxFansTagDO::getName, reqVO.getName())
.eqIfPresent(WxFansTagDO::getCount, reqVO.getCount())
.eqIfPresent(WxFansTagDO::getWxAccountId, reqVO.getWxAccountId())
.betweenIfPresent(WxFansTagDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(WxFansTagDO::getId));
}
}

View File

@ -0,0 +1,6 @@
/**
* @date 2022/6/20
* @author feng-dan
* @version 1.0
*/
package cn.iocoder.yudao.module.mp.framework;

View File

@ -0,0 +1,106 @@
package cn.iocoder.yudao.module.mp.framework.weixin;
import cn.iocoder.yudao.module.mp.handler.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.constant.WxMpEventConstants;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author fengdan
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class WxMpMessageRouterConfiguration {
@Resource
private WxMpService wxMpService;
@Resource
private LogHandler logHandler;
@Resource
private KfSessionHandler kfSessionHandler;
@Resource
private StoreCheckNotifyHandler storeCheckNotifyHandler;
@Resource
private MenuHandler menuHandler;
@Resource
private NullHandler nullHandler;
@Resource
private SubscribeHandler subscribeHandler;
@Resource
private UnsubscribeHandler unsubscribeHandler;
@Resource
private LocationHandler locationHandler;
@Resource
private ScanHandler scanHandler;
@Resource
private MsgHandler msgHandler;
@Bean
public WxMpMessageRouter messageRouter() {
final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
// 记录所有事件的日志 异步执行
newRouter.rule().handler(logHandler).next();
// 接收客服会话管理事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION)
.handler(kfSessionHandler).end();
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION)
.handler(kfSessionHandler)
.end();
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION)
.handler(kfSessionHandler).end();
// 门店审核事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxMpEventConstants.POI_CHECK_NOTIFY)
.handler(storeCheckNotifyHandler).end();
// 自定义菜单事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.MenuButtonType.CLICK).handler(menuHandler).end();
// 点击菜单连接事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.MenuButtonType.VIEW).handler(nullHandler).end();
// 关注事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.SUBSCRIBE).handler(subscribeHandler)
.end();
// 取消关注事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.UNSUBSCRIBE)
.handler(unsubscribeHandler).end();
// 上报地理位置事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.LOCATION).handler(locationHandler)
.end();
// 接收地理位置消息
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION)
.handler(locationHandler).end();
// 扫码事件
newRouter.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.SCAN).handler(scanHandler).end();
// 默认
newRouter.rule().async(false).handler(msgHandler).end();
return newRouter;
}
}

View File

@ -6,13 +6,10 @@ import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.mp.builder.TextBuilder; import cn.iocoder.yudao.module.mp.builder.TextBuilder;
import cn.iocoder.yudao.module.mp.config.WxMpProperties;
import cn.iocoder.yudao.module.mp.controller.admin.fansmsg.vo.WxFansMsgCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.fansmsg.vo.WxFansMsgCreateReqVO;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import cn.iocoder.yudao.module.mp.service.account.WxAccountService; import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import cn.iocoder.yudao.module.mp.service.fansmsg.WxFansMsgService; import cn.iocoder.yudao.module.mp.service.fansmsg.WxFansMsgService;
import cn.iocoder.yudao.module.mp.service.receivetext.WxReceiveTextService;
import cn.iocoder.yudao.module.mp.service.texttemplate.WxTextTemplateService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
@ -34,13 +31,6 @@ import java.util.Map;
@Component @Component
@Slf4j @Slf4j
public class MsgHandler implements WxMpMessageHandler { public class MsgHandler implements WxMpMessageHandler {
@Autowired
private WxReceiveTextService wxReceiveTextService;
@Autowired
private WxTextTemplateService wxTextTemplateService;
@Autowired @Autowired
private WxAccountService wxAccountService; private WxAccountService wxAccountService;
@ -50,9 +40,6 @@ public class MsgHandler implements WxMpMessageHandler {
@Resource @Resource
private FileApi fileApi; private FileApi fileApi;
@Autowired
private WxMpProperties wxMpProperties;
@Override @Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService, Map<String, Object> context, WxMpService weixinService,
@ -112,7 +99,7 @@ public class MsgHandler implements WxMpMessageHandler {
if (!downloadDir.exists()) { if (!downloadDir.exists()) {
downloadDir.mkdirs(); downloadDir.mkdirs();
} }
String filepath = downloadDirStr + String.valueOf(System.currentTimeMillis()) + ".png"; String filepath = downloadDirStr + System.currentTimeMillis() + ".png";
//微信pic url下载到本地防止失效 //微信pic url下载到本地防止失效
long size = HttpUtil.downloadFile(wxMessage.getPicUrl(), FileUtil.file(filepath)); long size = HttpUtil.downloadFile(wxMessage.getPicUrl(), FileUtil.file(filepath));
log.info("download pic size : {}", size); log.info("download pic size : {}", size);
@ -147,8 +134,7 @@ public class MsgHandler implements WxMpMessageHandler {
} }
//组装默认回复消息 //组装默认回复消息
String content = wxMpProperties.getDefaultContent();//默认 return new TextBuilder().build("测试", wxMessage, weixinService);
return new TextBuilder().build(content, wxMessage, weixinService);
} }

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.mp.mq.costomer.dict; package cn.iocoder.yudao.module.mp.mq.costomer;
import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener;
import cn.iocoder.yudao.module.mp.config.WxMpConfig; import cn.iocoder.yudao.module.mp.mq.message.WxConfigDataRefreshMessage;
import cn.iocoder.yudao.module.mp.mq.message.dict.WxConfigDataRefreshMessage; import cn.iocoder.yudao.module.mp.service.account.WxAccountService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -18,12 +18,12 @@ import javax.annotation.Resource;
public class WxConfigDataRefreshConsumer extends AbstractChannelMessageListener<WxConfigDataRefreshMessage> { public class WxConfigDataRefreshConsumer extends AbstractChannelMessageListener<WxConfigDataRefreshMessage> {
@Resource @Resource
private WxMpConfig wxMpConfig; private WxAccountService wxAccountService;
@Override @Override
public void onMessage(WxConfigDataRefreshMessage message) { public void onMessage(WxConfigDataRefreshMessage message) {
log.info("[onMessage][收到 WxConfigData 刷新消息]"); log.info("[onMessage][收到 WxConfigData 刷新消息]");
wxMpConfig.initWxConfig(); wxAccountService.initLoadWxMpConfigStorages();
} }
} }

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.mp.mq.message.dict; package cn.iocoder.yudao.module.mp.mq.message;
import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage; import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage;
import lombok.Data; import lombok.Data;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.mp.mq.producer.dict; package cn.iocoder.yudao.module.mp.mq.producer;
import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate;
import cn.iocoder.yudao.module.mp.mq.message.dict.WxConfigDataRefreshMessage; import cn.iocoder.yudao.module.mp.mq.message.WxConfigDataRefreshMessage;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;

View File

@ -81,4 +81,9 @@ public interface WxAccountService {
* @return * @return
*/ */
WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val); WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val);
/**
* 初始化
*/
void initLoadWxMpConfigStorages();
} }

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mp.service.account;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountExportReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountPageReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.WxAccountPageReqVO;
@ -10,30 +11,52 @@ import cn.iocoder.yudao.module.mp.convert.account.WxAccountConvert;
import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.WxAccountDO;
import cn.iocoder.yudao.module.mp.dal.mysql.account.WxAccountMapper; import cn.iocoder.yudao.module.mp.dal.mysql.account.WxAccountMapper;
import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.mp.mq.producer.dict.WxMpConfigDataProducer; import cn.iocoder.yudao.module.mp.mq.producer.WxMpConfigDataProducer;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 公众号账户 Service 实现类 * 公众号账户 Service 实现类
* *
* @author 芋道源码 * @author fengdan
*/ */
@Slf4j
@Service @Service
@Validated @Validated
public class WxAccountServiceImpl implements WxAccountService { public class WxAccountServiceImpl implements WxAccountService {
private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
@Resource @Resource
private WxAccountMapper wxAccountMapper; private WxAccountMapper wxAccountMapper;
@Resource @Resource
private WxMpConfigDataProducer wxMpConfigDataProducer; private WxMpConfigDataProducer wxMpConfigDataProducer;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private WxMpService wxMpService;
@Resource
private WxMpProperties wxMpProperties;
@Resource
@Lazy // 注入自己所以延迟加载
private WxAccountService self;
@Override @Override
public Long createWxAccount(WxAccountCreateReqVO createReqVO) { public Long createWxAccount(WxAccountCreateReqVO createReqVO) {
@ -94,4 +117,43 @@ public class WxAccountServiceImpl implements WxAccountService {
public WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val) { public WxAccountDO findBy(SFunction<WxAccountDO, ?> field, Object val) {
return wxAccountMapper.selectOne(field, val); return wxAccountMapper.selectOne(field, val);
} }
@PostConstruct
@TenantIgnore
@Override
public void initLoadWxMpConfigStorages() {
List<WxAccountDO> wxAccountList = this.wxAccountMapper.selectList();
if (CollectionUtils.isEmpty(wxAccountList)) {
log.info("未读取到公众号配置,请在管理后台添加");
return;
}
log.info("加载到{}条公众号配置", wxAccountList.size());
wxAccountList.forEach(account -> addAccountToRuntime(account, new RedisTemplateWxRedisOps(stringRedisTemplate)));
log.info("公众号配置加载完成");
}
/**
* 添加账号到当前程序如首次添加需初始化configStorageMap
*
* @param account 公众号
*/
private synchronized void addAccountToRuntime(WxAccountDO account, RedisTemplateWxRedisOps redisOps) {
String appId = account.getAppId();
WxMpConfigStorage wxMpRedisConfig = account.toWxMpConfigStorage(redisOps, wxMpProperties);
try {
wxMpService.addConfigStorage(appId, wxMpRedisConfig);
} catch (NullPointerException e) {
log.info("需初始化configStorageMap...");
Map<String, WxMpConfigStorage> configStorages = new HashMap<>(4);
configStorages.put(appId, wxMpRedisConfig);
wxMpService.setMultiConfigStorages(configStorages, appId);
}
}
@Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
public void schedulePeriodicRefresh() {
self.initLoadWxMpConfigStorages();
}
} }

View File

@ -1,71 +0,0 @@
package cn.iocoder.yudao.module.mp.service.fanstag;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.fanstag.WxFansTagDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 粉丝标签 Service 接口
*
* @author 芋道源码
*/
public interface WxFansTagService {
/**
* 创建粉丝标签
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createWxFansTag(@Valid WxFansTagCreateReqVO createReqVO);
/**
* 更新粉丝标签
*
* @param updateReqVO 更新信息
*/
void updateWxFansTag(@Valid WxFansTagUpdateReqVO updateReqVO);
/**
* 删除粉丝标签
*
* @param id 编号
*/
void deleteWxFansTag(Integer id);
/**
* 获得粉丝标签
*
* @param id 编号
* @return 粉丝标签
*/
WxFansTagDO getWxFansTag(Integer id);
/**
* 获得粉丝标签列表
*
* @param ids 编号
* @return 粉丝标签列表
*/
List<WxFansTagDO> getWxFansTagList(Collection<Integer> ids);
/**
* 获得粉丝标签分页
*
* @param pageReqVO 分页查询
* @return 粉丝标签分页
*/
PageResult<WxFansTagDO> getWxFansTagPage(WxFansTagPageReqVO pageReqVO);
/**
* 获得粉丝标签列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 粉丝标签列表
*/
List<WxFansTagDO> getWxFansTagList(WxFansTagExportReqVO exportReqVO);
}

View File

@ -1,85 +0,0 @@
package cn.iocoder.yudao.module.mp.service.fanstag;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
import cn.iocoder.yudao.module.mp.dal.dataobject.fanstag.WxFansTagDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert;
import cn.iocoder.yudao.module.mp.dal.mysql.fanstag.WxFansTagMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*;
/**
* 粉丝标签 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class WxFansTagServiceImpl implements WxFansTagService {
@Resource
private WxFansTagMapper wxFansTagMapper;
@Override
public Integer createWxFansTag(WxFansTagCreateReqVO createReqVO) {
// 插入
WxFansTagDO wxFansTag = WxFansTagConvert.INSTANCE.convert(createReqVO);
wxFansTagMapper.insert(wxFansTag);
// 返回
return wxFansTag.getId();
}
@Override
public void updateWxFansTag(WxFansTagUpdateReqVO updateReqVO) {
// 校验存在
this.validateWxFansTagExists(updateReqVO.getId());
// 更新
WxFansTagDO updateObj = WxFansTagConvert.INSTANCE.convert(updateReqVO);
wxFansTagMapper.updateById(updateObj);
}
@Override
public void deleteWxFansTag(Integer id) {
// 校验存在
this.validateWxFansTagExists(id);
// 删除
wxFansTagMapper.deleteById(id);
}
private void validateWxFansTagExists(Integer id) {
if (wxFansTagMapper.selectById(id) == null) {
throw exception(COMMON_NOT_EXISTS);
}
}
@Override
public WxFansTagDO getWxFansTag(Integer id) {
return wxFansTagMapper.selectById(id);
}
@Override
public List<WxFansTagDO> getWxFansTagList(Collection<Integer> ids) {
return wxFansTagMapper.selectBatchIds(ids);
}
@Override
public PageResult<WxFansTagDO> getWxFansTagPage(WxFansTagPageReqVO pageReqVO) {
return wxFansTagMapper.selectPage(pageReqVO);
}
@Override
public List<WxFansTagDO> getWxFansTagList(WxFansTagExportReqVO exportReqVO) {
return wxFansTagMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.mp.service.tag;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import javax.validation.Valid;
import java.util.List;
/**
* 粉丝标签 Service 接口
*
* @author fengdan
*/
public interface FansTagService {
/**
* 创建粉丝标签
*
* @param createReqVO 创建标签信息
* @return {@link WxUserTag} 用户标签对象
* @throws WxErrorException 微信异常
*/
WxUserTag createWxFansTag(FansTagCreateReqVO createReqVO) throws WxErrorException;
/**
* 更新粉丝标签
*
* @param updateReqVO 更新信息
* @return {@link Boolean}
* @throws WxErrorException 微信异常
*/
Boolean updateWxFansTag(@Valid FansTagUpdateReqVO updateReqVO) throws WxErrorException;
/**
* 删除粉丝标签
*
* @param id 编号
* @param appId 公众号appId
* @return {@link Boolean}
* @throws WxErrorException 微信异常
*/
Boolean deleteWxFansTag(Long id, String appId) throws WxErrorException;
/**
* 获取公众号已创建的标签
*
* @param appId 公众号appId
* @return 粉丝标签列表
* @throws WxErrorException 微信异常
*/
List<WxUserTag> getWxFansTagList(String appId) throws WxErrorException;
/**
* 获得粉丝标签分页
*
* @param pageReqVO 分页查询
* @return 粉丝标签分页
*/
PageResult<WxUserTag> getWxFansTagPage(FansTagPageReqVO pageReqVO);
/**
* 获得粉丝标签列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 粉丝标签列表
*/
List<WxUserTag> getWxFansTagList(FansTagExportReqVO exportReqVO);
}

View File

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.mp.service.tag;
import cn.hutool.core.util.ReUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO;
import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
/**
* 粉丝标签 Service 实现类
*
* @author fengdan
*/
@Slf4j
@Service
@Validated
public class FansTagServiceImpl implements FansTagService {
@Resource
private WxMpService wxMpService;
@Override
public WxUserTag createWxFansTag(FansTagCreateReqVO createReqVO) throws WxErrorException {
// TODO 切换公众号操作 调整为 aop 或者 过滤器\拦截器 处理
wxMpService.switchover(createReqVO.getAppId());
return wxMpService.getUserTagService().tagCreate(createReqVO.getName());
}
@Override
public Boolean updateWxFansTag(FansTagUpdateReqVO updateReqVO) throws WxErrorException {
wxMpService.switchover(updateReqVO.getAppId());
return wxMpService.getUserTagService().tagUpdate(updateReqVO.getId(), updateReqVO.getName());
}
@Override
public Boolean deleteWxFansTag(Long id, String appId) throws WxErrorException {
wxMpService.switchover(appId);
return wxMpService.getUserTagService().tagDelete(id);
}
@Override
public List<WxUserTag> getWxFansTagList(String appId) throws WxErrorException {
wxMpService.switchover(appId);
return wxMpService.getUserTagService().tagGet();
}
@Override
public PageResult<WxUserTag> getWxFansTagPage(FansTagPageReqVO pageReqVO) {
return null;
}
@Override
public List<WxUserTag> getWxFansTagList(FansTagExportReqVO exportReqVO) {
return null;
}
}

View File

@ -204,7 +204,7 @@ justauth:
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
wx: wx:
mp: mp:
useRedis: false # TODO @亚洲:要使用 redis 哈,和默认的 redis 使用同一个 useRedis: false
defaultContent: \u60A8\u597D\uFF0C\u6709\u4EC0\u4E48\u95EE\u9898\uFF1F defaultContent: \u60A8\u597D\uFF0C\u6709\u4EC0\u4E48\u95EE\u9898\uFF1F
redisConfig: redisConfig:
host: 127.0.0.1 host: 127.0.0.1

View File

@ -177,13 +177,13 @@ logging:
wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
mp: mp:
# 公众号配置(必填) # 公众号配置(必填)
app-id: wx041349c6f39b268b appId: wx041349c6f39b268b
secret: 5abee519483bc9f8cb37ce280e814bd0 secret: 5abee519483bc9f8cb37ce280e814bd0
# 存储配置,解决 AccessToken 的跨节点的共享 # 存储配置,解决 AccessToken 的跨节点的共享
config-storage: config-storage:
type: RedisTemplate # 采用 RedisTemplate 操作 Redis会自动从 Spring 中获取 type: RedisTemplate # 配置类型: Memory(默认), Jedis, RedisTemplate
key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置 key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 http-client-type: HttpClient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp
--- #################### 芋道相关配置 #################### --- #################### 芋道相关配置 ####################

View File

@ -1,52 +1,52 @@
import request from '@/utils/request' import request from '@/utils/request'
// 创建公众号账户 // 创建公众号账户
export function createWxAccount(data) { export function createAccount(data) {
return request({ return request({
url: '/wechatMp/wx-account/create', url: '/wechatMp/account/create',
method: 'post', method: 'post',
data: data data: data
}) })
} }
// 更新公众号账户 // 更新公众号账户
export function updateWxAccount(data) { export function updateAccount(data) {
return request({ return request({
url: '/wechatMp/wx-account/update', url: '/wechatMp/account/update',
method: 'put', method: 'put',
data: data data: data
}) })
} }
// 删除公众号账户 // 删除公众号账户
export function deleteWxAccount(id) { export function deleteAccount(id) {
return request({ return request({
url: '/wechatMp/wx-account/delete?id=' + id, url: '/wechatMp/account/delete?id=' + id,
method: 'delete' method: 'delete'
}) })
} }
// 获得公众号账户 // 获得公众号账户
export function getWxAccount(id) { export function getAccount(id) {
return request({ return request({
url: '/wechatMp/wx-account/get?id=' + id, url: '/wechatMp/account/get?id=' + id,
method: 'get' method: 'get'
}) })
} }
// 获得公众号账户分页 // 获得公众号账户分页
export function getWxAccountPage(query) { export function getAccountPage(query) {
return request({ return request({
url: '/wechatMp/wx-account/page', url: '/wechatMp/account/page',
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 导出公众号账户 Excel // 导出公众号账户 Excel
export function exportWxAccountExcel(query) { export function exportAccountExcel(query) {
return request({ return request({
url: '/wechatMp/wx-account/export-excel', url: '/wechatMp/account/export-excel',
method: 'get', method: 'get',
params: query, params: query,
responseType: 'blob' responseType: 'blob'

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 创建粉丝标签 // 创建粉丝标签
export function createWxFansTag(data) { export function createWxFansTag(data) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/create', url: '/wechatMp/fans-tag/create',
method: 'post', method: 'post',
data: data data: data
}) })
@ -12,7 +12,7 @@ export function createWxFansTag(data) {
// 更新粉丝标签 // 更新粉丝标签
export function updateWxFansTag(data) { export function updateWxFansTag(data) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/update', url: '/wechatMp/fans-tag/update',
method: 'put', method: 'put',
data: data data: data
}) })
@ -21,7 +21,7 @@ export function updateWxFansTag(data) {
// 删除粉丝标签 // 删除粉丝标签
export function deleteWxFansTag(id) { export function deleteWxFansTag(id) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/delete?id=' + id, url: '/wechatMp/fans-tag/delete?id=' + id,
method: 'delete' method: 'delete'
}) })
} }
@ -29,15 +29,15 @@ export function deleteWxFansTag(id) {
// 获得粉丝标签 // 获得粉丝标签
export function getWxFansTag(id) { export function getWxFansTag(id) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/get?id=' + id, url: '/wechatMp/fans-tag/get?id=' + id,
method: 'get' method: 'get'
}) })
} }
// 获得粉丝标签分页 // 获得粉丝标签分页
export function getWxFansTagPage(query) { export function getWxFansTagList(query) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/page', url: '/wechatMp/fans-tag/list',
method: 'get', method: 'get',
params: query params: query
}) })
@ -46,7 +46,7 @@ export function getWxFansTagPage(query) {
// 导出粉丝标签 Excel // 导出粉丝标签 Excel
export function exportWxFansTagExcel(query) { export function exportWxFansTagExcel(query) {
return request({ return request({
url: '/wechatMp/wx-fans-tag/export-excel', url: '/wechatMp/fans-tag/export-excel',
method: 'get', method: 'get',
params: query, params: query,
responseType: 'blob' responseType: 'blob'

View File

@ -3,14 +3,9 @@
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公众号名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入公众号名称" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.name" placeholder="请输入公众号名称" clearable
</el-form-item> @keyup.enter.native="handleQuery"/>
<el-form-item label="公众号账户" prop="account">
<el-input v-model="queryParams.account" placeholder="请输入公众号账户" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="公众号appId" prop="appId">
<el-input v-model="queryParams.appId" placeholder="请输入公众号appId" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd" <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
@ -26,11 +21,14 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['wechatMp:wx-account:create']">新增</el-button> v-hasPermi="['wechatMp:account:create']">新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading" <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['wechatMp:wx-account:export']">导出</el-button> :loading="exportLoading"
v-hasPermi="['wechatMp:account:export']">导出
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -38,14 +36,13 @@
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="id"/> <el-table-column label="编号" align="center" prop="id"/>
<el-table-column label="公众号名称" align="center" prop="name" /> <el-table-column label="名称" align="center" prop="name"/>
<el-table-column label="公众号账户" align="center" prop="account" /> <el-table-column label="微信原始ID" align="center" prop="account"/>
<el-table-column label="公众号appId" align="center" prop="appId"/> <el-table-column label="appId" align="center" prop="appId"/>
<el-table-column label="公众号密钥" align="center" prop="appSecret"/> <el-table-column label="url" align="center" prop="url"/>
<el-table-column label="公众号url" align="center" prop="url" /> <el-table-column label="Token" align="center" prop="token"/>
<el-table-column label="公众号token" align="center" prop="token" />
<el-table-column label="加密密钥" align="center" prop="aesKey"/> <el-table-column label="加密密钥" align="center" prop="aesKey"/>
<el-table-column label="二维码图片URL" align="center" prop="qrCodeUrl"/> <el-table-column label="二维码" align="center" prop="qrCodeUrl"/>
<el-table-column label="备注" align="center" prop="remark"/> <el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
@ -55,9 +52,11 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['wechatMp:wx-account:update']">修改</el-button> v-hasPermi="['wechatMp:account:update']">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['wechatMp:wx-account:delete']">删除</el-button> v-hasPermi="['wechatMp:account:delete']">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -71,16 +70,32 @@
<el-form-item label="公众号名称" prop="name"> <el-form-item label="公众号名称" prop="name">
<el-input v-model="form.name" placeholder="请输入公众号名称"/> <el-input v-model="form.name" placeholder="请输入公众号名称"/>
</el-form-item> </el-form-item>
<el-form-item label="公众号账户" prop="account">
<el-input v-model="form.account" placeholder="请输入公众号账户" /> <el-tooltip class="item" effect="dark"
content="在微信公众平台mp.weixin.qq.com的菜单【设置】-【公众号设置】-【帐号详情】中能找到原始ID"
placement="right">
<el-form-item label="微信原始ID" prop="account">
<el-input v-model="form.account" placeholder="请输入微信原始ID" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="公众号appId" prop="appId"> </el-tooltip>
<el-input v-model="form.appId" placeholder="请输入公众号appId"/>
<el-tooltip class="item" effect="dark"
content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到AppID "
placement="right">
<el-form-item label="AppID" prop="appId">
<el-input v-model="form.appId" placeholder="请输入公众号appId" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="公众号密钥" prop="appSecret"> </el-tooltip>
<el-input v-model="form.appSecret" placeholder="请输入公众号密钥"/>
<el-tooltip class="item" effect="dark"
content="在微信公众平台mp.weixin.qq.com的菜单【开发】-【基本配置】中能找到AppSecret"
placement="right">
<el-form-item label="AppSecret" prop="appSecret">
<el-input v-model="form.appSecret" placeholder="请输入公众号密钥" :disabled='disabled'/>
</el-form-item> </el-form-item>
<el-form-item label="公众号token" prop="token"> </el-tooltip>
<el-form-item label="token" prop="token">
<el-input v-model="form.token" placeholder="请输入公众号token"/> <el-input v-model="form.token" placeholder="请输入公众号token"/>
</el-form-item> </el-form-item>
<el-form-item label="加密密钥" prop="aesKey"> <el-form-item label="加密密钥" prop="aesKey">
@ -99,12 +114,18 @@
</template> </template>
<script> <script>
import { createWxAccount, updateWxAccount, deleteWxAccount, getWxAccount, getWxAccountPage, exportWxAccountExcel } from "@/api/wechatMp/wxAccount"; import {
createAccount,
deleteAccount,
exportAccountExcel,
getAccount,
getAccountPage,
updateAccount
} from '@/api/wechatMp/wxAccount'
export default { export default {
name: "WxAccount", name: 'wxAccount',
components: { components: {},
},
data() { data() {
return { return {
// //
@ -118,7 +139,7 @@ export default {
// //
list: [], list: [],
// //
title: "", title: '',
// //
open: false, open: false,
dateRangeCreateTime: [], dateRangeCreateTime: [],
@ -134,30 +155,37 @@ export default {
form: {}, form: {},
// //
rules: { rules: {
name: [{required: true, message: '公众号名称不能为空', trigger: 'blur'}],
account: [{required: true, message: '公众号账户不能为空', trigger: 'blur'}],
appId: [{required: true, message: '公众号appid不能为空', trigger: 'blur'}],
appSecret: [{required: true, message: '公众号密钥不能为空', trigger: 'blur'}],
},
//
disabled: false,
} }
};
}, },
created() { created() {
this.getList(); this.getList()
}, },
methods: { methods: {
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
this.loading = true; this.loading = true
// //
let params = {...this.queryParams}; let params = {...this.queryParams}
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
// //
getWxAccountPage(params).then(response => { getAccountPage(params).then(response => {
this.list = response.data.list; this.list = response.data.list
this.total = response.data.total; this.total = response.data.total
this.loading = false; this.loading = false
}); })
}, },
/** 取消按钮 */ /** 取消按钮 */
cancel() { cancel() {
this.open = false; this.open = false
this.reset(); this.disabled = false
this.reset()
}, },
/** 表单重置 */ /** 表单重置 */
reset() { reset() {
@ -170,85 +198,88 @@ export default {
token: undefined, token: undefined,
aesKey: undefined, aesKey: undefined,
remark: undefined, remark: undefined,
}; }
this.resetForm("form"); this.resetForm('form')
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.dateRangeCreateTime = []; this.dateRangeCreateTime = []
this.resetForm("queryForm"); this.resetForm('queryForm')
this.handleQuery(); this.handleQuery()
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset()
this.open = true; this.open = true
this.title = "添加公众号账户"; this.title = '添加公众号账户'
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset()
const id = row.id; const id = row.id
getWxAccount(id).then(response => { getAccount(id).then(response => {
this.form = response.data; this.form = response.data
this.open = true; this.open = true
this.title = "修改公众号账户"; this.title = '修改公众号账户'
}); this.disabled = true
})
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs['form'].validate(valid => {
if (!valid) { if (!valid) {
return; return
} }
// //
if (this.form.id != null) { if (this.form.id != null) {
updateWxAccount(this.form).then(response => { updateAccount(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess('修改成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
return; return
} }
// //
createWxAccount(this.form).then(response => { createAccount(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess('新增成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
}); })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id
this.$modal.confirm('是否确认删除公众号账户编号为"' + id + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除公众号账户编号为"' + id + '"的数据项?').then(function () {
return deleteWxAccount(id); return deleteAccount(id)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功')
}).catch(() => {}); }).catch(() => {
})
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
// //
let params = {...this.queryParams}; let params = {...this.queryParams}
params.pageNo = undefined; params.pageNo = undefined
params.pageSize = undefined; params.pageSize = undefined
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
// //
this.$modal.confirm('是否确认导出所有公众号账户数据项?').then(() => { this.$modal.confirm('是否确认导出所有公众号账户数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true
return exportWxAccountExcel(params); return exportAccountExcel(params)
}).then(response => { }).then(response => {
this.$download.excel(response, '公众号账户.xls'); this.$download.excel(response, '公众号账户.xls')
this.exportLoading = false; this.exportLoading = false
}).catch(() => {}); }).catch(() => {
})
}
} }
} }
};
</script> </script>

View File

@ -6,17 +6,7 @@
<el-form-item label="标签名称" prop="name"> <el-form-item label="标签名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="粉丝数量" prop="count">
<el-input v-model="queryParams.count" placeholder="请输入粉丝数量" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="微信账号ID" prop="wxAccountId">
<el-input v-model="queryParams.wxAccountId" placeholder="请输入微信账号ID" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
@ -27,36 +17,43 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['wechatMp:wx-fans-tag:create']">新增 v-hasPermi="['wechatMp:fans-tag:create']">新增
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading" :loading="exportLoading"
v-hasPermi="['wechatMp:wx-fans-tag:export']">导出 v-hasPermi="['wechatMp:fans-tag:export']">导出
</el-button> </el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<div style="display: flex;width: auto">
<div class="left_column" style="border: 1px solid #EBEEF5FF; width: 15%;height: auto">
<div style="padding: 10px 20px; border-bottom: 1px solid #ebeef5; box-sizing: border-box;"><span
style="font-size: 16px">公众号名称</span></div>
<div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">
<input type="text" placeholder="输入关键字进行过滤"
class="el-input__inner"/>
</div>
<div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">
<div style="margin-right: 5px;margin-left: 5px" v-for="(account,index) in accountList" @click="getAccountTag(account.appId)">{{ account.name }}</div>
</div>
</div>
<div class="right_column" style="width: 85%">
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="主键" align="center" prop="id"/> <el-table-column label="编号" align="center" prop="id"/>
<el-table-column label="标签名称" align="center" prop="name"/> <el-table-column label="标签名称" align="center" prop="name"/>
<el-table-column label="粉丝数量" align="center" prop="count"/>
<el-table-column label="微信账号ID" align="center" prop="wxAccountId"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['wechatMp:wx-fans-tag:update']">修改 v-hasPermi="['wechatMp:fans-tag:update']">修改
</el-button> </el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['wechatMp:wx-fans-tag:delete']">删除 v-hasPermi="['wechatMp:fans-tag:delete']">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -65,6 +62,10 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/> @pagination="getList"/>
</div>
</div>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
@ -86,18 +87,27 @@
</div> </div>
</template> </template>
<style>
.left_column {
height: 100%;
position: relative;
overflow: auto;
}
</style>
<script> <script>
import { import {
createWxFansTag, createWxFansTag,
updateWxFansTag,
deleteWxFansTag, deleteWxFansTag,
exportWxFansTagExcel,
getWxFansTag, getWxFansTag,
getWxFansTagPage, getWxFansTagList,
exportWxFansTagExcel updateWxFansTag
} from "@/api/wechatMp/wxFansTag"; } from '@/api/wechatMp/wxFansTag'
import {getAccountPage} from '@/api/wechatMp/wxAccount'
export default { export default {
name: "WxFansTag", name: 'WxFansTag',
components: {}, components: {},
data() { data() {
return { return {
@ -111,135 +121,145 @@
total: 0, total: 0,
// //
list: [], list: [],
//
accountList: [],
// //
title: "", title: '',
// //
open: false, open: false,
dateRangeCreateTime: [], dateRangeCreateTime: [],
// //
queryParams: { queryParams: {
pageNo: 1, appId: null,
pageSize: 10,
name: null,
count: null,
wxAccountId: null,
}, },
// //
form: {}, form: {},
// //
rules: {} rules: {}
}; }
}, },
created() { created() {
this.getList(); this.getAccountList()
}, },
methods: { methods: {
/** 查询列表 */ /** 查询列表 */
getList() { getList(appId) {
this.loading = true; this.loading = false
this.queryParams.appId = appId
// //
let params = {...this.queryParams}; let params = {...this.queryParams}
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// //
getWxFansTagPage(params).then(response => { getWxFansTagList(params).then(response => {
this.list = response.data.list; this.list = response.data
this.total = response.data.total; this.loading = false
this.loading = false; })
});
}, },
/** 查询列表 */
getAccountList() {
//
getAccountPage().then(response => {
this.accountList = response.data.list
})
},
/**
* 获取帐户标签
* @param appId 公众号appId
*/
getAccountTag(appId) {
this.getList(appId)
},
/** 取消按钮 */ /** 取消按钮 */
cancel() { cancel() {
this.open = false; this.open = false
this.reset(); this.reset()
}, },
/** 表单重置 */ /** 表单重置 */
reset() { reset() {
this.form = { this.form = {
id: undefined, appId: undefined,
name: undefined, }
count: undefined, this.resetForm('form')
wxAccountId: undefined,
};
this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.dateRangeCreateTime = []; this.dateRangeCreateTime = []
this.resetForm("queryForm"); this.resetForm('queryForm')
this.handleQuery(); this.handleQuery()
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset()
this.open = true; this.open = true
this.title = "添加粉丝标签"; this.title = '添加粉丝标签'
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset()
const id = row.id; const id = row.id
getWxFansTag(id).then(response => { getWxFansTag(id).then(response => {
this.form = response.data; this.form = response.data
this.open = true; this.open = true
this.title = "修改粉丝标签"; this.title = '修改粉丝标签'
}); })
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs['form'].validate(valid => {
if (!valid) { if (!valid) {
return; return
} }
// //
if (this.form.id != null) { if (this.form.id != null) {
updateWxFansTag(this.form).then(response => { updateWxFansTag(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess('修改成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
return; return
} }
// //
createWxFansTag(this.form).then(response => { createWxFansTag(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess('新增成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
}); })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id
this.$modal.confirm('是否确认删除粉丝标签编号为"' + id + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除粉丝标签编号为"' + id + '"的数据项?').then(function () {
return deleteWxFansTag(id); return deleteWxFansTag(id)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功')
}).catch(() => { }).catch(() => {
}); })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
// //
let params = {...this.queryParams}; let params = {...this.queryParams}
params.pageNo = undefined; params.pageNo = undefined
params.pageSize = undefined; params.pageSize = undefined
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
// //
this.$modal.confirm('是否确认导出所有粉丝标签数据项?').then(() => { this.$modal.confirm('是否确认导出所有粉丝标签数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true
return exportWxFansTagExcel(params); return exportWxFansTagExcel(params)
}).then(response => { }).then(response => {
this.$download.excel(response, '粉丝标签.xls'); this.$download.excel(response, '粉丝标签.xls')
this.exportLoading = false; this.exportLoading = false
}).catch(() => { }).catch(() => {
}); })
}
} }
} }
};
</script> </script>

File diff suppressed because it is too large Load Diff