新增更新微信小程序昵称和头像功能,更新账号初始化状态功能
This commit is contained in:
parent
708ed4ccba
commit
f4210cd6de
@ -0,0 +1,41 @@
|
||||
package ink.wgink.module.wechat.controller.app.miniapp;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
|
||||
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @ClassName: UserMiniAppController
|
||||
* @Description: 小程序用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/8/2 4:47 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Api(tags = ISystemConstant.API_TAGS_WECHAT_MINI_APP_PREFIX + "小程序用户")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.APP_PREFIX + "/miniapp/user")
|
||||
public class MiniappUserAppController {
|
||||
|
||||
@Autowired
|
||||
private IMiniappUserService miniAppUserService;
|
||||
|
||||
@ApiOperation(value = "更新信息", notes = "由用户主动授权更新微信头像、昵称")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update-info")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateInfo(@RequestHeader("token") String token,
|
||||
@RequestBody MiniAppUpdateInfoVO miniAppUpdateInfoVO) throws Exception {
|
||||
miniAppUserService.updateInfo(token, miniAppUpdateInfoVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ink.wgink.module.wechat.controller.official.account;
|
||||
package ink.wgink.module.wechat.controller.wechat.official.account;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
@ -4,9 +4,10 @@ import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniAppUserPO;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -30,6 +31,31 @@ public interface IMiniAppUserDao extends IInitBaseTable {
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 更新信息
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateInfo(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 更新是否初始化账号
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateIsInitAccount(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<MiniappUserPO> listPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
@ -37,5 +63,6 @@ public interface IMiniAppUserDao extends IInitBaseTable {
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
MiniAppUserPO getPO(Map<String, Object> params) throws SearchException;
|
||||
MiniappUserPO getPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,14 @@ import java.io.Serializable;
|
||||
* @Date: 2021/4/8 5:49 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class MiniAppUserPO implements Serializable {
|
||||
public class MiniappUserPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8186629510739913926L;
|
||||
private String appId;
|
||||
private String openId;
|
||||
private String userId;
|
||||
private String nickName;
|
||||
private String avatarUrl;
|
||||
private Integer isInitAccount;
|
||||
private String gmtCreate;
|
||||
|
||||
@ -45,6 +47,22 @@ public class MiniAppUserPO implements Serializable {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName == null ? "" : nickName.trim();
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl == null ? "" : avatarUrl.trim();
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public Integer getIsInitAccount() {
|
||||
return isInitAccount == null ? 0 : isInitAccount;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package ink.wgink.module.wechat.pojo.vos.miniapp;
|
||||
|
||||
/**
|
||||
* @ClassName: MiniAppInfoVO
|
||||
* @Description: 小程序用户信息
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/8/2 4:48 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel
|
||||
public class MiniAppUpdateInfoVO {
|
||||
|
||||
@ApiModelProperty(name = "nickName", value = "昵称")
|
||||
@CheckEmptyAnnotation(name = "昵称")
|
||||
private String nickName;
|
||||
@ApiModelProperty(name = "avatarUrl", value = "头像")
|
||||
@CheckEmptyAnnotation(name = "头像")
|
||||
private String avatarUrl;
|
||||
|
||||
public String getNickName() {
|
||||
return nickName == null ? "" : nickName.trim();
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl == null ? "" : avatarUrl.trim();
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"nickName\":\"")
|
||||
.append(nickName).append('\"');
|
||||
sb.append(",\"avatarUrl\":\"")
|
||||
.append(avatarUrl).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package ink.wgink.module.wechat.pojo.vos.miniapp;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: MiniAppUpdatePhoneVO
|
||||
* @Description: 小程序更新手机
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/8/2 5:20 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@ApiModel
|
||||
public class MiniappUpdatePhoneVO {
|
||||
|
||||
@ApiModelProperty(name = "phone", value = "手机号")
|
||||
@CheckEmptyAnnotation(name = "手机号", regex = "phone")
|
||||
private String phone;
|
||||
|
||||
public String getPhone() {
|
||||
return phone == null ? "" : phone.trim();
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"phone\":\"")
|
||||
.append(phone).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package ink.wgink.module.wechat.service.miniapp;
|
||||
|
||||
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniAppUserPO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IMiniAppUserService
|
||||
* @Description: 小程序用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/8 5:37 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IMiniAppUserService {
|
||||
|
||||
/**
|
||||
* 微信随机用户前缀
|
||||
*/
|
||||
String MINIAPP_RANDOM_USER_PREFIX = "WXM_";
|
||||
|
||||
/**
|
||||
* 创建用户并返回用户ID,已经存在的不操作
|
||||
*
|
||||
* @param appKey
|
||||
* @param openId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
String createAndReturnUserId(String appKey, String openId) throws Exception;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
MiniAppUserPO getPO(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
MiniAppUserPO getPO(String userId);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param appId
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
MiniAppUserPO getPO(String appId, String openId);
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package ink.wgink.module.wechat.service.miniapp;
|
||||
|
||||
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
||||
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IMiniAppUserService
|
||||
* @Description: 小程序用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/8 5:37 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IMiniappUserService {
|
||||
|
||||
/**
|
||||
* 微信随机用户前缀
|
||||
*/
|
||||
String MINIAPP_RANDOM_USER_PREFIX = "WXM_";
|
||||
|
||||
/**
|
||||
* 创建用户并返回用户ID,已经存在的不操作
|
||||
*
|
||||
* @param appKey
|
||||
* @param openId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
String createAndReturnUserId(String appKey, String openId) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新信息
|
||||
*
|
||||
* @param token token
|
||||
* @param miniAppUpdateInfoVO
|
||||
*/
|
||||
void updateInfo(String token, MiniAppUpdateInfoVO miniAppUpdateInfoVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新初始化状态
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param isInitAccount 是否是初始化账户,0:否,1:是
|
||||
*/
|
||||
void updateIsInitAccount(String userId, Integer isInitAccount);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<MiniappUserPO> listPO(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return
|
||||
*/
|
||||
List<MiniappUserPO> listPO(String userId);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param userIds 用户ID列表
|
||||
* @return
|
||||
*/
|
||||
List<MiniappUserPO> listPO(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
MiniappUserPO getPO(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return
|
||||
*/
|
||||
MiniappUserPO getPO(String userId);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param appId appId
|
||||
* @param openId openId
|
||||
* @return
|
||||
*/
|
||||
MiniappUserPO getPO(String appId, String openId);
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package ink.wgink.module.wechat.service.miniapp.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.wechat.dao.miniapp.IMiniAppUserDao;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniAppUserPO;
|
||||
import ink.wgink.module.wechat.service.miniapp.IMiniAppUserService;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MiniAppUserServiceImpl
|
||||
* @Description: 小程序用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/8 5:38 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class MiniAppUserServiceImpl extends DefaultBaseService implements IMiniAppUserService {
|
||||
|
||||
@Value("${user.default-password:"+ ISystemConstant.DEFAULT_PASSWORD +"}")
|
||||
private String defaultPassword;
|
||||
@Autowired
|
||||
private IMiniAppUserDao miniAppUserDao;
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@Override
|
||||
public String createAndReturnUserId(String appKey, String openId) {
|
||||
MiniAppUserPO miniAppUserPO = getPO(appKey, openId);
|
||||
if (miniAppUserPO != null) {
|
||||
LOG.debug("已经绑定小程序用户");
|
||||
return miniAppUserPO.getUserId();
|
||||
}
|
||||
// 随机字符串
|
||||
String randomUserName = WStringUtil.randomSubStr(openId, 6);
|
||||
UserVO userVO = new UserVO();
|
||||
userVO.setUserUsername(MINIAPP_RANDOM_USER_PREFIX + randomUserName);
|
||||
userVO.setUserName("微信M" + randomUserName);
|
||||
userVO.setUserPassword(defaultPassword);
|
||||
userVO.setUserState(0);
|
||||
userVO.setUserType(2);
|
||||
String userId = userService.saveAndReturnId(userVO, true);
|
||||
|
||||
Map<String, Object> params = getHashMap(6);
|
||||
params.put("appId", appKey);
|
||||
params.put("openId", openId);
|
||||
params.put("userId", userId);
|
||||
params.put("isInitAccount", 1);
|
||||
params.put("gmtCreate", DateUtil.getTime());
|
||||
miniAppUserDao.save(params);
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniAppUserPO getPO(Map<String, Object> params) {
|
||||
return miniAppUserDao.getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniAppUserPO getPO(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
return getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniAppUserPO getPO(String appId, String openId) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("appId", appId);
|
||||
params.put("openId", openId);
|
||||
return getPO(params);
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package ink.wgink.module.wechat.service.miniapp.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.wechat.dao.miniapp.IMiniAppUserDao;
|
||||
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
||||
import ink.wgink.module.wechat.pojo.vos.miniapp.MiniAppUpdateInfoVO;
|
||||
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MiniAppUserServiceImpl
|
||||
* @Description: 小程序用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/8 5:38 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class MiniappUserServiceImpl extends DefaultBaseService implements IMiniappUserService {
|
||||
|
||||
@Value("${user.default-password:" + ISystemConstant.DEFAULT_PASSWORD + "}")
|
||||
private String defaultPassword;
|
||||
@Autowired
|
||||
private IMiniAppUserDao miniappUserDao;
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@Override
|
||||
public String createAndReturnUserId(String appKey, String openId) {
|
||||
MiniappUserPO miniAppUserPO = getPO(appKey, openId);
|
||||
if (miniAppUserPO != null) {
|
||||
LOG.debug("已经绑定小程序用户");
|
||||
return miniAppUserPO.getUserId();
|
||||
}
|
||||
// 随机字符串
|
||||
String randomUserName = WStringUtil.randomSubStr(openId, 6);
|
||||
UserVO userVO = new UserVO();
|
||||
userVO.setUserUsername(MINIAPP_RANDOM_USER_PREFIX + randomUserName);
|
||||
userVO.setUserName("微信M" + randomUserName);
|
||||
userVO.setUserPassword(defaultPassword);
|
||||
userVO.setUserState(0);
|
||||
userVO.setUserType(2);
|
||||
String userId = userService.saveAndReturnId(userVO, true);
|
||||
|
||||
Map<String, Object> params = getHashMap(6);
|
||||
params.put("appId", appKey);
|
||||
params.put("openId", openId);
|
||||
params.put("userId", userId);
|
||||
params.put("isInitAccount", 1);
|
||||
params.put("gmtCreate", DateUtil.getTime());
|
||||
miniappUserDao.save(params);
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfo(String token, MiniAppUpdateInfoVO miniAppUpdateInfoVO) throws Exception {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
UserPO userPO = userService.getPO(userId);
|
||||
if (userPO == null) {
|
||||
throw new SearchException("非系统用户,请刷新小程序");
|
||||
}
|
||||
MiniappUserPO miniAppUserPO = getPO(userId);
|
||||
if (miniAppUserPO == null) {
|
||||
throw new SearchException("未绑定为用户,请刷新小程序");
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("nickName", miniAppUpdateInfoVO.getNickName());
|
||||
params.put("avatarUrl", miniAppUpdateInfoVO.getAvatarUrl());
|
||||
params.put("userId", userId);
|
||||
miniappUserDao.updateInfo(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIsInitAccount(String userId, Integer isInitAccount) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
params.put("isInitAccount", isInitAccount);
|
||||
miniappUserDao.updateIsInitAccount(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MiniappUserPO> listPO(Map<String, Object> params) {
|
||||
return miniappUserDao.listPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MiniappUserPO> listPO(String userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MiniappUserPO> listPO(List<String> userIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
return listPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniappUserPO getPO(Map<String, Object> params) {
|
||||
return miniappUserDao.getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniappUserPO getPO(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
return getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniappUserPO getPO(String appId, String openId) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("appId", appId);
|
||||
params.put("openId", openId);
|
||||
return getPO(params);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
<cache flushInterval="3600000"/>
|
||||
|
||||
<resultMap id="miniAppUserPO" type="ink.wgink.module.wechat.pojo.pos.miniapp.MiniAppUserPO">
|
||||
<resultMap id="miniappUserPO" type="ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO">
|
||||
<result column="app_id" property="appId"/>
|
||||
<result column="open_id" property="openId"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
@ -19,6 +19,8 @@
|
||||
`app_id` varchar(255) DEFAULT NULL COMMENT 'appid',
|
||||
`open_id` varchar(255) DEFAULT NULL COMMENT 'openid',
|
||||
`user_id` varchar(255) DEFAULT NULL COMMENT '用户ID',
|
||||
`nick_name` varchar(255) DEFAULT NULL COMMENT '微信昵称',
|
||||
`avatar_url` varchar(500) DEFAULT NULL COMMENT '微信头像',
|
||||
`is_init_account` int(1) DEFAULT '0' COMMENT '是否初始化账户',
|
||||
`gmt_create` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
@ -45,12 +47,61 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 详情 -->
|
||||
<select id="getPO" parameterType="map" resultMap="miniAppUserPO" useCache="true">
|
||||
<!-- 更新信息 -->
|
||||
<update id="updateInfo" parameterType="map">
|
||||
UPDATE
|
||||
wechat_mini_app_user
|
||||
SET
|
||||
nick_name = #{nickName},
|
||||
avatar_url = #{avatarUrl}
|
||||
WHERE
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<!-- 更新是否初始化账号 -->
|
||||
<update id="updateIsInitAccount" parameterType="map">
|
||||
UPDATE
|
||||
wechat_mini_app_user
|
||||
SET
|
||||
is_init_account = #{isInitAccount}
|
||||
WHERE
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<!-- 列表 -->
|
||||
<select id="listPO" parameterType="map" resultMap="miniappUserPO" useCache="true">
|
||||
SELECT
|
||||
app_id,
|
||||
open_id,
|
||||
user_id,
|
||||
nick_name,
|
||||
avatar_url,
|
||||
is_init_account,
|
||||
gmt_create
|
||||
FROM
|
||||
wechat_mini_app_user
|
||||
<where>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 详情 -->
|
||||
<select id="getPO" parameterType="map" resultMap="miniappUserPO" useCache="true">
|
||||
SELECT
|
||||
app_id,
|
||||
open_id,
|
||||
user_id,
|
||||
nick_name,
|
||||
avatar_url,
|
||||
is_init_account,
|
||||
gmt_create
|
||||
FROM
|
||||
|
Loading…
Reference in New Issue
Block a user