调整网格用户查询方式
This commit is contained in:
parent
fb48afc6ae
commit
7242bf50fd
@ -67,6 +67,13 @@ public class GridUserResourceController extends DefaultBaseController {
|
||||
return gridUserService.list(gridId, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "网格用户列表", notes = "网格用户列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/grid-ids")
|
||||
public List<GridUserDTO> listByGridIds(@RequestBody IdsVO idsVO) {
|
||||
return gridUserService.listByGridIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "网格用户分页列表", notes = "网格用户分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", required = true),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ink.wgink.module.map.dao.grid;
|
||||
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -8,6 +9,11 @@ import java.util.Map;
|
||||
|
||||
@Repository
|
||||
public interface IGridUserDao {
|
||||
|
||||
List<GridUserDTO> listGridUser(Map<String, Object> params);
|
||||
|
||||
|
||||
List<UserDTO> listUser(Map<String, Object> params);
|
||||
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ public interface IGridUserService {
|
||||
*/
|
||||
List<String> listUserId(String gridId, Map<String, Object> params);
|
||||
|
||||
List<GridUserDTO> listGridUser(Map<String, Object> params);
|
||||
|
||||
|
||||
/**
|
||||
* 网格用户列表
|
||||
*
|
||||
@ -68,6 +71,11 @@ public interface IGridUserService {
|
||||
*/
|
||||
List<GridUserDTO> list(String gridId, Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
List<GridUserDTO> listByGridIds(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 网格用户分页列表
|
||||
*
|
||||
@ -78,4 +86,7 @@ public interface IGridUserService {
|
||||
SuccessResultList<List<GridUserDTO>> listPage(String gridId, ListPage page);
|
||||
|
||||
List<UserDTO> listUser(Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -75,34 +75,22 @@ public class GridUserServiceImpl extends DefaultBaseService implements IGridUser
|
||||
return gridRelationService.listRelationId(gridId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridUserDTO> listGridUser(Map<String, Object> params) {
|
||||
return gridUserDao.listGridUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridUserDTO> list(String gridId, Map<String, Object> params) {
|
||||
List<GridRelationDTO> gridRelationDTOs = gridRelationService.listByGridId(gridId);
|
||||
if (gridRelationDTOs.isEmpty()) {
|
||||
return new ArrayList();
|
||||
}
|
||||
Set<String> userIdSet = new HashSet<>();
|
||||
for (GridRelationDTO gridRelationDTO : gridRelationDTOs) {
|
||||
userIdSet.add(gridRelationDTO.getRelationId());
|
||||
}
|
||||
List<UserDTO> userDTOs = userBaseService.listByUserIds(new ArrayList<>(userIdSet));
|
||||
if (userDTOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<GridUserDTO> gridUserDTOs = new ArrayList<>();
|
||||
for (UserDTO userDTO : userDTOs) {
|
||||
GridUserDTO gridUserDTO = new GridUserDTO();
|
||||
gridUserDTO.setGridId(gridId);
|
||||
BeanUtils.copyProperties(userDTO, gridUserDTO);
|
||||
for (GridRelationDTO gridRelationDTO : gridRelationDTOs) {
|
||||
if (StringUtils.equals(gridUserDTO.getUserId(), gridRelationDTO.getRelationId())) {
|
||||
gridUserDTO.setGmtCreate(gridRelationDTO.getGmtCreate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
gridUserDTOs.add(gridUserDTO);
|
||||
}
|
||||
return gridUserDTOs;
|
||||
params.put("gridId", gridId);
|
||||
return listGridUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridUserDTO> listByGridIds(List<String> gridIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
return listGridUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,4 +105,6 @@ public class GridUserServiceImpl extends DefaultBaseService implements IGridUser
|
||||
public List<UserDTO> listUser(Map<String, Object> params) {
|
||||
return gridUserDao.listUser(params);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,51 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.module.map.dao.grid.IGridUserDao">
|
||||
|
||||
<resultMap id="gridUserDTO" type="ink.wgink.module.map.pojo.dtos.grid.GridUserDTO">
|
||||
<id column="grid_id" property="gridId"/>
|
||||
<result column="useRId" property="userId"/>
|
||||
<result column="user_username" property="userUsername"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="user_phone" property="userPhone"/>
|
||||
<result column="gmt_create" property="gmtCreate"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="listGridUser" parameterType="map" resultMap="gridUserDTO">
|
||||
SELECT
|
||||
mgr.grid_id,
|
||||
su.user_id,
|
||||
su.user_username,
|
||||
su.user_name,
|
||||
su.user_email,
|
||||
su.user_phone,
|
||||
su.gmt_create
|
||||
FROM
|
||||
map_grid_relation mgr
|
||||
INNER JOIN
|
||||
map_grid mg
|
||||
ON
|
||||
mgr.grid_id = mg.grid_id
|
||||
INNER JOIN
|
||||
sys_user su
|
||||
ON
|
||||
mgr.relation_id = su.user_id
|
||||
WHERE
|
||||
mg.is_delete = 0
|
||||
AND
|
||||
su.is_delete = 0
|
||||
<if test="gridId != null and gridId != ''">
|
||||
AND
|
||||
mgr.grid_id = #{gridId}
|
||||
</if>
|
||||
<if test="gridIds != null and gridIds.size > 0">
|
||||
AND
|
||||
mgr.grid_id IN
|
||||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||||
#{gridIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="listUser" parameterType="map" resultMap="ink.wgink.service.user.dao.IUserDao.userDTO">
|
||||
SELECT
|
||||
su.user_id,
|
||||
|
Loading…
Reference in New Issue
Block a user