添加接口:测试推送

This commit is contained in:
liuchengqian 2022-09-07 11:54:07 +08:00
parent 0c3216c6d3
commit d5dd11ef3a
2 changed files with 15 additions and 32 deletions

View File

@ -5,7 +5,6 @@ import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserPushAccountQo;
import com.xkrs.sms.PushHelper;
import com.xkrs.utils.ListUtils;
import org.apache.hc.core5.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;
@ -33,8 +32,8 @@ public class PushController {
@PostMapping("/bindUserPushInfo")
public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) {
Integer id = sysUserPushAccountQo.getId();
String userAccount = sysUserPushAccountQo.getUserAccount();
String regID = sysUserPushAccountQo.getRegID();
String userAccount = sysUserPushAccountQo.getUserAccount();
if (null == id) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败id == null", locale);
}
@ -42,32 +41,17 @@ public class PushController {
if (targetSysUserOptional.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败id不存在", locale);
}
if (TextUtils.isEmpty(userAccount)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败userAccount == null", locale);
}
if (TextUtils.isEmpty(regID)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败regID == null", locale);
}
if (TextUtils.isEmpty(userAccount)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败userAccount == null", locale);
}
SysUserEntity targetSysUser = targetSysUserOptional.get();
// 更新 regID
targetSysUser.setPushRegID(regID);
// 更新 userAccount
targetSysUser.setPushUserAccount(userAccount);
// 更新 regID
String pushRegIDs = targetSysUser.getPushRegID();
if (TextUtils.isEmpty(pushRegIDs)) {
targetSysUser.setPushRegID(regID);
} else {
List<String> pushRegIDList = new ArrayList<>();
if (pushRegIDs.contains(",")) {
pushRegIDList.addAll(ListUtils.toStringList(pushRegIDs, ","));
} else {
pushRegIDList.add(pushRegIDs);
}
if (!pushRegIDList.contains(regID)) {
pushRegIDList.add(regID);
}
String newPushRegIDs = ListUtils.fromStringList(pushRegIDList, ",");
targetSysUser.setPushRegID(newPushRegIDs);
}
sysUserDao.save(targetSysUser);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "绑定成功", locale);
}

View File

@ -4,10 +4,10 @@ public class SysUserPushAccountQo {
private Integer id;
private String userAccount;
private String regID;
private String userAccount;
public SysUserPushAccountQo() {
}
@ -19,14 +19,6 @@ public class SysUserPushAccountQo {
this.id = id;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
public String getRegID() {
return regID;
}
@ -35,4 +27,11 @@ public class SysUserPushAccountQo {
this.regID = regID;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
}