消息推送

This commit is contained in:
liupopo
2023-03-17 18:13:18 +08:00
parent a049d9905c
commit cd96921473
14 changed files with 207 additions and 25 deletions

View File

@@ -368,7 +368,7 @@ public class SingelHomeController {
log.info("用户名或密码错误");
return new CommonResult().failed("用户名或密码错误");
}
if (StringUtils.isNotBlank(cid) && StringUtils.isNotBlank(phone)) {
if (StringUtils.isNotBlank(cid) && StringUtils.isNotBlank(phone) && !"null".equals(cid)) {
ThreadUtil.execute(() -> pushCidsService.bindPhone(cid, phone));
}
return new CommonResult().success(token);
@@ -399,7 +399,7 @@ public class SingelHomeController {
if (token.get("token") == null) {
return new CommonResult().validateFailed("用户名或密码错误");
}
if (StringUtils.isNotBlank(cid) && StringUtils.isNotBlank(phone)) {
if (StringUtils.isNotBlank(cid) && StringUtils.isNotBlank(phone) && !"null".equals(cid)) {
ThreadUtil.execute(() -> pushCidsService.bindPhone(cid, phone));
}
return new CommonResult().success(token);
@@ -470,6 +470,12 @@ public class SingelHomeController {
if (StringUtils.isBlank(type)) {
return new CommonResult().failed("参数错误type");
}
UmsMember byUsername = memberService.getByUsername(phone);
if (byUsername == null) {
return new CommonResult().failed("该手机号未注册!");
}
//缓存识别码
String redisKey = "";
if (SmsEnum.SendEnum.LOGIN.getCode().equals(type)) {
@@ -616,8 +622,9 @@ public class SingelHomeController {
@ApiOperation(value = "登出功能")
@RequestMapping(value = "/logout", method = RequestMethod.POST)
@ResponseBody
public Object logout() {
public Object logout(@RequestParam("cid") String cid) {
SecurityContextHolder.getContext().setAuthentication(null);
ThreadUtil.execute(() -> pushCidsService.unbindPhone(cid));
return new CommonResult().success(null);
}
@@ -629,6 +636,6 @@ public class SingelHomeController {
if (StringUtils.isNotBlank(cid)) {
ThreadUtil.execute(() -> pushCidsService.pushCid(cid));
}
return new CommonResult().success();
return new CommonResult().success("OK");
}
}

View File

@@ -25,6 +25,7 @@
*********************************************************/
package com.zscat.mallplus.unipush;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -69,10 +70,8 @@ public class PushCidsService extends ServiceImpl<PushCidsMapper, PushCids> {
if (list != null && list.size() == 1) { // 只有一条cid数据判断是否和手机号相同
PushCids pc = list.get(0);
if (!phone.equals(pc.getUserPhone())) { // 手机号不同或为空,更新手机号
UpdateWrapper<PushCids> uw = new UpdateWrapper<>();
uw.set("userPhone", phone);
uw.eq("getuiCid", cid);
baseMapper.update(null, uw);
pc.setUserPhone(phone);
baseMapper.updateById(pc);
}
return;
}
@@ -91,4 +90,13 @@ public class PushCidsService extends ServiceImpl<PushCidsMapper, PushCids> {
uw.eq("getuiCid", cid);
baseMapper.delete(uw);
}
public void unbindPhone(String cid) {
if (StrUtil.isBlank(cid))
return;
UpdateWrapper<PushCids> uw = new UpdateWrapper<>();
uw.set("userPhone", "");
uw.eq("getuiCid", cid);
baseMapper.update(null, uw);
}
}

View File

@@ -44,7 +44,8 @@ spring.redis.host=127.0.0.1
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=123456
spring.redis.password=
#spring.redis.password=123456
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-active=8
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09

View File

@@ -53,10 +53,10 @@ oss.aliyun.first.bucketName=yxt-sc
oss.aliyun.first.endPoint=oss-cn-huhehaote.aliyuncs.com
oss.aliyun.first.styleName=
oss.aliyun.first.prefix=web
oss.aliyun.second.accessKeyId=\u02A1\uFFFD\uFFFD...
oss.aliyun.second.accessKeySecret=\u02A1\uFFFD\uFFFD...
oss.aliyun.second.accessKeyId=\u7701\u951F\u65A4\u62F7...
oss.aliyun.second.accessKeySecret=\u7701\u951F\u65A4\u62F7...
#oss.aliyun.second.accessKeyId=\u02A1\uFFFD\uFFFD...
#oss.aliyun.second.accessKeySecret=\u02A1\uFFFD\uFFFD...
#oss.aliyun.second.accessKeyId=\u7701\u951F\u65A4\u62F7...
#oss.aliyun.second.accessKeySecret=\u7701\u951F\u65A4\u62F7...
oss.aliyun.second.bucketName=peterjava
oss.aliyun.second.endPoint=oss-cn-huhehaote.aliyuncs.com
oss.aliyun.second.styleName=