添加用户头像问题
This commit is contained in:
parent
6ee3e79c75
commit
321d29c43e
@ -57,6 +57,8 @@ public class ClientUserAuthConverter implements UserAuthenticationConverter {
|
|||||||
userInfoBO.setUserUsername(userInfo.get("username").toString());
|
userInfoBO.setUserUsername(userInfo.get("username").toString());
|
||||||
userInfoBO.setUserName(userInfo.get("userName").toString());
|
userInfoBO.setUserName(userInfo.get("userName").toString());
|
||||||
userInfoBO.setUserPhone(userInfo.get("userPhone") == null ? "" : userInfo.get("userPhone").toString());
|
userInfoBO.setUserPhone(userInfo.get("userPhone") == null ? "" : userInfo.get("userPhone").toString());
|
||||||
|
userInfoBO.setUserAvatar(userInfo.get("userAvatar") == null ? "" : userInfo.get("userAvatar").toString());
|
||||||
|
userInfoBO.setUserEmail(userInfo.get("userEmail") == null ? "" : userInfo.get("userEmail").toString());
|
||||||
if (ISystemConstant.ADMIN.equals(principal.toString())) {
|
if (ISystemConstant.ADMIN.equals(principal.toString())) {
|
||||||
authorities = new LinkedHashSet<>();
|
authorities = new LinkedHashSet<>();
|
||||||
authorities.add(new RoleGrantedAuthority("ROLE_ALL"));
|
authorities.add(new RoleGrantedAuthority("ROLE_ALL"));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cm.common.plugin.oauth.service.user;
|
package com.cm.common.plugin.oauth.service.user;
|
||||||
|
|
||||||
|
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||||
import com.cm.common.result.SuccessResultLayImData;
|
import com.cm.common.result.SuccessResultLayImData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,6 +18,15 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface IUserImService {
|
public interface IUserImService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户默认头像
|
||||||
|
*/
|
||||||
|
String DEFAULT_USER_AVATAR = "assets/images/chat_user.png";
|
||||||
|
/**
|
||||||
|
* 组默认头像
|
||||||
|
*/
|
||||||
|
String DEFAULT_GROUP_AVATAR = "assets/images/chat_group.png";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取初始化数据
|
* 获取初始化数据
|
||||||
*
|
*
|
||||||
@ -32,5 +42,19 @@ public interface IUserImService {
|
|||||||
*/
|
*/
|
||||||
List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params);
|
List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成员数据
|
||||||
|
*
|
||||||
|
* @param departmentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
SuccessResultLayImData<SuccessResultLayImData.MemberData> getMemberData(String departmentId);
|
SuccessResultLayImData<SuccessResultLayImData.MemberData> getMemberData(String departmentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门用户列表(包含系统管理员)
|
||||||
|
*
|
||||||
|
* @param departmentIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserDepartmentResourceBO> listUserDepartmentResource(List<String> departmentIds);
|
||||||
}
|
}
|
||||||
|
@ -44,23 +44,30 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
@Override
|
@Override
|
||||||
public SuccessResultLayImData<SuccessResultLayImData.InitData> getInitData() {
|
public SuccessResultLayImData<SuccessResultLayImData.InitData> getInitData() {
|
||||||
try {
|
try {
|
||||||
|
// 个人信息
|
||||||
UserInfoBO currentUser = securityComponent.getCurrentUser();
|
UserInfoBO currentUser = securityComponent.getCurrentUser();
|
||||||
SuccessResultLayImData.User mine = new SuccessResultLayImData.User();
|
SuccessResultLayImData.User mine = new SuccessResultLayImData.User();
|
||||||
mine.setId(currentUser.getUserId());
|
mine.setId(currentUser.getUserId());
|
||||||
mine.setUsername(currentUser.getUserName());
|
mine.setUsername(StringUtils.equals(currentUser.getUserUsername(), ISystemConstant.ADMIN) ? "系统管理员" : currentUser.getUserName());
|
||||||
mine.setAvatar("assets/images/random-avatar1.jpg");
|
if (StringUtils.isBlank(currentUser.getUserAvatar())) {
|
||||||
|
mine.setAvatar(DEFAULT_USER_AVATAR);
|
||||||
|
} else {
|
||||||
|
mine.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + currentUser.getUserAvatar());
|
||||||
|
}
|
||||||
mine.setStatus("online");
|
mine.setStatus("online");
|
||||||
mine.setSign("暂无签名");
|
mine.setSign("暂无签名");
|
||||||
|
|
||||||
Map<String, Object> params = getHashMap(2);
|
Map<String, Object> params = getHashMap(2);
|
||||||
|
// 用户所在部门集合
|
||||||
|
Set<SuccessResultLayImData.Friend> userFriendSet = new HashSet<>();
|
||||||
|
|
||||||
// 用户所在部门ID集合
|
// 朋友
|
||||||
Set<String> userFriendIdSet = new HashSet<>();
|
|
||||||
List<SuccessResultLayImData.Friend> friends = listDepartmentUser(params);
|
List<SuccessResultLayImData.Friend> friends = listDepartmentUser(params);
|
||||||
setFriends(currentUser, mine, friends, userFriendIdSet);
|
setFriends(currentUser, mine, friends, userFriendSet);
|
||||||
|
|
||||||
|
// 用户组
|
||||||
List<SuccessResultLayImData.Group> groups = new ArrayList<>();
|
List<SuccessResultLayImData.Group> groups = new ArrayList<>();
|
||||||
setGroups(currentUser, friends, groups, userFriendIdSet);
|
setGroups(currentUser, friends, groups, userFriendSet);
|
||||||
|
|
||||||
SuccessResultLayImData.InitData initData = new SuccessResultLayImData.InitData();
|
SuccessResultLayImData.InitData initData = new SuccessResultLayImData.InitData();
|
||||||
initData.setMine(mine);
|
initData.setMine(mine);
|
||||||
@ -96,12 +103,16 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
user.setUsername(userDepartmentResourceBO.getUserName());
|
user.setUsername(userDepartmentResourceBO.getUserName());
|
||||||
user.setSign("暂无签名");
|
user.setSign("暂无签名");
|
||||||
if (StringUtils.isBlank(userDepartmentResourceBO.getUserAvatar())) {
|
if (StringUtils.isBlank(userDepartmentResourceBO.getUserAvatar())) {
|
||||||
user.setAvatar("assets/images/chat_user.png");
|
user.setAvatar(DEFAULT_USER_AVATAR);
|
||||||
} else {
|
} else {
|
||||||
user.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + user.getAvatar());
|
user.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + userDepartmentResourceBO.getUserAvatar());
|
||||||
}
|
}
|
||||||
list.add(user);
|
list.add(user);
|
||||||
}
|
}
|
||||||
|
// 添加管理员
|
||||||
|
SuccessResultLayImData.User adminUser = getAdminUser();
|
||||||
|
adminUser.setAvatar(DEFAULT_USER_AVATAR);
|
||||||
|
list.add(adminUser);
|
||||||
return new SuccessResultLayImData<>(0, "", memberData);
|
return new SuccessResultLayImData<>(0, "", memberData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
@ -109,6 +120,19 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserDepartmentResourceBO> listUserDepartmentResource(List<String> departmentIds) {
|
||||||
|
List<UserDepartmentResourceBO> userDepartmentResourceBOS = userService.listUserDepartmentResourceByDepartmentIds(departmentIds);
|
||||||
|
// 添加系统管理员
|
||||||
|
UserDepartmentResourceBO userDepartmentResourceBO = new UserDepartmentResourceBO();
|
||||||
|
userDepartmentResourceBO.setUserId("1");
|
||||||
|
userDepartmentResourceBO.setUserUsername(ISystemConstant.ADMIN);
|
||||||
|
userDepartmentResourceBO.setUserName("系统管理员");
|
||||||
|
userDepartmentResourceBO.setUserAvatar(DEFAULT_USER_AVATAR);
|
||||||
|
userDepartmentResourceBOS.add(userDepartmentResourceBO);
|
||||||
|
return userDepartmentResourceBOS;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置朋友列表
|
* 设置朋友列表
|
||||||
*
|
*
|
||||||
@ -116,19 +140,15 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
* @param mine
|
* @param mine
|
||||||
* @param friends
|
* @param friends
|
||||||
*/
|
*/
|
||||||
private void setFriends(UserInfoBO currentUser, SuccessResultLayImData.User mine, List<SuccessResultLayImData.Friend> friends, Set<String> userFriendIdSet) {
|
private void setFriends(UserInfoBO currentUser, SuccessResultLayImData.User mine, List<SuccessResultLayImData.Friend> friends, Set<SuccessResultLayImData.Friend> userFriendSet) {
|
||||||
// 非管理员添加系统管理员
|
// 非管理员添加系统管理员
|
||||||
if (!StringUtils.equals(ISystemConstant.ADMIN, currentUser.getUserUsername())) {
|
if (!StringUtils.equals(ISystemConstant.ADMIN, currentUser.getUserUsername())) {
|
||||||
// 加载管理员
|
// 加载管理员
|
||||||
SuccessResultLayImData.Friend adminFriend = new SuccessResultLayImData.Friend();
|
SuccessResultLayImData.Friend adminFriend = new SuccessResultLayImData.Friend();
|
||||||
adminFriend.setId("admin");
|
adminFriend.setId("admin");
|
||||||
adminFriend.setGroupname("管理员");
|
adminFriend.setGroupname("管理员");
|
||||||
SuccessResultLayImData.User user = new SuccessResultLayImData.User();
|
|
||||||
user.setId("1");
|
|
||||||
mine.setStatus("offline");
|
|
||||||
user.setUsername("系统管理员");
|
|
||||||
List<SuccessResultLayImData.User> users = new ArrayList<>();
|
List<SuccessResultLayImData.User> users = new ArrayList<>();
|
||||||
users.add(user);
|
users.add(getAdminUser());
|
||||||
adminFriend.setList(users);
|
adminFriend.setList(users);
|
||||||
friends.add(adminFriend);
|
friends.add(adminFriend);
|
||||||
}
|
}
|
||||||
@ -138,13 +158,13 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
SuccessResultLayImData.User user = friend.getList().get(j);
|
SuccessResultLayImData.User user = friend.getList().get(j);
|
||||||
// 删除自己
|
// 删除自己
|
||||||
if (StringUtils.equals(user.getId(), mine.getId())) {
|
if (StringUtils.equals(user.getId(), mine.getId())) {
|
||||||
userFriendIdSet.add(friend.getId());
|
userFriendSet.add(friend);
|
||||||
friend.getList().remove(j);
|
friend.getList().remove(j);
|
||||||
j--;
|
j--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(user.getAvatar())) {
|
if (StringUtils.isBlank(user.getAvatar())) {
|
||||||
user.setAvatar("assets/images/chat_user.png");
|
user.setAvatar(DEFAULT_USER_AVATAR);
|
||||||
} else {
|
} else {
|
||||||
user.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + user.getAvatar());
|
user.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + user.getAvatar());
|
||||||
}
|
}
|
||||||
@ -160,6 +180,19 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统管理员
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private SuccessResultLayImData.User getAdminUser() {
|
||||||
|
SuccessResultLayImData.User user = new SuccessResultLayImData.User();
|
||||||
|
user.setId("1");
|
||||||
|
user.setStatus("offline");
|
||||||
|
user.setUsername("系统管理员");
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置组
|
* 设置组
|
||||||
*
|
*
|
||||||
@ -168,27 +201,24 @@ public class UserImServiceImpl extends AbstractService implements IUserImService
|
|||||||
* @param groups
|
* @param groups
|
||||||
* @param userFriendIdSet
|
* @param userFriendIdSet
|
||||||
*/
|
*/
|
||||||
private void setGroups(UserInfoBO currentUser, List<SuccessResultLayImData.Friend> friends, List<SuccessResultLayImData.Group> groups, Set<String> userFriendIdSet) {
|
private void setGroups(UserInfoBO currentUser, List<SuccessResultLayImData.Friend> friends, List<SuccessResultLayImData.Group> groups, Set<SuccessResultLayImData.Friend> userFriendSet) {
|
||||||
// 管理员添加所有组
|
// 管理员添加所有组
|
||||||
if (StringUtils.equals(ISystemConstant.ADMIN, currentUser.getUserUsername())) {
|
if (StringUtils.equals(ISystemConstant.ADMIN, currentUser.getUserUsername())) {
|
||||||
for (SuccessResultLayImData.Friend friend : friends) {
|
for (SuccessResultLayImData.Friend friend : friends) {
|
||||||
SuccessResultLayImData.Group group = new SuccessResultLayImData.Group();
|
SuccessResultLayImData.Group group = new SuccessResultLayImData.Group();
|
||||||
group.setId(friend.getId());
|
group.setId(friend.getId());
|
||||||
group.setGroupname(friend.getGroupname());
|
group.setGroupname(friend.getGroupname());
|
||||||
group.setAvatar("assets/images/chat_group.png");
|
group.setAvatar(DEFAULT_GROUP_AVATAR);
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 非管理员添加自己所在部门
|
// 非管理员添加自己所在部门
|
||||||
for (SuccessResultLayImData.Friend friend : friends) {
|
for (SuccessResultLayImData.Friend friend : userFriendSet) {
|
||||||
if (!userFriendIdSet.contains(friend.getId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SuccessResultLayImData.Group group = new SuccessResultLayImData.Group();
|
SuccessResultLayImData.Group group = new SuccessResultLayImData.Group();
|
||||||
group.setId(friend.getId());
|
group.setId(friend.getId());
|
||||||
group.setGroupname(friend.getGroupname());
|
group.setGroupname(friend.getGroupname());
|
||||||
group.setAvatar("assets/images/chat_group.png");
|
group.setAvatar(DEFAULT_GROUP_AVATAR);
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user