diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java index 2c96100..ad78a3c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -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); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 1e669b3..c6bbeb9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -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); + } + /** * 用户注册 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java new file mode 100644 index 0000000..7fa42de --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java @@ -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 queryAll(TbShopVideo tbShopVideo); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java new file mode 100644 index 0000000..6123ff4 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java @@ -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; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index d8127b8..57217a6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -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)); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java new file mode 100644 index 0000000..4ef257f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java @@ -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)); + } +} diff --git a/src/main/resources/mapper/TbShopVideoMapper.xml b/src/main/resources/mapper/TbShopVideoMapper.xml new file mode 100644 index 0000000..bf6fc25 --- /dev/null +++ b/src/main/resources/mapper/TbShopVideoMapper.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + id + , shop_id, type, name, channel_id, source_id, source_url, status ,created_time, update_time + + + + + + + + +