新增即时消息相关接口

This commit is contained in:
wanggeng888 2021-01-18 13:04:33 +08:00
parent 5ee3daf7d3
commit 7cb6bd4f8a
8 changed files with 175 additions and 2 deletions

View File

@ -0,0 +1,42 @@
package com.cm.serviceusercenter.controller.resources.system.user;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.SearchException;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultLayImData;
import com.cm.serviceusercenter.controller.BaseController;
import com.cm.serviceusercenter.service.system.user.IUserImService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: UserImResourceController
* @Description: 用户即时消息
* @Author: wanggeng
* @Date: 2021/1/15 10:53 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "用户信息管理")
@RestController
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/user/im")
public class UserImResourceController extends BaseController {
@Autowired
private IUserImService userImService;
@ApiOperation(value = "获取部门用户信息", notes = "获取部门用户信息接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listdepartmentuser")
public List<SuccessResultLayImData.Friend> listDepartmentUser() throws SearchException {
Map<String, Object> params = requestParams();
return userImService.listDepartmentUser(params);
}
}

View File

@ -74,7 +74,7 @@ public class UserResourceController extends BaseController {
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("listdepartmentusers/{departmentId}")
public List<DepartmentUserDTO> listdepartmentusers(@PathVariable("departmentId") String departmentId) throws SearchException {
public List<DepartmentUserDTO> listDepartmentUsers(@PathVariable("departmentId") String departmentId) throws SearchException {
Map<String, Object> params = getParams();
params.put("departmentId", departmentId);
return userService.listSelectDepartmentUser(params);

View File

@ -370,4 +370,12 @@ public interface IDepartmentService {
* @throws SearchException
*/
List<DepartmentResourceBO> listDepartmentResourceByUserIds(List<String> userIds) throws SearchException;
/**
* 部门列表
* @param params
* @return
* @throws SearchException
*/
List<DepartmentSimpleDTO> listDepartmentSimple(Map<String, Object> params) throws SearchException;
}

View File

@ -587,6 +587,11 @@ public class DepartmentServiceImpl extends BaseService implements IDepartmentSer
return departmentDao.listDepartmentResource(params);
}
@Override
public List<DepartmentSimpleDTO> listDepartmentSimple(Map<String, Object> params) throws SearchException {
return departmentDao.listDepartmentSimple(params);
}
/**
* 合并组织到指定组织
*

View File

@ -0,0 +1,29 @@
package com.cm.serviceusercenter.service.system.user;
import com.cm.common.exception.SearchException;
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: IUserImService
* @Description: 即使消息
* @Author: wanggeng
* @Date: 2021/1/15 10:55 上午
* @Version: 1.0
*/
public interface IUserImService {
/**
* 获取部门用户信息
*
* @param params
* @return
* @throws SearchException
*/
List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,82 @@
package com.cm.serviceusercenter.service.system.user.impl;
import com.alibaba.druid.util.StringUtils;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.pojo.bos.department.DepartmentResourceBO;
import com.cm.common.result.SuccessResultLayImData;
import com.cm.serviceusercenter.pojo.dtos.DepartmentUserDTO;
import com.cm.serviceusercenter.pojo.dtos.department.DepartmentSimpleDTO;
import com.cm.serviceusercenter.service.BaseService;
import com.cm.serviceusercenter.service.system.department.IDepartmentService;
import com.cm.serviceusercenter.service.system.user.IUserImService;
import com.cm.serviceusercenter.service.system.user.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: UserImService
* @Description: 即使消息
* @Author: wanggeng
* @Date: 2021/1/15 10:55 上午
* @Version: 1.0
*/
@Service
public class UserImService extends BaseService implements IUserImService {
@Autowired
private IDepartmentService departmentService;
@Autowired
private IUserService userService;
@Override
public List<SuccessResultLayImData.Friend> listDepartmentUser(Map<String, Object> params) throws SearchException {
params.put("orderByCode", "orderByCode");
// 所有部门
List<DepartmentSimpleDTO> departmentSimpleDTOs = departmentService.listDepartmentSimple(params);
// 所有部门用户
List<DepartmentUserDTO> departmentUserDTOs = userService.listDepartmentUsers(params);
// 组装
List<SuccessResultLayImData.Friend> friends = new ArrayList<>();
for (int i = 0; i < departmentSimpleDTOs.size(); i++) {
DepartmentSimpleDTO departmentSimpleDTO = departmentSimpleDTOs.get(i);
Map<String, DepartmentUserDTO> departmentUserDTOMap = new HashMap<>(16);
for (int j = 0; j < departmentUserDTOs.size(); j++) {
DepartmentUserDTO departmentUserDTO = departmentUserDTOs.get(j);
if (!StringUtils.equals(departmentSimpleDTO.getDepartmentId(), departmentUserDTO.getDepartmentId())) {
continue;
}
departmentUserDTOMap.put(departmentUserDTO.getDepartmentId(), departmentUserDTO);
departmentUserDTOs.remove(j);
j--;
}
if (departmentUserDTOMap.isEmpty()) {
departmentSimpleDTOs.remove(i);
i--;
continue;
}
SuccessResultLayImData.Friend friend = new SuccessResultLayImData.Friend();
friend.setId(departmentSimpleDTO.getDepartmentId());
friend.setGroupname(departmentSimpleDTO.getDepartmentName());
List<SuccessResultLayImData.User> users = new ArrayList<>();
friend.setList(users);
for (Map.Entry<String, DepartmentUserDTO> kv : departmentUserDTOMap.entrySet()) {
DepartmentUserDTO departmentUserDTO = kv.getValue();
SuccessResultLayImData.User user = new SuccessResultLayImData.User();
user.setId(departmentUserDTO.getUserId());
user.setUsername(departmentUserDTO.getUserName());
user.setAvatar(departmentUserDTO.getUserAvatar());
users.add(user);
}
friends.add(friend);
}
return friends;
}
}

View File

@ -802,7 +802,10 @@ public class UserServiceImpl extends BaseService implements IUserService {
@Override
public List<DepartmentUserDTO> listDepartmentUsers(Map<String, Object> params) throws SearchException {
return userDao.listDepartmentUsers(params);
List<DepartmentUserDTO> departmentUserDTOs = userDao.listDepartmentUsers(params);
List<DepartmentUserDTO> destDepartmentUserDTOs = Arrays.asList(new DepartmentUserDTO[departmentUserDTOs.size()]);
Collections.copy(destDepartmentUserDTOs, departmentUserDTOs);
return new ArrayList<>(destDepartmentUserDTOs);
}
@Override

View File

@ -827,6 +827,10 @@
AND
gmt_modified <![CDATA[ >= ]]> #{updateDate}
</if>
<if test="orderByCode != null">
ORDER BY
department_code
</if>
</select>
<!-- 统计部门数量 -->