新增即使消息接口
This commit is contained in:
parent
541dee8f1f
commit
a6ff68ab82
@ -201,4 +201,9 @@ public interface IApiConsts {
|
||||
*/
|
||||
String LIST_USER_RESOURCE_BY_KEYWORDS = "%s/resource/user/listresourcebykeywords/%s";
|
||||
|
||||
/**
|
||||
* LayIM 部门用户
|
||||
*/
|
||||
String LIST_LAYIM_DEPARTMENT_USER = "%s/resource/user/im/listdepartmentuser";
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.cm.common.plugin.oauth.controller.apis.user;
|
||||
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserImService;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResultLayImData;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentUserController
|
||||
* @Description: 用户即时消息
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/15 10:03 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户即时消息")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/user/im")
|
||||
public class UserImController {
|
||||
|
||||
@Autowired
|
||||
private IUserImService userImService;
|
||||
|
||||
@ApiOperation(value = "获取初始化数据", notes = "获取初始化数据接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("getinitdata")
|
||||
public SuccessResultLayImData<SuccessResultLayImData.InitData> getInitData() {
|
||||
return userImService.getInitData();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.cm.common.plugin.oauth.service.user;
|
||||
|
||||
import com.cm.common.result.SuccessResultLayImData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IUserDepartmentService
|
||||
* @Description: 用户即时消息
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/15 10:05 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IUserImService {
|
||||
|
||||
/**
|
||||
* 获取初始化数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
SuccessResultLayImData<SuccessResultLayImData.InitData> getInitData();
|
||||
|
||||
/**
|
||||
* 部门用户列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params);
|
||||
}
|
@ -8,6 +8,7 @@ import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
||||
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultLayImData;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import org.aspectj.lang.annotation.DeclareError;
|
||||
|
||||
|
@ -0,0 +1,99 @@
|
||||
package com.cm.common.plugin.oauth.service.user.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.cm.common.base.AbstractService;
|
||||
import com.cm.common.config.properties.ApiPathProperties;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.plugin.IApiConsts;
|
||||
import com.cm.common.plugin.oauth.service.department.IDepartmentService;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserImService;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserService;
|
||||
import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
||||
import com.cm.common.plugin.utils.RestTemplateUtil;
|
||||
import com.cm.common.pojo.bos.UserInfoBO;
|
||||
import com.cm.common.result.SuccessResultLayImData;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: UserDepartmentServiceImpl
|
||||
* @Description: 用户即时消息
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/15 10:05 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class UserImServiceImpl extends AbstractService implements IUserImService {
|
||||
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
@Autowired
|
||||
private IDepartmentService departmentService;
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
@Autowired
|
||||
private ApiPathProperties apiPathProperties;
|
||||
|
||||
@Override
|
||||
public SuccessResultLayImData<SuccessResultLayImData.InitData> getInitData() {
|
||||
UserInfoBO currentUser = securityComponent.getCurrentUser();
|
||||
SuccessResultLayImData.User mine = new SuccessResultLayImData.User();
|
||||
mine.setId(currentUser.getUserId());
|
||||
mine.setUsername(currentUser.getUserName());
|
||||
mine.setAvatar("assets/images/random-avatar1.jpg");
|
||||
mine.setStatus("online");
|
||||
mine.setSign("");
|
||||
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
|
||||
List<SuccessResultLayImData.Friend> friends = listDepartmentUser(params);
|
||||
// 非管理员添加系统管理员
|
||||
if(!StringUtils.equals(ISystemConstant.ADMIN, currentUser.getUserUsername())) {
|
||||
// 加载管理员
|
||||
SuccessResultLayImData.Friend adminFriend = new SuccessResultLayImData.Friend();
|
||||
adminFriend.setId("admin");
|
||||
adminFriend.setGroupname("管理员");
|
||||
SuccessResultLayImData.User user = new SuccessResultLayImData.User();
|
||||
user.setId("1");
|
||||
user.setUsername("系统管理员");
|
||||
List<SuccessResultLayImData.User> users = new ArrayList<>();
|
||||
users.add(user);
|
||||
adminFriend.setList(users);
|
||||
friends.add(adminFriend);
|
||||
}
|
||||
for (SuccessResultLayImData.Friend friend : friends) {
|
||||
for (SuccessResultLayImData.User user : friend.getList()) {
|
||||
if (StringUtils.isBlank(user.getAvatar())) {
|
||||
user.setAvatar("assets/images/random-avatar1.jpg");
|
||||
} else {
|
||||
user.setAvatar(apiPathProperties.getUserCenter() + "/route/file/downloadfile/true/" + user.getAvatar());
|
||||
}
|
||||
user.setStatus("online");
|
||||
user.setSign("");
|
||||
}
|
||||
}
|
||||
|
||||
SuccessResultLayImData.InitData initData = new SuccessResultLayImData.InitData();
|
||||
initData.setMine(mine);
|
||||
initData.setFriend(friends);
|
||||
initData.setGroup(new ArrayList<>());
|
||||
return new SuccessResultLayImData<>(0, "", initData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params) {
|
||||
params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
|
||||
String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_LAYIM_DEPARTMENT_USER, apiPathProperties.getUserCenter()), params);
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
List<SuccessResultLayImData.Friend> friends = JSONArray.parseArray(result, SuccessResultLayImData.Friend.class);
|
||||
return friends;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user