Commit 372b4a70aa6c2606cec7c1d05379b1df9afb7d4e

Authored by fengdan
1 parent 977cc19f

fix(粉丝标签管理): 增、删、改、查

yudao-module-wechat/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java
@@ -10,8 +10,8 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; @@ -10,8 +10,8 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
10 public interface ErrorCodeConstants { 10 public interface ErrorCodeConstants {
11 11
12 // ========== 用户相关 1004001000============ 12 // ========== 用户相关 1004001000============
13 - ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在");  
14 - ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在");  
15 - ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在"); 13 + ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1004001000, "公众号账户不存在");
  14 + ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1004001001, "粉丝账号不存在");
  15 + ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1004001002, "用户不存在");
16 16
17 } 17 }
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/fanstag/FansTagController.java
@@ -8,8 +8,8 @@ import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*; @@ -8,8 +8,8 @@ import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.*;
8 import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert; 8 import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert;
9 import cn.iocoder.yudao.module.mp.service.tag.FansTagService; 9 import cn.iocoder.yudao.module.mp.service.tag.FansTagService;
10 import io.swagger.annotations.Api; 10 import io.swagger.annotations.Api;
11 -import io.swagger.annotations.ApiImplicitParam;  
12 import io.swagger.annotations.ApiOperation; 11 import io.swagger.annotations.ApiOperation;
  12 +import me.chanjar.weixin.common.error.WxErrorException;
13 import me.chanjar.weixin.mp.bean.tag.WxUserTag; 13 import me.chanjar.weixin.mp.bean.tag.WxUserTag;
14 import org.springframework.security.access.prepost.PreAuthorize; 14 import org.springframework.security.access.prepost.PreAuthorize;
15 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
@@ -18,8 +18,8 @@ import org.springframework.web.bind.annotation.*; @@ -18,8 +18,8 @@ import org.springframework.web.bind.annotation.*;
18 import javax.annotation.Resource; 18 import javax.annotation.Resource;
19 import javax.servlet.http.HttpServletResponse; 19 import javax.servlet.http.HttpServletResponse;
20 import javax.validation.Valid; 20 import javax.validation.Valid;
  21 +import javax.validation.constraints.NotEmpty;
21 import java.io.IOException; 22 import java.io.IOException;
22 -import java.util.Collection;  
23 import java.util.List; 23 import java.util.List;
24 24
25 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 25 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E @@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
30 */ 30 */
31 @Api(tags = "管理后台 - 粉丝标签") 31 @Api(tags = "管理后台 - 粉丝标签")
32 @RestController 32 @RestController
33 -@RequestMapping("/wechat-mp/fans-tag") 33 +@RequestMapping("/wechatMp/fans-tag")
34 @Validated 34 @Validated
35 public class FansTagController { 35 public class FansTagController {
36 36
@@ -39,57 +39,53 @@ public class FansTagController { @@ -39,57 +39,53 @@ public class FansTagController {
39 39
40 @PostMapping("/create") 40 @PostMapping("/create")
41 @ApiOperation("创建粉丝标签") 41 @ApiOperation("创建粉丝标签")
42 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:create')")  
43 - public CommonResult<WxUserTag> createWxFansTag(@Valid @RequestBody FansTagCreateReqVO createReqVO) { 42 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:create')")
  43 + public CommonResult<WxUserTag> createWxFansTag(@Valid @RequestBody FansTagCreateReqVO createReqVO) throws WxErrorException {
44 return success(fansTagService.createWxFansTag(createReqVO)); 44 return success(fansTagService.createWxFansTag(createReqVO));
45 } 45 }
46 46
47 @PutMapping("/update") 47 @PutMapping("/update")
48 @ApiOperation("更新粉丝标签") 48 @ApiOperation("更新粉丝标签")
49 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:update')")  
50 - public CommonResult<Boolean> updateWxFansTag(@Valid @RequestBody FansTagUpdateReqVO updateReqVO) {  
51 - fansTagService.updateWxFansTag(updateReqVO);  
52 - return success(true); 49 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:update')")
  50 + public CommonResult<Boolean> updateWxFansTag(@Valid @RequestBody FansTagUpdateReqVO updateReqVO) throws WxErrorException {
  51 + return success(fansTagService.updateWxFansTag(updateReqVO));
53 } 52 }
54 53
55 @DeleteMapping("/delete") 54 @DeleteMapping("/delete")
56 @ApiOperation("删除粉丝标签") 55 @ApiOperation("删除粉丝标签")
57 - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class)  
58 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:delete')")  
59 - public CommonResult<Boolean> deleteWxFansTag(@RequestParam("id") Integer id) {  
60 - fansTagService.deleteWxFansTag(id);  
61 - return success(true);  
62 - }  
63 -  
64 - @GetMapping("/get")  
65 - @ApiOperation("获得粉丝标签")  
66 - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class)  
67 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")  
68 - public CommonResult<FansTagRespVO> getWxFansTag(@RequestParam("id") Integer id) {  
69 - WxUserTag wxFansTag = fansTagService.getWxFansTag(id);  
70 - return success(WxFansTagConvert.INSTANCE.convert(wxFansTag)); 56 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:delete')")
  57 + public CommonResult<Boolean> deleteWxFansTag(@RequestParam("id") Long id,
  58 + @RequestParam("appId") String appId) throws WxErrorException {
  59 + return success(fansTagService.deleteWxFansTag(id, appId));
71 } 60 }
72 61
73 @GetMapping("/list") 62 @GetMapping("/list")
74 - @ApiOperation("获得粉丝标签列表")  
75 - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)  
76 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")  
77 - public CommonResult<List<FansTagRespVO>> getWxFansTagList(@RequestParam("ids") Collection<Integer> ids) {  
78 - List<WxUserTag> list = fansTagService.getWxFansTagList(ids); 63 + @ApiOperation("获取公众号已创建的标签")
  64 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
  65 + public CommonResult<List<FansTagRespVO>> getWxFansTagList(@NotEmpty(message = "公众号appId不能为空")
  66 + @RequestParam("appId") String appId) throws WxErrorException {
  67 + List<WxUserTag> list = fansTagService.getWxFansTagList(appId);
79 return success(WxFansTagConvert.INSTANCE.convertList(list)); 68 return success(WxFansTagConvert.INSTANCE.convertList(list));
80 } 69 }
81 70
82 @GetMapping("/page") 71 @GetMapping("/page")
83 - @ApiOperation("获得粉丝标签分页")  
84 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:query')")  
85 - public CommonResult<PageResult<FansTagRespVO>> getWxFansTagPage(@Valid FansTagPageReqVO pageVO) {  
86 - PageResult<WxUserTag> pageResult = fansTagService.getWxFansTagPage(pageVO);  
87 - return success(WxFansTagConvert.INSTANCE.convertPage(pageResult)); 72 + @ApiOperation("获取公众号已创建的标签")
  73 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
  74 + public CommonResult<PageResult<FansTagRespVO>> page() throws WxErrorException {
  75 + PageResult<WxUserTag> page = new PageResult<>();
  76 + return success(WxFansTagConvert.INSTANCE.convertPage(page));
  77 + }
  78 +
  79 + @GetMapping("/tagListUser")
  80 + @ApiOperation("获取标签下粉丝列表")
  81 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:query')")
  82 + public CommonResult<String> tagListUser(@Valid FansTagPageReqVO pageVO) {
  83 + return success("");
88 } 84 }
89 85
90 @GetMapping("/export-excel") 86 @GetMapping("/export-excel")
91 @ApiOperation("导出粉丝标签 Excel") 87 @ApiOperation("导出粉丝标签 Excel")
92 - @PreAuthorize("@ss.hasPermission('wechatMp:wx-fans-tag:export')") 88 + @PreAuthorize("@ss.hasPermission('wechatMp:fans-tag:export')")
93 @OperateLog(type = EXPORT) 89 @OperateLog(type = EXPORT)
94 public void exportWxFansTagExcel(@Valid FansTagExportReqVO exportReqVO, 90 public void exportWxFansTagExcel(@Valid FansTagExportReqVO exportReqVO,
95 HttpServletResponse response) throws IOException { 91 HttpServletResponse response) throws IOException {
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/fanstag/vo/FansTagBaseVO.java
@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo; @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
3 import io.swagger.annotations.ApiModelProperty; 3 import io.swagger.annotations.ApiModelProperty;
4 import lombok.Data; 4 import lombok.Data;
5 5
  6 +import javax.validation.constraints.NotBlank;
  7 +
6 /** 8 /**
7 * 粉丝标签 Base VO,提供给添加、修改、详细的子 VO 使用 9 * 粉丝标签 Base VO,提供给添加、修改、详细的子 VO 使用
8 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 10 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
@@ -12,9 +14,7 @@ import lombok.Data; @@ -12,9 +14,7 @@ import lombok.Data;
12 @Data 14 @Data
13 public class FansTagBaseVO { 15 public class FansTagBaseVO {
14 16
15 - @ApiModelProperty(value = "标签名,UTF8编码.") 17 + @NotBlank(message = "标签名不能为空")
  18 + @ApiModelProperty(value = "标签名,UTF8编码")
16 private String name; 19 private String name;
17 -  
18 - @ApiModelProperty(value = "此标签下粉丝数")  
19 - private Integer count;  
20 } 20 }
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/fanstag/vo/FansTagCreateReqVO.java
1 package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo; 1 package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
2 2
3 -import lombok.*;  
4 -import io.swagger.annotations.*; 3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +
  9 +import javax.validation.constraints.NotBlank;
5 10
6 /** 11 /**
7 * @author fengdan 12 * @author fengdan
@@ -11,5 +16,7 @@ import io.swagger.annotations.*; @@ -11,5 +16,7 @@ import io.swagger.annotations.*;
11 @EqualsAndHashCode(callSuper = true) 16 @EqualsAndHashCode(callSuper = true)
12 @ToString(callSuper = true) 17 @ToString(callSuper = true)
13 public class FansTagCreateReqVO extends FansTagBaseVO { 18 public class FansTagCreateReqVO extends FansTagBaseVO {
14 - 19 + @NotBlank(message = "公众号appId不能为空")
  20 + @ApiModelProperty("微信公众号appId")
  21 + private String appId;
15 } 22 }
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/fanstag/vo/FansTagPageReqVO.java
1 package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo; 1 package cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo;
2 2
3 -import lombok.*;  
4 -  
5 -import java.util.*;  
6 -  
7 -import io.swagger.annotations.*;  
8 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
9 -import org.springframework.format.annotation.DateTimeFormat; 4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
10 9
11 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 10 +import javax.validation.constraints.NotEmpty;
12 11
  12 +/**
  13 + * @author fengdan
  14 + */
13 @ApiModel("管理后台 - 粉丝标签分页 Request VO") 15 @ApiModel("管理后台 - 粉丝标签分页 Request VO")
14 @Data 16 @Data
15 @EqualsAndHashCode(callSuper = true) 17 @EqualsAndHashCode(callSuper = true)
16 @ToString(callSuper = true) 18 @ToString(callSuper = true)
17 public class FansTagPageReqVO extends PageParam { 19 public class FansTagPageReqVO extends PageParam {
18 20
19 - @ApiModelProperty(value = "标签名称")  
20 - private String name;  
21 -  
22 - @ApiModelProperty(value = "粉丝数量")  
23 - private Integer count;  
24 -  
25 - @ApiModelProperty(value = "微信账号ID")  
26 - private String wxAccountId;  
27 -  
28 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
29 - @ApiModelProperty(value = "开始创建时间")  
30 - private Date beginCreateTime;  
31 -  
32 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
33 - @ApiModelProperty(value = "结束创建时间")  
34 - private Date endCreateTime; 21 + @NotEmpty(message = "公众号appId不能为空")
  22 + @ApiModelProperty("微信公众号appId")
  23 + private String appId;
35 24
36 } 25 }
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/fanstag/vo/FansTagUpdateReqVO.java
@@ -5,14 +5,21 @@ import io.swagger.annotations.*; @@ -5,14 +5,21 @@ import io.swagger.annotations.*;
5 5
6 import javax.validation.constraints.*; 6 import javax.validation.constraints.*;
7 7
  8 +/**
  9 + * @author fengdan
  10 + */
8 @ApiModel("管理后台 - 粉丝标签更新 Request VO") 11 @ApiModel("管理后台 - 粉丝标签更新 Request VO")
9 @Data 12 @Data
10 @EqualsAndHashCode(callSuper = true) 13 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 14 @ToString(callSuper = true)
12 public class FansTagUpdateReqVO extends FansTagBaseVO { 15 public class FansTagUpdateReqVO extends FansTagBaseVO {
13 16
14 - @ApiModelProperty(value = "主键", required = true) 17 + @ApiModelProperty(value = "标签id,由微信分配", required = true)
15 @NotNull(message = "主键不能为空") 18 @NotNull(message = "主键不能为空")
16 - private Integer id; 19 + private Long id;
  20 +
  21 + @NotBlank(message = "公众号appId不能为空")
  22 + @ApiModelProperty("微信公众号appId")
  23 + private String appId;
17 24
18 } 25 }
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/FansTagService.java
@@ -5,10 +5,10 @@ import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO @@ -5,10 +5,10 @@ import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO
5 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO; 5 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO;
6 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO; 6 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO;
7 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO; 7 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO;
  8 +import me.chanjar.weixin.common.error.WxErrorException;
8 import me.chanjar.weixin.mp.bean.tag.WxUserTag; 9 import me.chanjar.weixin.mp.bean.tag.WxUserTag;
9 10
10 import javax.validation.Valid; 11 import javax.validation.Valid;
11 -import java.util.Collection;  
12 import java.util.List; 12 import java.util.List;
13 13
14 /** 14 /**
@@ -21,40 +21,39 @@ public interface FansTagService { @@ -21,40 +21,39 @@ public interface FansTagService {
21 /** 21 /**
22 * 创建粉丝标签 22 * 创建粉丝标签
23 * 23 *
24 - * @param createReqVO 创建信息  
25 - * @return 编号 24 + * @param createReqVO 创建标签信息
  25 + * @return {@link WxUserTag} 用户标签对象
  26 + * @throws WxErrorException 微信异常
26 */ 27 */
27 - WxUserTag createWxFansTag(@Valid FansTagCreateReqVO createReqVO); 28 + WxUserTag createWxFansTag(FansTagCreateReqVO createReqVO) throws WxErrorException;
28 29
29 /** 30 /**
30 * 更新粉丝标签 31 * 更新粉丝标签
31 * 32 *
32 * @param updateReqVO 更新信息 33 * @param updateReqVO 更新信息
  34 + * @return {@link Boolean}
  35 + * @throws WxErrorException 微信异常
33 */ 36 */
34 - void updateWxFansTag(@Valid FansTagUpdateReqVO updateReqVO); 37 + Boolean updateWxFansTag(@Valid FansTagUpdateReqVO updateReqVO) throws WxErrorException;
35 38
36 /** 39 /**
37 * 删除粉丝标签 40 * 删除粉丝标签
38 * 41 *
39 - * @param id 编号 42 + * @param id 编号
  43 + * @param appId 公众号appId
  44 + * @return {@link Boolean}
  45 + * @throws WxErrorException 微信异常
40 */ 46 */
41 - void deleteWxFansTag(Integer id); 47 + Boolean deleteWxFansTag(Long id, String appId) throws WxErrorException;
42 48
43 /** 49 /**
44 - * 获得粉丝标签 50 + * 获取公众号已创建的标签
45 * 51 *
46 - * @param id 编号  
47 - * @return 粉丝标签  
48 - */  
49 - WxUserTag getWxFansTag(Integer id);  
50 -  
51 - /**  
52 - * 获得粉丝标签列表  
53 - *  
54 - * @param ids 编号 52 + * @param appId 公众号appId
55 * @return 粉丝标签列表 53 * @return 粉丝标签列表
  54 + * @throws WxErrorException 微信异常
56 */ 55 */
57 - List<WxUserTag> getWxFansTagList(Collection<Integer> ids); 56 + List<WxUserTag> getWxFansTagList(String appId) throws WxErrorException;
58 57
59 /** 58 /**
60 * 获得粉丝标签分页 59 * 获得粉丝标签分页
yudao-module-wechat/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/FansTagServiceImpl.java
1 package cn.iocoder.yudao.module.mp.service.tag; 1 package cn.iocoder.yudao.module.mp.service.tag;
2 2
  3 +import cn.hutool.core.util.ReUtil;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO; 5 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagCreateReqVO;
5 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO; 6 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagExportReqVO;
6 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO; 7 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagPageReqVO;
7 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO; 8 import cn.iocoder.yudao.module.mp.controller.admin.fanstag.vo.FansTagUpdateReqVO;
8 -import cn.iocoder.yudao.module.mp.convert.fanstag.WxFansTagConvert;  
9 import lombok.extern.slf4j.Slf4j; 9 import lombok.extern.slf4j.Slf4j;
10 import me.chanjar.weixin.common.error.WxErrorException; 10 import me.chanjar.weixin.common.error.WxErrorException;
11 import me.chanjar.weixin.mp.api.WxMpService; 11 import me.chanjar.weixin.mp.api.WxMpService;
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Service; @@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
14 import org.springframework.validation.annotation.Validated; 14 import org.springframework.validation.annotation.Validated;
15 15
16 import javax.annotation.Resource; 16 import javax.annotation.Resource;
17 -import java.util.Collection;  
18 import java.util.List; 17 import java.util.List;
19 18
20 /** 19 /**
@@ -26,42 +25,33 @@ import java.util.List; @@ -26,42 +25,33 @@ import java.util.List;
26 @Service 25 @Service
27 @Validated 26 @Validated
28 public class FansTagServiceImpl implements FansTagService { 27 public class FansTagServiceImpl implements FansTagService {
29 -  
30 @Resource 28 @Resource
31 private WxMpService wxMpService; 29 private WxMpService wxMpService;
32 30
33 @Override 31 @Override
34 - public WxUserTag createWxFansTag(FansTagCreateReqVO createReqVO) {  
35 - try {  
36 - return wxMpService.getUserTagService().tagCreate("wxFansTag");  
37 - } catch (WxErrorException e) {  
38 - throw new RuntimeException(e);  
39 - } 32 + public WxUserTag createWxFansTag(FansTagCreateReqVO createReqVO) throws WxErrorException {
  33 + // TODO 切换公众号操作 调整为 aop 或者 过滤器\拦截器 处理
  34 + wxMpService.switchover(createReqVO.getAppId());
  35 + return wxMpService.getUserTagService().tagCreate(createReqVO.getName());
40 } 36 }
41 37
42 @Override 38 @Override
43 - public void updateWxFansTag(FansTagUpdateReqVO updateReqVO) {  
44 - // 校验存在  
45 - // 更新  
46 - WxUserTag updateObj = WxFansTagConvert.INSTANCE.convert(updateReqVO);  
47 - 39 + public Boolean updateWxFansTag(FansTagUpdateReqVO updateReqVO) throws WxErrorException {
  40 + wxMpService.switchover(updateReqVO.getAppId());
  41 + return wxMpService.getUserTagService().tagUpdate(updateReqVO.getId(), updateReqVO.getName());
48 } 42 }
49 43
50 @Override 44 @Override
51 - public void deleteWxFansTag(Integer id) {  
52 - // 校验存在  
53 - // 删除 45 + public Boolean deleteWxFansTag(Long id, String appId) throws WxErrorException {
  46 + wxMpService.switchover(appId);
  47 + return wxMpService.getUserTagService().tagDelete(id);
54 } 48 }
55 49
56 50
57 @Override 51 @Override
58 - public WxUserTag getWxFansTag(Integer id) {  
59 - return null;  
60 - }  
61 -  
62 - @Override  
63 - public List<WxUserTag> getWxFansTagList(Collection<Integer> ids) {  
64 - return null; 52 + public List<WxUserTag> getWxFansTagList(String appId) throws WxErrorException {
  53 + wxMpService.switchover(appId);
  54 + return wxMpService.getUserTagService().tagGet();
65 } 55 }
66 56
67 @Override 57 @Override
yudao-ui-admin/src/api/wechatMp/wxFansTag.js
@@ -3,7 +3,7 @@ import request from &#39;@/utils/request&#39; @@ -3,7 +3,7 @@ import request from &#39;@/utils/request&#39;
3 // 创建粉丝标签 3 // 创建粉丝标签
4 export function createWxFansTag(data) { 4 export function createWxFansTag(data) {
5 return request({ 5 return request({
6 - url: '/wechatMp/wx-fans-tag/create', 6 + url: '/wechatMp/fans-tag/create',
7 method: 'post', 7 method: 'post',
8 data: data 8 data: data
9 }) 9 })
@@ -12,7 +12,7 @@ export function createWxFansTag(data) { @@ -12,7 +12,7 @@ export function createWxFansTag(data) {
12 // 更新粉丝标签 12 // 更新粉丝标签
13 export function updateWxFansTag(data) { 13 export function updateWxFansTag(data) {
14 return request({ 14 return request({
15 - url: '/wechatMp/wx-fans-tag/update', 15 + url: '/wechatMp/fans-tag/update',
16 method: 'put', 16 method: 'put',
17 data: data 17 data: data
18 }) 18 })
@@ -21,7 +21,7 @@ export function updateWxFansTag(data) { @@ -21,7 +21,7 @@ export function updateWxFansTag(data) {
21 // 删除粉丝标签 21 // 删除粉丝标签
22 export function deleteWxFansTag(id) { 22 export function deleteWxFansTag(id) {
23 return request({ 23 return request({
24 - url: '/wechatMp/wx-fans-tag/delete?id=' + id, 24 + url: '/wechatMp/fans-tag/delete?id=' + id,
25 method: 'delete' 25 method: 'delete'
26 }) 26 })
27 } 27 }
@@ -29,15 +29,15 @@ export function deleteWxFansTag(id) { @@ -29,15 +29,15 @@ export function deleteWxFansTag(id) {
29 // 获得粉丝标签 29 // 获得粉丝标签
30 export function getWxFansTag(id) { 30 export function getWxFansTag(id) {
31 return request({ 31 return request({
32 - url: '/wechatMp/wx-fans-tag/get?id=' + id, 32 + url: '/wechatMp/fans-tag/get?id=' + id,
33 method: 'get' 33 method: 'get'
34 }) 34 })
35 } 35 }
36 36
37 // 获得粉丝标签分页 37 // 获得粉丝标签分页
38 -export function getWxFansTagPage(query) { 38 +export function getWxFansTagList(query) {
39 return request({ 39 return request({
40 - url: '/wechatMp/wx-fans-tag/page', 40 + url: '/wechatMp/fans-tag/list',
41 method: 'get', 41 method: 'get',
42 params: query 42 params: query
43 }) 43 })
@@ -46,7 +46,7 @@ export function getWxFansTagPage(query) { @@ -46,7 +46,7 @@ export function getWxFansTagPage(query) {
46 // 导出粉丝标签 Excel 46 // 导出粉丝标签 Excel
47 export function exportWxFansTagExcel(query) { 47 export function exportWxFansTagExcel(query) {
48 return request({ 48 return request({
49 - url: '/wechatMp/wx-fans-tag/export-excel', 49 + url: '/wechatMp/fans-tag/export-excel',
50 method: 'get', 50 method: 'get',
51 params: query, 51 params: query,
52 responseType: 'blob' 52 responseType: 'blob'
yudao-ui-admin/src/views/wechatMp/wxFansTag/index.vue
@@ -6,17 +6,7 @@ @@ -6,17 +6,7 @@
6 <el-form-item label="标签名称" prop="name"> 6 <el-form-item label="标签名称" prop="name">
7 <el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/> 7 <el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/>
8 </el-form-item> 8 </el-form-item>
9 - <el-form-item label="粉丝数量" prop="count">  
10 - <el-input v-model="queryParams.count" placeholder="请输入粉丝数量" clearable @keyup.enter.native="handleQuery"/>  
11 - </el-form-item>  
12 - <el-form-item label="微信账号ID" prop="wxAccountId">  
13 - <el-input v-model="queryParams.wxAccountId" placeholder="请输入微信账号ID" clearable  
14 - @keyup.enter.native="handleQuery"/>  
15 - </el-form-item>  
16 - <el-form-item label="创建时间">  
17 - <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"  
18 - type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/>  
19 - </el-form-item> 9 +
20 <el-form-item> 10 <el-form-item>
21 <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> 11 <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
22 <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> 12 <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
@@ -27,43 +17,54 @@ @@ -27,43 +17,54 @@
27 <el-row :gutter="10" class="mb8"> 17 <el-row :gutter="10" class="mb8">
28 <el-col :span="1.5"> 18 <el-col :span="1.5">
29 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" 19 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
30 - v-hasPermi="['wechatMp:wx-fans-tag:create']">新增 20 + v-hasPermi="['wechatMp:fans-tag:create']">新增
31 </el-button> 21 </el-button>
32 </el-col> 22 </el-col>
33 <el-col :span="1.5"> 23 <el-col :span="1.5">
34 <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" 24 <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
35 :loading="exportLoading" 25 :loading="exportLoading"
36 - v-hasPermi="['wechatMp:wx-fans-tag:export']">导出 26 + v-hasPermi="['wechatMp:fans-tag:export']">导出
37 </el-button> 27 </el-button>
38 </el-col> 28 </el-col>
39 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 29 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
40 </el-row> 30 </el-row>
  31 + <div style="display: flex;width: auto">
  32 + <div class="left_column" style="border: 1px solid #EBEEF5FF; width: 15%;height: auto">
  33 + <div style="padding: 10px 20px; border-bottom: 1px solid #ebeef5; box-sizing: border-box;"><span
  34 + style="font-size: 16px">公众号名称</span></div>
  35 +
  36 + <div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">
  37 + <input type="text" placeholder="输入关键字进行过滤"
  38 + class="el-input__inner"/>
  39 + </div>
  40 +
  41 + <div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">
  42 + <div style="margin-right: 5px;margin-left: 5px" v-for="(account,index) in accountList" @click="getAccountTag(account.appId)">{{ account.name }}</div>
  43 + </div>
  44 + </div>
  45 + <div class="right_column" style="width: 85%">
  46 + <!-- 列表 -->
  47 + <el-table v-loading="loading" :data="list">
  48 + <el-table-column label="编号" align="center" prop="id"/>
  49 + <el-table-column label="标签名称" align="center" prop="name"/>
  50 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  51 + <template slot-scope="scope">
  52 + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  53 + v-hasPermi="['wechatMp:fans-tag:update']">修改
  54 + </el-button>
  55 + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  56 + v-hasPermi="['wechatMp:fans-tag:delete']">删除
  57 + </el-button>
  58 + </template>
  59 + </el-table-column>
  60 + </el-table>
  61 + <!-- 分页组件 -->
  62 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  63 + @pagination="getList"/>
  64 +
  65 + </div>
  66 + </div>
41 67
42 - <!-- 列表 -->  
43 - <el-table v-loading="loading" :data="list">  
44 - <el-table-column label="主键" align="center" prop="id"/>  
45 - <el-table-column label="标签名称" align="center" prop="name"/>  
46 - <el-table-column label="粉丝数量" align="center" prop="count"/>  
47 - <el-table-column label="微信账号ID" align="center" prop="wxAccountId"/>  
48 - <el-table-column label="创建时间" align="center" prop="createTime" width="180">  
49 - <template slot-scope="scope">  
50 - <span>{{ parseTime(scope.row.createTime) }}</span>  
51 - </template>  
52 - </el-table-column>  
53 - <el-table-column label="操作" align="center" class-name="small-padding fixed-width">  
54 - <template slot-scope="scope">  
55 - <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"  
56 - v-hasPermi="['wechatMp:wx-fans-tag:update']">修改  
57 - </el-button>  
58 - <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"  
59 - v-hasPermi="['wechatMp:wx-fans-tag:delete']">删除  
60 - </el-button>  
61 - </template>  
62 - </el-table-column>  
63 - </el-table>  
64 - <!-- 分页组件 -->  
65 - <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"  
66 - @pagination="getList"/>  
67 68
68 <!-- 对话框(添加 / 修改) --> 69 <!-- 对话框(添加 / 修改) -->
69 <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> 70 <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -86,160 +87,179 @@ @@ -86,160 +87,179 @@
86 </div> 87 </div>
87 </template> 88 </template>
88 89
  90 +<style>
  91 +.left_column {
  92 + height: 100%;
  93 + position: relative;
  94 + overflow: auto;
  95 +}
  96 +</style>
  97 +
89 <script> 98 <script>
90 - import {  
91 - createWxFansTag,  
92 - updateWxFansTag,  
93 - deleteWxFansTag,  
94 - getWxFansTag,  
95 - getWxFansTagPage,  
96 - exportWxFansTagExcel  
97 - } from "@/api/wechatMp/wxFansTag"; 99 +import {
  100 + createWxFansTag,
  101 + deleteWxFansTag,
  102 + exportWxFansTagExcel,
  103 + getWxFansTag,
  104 + getWxFansTagList,
  105 + updateWxFansTag
  106 +} from '@/api/wechatMp/wxFansTag'
  107 +import {getAccountPage} from '@/api/wechatMp/wxAccount'
98 108
99 - export default {  
100 - name: "WxFansTag",  
101 - components: {},  
102 - data() {  
103 - return {  
104 - // 遮罩层  
105 - loading: true,  
106 - // 导出遮罩层  
107 - exportLoading: false,  
108 - // 显示搜索条件  
109 - showSearch: true,  
110 - // 总条数  
111 - total: 0,  
112 - // 粉丝标签列表  
113 - list: [],  
114 - // 弹出层标题  
115 - title: "",  
116 - // 是否显示弹出层  
117 - open: false,  
118 - dateRangeCreateTime: [],  
119 - // 查询参数  
120 - queryParams: {  
121 - pageNo: 1,  
122 - pageSize: 10,  
123 - name: null,  
124 - count: null,  
125 - wxAccountId: null,  
126 - },  
127 - // 表单参数  
128 - form: {},  
129 - // 表单校验  
130 - rules: {}  
131 - }; 109 +export default {
  110 + name: 'WxFansTag',
  111 + components: {},
  112 + data() {
  113 + return {
  114 + // 遮罩层
  115 + loading: true,
  116 + // 导出遮罩层
  117 + exportLoading: false,
  118 + // 显示搜索条件
  119 + showSearch: true,
  120 + // 总条数
  121 + total: 0,
  122 + // 粉丝标签列表
  123 + list: [],
  124 + // 账号列表
  125 + accountList: [],
  126 + // 弹出层标题
  127 + title: '',
  128 + // 是否显示弹出层
  129 + open: false,
  130 + dateRangeCreateTime: [],
  131 + // 查询参数
  132 + queryParams: {
  133 + appId: null,
  134 + },
  135 + // 表单参数
  136 + form: {},
  137 + // 表单校验
  138 + rules: {}
  139 + }
  140 + },
  141 + created() {
  142 + this.getAccountList()
  143 + },
  144 + methods: {
  145 + /** 查询列表 */
  146 + getList(appId) {
  147 + this.loading = false
  148 + this.queryParams.appId = appId
  149 + // 处理查询参数
  150 + let params = {...this.queryParams}
  151 + // 执行查询
  152 + getWxFansTagList(params).then(response => {
  153 + this.list = response.data
  154 + this.loading = false
  155 + })
132 }, 156 },
133 - created() {  
134 - this.getList(); 157 + /** 查询列表 */
  158 + getAccountList() {
  159 + // 执行查询
  160 + getAccountPage().then(response => {
  161 + this.accountList = response.data.list
  162 + })
135 }, 163 },
136 - methods: {  
137 - /** 查询列表 */  
138 - getList() {  
139 - this.loading = true;  
140 - // 处理查询参数  
141 - let params = {...this.queryParams};  
142 - this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');  
143 - // 执行查询  
144 - getWxFansTagPage(params).then(response => {  
145 - this.list = response.data.list;  
146 - this.total = response.data.total;  
147 - this.loading = false;  
148 - });  
149 - },  
150 - /** 取消按钮 */  
151 - cancel() {  
152 - this.open = false;  
153 - this.reset();  
154 - },  
155 - /** 表单重置 */  
156 - reset() {  
157 - this.form = {  
158 - id: undefined,  
159 - name: undefined,  
160 - count: undefined,  
161 - wxAccountId: undefined,  
162 - };  
163 - this.resetForm("form");  
164 - },  
165 - /** 搜索按钮操作 */  
166 - handleQuery() {  
167 - this.queryParams.pageNo = 1;  
168 - this.getList();  
169 - },  
170 - /** 重置按钮操作 */  
171 - resetQuery() {  
172 - this.dateRangeCreateTime = [];  
173 - this.resetForm("queryForm");  
174 - this.handleQuery();  
175 - },  
176 - /** 新增按钮操作 */  
177 - handleAdd() {  
178 - this.reset();  
179 - this.open = true;  
180 - this.title = "添加粉丝标签";  
181 - },  
182 - /** 修改按钮操作 */  
183 - handleUpdate(row) {  
184 - this.reset();  
185 - const id = row.id;  
186 - getWxFansTag(id).then(response => {  
187 - this.form = response.data;  
188 - this.open = true;  
189 - this.title = "修改粉丝标签";  
190 - });  
191 - },  
192 - /** 提交按钮 */  
193 - submitForm() {  
194 - this.$refs["form"].validate(valid => {  
195 - if (!valid) {  
196 - return;  
197 - }  
198 - // 修改的提交  
199 - if (this.form.id != null) {  
200 - updateWxFansTag(this.form).then(response => {  
201 - this.$modal.msgSuccess("修改成功");  
202 - this.open = false;  
203 - this.getList();  
204 - });  
205 - return;  
206 - }  
207 - // 添加的提交  
208 - createWxFansTag(this.form).then(response => {  
209 - this.$modal.msgSuccess("新增成功");  
210 - this.open = false;  
211 - this.getList();  
212 - });  
213 - });  
214 - },  
215 - /** 删除按钮操作 */  
216 - handleDelete(row) {  
217 - const id = row.id;  
218 - this.$modal.confirm('是否确认删除粉丝标签编号为"' + id + '"的数据项?').then(function () {  
219 - return deleteWxFansTag(id);  
220 - }).then(() => {  
221 - this.getList();  
222 - this.$modal.msgSuccess("删除成功");  
223 - }).catch(() => {  
224 - });  
225 - },  
226 - /** 导出按钮操作 */  
227 - handleExport() {  
228 - // 处理查询参数  
229 - let params = {...this.queryParams};  
230 - params.pageNo = undefined;  
231 - params.pageSize = undefined;  
232 - this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');  
233 - // 执行导出  
234 - this.$modal.confirm('是否确认导出所有粉丝标签数据项?').then(() => {  
235 - this.exportLoading = true;  
236 - return exportWxFansTagExcel(params);  
237 - }).then(response => {  
238 - this.$download.excel(response, '粉丝标签.xls');  
239 - this.exportLoading = false;  
240 - }).catch(() => {  
241 - }); 164 +
  165 + /**
  166 + * 获取帐户标签
  167 + * @param appId 公众号appId
  168 + */
  169 + getAccountTag(appId) {
  170 + this.getList(appId)
  171 + },
  172 +
  173 + /** 取消按钮 */
  174 + cancel() {
  175 + this.open = false
  176 + this.reset()
  177 + },
  178 + /** 表单重置 */
  179 + reset() {
  180 + this.form = {
  181 + appId: undefined,
242 } 182 }
  183 + this.resetForm('form')
  184 + },
  185 + /** 搜索按钮操作 */
  186 + handleQuery() {
  187 + this.queryParams.pageNo = 1
  188 + this.getList()
  189 + },
  190 + /** 重置按钮操作 */
  191 + resetQuery() {
  192 + this.dateRangeCreateTime = []
  193 + this.resetForm('queryForm')
  194 + this.handleQuery()
  195 + },
  196 + /** 新增按钮操作 */
  197 + handleAdd() {
  198 + this.reset()
  199 + this.open = true
  200 + this.title = '添加粉丝标签'
  201 + },
  202 + /** 修改按钮操作 */
  203 + handleUpdate(row) {
  204 + this.reset()
  205 + const id = row.id
  206 + getWxFansTag(id).then(response => {
  207 + this.form = response.data
  208 + this.open = true
  209 + this.title = '修改粉丝标签'
  210 + })
  211 + },
  212 + /** 提交按钮 */
  213 + submitForm() {
  214 + this.$refs['form'].validate(valid => {
  215 + if (!valid) {
  216 + return
  217 + }
  218 + // 修改的提交
  219 + if (this.form.id != null) {
  220 + updateWxFansTag(this.form).then(response => {
  221 + this.$modal.msgSuccess('修改成功')
  222 + this.open = false
  223 + this.getList()
  224 + })
  225 + return
  226 + }
  227 + // 添加的提交
  228 + createWxFansTag(this.form).then(response => {
  229 + this.$modal.msgSuccess('新增成功')
  230 + this.open = false
  231 + this.getList()
  232 + })
  233 + })
  234 + },
  235 + /** 删除按钮操作 */
  236 + handleDelete(row) {
  237 + const id = row.id
  238 + this.$modal.confirm('是否确认删除粉丝标签编号为"' + id + '"的数据项?').then(function () {
  239 + return deleteWxFansTag(id)
  240 + }).then(() => {
  241 + this.getList()
  242 + this.$modal.msgSuccess('删除成功')
  243 + }).catch(() => {
  244 + })
  245 + },
  246 + /** 导出按钮操作 */
  247 + handleExport() {
  248 + // 处理查询参数
  249 + let params = {...this.queryParams}
  250 + params.pageNo = undefined
  251 + params.pageSize = undefined
  252 + this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
  253 + // 执行导出
  254 + this.$modal.confirm('是否确认导出所有粉丝标签数据项?').then(() => {
  255 + this.exportLoading = true
  256 + return exportWxFansTagExcel(params)
  257 + }).then(response => {
  258 + this.$download.excel(response, '粉丝标签.xls')
  259 + this.exportLoading = false
  260 + }).catch(() => {
  261 + })
243 } 262 }
244 - }; 263 + }
  264 +}
245 </script> 265 </script>