更新用户信息 头像/昵称

视频号/小程序/公众号mapper  暂未投入使用
This commit is contained in:
wangw 2024-04-15 10:07:53 +08:00
parent 7d3fe9deb7
commit d7dfeee159
7 changed files with 337 additions and 4 deletions

View File

@ -67,6 +67,7 @@ public class LoginFilter implements Filter {
chain.doFilter(req, resp);
return;
}
//environment 环境标识 wx app 后续environment不可为空
String environment = request.getHeader("environment");
//token校验目前只对app生效
@ -85,10 +86,17 @@ public class LoginFilter implements Filter {
response.getWriter().flush();//流里边的缓存刷出
return;
}
//获取当前登录人的用户id
String loginName = TokenUtil.parseParamFromToken(token).getString("userId");
//获取redis中的token
String message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName));
String message = "";
if(environment.equals("app")){
//获取当前登录人的用户id
String loginName = TokenUtil.parseParamFromToken(token).getString("userId");
//获取redis中的token
message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName));
}else if(environment.equals("wx")){
//获取当前登录人的用户id
String openId = TokenUtil.parseParamFromToken(token).getString("openId");
message = redisUtil.getMessage(RedisCst.ONLINE_USER.concat(openId));
}
if (StringUtils.isBlank(message)) {
Result result = new Result(CodeEnum.TOKEN_EXPIRED);
String jsonString = JSONObject.toJSONString(result);

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto;
import com.chaozhanggui.system.cashierservice.entity.dto.OnlineUserDto;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
@ -221,6 +222,14 @@ public class LoginContoller {
return loginService.userInfo(userId, shopId);
}
@PostMapping("/upUserInfo")
public Result userInfo(@RequestHeader String token, @RequestBody TbUserInfo userInfo) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
userInfo.setId(Integer.valueOf(userId));
userInfo.setUpdatedAt(System.currentTimeMillis());
return loginService.upUserInfo(userInfo);
}
/**
* 用户注册

View File

@ -0,0 +1,32 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopVideo;
import java.util.List;
/**
* (TbShopVideo)表数据库访问层
*
* @author ww
* @since 2024-04-12 14:50:09
*/
public interface TbShopVideoMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopVideo queryById(Integer id);
/**
* 查询数据
*
* @param tbShopVideo 查询条件
* @return 对象列表
*/
List<TbShopVideo> queryAll(TbShopVideo tbShopVideo);
}

View File

@ -0,0 +1,159 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import java.io.Serializable;
/**
* 商户视频号(TbShopVideo)实体类
*
* @author ww
* @since 2024-04-12 14:50:09
*/
public class TbShopVideo implements Serializable {
private static final long serialVersionUID = 521986900418854409L;
private Integer id;
/**
* 店铺id
*/
private Integer shopId;
/**
* 1-公众号2-小程序3-视频号
*/
private Integer type;
/**
* 描述信息
*/
private String name;
/**
* 渠道id(视频号id)
*/
private Integer channelId;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 资源Id(视频号id)(公众号id)
*/
private Integer sourceId;
/**
* 资源地址
*/
private String sourceUrl;
/**
* 0:关闭1开启
*/
private Integer status;
/**
* 视频id
*/
private Integer videoId;
/**
* 视频地址
*/
private String videoUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getChannelId() {
return channelId;
}
public void setChannelId(Integer channelId) {
this.channelId = channelId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getSourceId() {
return sourceId;
}
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
public String getSourceUrl() {
return sourceUrl;
}
public void setSourceUrl(String sourceUrl) {
this.sourceUrl = sourceUrl;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getVideoId() {
return videoId;
}
public void setVideoId(Integer videoId) {
this.videoId = videoId;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
}

View File

@ -123,7 +123,11 @@ public class LoginService {
tbShopUser.setUserId(userInfo.getId().toString());
tbShopUser.setMiniOpenId(openId);
tbShopUser.setCreatedAt(System.currentTimeMillis());
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.insert(tbShopUser);
}else {
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
shopMap.put("shopId", tbShopUser.getShopId());
shopMap.put("name", tbShopInfo.getShopName());
@ -304,6 +308,11 @@ public class LoginService {
return Result.success(CodeEnum.ENCRYPT, map);
}
public Result upUserInfo(TbUserInfo userInfo){
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
return Result.success(CodeEnum.SUCCESS);
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(RandomUtil.randomNumbers(10));

View File

@ -0,0 +1,38 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.dao.TbShopVideoMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopVideo;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import javax.annotation.Resource;
/**
* 视频号 公众号
* @author ww
* @since 2024-04-12 14:50:10
*/
public class TbShopVideoService {
@Resource
private TbShopVideoMapper tbShopVideoMapper;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
public Result queryById(Integer id) {
return Result.success(CodeEnum.ENCRYPT,tbShopVideoMapper.queryById(id));
}
/**
* @param tbShopVideo 筛选条件
* @return 查询结果
*/
public Result queryAll(TbShopVideo tbShopVideo) {
tbShopVideo.setStatus(1);
return Result.success(CodeEnum.ENCRYPT,tbShopVideoMapper.queryAll(tbShopVideo));
}
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopVideoMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopVideo" id="TbShopVideoMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="channelId" column="channel_id" jdbcType="INTEGER"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="sourceId" column="source_id" jdbcType="INTEGER"/>
<result property="sourceUrl" column="source_url" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
, shop_id, type, name, channel_id, source_id, source_url, status ,created_time, update_time</sql>
<!--查询单个-->
<select id="queryById" resultMap="TbShopVideoMap">
select
<include refid="Base_Column_List"/>
from tb_shop_video
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAll" resultMap="TbShopVideoMap">
select
<include refid="Base_Column_List"/>
from tb_shop_video
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="shopId != null">
and shop_id = #{shopId}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="channelId != null">
and channel_id = #{channelId}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="sourceId != null">
and source_id = #{sourceId}
</if>
<if test="sourceUrl != null and sourceUrl != ''">
and source_url = #{sourceUrl}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="videoId != null">
and video_id = #{videoId}
</if>
<if test="videoUrl != null and videoUrl != ''">
and video_url = #{videoUrl}
</if>
</where>
</select>
</mapper>