增加网格用户关联解除绑定功能
This commit is contained in:
parent
7d4446a92a
commit
328f0a06eb
@ -129,4 +129,70 @@ public class GridAppController extends DefaultBaseController {
|
||||
return gridService.listWithPointByRelationId(relationId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "我的网格列表", notes = "我的网格列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-of-mine")
|
||||
public List<GridDTO> listOfMine(@RequestHeader("token") String token, @RequestParam(name = "areaCodeLike", required = false) String areaCodeLike) {
|
||||
if (!StringUtils.isBlank(areaCodeLike)) {
|
||||
areaCodeLike = WStringUtil.cutContinuityRepeatCharDesc(areaCodeLike, '0', 3);
|
||||
}
|
||||
Map<String, Object> params = requestParams();
|
||||
params.put("areaCodeLike", areaCodeLike);
|
||||
return gridService.listOfMine(token, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "我的网格分页列表", notes = "我的网格分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "areaCodeLike", value = "地区编码", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-of-mine")
|
||||
public SuccessResultList<List<GridDTO>> listPageOfMine(@RequestHeader("token") String token, @RequestParam(name = "areaCodeLike", required = false) String areaCodeLike, ListPage page) {
|
||||
if (!StringUtils.isBlank(areaCodeLike)) {
|
||||
areaCodeLike = WStringUtil.cutContinuityRepeatCharDesc(areaCodeLike, '0', 3);
|
||||
}
|
||||
Map<String, Object> params = requestParams();
|
||||
params.put("areaCodeLike", areaCodeLike);
|
||||
page.setParams(params);
|
||||
return gridService.listPageOfMine(token, page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不是我的网格列表", notes = "不是我的网格列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-not-mine")
|
||||
public List<GridDTO> listNotMine(@RequestHeader("token") String token, @RequestParam(name = "areaCodeLike", required = false) String areaCodeLike) {
|
||||
if (!StringUtils.isBlank(areaCodeLike)) {
|
||||
areaCodeLike = WStringUtil.cutContinuityRepeatCharDesc(areaCodeLike, '0', 3);
|
||||
}
|
||||
Map<String, Object> params = requestParams();
|
||||
params.put("areaCodeLike", areaCodeLike);
|
||||
return gridService.listNotMine(token, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不是我的网格分页列表", notes = "不是我的网格分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "areaCodeLike", value = "地区编码", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-not-mine")
|
||||
public SuccessResultList<List<GridDTO>> listPageNotMine(@RequestHeader("token") String token, @RequestParam(name = "areaCodeLike", required = false) String areaCodeLike, ListPage page) {
|
||||
if (!StringUtils.isBlank(areaCodeLike)) {
|
||||
areaCodeLike = WStringUtil.cutContinuityRepeatCharDesc(areaCodeLike, '0', 3);
|
||||
}
|
||||
Map<String, Object> params = requestParams();
|
||||
params.put("areaCodeLike", areaCodeLike);
|
||||
page.setParams(params);
|
||||
return gridService.listPageNotMine(token, page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package ink.wgink.module.map.controller.app.api.grid;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.map.service.grid.IGridUserService;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @ClassName: GridUserController
|
||||
* @Description: 网格用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/10/20 5:42 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "网格用户接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/grid/user")
|
||||
public class GridUserAppController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IGridUserService gridUserService;
|
||||
|
||||
@ApiOperation(value = "新增我的网格", notes = "新增我的网格接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gridIdId", value = "网格ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("save-of-mine/{gridId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult saveOfMine(@RequestHeader() String token, @PathVariable("gridId") String gridId) throws Exception {
|
||||
gridUserService.saveOfMine(token, gridId);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除我的网格", notes = "删除我的网格接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gridId", value = "网格ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("delete-of-mine/{gridId}")
|
||||
public SuccessResult deleteOfMine(@RequestHeader("token") String token, @PathVariable("gridId") String gridId) {
|
||||
gridUserService.deleteOfMine(token, gridId);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
@ -39,6 +39,14 @@ public interface IGridRelationDao extends IInitBaseTable {
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 网格关联详情
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
GridRelationDTO get(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 网关关联列表
|
||||
*
|
||||
|
@ -131,4 +131,12 @@ public interface IGridRelationService {
|
||||
*/
|
||||
List<String> listRelationId(List<String> gridIds);
|
||||
|
||||
/**
|
||||
* 网格关联详情
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @param relationId 关联ID
|
||||
* @return
|
||||
*/
|
||||
GridRelationDTO getByGridIdAndRelationId(String gridId, String relationId);
|
||||
}
|
||||
|
@ -277,4 +277,40 @@ public interface IGridService {
|
||||
* @return
|
||||
*/
|
||||
List<GridDTO> listAllWithPointByAreaCode(String areaCode, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 我的网格列表
|
||||
*
|
||||
* @param token
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<GridDTO> listOfMine(String token, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 我的网格分页列表
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<GridDTO>> listPageOfMine(String token, ListPage page);
|
||||
|
||||
/**
|
||||
* 不是我的网格列表
|
||||
*
|
||||
* @param token
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<GridDTO> listNotMine(String token, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 不是我的网格分页列表
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<GridDTO>> listPageNotMine(String token, ListPage page);
|
||||
}
|
||||
|
@ -17,6 +17,14 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IGridUserService {
|
||||
|
||||
/**
|
||||
* 新增我的网格
|
||||
*
|
||||
* @param token
|
||||
* @param gridId
|
||||
*/
|
||||
void saveOfMine(String token, String gridId);
|
||||
|
||||
/**
|
||||
* 删除网格用户
|
||||
*
|
||||
@ -25,6 +33,14 @@ public interface IGridUserService {
|
||||
*/
|
||||
void delete(String gridId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 删除我的网格
|
||||
*
|
||||
* @param token
|
||||
* @param gridId
|
||||
*/
|
||||
void deleteOfMine(String token, String gridId);
|
||||
|
||||
/**
|
||||
* 修改网格用户
|
||||
*
|
||||
|
@ -41,7 +41,9 @@ public class GridRelationServiceImpl extends DefaultBaseService implements IGrid
|
||||
params.put("relationId", relationId);
|
||||
gridRelationDao.save(params);
|
||||
}
|
||||
gridRelationSaveAfterHandler.handle(relationIdArray);
|
||||
if (gridRelationSaveAfterHandler != null) {
|
||||
gridRelationSaveAfterHandler.handle(relationIdArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,6 +160,14 @@ public class GridRelationServiceImpl extends DefaultBaseService implements IGrid
|
||||
return listRelationIdByGridRelation(gridRelationDTOs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridRelationDTO getByGridIdAndRelationId(String gridId, String relationId) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("gridId", gridId);
|
||||
params.put("relationId", relationId);
|
||||
return gridRelationDao.get(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网格ID列表
|
||||
*
|
||||
|
@ -416,6 +416,34 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
return list(params, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridDTO> listOfMine(String token, Map<String, Object> params) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
params.put("relationId", userId);
|
||||
return list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<GridDTO>> listPageOfMine(String token, ListPage page) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
page.getParams().put("relationId", userId);
|
||||
return listPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GridDTO> listNotMine(String token, Map<String, Object> params) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
params.put("excludeRelationId", userId);
|
||||
return list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<GridDTO>> listPageNotMine(String token, ListPage page) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
page.getParams().put("excludeRelationId", userId);
|
||||
return listPage(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置网格点
|
||||
*
|
||||
|
@ -3,6 +3,7 @@ package ink.wgink.module.map.service.grid.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridRelationDTO;
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridUserDTO;
|
||||
@ -34,11 +35,27 @@ public class GridUserServiceImpl extends DefaultBaseService implements IGridUser
|
||||
@Autowired
|
||||
private IGridRelationService gridRelationService;
|
||||
|
||||
@Override
|
||||
public void saveOfMine(String token, String gridId) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
GridRelationDTO gridRelationDTO = gridRelationService.getByGridIdAndRelationId(gridId, userId);
|
||||
if (gridRelationDTO != null) {
|
||||
throw new SearchException("已经添加网格");
|
||||
}
|
||||
gridRelationService.save(gridId, Arrays.asList(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String gridId, List<String> userIds) {
|
||||
gridRelationService.delete(gridId, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOfMine(String token, String gridId) {
|
||||
String userId = getAppTokenUser(token).getId();
|
||||
gridRelationService.delete(gridId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String gridId, IdsVO idsVO) {
|
||||
// 删除全部关联关系
|
||||
|
@ -266,6 +266,28 @@
|
||||
AND
|
||||
t1.area_code != #{excludeAreaCode}
|
||||
</if>
|
||||
<if test="relationId != null and relationId != ''">
|
||||
AND
|
||||
t1.grid_id IN (
|
||||
SELECT
|
||||
st1.grid_id
|
||||
FROM
|
||||
map_grid_relation st1
|
||||
WHERE
|
||||
relation_id = #{relationId}
|
||||
)
|
||||
</if>
|
||||
<if test="excludeRelationId != null and excludeRelationId != ''">
|
||||
AND
|
||||
t1.grid_id NOT IN (
|
||||
SELECT
|
||||
st1.grid_id
|
||||
FROM
|
||||
map_grid_relation st1
|
||||
WHERE
|
||||
relation_id = #{relationId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 网格列表(group) -->
|
||||
|
@ -63,6 +63,20 @@
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<!-- 网格关联详情 -->
|
||||
<select id="get" parameterType="map" resultMap="gridRelationDTO" useCache="true">
|
||||
SELECT
|
||||
relation_id,
|
||||
LEFT(gmt_create, 19) gmt_create,
|
||||
grid_id
|
||||
FROM
|
||||
map_grid_relation
|
||||
WHERE
|
||||
grid_id = #{gridId}
|
||||
AND
|
||||
relation_id = #{relationId}
|
||||
</select>
|
||||
|
||||
<!-- 获取关联关系列表 -->
|
||||
<select id="list" parameterType="map" resultMap="gridRelationDTO" useCache="true">
|
||||
SELECT
|
||||
|
Loading…
Reference in New Issue
Block a user