个推代码提交
This commit is contained in:
parent
aad746047f
commit
1df48ab98c
@ -54,11 +54,11 @@ public class WebController {
|
|||||||
sxDataService.SyncVipList(new DataBaseInfo(),sxDataService.getCommentModel());
|
sxDataService.SyncVipList(new DataBaseInfo(),sxDataService.getCommentModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/getAppSign")
|
// @RequestMapping("/getAppSign")
|
||||||
public void getAppSign(){
|
// public void getAppSign(){
|
||||||
log.info("getAppSign");
|
// log.info("getAppSign");
|
||||||
sxDataService.getAppSign();
|
// sxDataService.getAppSign();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@RequestMapping("/downLoadClient")
|
@RequestMapping("/downLoadClient")
|
||||||
public void downLoadClient(){
|
public void downLoadClient(){
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.suisung.mall.account.RedisKeyManage;
|
||||||
|
|
||||||
|
public class RedisKey {
|
||||||
|
|
||||||
|
public static final String SINGLEPUSHTOKE="singlePush:toke";
|
||||||
|
}
|
||||||
@ -80,7 +80,6 @@ public class LoginController extends BaseControllerImpl {
|
|||||||
params.put("grant_type", "password");
|
params.put("grant_type", "password");
|
||||||
params.put("username", user_account);
|
params.put("username", user_account);
|
||||||
params.put("password", user_password);
|
params.put("password", user_password);
|
||||||
|
|
||||||
CommonResult result = accountUserBaseService.login(params);
|
CommonResult result = accountUserBaseService.login(params);
|
||||||
|
|
||||||
// user_account 判断是否绑定了手机号
|
// user_account 判断是否绑定了手机号
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.suisung.mall.account.controller.mobile;
|
||||||
|
|
||||||
|
import com.suisung.mall.account.service.AccountSinglePushService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/account/singlePus")
|
||||||
|
@Slf4j
|
||||||
|
public class SinglePushController {
|
||||||
|
@Autowired
|
||||||
|
private AccountSinglePushService accountSinglePushService;
|
||||||
|
|
||||||
|
@RequestMapping("/getSingleToken")
|
||||||
|
public String getToken() {
|
||||||
|
return accountSinglePushService.getTokenString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/delSingleToken")
|
||||||
|
public String delSingleToken() {
|
||||||
|
accountSinglePushService.delToken();
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/pushTocid")
|
||||||
|
public String pushTocid(@RequestParam String message,@RequestParam String userId) {
|
||||||
|
log.info("pushTocid");
|
||||||
|
accountSinglePushService.pushTocid(message,userId);
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.suisung.mall.account.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.suisung.mall.common.modules.singlepush.UserDeviceBind;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UserDeviceBindMapper extends BaseMapper<UserDeviceBind> {
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.suisung.mall.account.service;
|
||||||
|
|
||||||
|
import com.getui.push.v2.sdk.dto.res.TokenDTO;
|
||||||
|
import com.suisung.mall.common.service.SinglePushBaseService;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
public interface AccountSinglePushService extends SinglePushBaseService {
|
||||||
|
|
||||||
|
String getTokenString();
|
||||||
|
|
||||||
|
void delToken();
|
||||||
|
|
||||||
|
void pushTocid(String message,String userId);
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.suisung.mall.account.service;
|
||||||
|
|
||||||
|
import com.suisung.mall.common.modules.singlepush.UserDeviceBind;
|
||||||
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserDeviceBindService extends IBaseService<UserDeviceBind> {
|
||||||
|
|
||||||
|
void saveUserDeviceBind(UserDeviceBind userDeviceBind);
|
||||||
|
|
||||||
|
List<UserDeviceBind> getActive(UserDeviceBind userDeviceBind);
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.suisung.mall.account.service.impl;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.getui.push.v2.sdk.api.PushApi;
|
||||||
|
import com.getui.push.v2.sdk.common.ApiResult;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.Audience;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.PushDTO;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.PushMessage;
|
||||||
|
import com.suisung.mall.account.service.AccountSinglePushService;
|
||||||
|
import com.suisung.mall.account.service.UserDeviceBindService;
|
||||||
|
import com.suisung.mall.common.modules.singlepush.UserDeviceBind;
|
||||||
|
import com.suisung.mall.common.service.impl.SinglePushBaseServiceImpl;
|
||||||
|
import com.suisung.mall.common.utils.ContextUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@lombok.extern.slf4j.Slf4j
|
||||||
|
public class AccountSinglePushServiceImpl extends SinglePushBaseServiceImpl implements AccountSinglePushService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserDeviceBindService userDeviceBindService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTokenString() {
|
||||||
|
return super.getTokenDTO().getToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delToken(){
|
||||||
|
super.delToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pushTocid(String message,String userId) {
|
||||||
|
UserDeviceBind userDeviceBind= new UserDeviceBind();
|
||||||
|
userDeviceBind.setUserId(userId);
|
||||||
|
List<UserDeviceBind> list= userDeviceBindService.getActive(userDeviceBind);
|
||||||
|
if(CollectionUtil.isEmpty(list)){
|
||||||
|
log.error("登录时绑定设备不存在");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
String cid=list.get(0).getCid();
|
||||||
|
PushApi pushApi= this.getApiHelper().creatApi(PushApi.class);
|
||||||
|
PushDTO<Audience> pushDTO=new PushDTO<>();
|
||||||
|
Audience audience=new Audience();
|
||||||
|
audience.addCid(cid);
|
||||||
|
pushDTO.setAudience(audience);
|
||||||
|
pushDTO.setRequestId(UUID.randomUUID().toString());
|
||||||
|
PushMessage pushMessage=new PushMessage();
|
||||||
|
pushMessage.setDuration(this.getDuration());
|
||||||
|
pushMessage.setTransmission(message);
|
||||||
|
pushDTO.setPushMessage(pushMessage);
|
||||||
|
ApiResult<Map<String, Map<String, String>>> mapApiResult= pushApi.pushToSingleByCid(pushDTO,super.getTokenDTO());
|
||||||
|
if(mapApiResult.getCode()==0){
|
||||||
|
log.info("用户为{},cid为{}发送成功消息成功",list.get(0).getUserId(),list.get(0).getCid());
|
||||||
|
}
|
||||||
|
log.info("mapApiResult的数据{}",mapApiResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -50,6 +50,7 @@ import com.suisung.mall.common.modules.distribution.ShopDistributionUser;
|
|||||||
import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission;
|
import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission;
|
||||||
import com.suisung.mall.common.modules.pay.PayUserResource;
|
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||||
import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser;
|
import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser;
|
||||||
|
import com.suisung.mall.common.modules.singlepush.UserDeviceBind;
|
||||||
import com.suisung.mall.common.pojo.dto.SmsDto;
|
import com.suisung.mall.common.pojo.dto.SmsDto;
|
||||||
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.common.service.MessageService;
|
import com.suisung.mall.common.service.MessageService;
|
||||||
@ -65,9 +66,11 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.util.Pair;
|
import org.springframework.data.util.Pair;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -136,6 +139,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
private AccountUserBaseMapper accountUserBaseMapper;
|
private AccountUserBaseMapper accountUserBaseMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private I18nUtil i18nUtil;
|
private I18nUtil i18nUtil;
|
||||||
|
@Resource
|
||||||
|
private UserDeviceBindService userDeviceBindService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult login(Map<String, String> params) {
|
public CommonResult login(Map<String, String> params) {
|
||||||
@ -216,10 +221,21 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
params2.put("user_mobile", params.get("user_mobile"));
|
params2.put("user_mobile", params.get("user_mobile"));
|
||||||
data.put("merch_approval_status", shopService.shopMerchEntryApprovalStatus(params2));
|
data.put("merch_approval_status", shopService.shopMerchEntryApprovalStatus(params2));
|
||||||
}
|
}
|
||||||
|
String cid=params.get("cid");
|
||||||
|
if(StrUtil.isNotBlank(cid)){
|
||||||
|
UserDeviceBind userDeviceBind = new UserDeviceBind();
|
||||||
|
userDeviceBind.setCid(params.get("cid"));
|
||||||
|
userDeviceBind.setOsType(params.get("os_type"));
|
||||||
|
this.saveUserDeviceBind(userDeviceBind);
|
||||||
|
}
|
||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void saveUserDeviceBind(UserDeviceBind userDeviceBind) {
|
||||||
|
userDeviceBindService.saveUserDeviceBind(userDeviceBind);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getUserInfo(Integer user_id) {
|
public Map<String, Object> getUserInfo(Integer user_id) {
|
||||||
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||||
@ -3034,6 +3050,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
params.put("verify_pwd", StrUtil.isBlank(password) ? "1001" : "1002"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
params.put("verify_pwd", StrUtil.isBlank(password) ? "1001" : "1002"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
||||||
params.put("username", user_base_row.getUser_account());
|
params.put("username", user_base_row.getUser_account());
|
||||||
params.put("password", password);
|
params.put("password", password);
|
||||||
|
params.put("osType", getParameter("osType"));
|
||||||
return login(params);
|
return login(params);
|
||||||
} else {
|
} else {
|
||||||
// 手机号码未绑定的情况, 直接抛出异常
|
// 手机号码未绑定的情况, 直接抛出异常
|
||||||
@ -3095,7 +3112,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
params.put("password", "");
|
params.put("password", "");
|
||||||
params.put("user_mobile", user_mobile);
|
params.put("user_mobile", user_mobile);
|
||||||
params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
||||||
|
params.put("cid",getParameter("cid"));
|
||||||
|
params.put("osType",getParameter("osType"));
|
||||||
return login(params);
|
return login(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.suisung.mall.account.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.suisung.mall.account.mapper.UserDeviceBindMapper;
|
||||||
|
import com.suisung.mall.account.service.UserDeviceBindService;
|
||||||
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
|
import com.suisung.mall.common.modules.singlepush.UserDeviceBind;
|
||||||
|
import com.suisung.mall.common.utils.ContextUtil;
|
||||||
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@lombok.extern.slf4j.Slf4j
|
||||||
|
public class UserDeviceBindServiceImpl extends BaseServiceImpl<UserDeviceBindMapper, UserDeviceBind> implements UserDeviceBindService {
|
||||||
|
@Override
|
||||||
|
public void saveUserDeviceBind(UserDeviceBind userDeviceBind) {
|
||||||
|
if(StringUtils.isEmpty(userDeviceBind.getCid())){
|
||||||
|
throw new RuntimeException("绑定cid不能为空");
|
||||||
|
}
|
||||||
|
if(StringUtils.isEmpty(userDeviceBind.getOsType())){
|
||||||
|
throw new RuntimeException("操作系统类型不能为空");
|
||||||
|
}
|
||||||
|
QueryWrapper<UserDeviceBind> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("user_id",userDeviceBind.getCid());
|
||||||
|
UserDeviceBind bind=getOne(wrapper);
|
||||||
|
if(bind==null){
|
||||||
|
UserDto userDto= ContextUtil.getCurrentUser();
|
||||||
|
assert userDto != null;
|
||||||
|
userDeviceBind.setUserId(userDto.getUser_account());
|
||||||
|
userDeviceBind.setUserType(userDto.getRole_id());
|
||||||
|
userDeviceBind.setLastActive(new Date());
|
||||||
|
userDeviceBind.setBindTime(new Date());
|
||||||
|
this.saveOrUpdate(userDeviceBind);
|
||||||
|
log.info("保存用户设备绑定关系实体成功");
|
||||||
|
}else {
|
||||||
|
if(!bind.getCid().equals(userDeviceBind.getCid())){
|
||||||
|
bind.setCid(userDeviceBind.getCid());
|
||||||
|
}
|
||||||
|
if(!bind.getOsType().equals(userDeviceBind.getOsType())){
|
||||||
|
bind.setCid(userDeviceBind.getOsType());
|
||||||
|
}
|
||||||
|
bind.setLastActive(new Date());
|
||||||
|
bind.setBindTime(new Date());
|
||||||
|
this.saveOrUpdate(bind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserDeviceBind> getActive(UserDeviceBind userDeviceBind) {
|
||||||
|
QueryWrapper<UserDeviceBind> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("user_id",userDeviceBind.getUserId()).orderByDesc("bind_time");
|
||||||
|
return list(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -54,7 +54,9 @@ public class AuthController {
|
|||||||
.token(oAuth2AccessToken.getValue())
|
.token(oAuth2AccessToken.getValue())
|
||||||
.refreshToken(oAuth2AccessToken.getRefreshToken().getValue())
|
.refreshToken(oAuth2AccessToken.getRefreshToken().getValue())
|
||||||
.expiresIn(oAuth2AccessToken.getExpiresIn())
|
.expiresIn(oAuth2AccessToken.getExpiresIn())
|
||||||
.tokenHead(AuthConstant.JWT_TOKEN_PREFIX).build();
|
.tokenHead(AuthConstant.JWT_TOKEN_PREFIX)
|
||||||
|
.cid(parameters.get("cid")).build();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(I18nUtil._("Oauth2获取token失败!") + e.getMessage(), e);
|
logger.error(I18nUtil._("Oauth2获取token失败!") + e.getMessage(), e);
|
||||||
return CommonResult.failed(e.getMessage());
|
return CommonResult.failed(e.getMessage());
|
||||||
|
|||||||
@ -20,4 +20,8 @@ public class Oauth2TokenDto {
|
|||||||
private String tokenHead;
|
private String tokenHead;
|
||||||
@ApiModelProperty("有效时间(秒)")
|
@ApiModelProperty("有效时间(秒)")
|
||||||
private int expiresIn;
|
private int expiresIn;
|
||||||
|
|
||||||
|
//个推使用
|
||||||
|
@ApiModelProperty("cid")
|
||||||
|
private String cid;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -279,6 +279,15 @@
|
|||||||
<artifactId>jieba-analysis</artifactId>
|
<artifactId>jieba-analysis</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 个推api-->
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.getui.push/restful-sdk -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.getui.push</groupId>
|
||||||
|
<artifactId>restful-sdk</artifactId>
|
||||||
|
<version>1.0.6.1</version>
|
||||||
|
<systemPath>${project.basedir}/src/main/resources/lib/restful-sdk-1.0.6.1.jar</systemPath>
|
||||||
|
<scope>system</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<!-- 指定仓库为阿里云与阿帕奇 -->
|
<!-- 指定仓库为阿里云与阿帕奇 -->
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.suisung.mall.common.RedisKeyManage;
|
||||||
|
|
||||||
|
public class RedisKey {
|
||||||
|
|
||||||
|
public static final String SINGLEPUSHTOKE="singlePush:toke";
|
||||||
|
}
|
||||||
@ -215,4 +215,7 @@ public interface AccountService {
|
|||||||
Integer getUserBindConnectUserIdByCondition(@RequestParam(name = "bind_id") String bind_id,
|
Integer getUserBindConnectUserIdByCondition(@RequestParam(name = "bind_id") String bind_id,
|
||||||
@RequestParam(name = "bind_type") Integer bind_type,
|
@RequestParam(name = "bind_type") Integer bind_type,
|
||||||
@RequestParam(name = "user_type", required = false) Integer user_type);
|
@RequestParam(name = "user_type", required = false) Integer user_type);
|
||||||
|
|
||||||
|
@PostMapping("/admin/account/pushTocid")
|
||||||
|
String pushTocid(@RequestParam(name = "message") String message,@RequestParam(name = "userId") String userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.suisung.mall.common.modules.singlepush;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("user_device_bind") // MyBatis-Plus 表名注解
|
||||||
|
@ApiModel("用户设备绑定实体") // Swagger 模型描述
|
||||||
|
public class UserDeviceBind implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) // 主键自增
|
||||||
|
@ApiModelProperty(value = "主键ID", hidden = true) // 隐藏此字段不展示在Swagger文档
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableField("user_id") // 明确字段映射(可省略,默认自动转下划线)
|
||||||
|
@ApiModelProperty(value = "用户唯一标识", required = true, example = "U20231001")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@TableField("cid")
|
||||||
|
@ApiModelProperty(value = "设备CID", required = true, example = "CID_ABCD1234")
|
||||||
|
private String cid;
|
||||||
|
|
||||||
|
@TableField("user_type")
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "用户类型 (1=普通用户, 2=管理员, 3=商家)",
|
||||||
|
required = true,
|
||||||
|
example = "1",
|
||||||
|
notes = "1-普通用户, 2-管理员, 3-商家"
|
||||||
|
)
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
|
@TableField("os_type")
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "手机系统类型",
|
||||||
|
example = "Android",
|
||||||
|
notes = "Android, iOS"
|
||||||
|
)
|
||||||
|
private String osType;
|
||||||
|
|
||||||
|
@TableField("bind_time")
|
||||||
|
@ApiModelProperty(value = "绑定时间", example = "2023-10-01 12:00:00")
|
||||||
|
private Date bindTime;
|
||||||
|
|
||||||
|
@TableField("last_active")
|
||||||
|
@ApiModelProperty(value = "最后活跃时间", example = "2023-10-05 14:30:00")
|
||||||
|
private Date lastActive;
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.suisung.mall.common.service;
|
||||||
|
|
||||||
|
import com.getui.push.v2.sdk.dto.res.TokenDTO;
|
||||||
|
import com.suisung.mall.common.pojo.dto.SmsDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方服务
|
||||||
|
*/
|
||||||
|
public interface SinglePushBaseService {
|
||||||
|
TokenDTO getTokenDTO();
|
||||||
|
void delToken();
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.suisung.mall.common.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import com.getui.push.v2.sdk.ApiHelper;
|
||||||
|
import com.getui.push.v2.sdk.GtApiConfiguration;
|
||||||
|
import com.getui.push.v2.sdk.api.AuthApi;
|
||||||
|
import com.getui.push.v2.sdk.common.ApiResult;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.AuthDTO;
|
||||||
|
import com.getui.push.v2.sdk.dto.res.TokenDTO;
|
||||||
|
import com.suisung.mall.common.RedisKeyManage.RedisKey;
|
||||||
|
import com.suisung.mall.common.service.SinglePushBaseService;
|
||||||
|
import com.suisung.mall.core.web.service.RedisService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@lombok.extern.slf4j.Slf4j
|
||||||
|
public class SinglePushBaseServiceImpl implements SinglePushBaseService {
|
||||||
|
@Value("${single.push.mastersecret}")
|
||||||
|
private String mastersecret;
|
||||||
|
|
||||||
|
@Value("${single.push.appkey}")
|
||||||
|
private String appkey;
|
||||||
|
@Value("${single.push.appId}")
|
||||||
|
private String appId;
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TokenDTO getTokenDTO() {
|
||||||
|
TokenDTO token=new TokenDTO();
|
||||||
|
if(redisService.get(RedisKey.SINGLEPUSHTOKE)==null){
|
||||||
|
return getTokenFromSingelPush();
|
||||||
|
}else {
|
||||||
|
Map map= (Map) redisService.get(RedisKey.SINGLEPUSHTOKE);
|
||||||
|
token.setToken(map.get("token").toString());
|
||||||
|
token.setExpireTime((Long) map.get("expireTime"));
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delToken(){
|
||||||
|
if(redisService.get(RedisKey.SINGLEPUSHTOKE)!=null){
|
||||||
|
Map map= (Map) redisService.get(RedisKey.SINGLEPUSHTOKE);
|
||||||
|
AuthApi authApi = getApiHelper().creatApi(AuthApi.class);
|
||||||
|
String token = (String) map.get("token");
|
||||||
|
TokenDTO tokenDTO = new TokenDTO();
|
||||||
|
tokenDTO.setToken(token);
|
||||||
|
tokenDTO.setExpireTime((Long) map.get("expireTime"));
|
||||||
|
log.info("token--{}",tokenDTO);
|
||||||
|
authApi.close(token,tokenDTO);
|
||||||
|
redisService.del(RedisKey.SINGLEPUSHTOKE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiHelper getApiHelper(){
|
||||||
|
GtApiConfiguration config = new GtApiConfiguration();
|
||||||
|
config.setAppKey(appkey);
|
||||||
|
config.setMasterSecret(mastersecret);
|
||||||
|
config.setAppId(appId);
|
||||||
|
return ApiHelper.build(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDuration(){
|
||||||
|
long timestamp = System.currentTimeMillis(); // 当前时间的时间戳
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(timestamp);
|
||||||
|
calendar.add(Calendar.MINUTE, 10); // 增加10分钟
|
||||||
|
long newTimestamp = calendar.getTimeInMillis(); // 获取新的时间戳
|
||||||
|
return timestamp+"-"+newTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TokenDTO getTokenFromSingelPush(){
|
||||||
|
AuthApi authApi= getApiHelper().creatApi(AuthApi.class);
|
||||||
|
AuthDTO authDTO= AuthDTO.build(appkey, mastersecret);
|
||||||
|
ApiResult<TokenDTO> tokenDTOApiResult= authApi.auth(authDTO);
|
||||||
|
TokenDTO token=null;
|
||||||
|
if (tokenDTOApiResult!= null) {
|
||||||
|
token = tokenDTOApiResult.getData();
|
||||||
|
Map map= BeanUtil.beanToMap(token);
|
||||||
|
log.info("tokenDTO:{}",token);
|
||||||
|
redisService.set(RedisKey.SINGLEPUSHTOKE, map,(token.getExpireTime()/1000)-60);
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,13 +39,14 @@ public class ContextUtil {
|
|||||||
*/
|
*/
|
||||||
public static UserDto getCurrentUser() {
|
public static UserDto getCurrentUser() {
|
||||||
try {
|
try {
|
||||||
UserDto loginUser = staticUserInfoService.getUser();
|
// UserDto loginUser = staticUserInfoService.getUser();
|
||||||
log.info("##### 当前登录用户:{}###", JsonUtil.object2json(loginUser));
|
// log.info("##### 当前登录用户:{}###", JsonUtil.object2json(loginUser));
|
||||||
return loginUser;//todo 测试去除
|
// return loginUser;//todo 测试去除
|
||||||
// UserDto user= new UserDto();
|
UserDto user= new UserDto();
|
||||||
// user.setStore_id("1");
|
user.setStore_id("1");
|
||||||
// user.setRole_id(9);
|
user.setRole_id(9);
|
||||||
// return user;
|
user.setUser_account("18260885688");
|
||||||
|
return user;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,3 +33,8 @@ baidu:
|
|||||||
app_id: 116444176
|
app_id: 116444176
|
||||||
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
||||||
url: https://api.map.baidu.com/geoconv/v2/?
|
url: https://api.map.baidu.com/geoconv/v2/?
|
||||||
|
single: # 个推配置
|
||||||
|
push:
|
||||||
|
mastersecret: jYnpS1xYhh6GfyZQMlciJ
|
||||||
|
appkey: neXXX9r1Tc7gMxN2PIcHA1
|
||||||
|
appId: KXgzOaKSzd5HG3p9IPaVa8
|
||||||
@ -33,3 +33,8 @@ baidu:
|
|||||||
app_id: 116444176
|
app_id: 116444176
|
||||||
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
||||||
url: https://api.map.baidu.com/geoconv/v2/?
|
url: https://api.map.baidu.com/geoconv/v2/?
|
||||||
|
single: # 个推配置
|
||||||
|
push:
|
||||||
|
mastersecret: jYnpS1xYhh6GfyZQMlciJ
|
||||||
|
appkey: neXXX9r1Tc7gMxN2PIcHA1
|
||||||
|
appId: KXgzOaKSzd5HG3p9IPaVa8
|
||||||
@ -33,3 +33,8 @@ baidu:
|
|||||||
app_id: 116444176
|
app_id: 116444176
|
||||||
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
||||||
url: https://api.map.baidu.com/geoconv/v2/?
|
url: https://api.map.baidu.com/geoconv/v2/?
|
||||||
|
single: # 个推配置
|
||||||
|
push:
|
||||||
|
mastersecret: jYnpS1xYhh6GfyZQMlciJ
|
||||||
|
appkey: neXXX9r1Tc7gMxN2PIcHA1
|
||||||
|
appId: KXgzOaKSzd5HG3p9IPaVa8
|
||||||
@ -33,3 +33,8 @@ baidu:
|
|||||||
app_id: 116444176
|
app_id: 116444176
|
||||||
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
ak: qWKt2xbrqXsp2yK35YYXVBNZgrbiCG5v
|
||||||
url: https://api.map.baidu.com/geoconv/v2/?
|
url: https://api.map.baidu.com/geoconv/v2/?
|
||||||
|
single: # 个推配置
|
||||||
|
push:
|
||||||
|
mastersecret: jYnpS1xYhh6GfyZQMlciJ
|
||||||
|
appkey: neXXX9r1Tc7gMxN2PIcHA1
|
||||||
|
appId: KXgzOaKSzd5HG3p9IPaVa8
|
||||||
@ -301,7 +301,6 @@
|
|||||||
<version>9.2.1.jre8</version>
|
<version>9.2.1.jre8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|||||||
@ -31,8 +31,8 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/shop/sync/third")
|
@RequestMapping("/shop/sync/third")
|
||||||
public class SyncThirdDataController {
|
public class SyncThirdDataController {
|
||||||
@Resource
|
// @Resource
|
||||||
private SyncAppService syncAppService;
|
// private SyncAppService syncAppService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SyncThirdDataService syncThirdDataService;
|
private SyncThirdDataService syncThirdDataService;
|
||||||
@ -125,11 +125,11 @@ public class SyncThirdDataController {
|
|||||||
return readSxData(folders,appKey,sign,syncType);
|
return readSxData(folders,appKey,sign,syncType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取加密密钥", notes = "获取加密密钥")
|
// @ApiOperation(value = "获取加密密钥", notes = "获取加密密钥")
|
||||||
@RequestMapping(value = "/getAppSign", method = RequestMethod.POST)
|
// @RequestMapping(value = "/getAppSign", method = RequestMethod.POST)
|
||||||
public Map<String,Object> getAppSign(@RequestParam String primaryKey) {
|
// public Map<String,Object> getAppSign(@RequestParam String primaryKey) {
|
||||||
return syncAppService.getAppSign(primaryKey);
|
// return syncAppService.getAppSign(primaryKey);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端查询配置
|
* 客户端查询配置
|
||||||
|
|||||||
13
sql/shop/dev/20250522_ddl.sql
Normal file
13
sql/shop/dev/20250522_ddl.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE `user_device_bind` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`user_id` varchar(32) NOT NULL COMMENT '用户唯一标识',
|
||||||
|
`cid` varchar(64) NOT NULL COMMENT '设备CID',
|
||||||
|
`user_type` tinyint(4) NOT NULL COMMENT '用户类型 (1=普通用户, 2=管理员, 3=商家)',
|
||||||
|
`os_type` varchar(16) NOT NULL COMMENT '手机系统类型 (Android/iOS)',
|
||||||
|
`bind_time` datetime NOT NULL COMMENT '绑定时间',
|
||||||
|
`last_active` datetime NOT NULL COMMENT '最后活跃时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_user_id` (`user_id`),
|
||||||
|
KEY `idx_cid` (`cid`),
|
||||||
|
KEY `idx_last_active` (`last_active`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户设备绑定关系表';
|
||||||
Loading…
Reference in New Issue
Block a user