diff --git a/im-platform/src/main/java/com/bx/implatform/controller/UserController.java b/im-platform/src/main/java/com/bx/implatform/controller/UserController.java index d609482..50b3fdc 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/UserController.java +++ b/im-platform/src/main/java/com/bx/implatform/controller/UserController.java @@ -360,4 +360,32 @@ public class UserController { return ResultUtils.success(location,"获取成功"); } + @PostMapping("/remark/save") + @Operation(summary = "保存用户备注") + public Result saveRemark(@RequestBody JSONObject jsonObject) { + Long userId = jsonObject.getLong("userId"); + String remark = jsonObject.getStr("remark"); + + if (ObjectUtil.isNull(userId)) { + return ResultUtils.error(XSS_PARAM_ERROR, "用户ID不能为空"); + } + + userService.saveUserRemark(userId, remark); + return ResultUtils.success(); + } + + @PostMapping("/phone/save") + @Operation(summary = "保存用户手机号") + public Result savePhone(@RequestBody JSONObject jsonObject) { + Long userId = jsonObject.getLong("userId"); + String phone = jsonObject.getStr("phone"); + + if (ObjectUtil.isNull(userId)) { + return ResultUtils.error(XSS_PARAM_ERROR, "用户ID不能为空"); + } + + userService.saveUserPhone(userId, phone); + return ResultUtils.success(); + } + } \ No newline at end of file diff --git a/im-platform/src/main/java/com/bx/implatform/entity/User.java b/im-platform/src/main/java/com/bx/implatform/entity/User.java index b3f4ece..a5701a4 100644 --- a/im-platform/src/main/java/com/bx/implatform/entity/User.java +++ b/im-platform/src/main/java/com/bx/implatform/entity/User.java @@ -138,4 +138,14 @@ public class User { * 语言 */ private String language; + + /** + * 用户备注 + */ + private String remark; + + /** + * 用户联系方式 + */ + private String phone; } diff --git a/im-platform/src/main/java/com/bx/implatform/service/UserService.java b/im-platform/src/main/java/com/bx/implatform/service/UserService.java index 3043e56..7c4f99a 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/UserService.java +++ b/im-platform/src/main/java/com/bx/implatform/service/UserService.java @@ -149,5 +149,19 @@ public interface UserService extends IService { */ List getEnableChangeCustomerList(Long userId); + /** + * 用户备注 + * @param userId 用户id + * @param remark 用户备注 + */ + void saveUserRemark(Long userId, String remark); + + /** + * 用户联系方式 + * @param userId 用户id + * @param phone 用户联系方式 + */ + void saveUserPhone(Long userId, String phone); + } diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java index 683ad8b..791c27f 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java @@ -703,4 +703,30 @@ public class UserServiceImpl extends ServiceImpl implements Us return this.list(queryWrapper); } + + @Override + public void saveUserRemark(Long userId, String remark) { + User user = this.getById(userId); + if (user == null) { + throw new GlobalException("用户不存在"); + } + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate(); + wrapper.eq(User::getId, userId); + wrapper.set(User::getRemark, remark); + this.update(wrapper); + } + + @Override + public void saveUserPhone(Long userId, String phone) { + User user = this.getById(userId); + if (user == null) { + throw new GlobalException("用户不存在"); + } + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate(); + wrapper.eq(User::getId, userId); + wrapper.set(User::getPhone, phone); + this.update(wrapper); + } + + } diff --git a/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java b/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java index 29e0453..73b632f 100644 --- a/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java +++ b/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java @@ -72,14 +72,16 @@ public class UserVO { // @Schema(description = "所有分组名称") // private List groupNameList; - // 修改为完整的UserGroup列表 - private List groupList; // 完整的分组信息列表 + private List groupList; - // 修改为完整的UserGroup列表 - private List labelList; // 完整的分组信息列表 + private List labelList; private String platformName; private String language; + private String remark; + + private String phone; + } \ No newline at end of file diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 5b136d0..0974788 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -169,6 +169,19 @@
用户语言
{{ getLanguageText(userInfo.language) }}
+
+
手机号
+
+ +
+
标签
@@ -211,6 +224,22 @@
+
+
备注
+
+ +
+
@@ -334,6 +363,8 @@ export default { showQuickReplyBox: false, // 快捷回复弹窗 quickReplyList: [], // 快捷回复列表 quickLoading: false, // 加载状态 + userRemark: "", //用户备注 + userPhone: "", //用户联系方式 lockMessage: false, showMinIdx: 0, reqQueue: [], @@ -358,6 +389,46 @@ export default { }; }, methods: { + saveUserRemark() { + const remark = this.userRemark || ""; + + if (remark === (this.userInfo.remark || "")) { + return; + } + this.$http + .post("/user/remark/save", { + userId: this.userInfo.id, + remark: remark, + }) + .then(() => { + this.userInfo.remark = remark; + this.$message.success("备注保存成功"); + }) + .catch(() => { + this.$message.error("备注保存失败"); + }); + }, + + saveUserPhone() { + const phone = this.userPhone || ""; + if (phone === (this.userInfo.phone || "")) { + return; + } + this.$http + .post("/user/phone/save", { + userId: this.userInfo.id, + phone: phone, + }) + .then(() => { + this.userInfo.phone = phone; + this.$message.success("手机号保存成功"); + }) + .catch(() => { + this.$message.error("手机号保存失败"); + }); + }, + + getLanguageText(lang) { if (!lang) return '未知'; const langMap = { @@ -872,7 +943,8 @@ export default { } this.userInfo = userInfo; - + this.userRemark = userInfo.remark || ""; + this.userPhone = userInfo.phone || ""; this.updateFriendInfo(); await this.loadLabelOptions(friendId); this.selectedLabels = [];