From d5dd11ef3ae89cd77a64b64158a254116e5fcf10 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 7 Sep 2022 11:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/PushController.java | 28 ++++--------------- .../xkrs/model/qo/SysUserPushAccountQo.java | 19 ++++++------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/xkrs/controller/PushController.java b/src/main/java/com/xkrs/controller/PushController.java index 7c69505..5f456c3 100644 --- a/src/main/java/com/xkrs/controller/PushController.java +++ b/src/main/java/com/xkrs/controller/PushController.java @@ -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 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); } diff --git a/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java b/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java index 830fd44..a18c68d 100644 --- a/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java +++ b/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java @@ -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; + } }