Browse Source

添加用户备注与用户联系方式功能

master
[yxf] 6 days ago
parent
commit
dedd601024
  1. 28
      im-platform/src/main/java/com/bx/implatform/controller/UserController.java
  2. 10
      im-platform/src/main/java/com/bx/implatform/entity/User.java
  3. 14
      im-platform/src/main/java/com/bx/implatform/service/UserService.java
  4. 26
      im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java
  5. 10
      im-platform/src/main/java/com/bx/implatform/vo/UserVO.java
  6. 74
      im-web/src/components/chat/ChatBox.vue

28
im-platform/src/main/java/com/bx/implatform/controller/UserController.java

@ -360,4 +360,32 @@ public class UserController {
return ResultUtils.success(location,"获取成功"); 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();
}
} }

10
im-platform/src/main/java/com/bx/implatform/entity/User.java

@ -138,4 +138,14 @@ public class User {
* 语言 * 语言
*/ */
private String language; private String language;
/**
* 用户备注
*/
private String remark;
/**
* 用户联系方式
*/
private String phone;
} }

14
im-platform/src/main/java/com/bx/implatform/service/UserService.java

@ -149,5 +149,19 @@ public interface UserService extends IService<User> {
*/ */
List<User> getEnableChangeCustomerList(Long userId); List<User> 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);
} }

26
im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java

@ -703,4 +703,30 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
return this.list(queryWrapper); return this.list(queryWrapper);
} }
@Override
public void saveUserRemark(Long userId, String remark) {
User user = this.getById(userId);
if (user == null) {
throw new GlobalException("用户不存在");
}
LambdaUpdateWrapper<User> 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<User> wrapper = Wrappers.lambdaUpdate();
wrapper.eq(User::getId, userId);
wrapper.set(User::getPhone, phone);
this.update(wrapper);
}
} }

10
im-platform/src/main/java/com/bx/implatform/vo/UserVO.java

@ -72,14 +72,16 @@ public class UserVO {
// @Schema(description = "所有分组名称") // @Schema(description = "所有分组名称")
// private List<String> groupNameList; // private List<String> groupNameList;
// 修改为完整的UserGroup列表 private List<UserGroupVO> groupList;
private List<UserGroupVO> groupList; // 完整的分组信息列表
// 修改为完整的UserGroup列表 private List<UserLabelVO> labelList;
private List<UserLabelVO> labelList; // 完整的分组信息列表
private String platformName; private String platformName;
private String language; private String language;
private String remark;
private String phone;
} }

74
im-web/src/components/chat/ChatBox.vue

@ -169,6 +169,19 @@
<div class="info-label">用户语言</div> <div class="info-label">用户语言</div>
<div class="info-value">{{ getLanguageText(userInfo.language) }}</div> <div class="info-value">{{ getLanguageText(userInfo.language) }}</div>
</div> </div>
<div class="info-item">
<div class="info-label">手机号</div>
<div class="info-value">
<el-input
v-model="userPhone"
placeholder="请输入手机号"
maxlength="20"
size="small"
@blur="saveUserPhone"
style="width: 100%;"
></el-input>
</div>
</div>
<div class="info-item"> <div class="info-item">
<div class="info-label">标签</div> <div class="info-label">标签</div>
<div class="info-value"> <div class="info-value">
@ -211,6 +224,22 @@
</el-select> </el-select>
</div> </div>
</div> </div>
<div class="info-item">
<div class="info-label">备注</div>
<div class="info-value">
<el-input
v-model="userRemark"
type="textarea"
:rows="2"
placeholder="请输入用户备注"
maxlength="200"
show-word-limit
size="small"
@blur="saveUserRemark"
style="width: 100%;"
></el-input>
</div>
</div>
</div> </div>
</div> </div>
</el-aside> </el-aside>
@ -334,6 +363,8 @@ export default {
showQuickReplyBox: false, // showQuickReplyBox: false, //
quickReplyList: [], // quickReplyList: [], //
quickLoading: false, // quickLoading: false, //
userRemark: "", //
userPhone: "", //
lockMessage: false, lockMessage: false,
showMinIdx: 0, showMinIdx: 0,
reqQueue: [], reqQueue: [],
@ -358,6 +389,46 @@ export default {
}; };
}, },
methods: { 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) { getLanguageText(lang) {
if (!lang) return '未知'; if (!lang) return '未知';
const langMap = { const langMap = {
@ -872,7 +943,8 @@ export default {
} }
this.userInfo = userInfo; this.userInfo = userInfo;
this.userRemark = userInfo.remark || "";
this.userPhone = userInfo.phone || "";
this.updateFriendInfo(); this.updateFriendInfo();
await this.loadLabelOptions(friendId); await this.loadLabelOptions(friendId);
this.selectedLabels = []; this.selectedLabels = [];

Loading…
Cancel
Save