mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 07:55:06 +08:00
mp:实现 user 的 ui 界面
This commit is contained in:
@ -27,6 +27,10 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode TAG_DELETE_FAIL = new ErrorCode(1006002001, "删除标签失败,原因:{}");
|
||||
ErrorCode TAG_GET_FAIL = new ErrorCode(1006002001, "获得标签失败,原因:{}");
|
||||
|
||||
// ========== 公众号标签 1006003000============
|
||||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1006003000, "用户不存在");
|
||||
ErrorCode USER_UPDATE_TAG_FAIL = new ErrorCode(1006003001, "更新用户标签失败,原因:{}");
|
||||
|
||||
// TODO 要处理下
|
||||
ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1006001002, "用户不存在");
|
||||
|
||||
|
@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.mp.controller.admin.tag;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.*;
|
||||
import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO;
|
||||
import cn.iocoder.yudao.module.mp.service.tag.MpTagService;
|
||||
@ -18,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -62,6 +60,14 @@ public class MpTagController {
|
||||
return success(MpTagConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获取公众号账号精简信息列表")
|
||||
@PreAuthorize("@ss.hasPermission('mp:account:query')")
|
||||
public CommonResult<List<MpTagSimpleRespVO>> getSimpleTags() {
|
||||
List<MpTagDO> list = mpTagService.getTagList();
|
||||
return success(MpTagConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
|
||||
@PostMapping("/sync")
|
||||
@ApiOperation("同步公众号标签")
|
||||
@ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true, dataTypeClass = Long.class)
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.tag.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("管理后台 - 公众号标签精简信息 Response VO")
|
||||
@Data
|
||||
public class MpTagSimpleRespVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "公众号的标签编号", required = true, example = "2048")
|
||||
private Long tagId;
|
||||
|
||||
@ApiModelProperty(value = "标签名称", required = true, example = "快乐")
|
||||
private String name;
|
||||
|
||||
}
|
@ -3,3 +3,16 @@ POST {{baseUrl}}/mp/user/sync?accountId=1
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenentId}}
|
||||
|
||||
### 请求 /mp/user/update 接口 => 成功
|
||||
PUT {{baseUrl}}/mp/user/update
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenentId}}
|
||||
|
||||
{
|
||||
"id": "3",
|
||||
"nickname": "test",
|
||||
"remark": "测试备注",
|
||||
"tagIds": [103, 104]
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.mp.controller.admin.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.*;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO;
|
||||
import cn.iocoder.yudao.module.mp.service.user.MpUserService;
|
||||
@ -18,7 +20,7 @@ import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理后台 - 微信公众号粉丝")
|
||||
@Api(tags = "管理后台 - 公众号粉丝")
|
||||
@RestController
|
||||
@RequestMapping("/mp/user")
|
||||
@Validated
|
||||
@ -28,13 +30,29 @@ public class MpUserController {
|
||||
private MpUserService mpUserService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得微信公众号粉丝分页")
|
||||
@ApiOperation("获得公众号粉丝分页")
|
||||
@PreAuthorize("@ss.hasPermission('mp:user:query')")
|
||||
public CommonResult<PageResult<MpUserRespVO>> getUserPage(@Valid MpUserPageReqVO pageVO) {
|
||||
PageResult<MpUserDO> pageResult = mpUserService.getUserPage(pageVO);
|
||||
return success(MpUserConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得公众号粉丝")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('mp:user:query')")
|
||||
public CommonResult<MpUserRespVO> getUser(@RequestParam("id") Long id) {
|
||||
return success(MpUserConvert.INSTANCE.convert(mpUserService.getUser(id)));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新公众号粉丝")
|
||||
@PreAuthorize("@ss.hasPermission('mp:user:update')")
|
||||
public CommonResult<Boolean> updateUser(@Valid @RequestBody MpUserUpdateReqVO updateReqVO) {
|
||||
mpUserService.updateUser(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/sync")
|
||||
@ApiOperation("同步公众号粉丝")
|
||||
@ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true, dataTypeClass = Long.class)
|
||||
|
@ -1,58 +0,0 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.user.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 微信公众号粉丝 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class MpUserBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "用户标识")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty(value = "订阅状态,0未关注,1已关注")
|
||||
private Integer subscribeStatus;
|
||||
|
||||
@ApiModelProperty(value = "订阅时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date subscribeTime;
|
||||
|
||||
@ApiModelProperty(value = "订阅时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date unsubscribeTime;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "语言")
|
||||
private String language;
|
||||
|
||||
@ApiModelProperty(value = "国家")
|
||||
private String country;
|
||||
|
||||
@ApiModelProperty(value = "省份")
|
||||
private String province;
|
||||
|
||||
@ApiModelProperty(value = "城市")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty(value = "头像地址")
|
||||
private String headImageUrl;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "微信公众号ID")
|
||||
private Long accountId;
|
||||
|
||||
@ApiModelProperty(value = "微信公众号appid")
|
||||
private String appId;
|
||||
|
||||
}
|
@ -1,22 +1,28 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.user.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
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;
|
||||
|
||||
@ApiModel("管理后台 - 微信公众号粉丝分页 Request VO")
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("管理后台 - 公众号粉丝分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MpUserPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户标识")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "微信公众号 ID")
|
||||
@ApiModelProperty(value = "公众号账号的编号", required = true, example = "2048")
|
||||
@NotNull(message = "公众号账号的编号不能为空")
|
||||
private Long accountId;
|
||||
|
||||
@ApiModelProperty(value = "公众号用户标识", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", notes = "模糊匹配")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty(value = "公众号用户昵称", example = "芋艿", notes = "模糊匹配")
|
||||
private String nickname;
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,53 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.user.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("管理后台 - 微信公众号粉丝 Response VO")
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 公众号粉丝 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MpUserRespVO extends MpUserBaseVO {
|
||||
public class MpUserRespVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "公众号用户标识", required = true, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty(value = "关注状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
private Integer subscribeStatus;
|
||||
@ApiModelProperty(value = "关注时间", required = true)
|
||||
private LocalDateTime subscribeTime;
|
||||
@ApiModelProperty(value = "取消关注时间")
|
||||
private LocalDateTime unsubscribeTime;
|
||||
|
||||
@ApiModelProperty(value = "昵称", example = "芋道")
|
||||
private String nickname;
|
||||
@ApiModelProperty(value = "头像地址", example = "https://www.iocoder.cn/1.png")
|
||||
private String headImageUrl;
|
||||
@ApiModelProperty(value = "语言", example = "zh_CN")
|
||||
private String language;
|
||||
@ApiModelProperty(value = "国家", example = "中国")
|
||||
private String country;
|
||||
@ApiModelProperty(value = "省份", example = "广东省")
|
||||
private String province;
|
||||
@ApiModelProperty(value = "城市", example = "广州市")
|
||||
private String city;
|
||||
@ApiModelProperty(value = "备注", example = "你是一个芋头嘛")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "标签编号数组", example = "1,2,3")
|
||||
private List<Long> tagIds;
|
||||
|
||||
@ApiModelProperty(value = "公众号账号的编号", required = true, example = "1")
|
||||
private Long accountId;
|
||||
@ApiModelProperty(value = "公众号账号的 appId", required = true, example = "wx1234567890")
|
||||
private String appId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.mp.controller.admin.user.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 公众号粉丝更新 Request VO")
|
||||
@Data
|
||||
public class MpUserUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "昵称", example = "芋道")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "你是一个芋头嘛")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "标签编号数组", example = "1,2,3")
|
||||
private List<Long> tagIds;
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mp.convert.tag;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO;
|
||||
@ -36,4 +37,6 @@ public interface MpTagConvert {
|
||||
})
|
||||
MpTagDO convert(WxUserTag tag, MpAccountDO account);
|
||||
|
||||
List<MpTagSimpleRespVO> convertList02(List<MpTagDO> list);
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
@ -49,4 +50,6 @@ public interface MpUserConvert {
|
||||
return CollectionUtils.convertList(wxUsers, wxUser -> convert(account, wxUser));
|
||||
}
|
||||
|
||||
MpUserDO convert(MpUserUpdateReqVO bean);
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公众号标签 Service 接口
|
||||
@ -45,6 +46,8 @@ public interface MpTagService {
|
||||
*/
|
||||
PageResult<MpTagDO> getTagPage(MpTagPageReqVO pageReqVO);
|
||||
|
||||
List<MpTagDO> getTagList();
|
||||
|
||||
/**
|
||||
* 同步公众号标签
|
||||
*
|
||||
|
@ -116,6 +116,11 @@ public class MpTagServiceImpl implements MpTagService {
|
||||
return mpTagMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MpTagDO> getTagList() {
|
||||
return mpTagMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncTag(Long accountId) {
|
||||
@ -127,7 +132,7 @@ public class MpTagServiceImpl implements MpTagService {
|
||||
try {
|
||||
wxTags = mpService.getUserTagService().tagGet();
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw exception(TAG_GET_FAIL, e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
// 第二步,合并更新回自己的数据库;由于标签只有 100 个,所以直接 for 循环操作
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mp.service.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
|
||||
@ -74,4 +75,11 @@ public interface MpUserService {
|
||||
*/
|
||||
void updateUserUnsubscribe(String appId, String openId);
|
||||
|
||||
/**
|
||||
* 更新公众号粉丝
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateUser(MpUserUpdateReqVO updateReqVO);
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO;
|
||||
import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO;
|
||||
@ -29,6 +30,10 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_UPDATE_TAG_FAIL;
|
||||
|
||||
/**
|
||||
* 微信公众号粉丝 Service 实现类
|
||||
*
|
||||
@ -156,14 +161,55 @@ public class MpUserServiceImpl implements MpUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserUnsubscribe(String appId, String openId) {
|
||||
MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, openId);
|
||||
public void updateUserUnsubscribe(String appId, String openid) {
|
||||
MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, openid);
|
||||
if (dbUser == null) {
|
||||
log.error("[updateUserUnsubscribe][微信公众号粉丝 appId({}) openId({}) 不存在]", appId, openId);
|
||||
log.error("[updateUserUnsubscribe][微信公众号粉丝 appId({}) openid({}) 不存在]", appId, openid);
|
||||
return;
|
||||
}
|
||||
mpUserMapper.updateById(new MpUserDO().setId(dbUser.getId()).setSubscribeStatus(CommonStatusEnum.DISABLE.getStatus())
|
||||
.setSubscribeTime(LocalDateTime.now()));
|
||||
.setUnsubscribeTime(LocalDateTime.now()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(MpUserUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
MpUserDO user = validateUserExists(updateReqVO.getId());
|
||||
|
||||
// 第一步,更新标签到公众号
|
||||
updateUserTag(user.getAppId(), user.getOpenid(), updateReqVO.getTagIds());
|
||||
|
||||
// 第二步,更新基本信息到数据库
|
||||
MpUserDO updateObj = MpUserConvert.INSTANCE.convert(updateReqVO).setId(user.getId());
|
||||
mpUserMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private MpUserDO validateUserExists(Long id) {
|
||||
MpUserDO user = mpUserMapper.selectById(id);
|
||||
if (user == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
private void updateUserTag(String appId, String openid, List<Long> tagIds) {
|
||||
WxMpService mpService = mpServiceFactory.getRequiredMpService(appId);
|
||||
try {
|
||||
// 第一步,先取消原来的标签
|
||||
List<Long> oldTagIds = mpService.getUserTagService().userTagList(openid);
|
||||
for (Long tagId : oldTagIds) {
|
||||
mpService.getUserTagService().batchUntagging(tagId, new String[]{openid});
|
||||
}
|
||||
// 第二步,再设置新的标签
|
||||
if (CollUtil.isEmpty(tagIds)) {
|
||||
return;
|
||||
}
|
||||
for (Long tagId: tagIds) {
|
||||
mpService.getUserTagService().batchTagging(tagId, new String[]{openid});
|
||||
}
|
||||
} catch (WxErrorException e) {
|
||||
throw exception(USER_UPDATE_TAG_FAIL, e.getError().getErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user