增加接口完善区域用户功能

This commit is contained in:
TS-QD1 2023-05-18 21:58:26 +08:00
parent 6995037bc3
commit c637b2a344
14 changed files with 272 additions and 8 deletions

View File

@ -2,15 +2,19 @@ package ink.wgink.module.dictionary.controller.api;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.pojo.dtos.AreaZTreeDTO;
import ink.wgink.module.dictionary.pojo.vos.AreaVO;
import ink.wgink.module.dictionary.service.IAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.pojo.vos.IdsVO;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -138,6 +142,22 @@ public class AreaController extends DefaultBaseController {
return areaService.listZTree(params);
}
@ApiOperation(value = "地区字典zTree列表", notes = "地区字典zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-area-ztree")
public List<AreaZTreeDTO> listAreaZTree() {
Map<String, Object> params = requestParams();
String parentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
parentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
params.put("areaParentId", parentId);
return areaService.listAreaZTree(params);
}
@ApiOperation(value = "地区字典列表(通过地区字典编码)", notes = "地区字典列表(通过地区字典编码)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "areaCode", value = "地区字典编码", paramType = "path")
@ -156,4 +176,24 @@ public class AreaController extends DefaultBaseController {
return new SuccessResult();
}
@ApiOperation(value = "区域列表", notes = "区域列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("list/ids")
public List<AreaDTO> list(@RequestBody IdsVO idsVO) {
if (idsVO.getIds().isEmpty()) {
throw new ParamsException("id列表不能为空");
}
return areaService.list(idsVO.getIds());
}
@ApiOperation(value = "区域列表", notes = "区域列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("list/codes")
public List<AreaDTO> listByCodes(@RequestBody IdsVO idsVO) {
if (idsVO.getIds().isEmpty()) {
throw new ParamsException("id列表不能为空");
}
return areaService.listByCodes(idsVO.getIds());
}
}

View File

@ -6,6 +6,7 @@ import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.interfaces.init.IInitBaseTable;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.pojo.dtos.AreaZTreeDTO;
import ink.wgink.pojo.dtos.ZTreeDTO;
import org.springframework.stereotype.Repository;
@ -108,6 +109,9 @@ public interface IAreaDao extends IInitBaseTable {
*/
List<ZTreeDTO> listZTree(Map<String, Object> params) throws SearchException;
List<AreaZTreeDTO> listAreaZTree(Map<String, Object> params);
/**
* 子列表个数
*

View File

@ -0,0 +1,16 @@
package ink.wgink.module.dictionary.pojo.dtos;
import ink.wgink.pojo.dtos.ZTreeDTO;
public class AreaZTreeDTO extends ZTreeDTO {
private String areaCode;
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
}

View File

@ -1,6 +1,7 @@
package ink.wgink.module.dictionary.service;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.pojo.dtos.AreaZTreeDTO;
import ink.wgink.module.dictionary.pojo.vos.AreaVO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
@ -87,6 +88,8 @@ public interface IAreaService {
*/
List<AreaDTO> list();
List<AreaDTO> list(List<String> areaIds);
/**
* 通过上级ID获取地区字典列表
*
@ -119,6 +122,13 @@ public interface IAreaService {
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
*
* @param params
* @return
*/
List<AreaZTreeDTO> listAreaZTree(Map<String, Object> params);
/**
* 地区字典列表通过地区字典编码
*
@ -148,4 +158,15 @@ public interface IAreaService {
*/
void updateShortAndMergerName();
/**
* 路径区域列表
*
* @param areaCode
* @return
*/
List<AreaDTO> listPathAreaByCode(String areaCode);
List<AreaDTO> listPathArea(String areaId);
}

View File

@ -6,6 +6,7 @@ import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.dictionary.dao.IAreaDao;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.module.dictionary.pojo.dtos.AreaZTreeDTO;
import ink.wgink.module.dictionary.pojo.vos.AreaVO;
import ink.wgink.module.dictionary.service.IAreaService;
import ink.wgink.pojo.ListPage;
@ -102,6 +103,13 @@ public class AreaServiceImpl extends DefaultBaseService implements IAreaService
return areaDao.list(params);
}
@Override
public List<AreaDTO> list(List<String> areaIds) {
Map<String, Object> params = getHashMap(0);
params.put("areaIds", areaIds);
return areaDao.list(params);
}
@Override
public List<AreaDTO> listByParentId(String areaParentId) {
Map<String, Object> params = getHashMap(1);
@ -136,6 +144,25 @@ public class AreaServiceImpl extends DefaultBaseService implements IAreaService
return zTreeDTOs;
}
@Override
public List<AreaZTreeDTO> listAreaZTree(Map<String, Object> params) {
List<AreaZTreeDTO> areaZTreeDTOS = areaDao.listAreaZTree(params);
for (AreaZTreeDTO areaZTreeDTO : areaZTreeDTOS) {
Integer subCount = areaDao.countByParentId(areaZTreeDTO.getId());
setAreaZTreeInfo(areaZTreeDTO, subCount);
}
return areaZTreeDTOS;
}
protected void setAreaZTreeInfo(AreaZTreeDTO areaZTreeDTO, Integer subCount) {
areaZTreeDTO.setUrl("javascript:void(0);");
if (null != subCount && 0 < subCount) {
areaZTreeDTO.setIsParent(true);
} else {
areaZTreeDTO.setIsParent(false);
}
}
@Override
public List<AreaDTO> listByCode(String areaCode) {
Map<String, Object> params = getHashMap(1);
@ -176,6 +203,43 @@ public class AreaServiceImpl extends DefaultBaseService implements IAreaService
}
}
@Override
public List<AreaDTO> listPathAreaByCode(String areaCode) {
AreaDTO areaDTO = getByCode(areaCode);
return listPathArea(areaDTO);
}
@Override
public List<AreaDTO> listPathArea(String areaId) {
AreaDTO areaDTO = get(areaId);
return listPathArea(areaDTO);
}
private List<AreaDTO> listPathArea(AreaDTO areaDTO) {
if (areaDTO == null) {
return new ArrayList<>();
}
List<AreaDTO> areaDTOS = new ArrayList<>();
areaDTOS.add(0, areaDTO);
setPathArea(areaDTOS, areaDTO.getAreaParentId());
return areaDTOS;
}
/**
* 设置路径区域
*
* @param areaDTOS
* @param areaId
*/
private void setPathArea(List<AreaDTO> areaDTOS, String areaId) {
AreaDTO areaDTO = get(areaId);
if (areaDTO == null) {
return;
}
areaDTOS.add(0, areaDTO);
setPathArea(areaDTOS, areaDTO.getAreaParentId());
}
/**
* 是否正在更新
*

View File

@ -20,13 +20,17 @@
<result property="areaFirst" column="area_first"/>
</resultMap>
<resultMap id="areaZTreeDTO" type="ink.wgink.pojo.dtos.ZTreeDTO">
<resultMap id="zTreeDTO" type="ink.wgink.pojo.dtos.ZTreeDTO">
<id property="id" column="area_id"/>
<result property="pId" column="area_parent_id"/>
<result property="name" column="area_name"/>
<result property="title" column="area_merger_name"/>
</resultMap>
<resultMap id="areaZTreeDTO" type="ink.wgink.module.dictionary.pojo.dtos.AreaZTreeDTO" extends="zTreeDTO">
<result property="areaCode" column="area_code"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `data_area` (
@ -166,7 +170,21 @@
</update>
<!-- ztree列表 -->
<select id="listZTree" parameterType="map" resultMap="areaZTreeDTO">
<select id="listZTree" parameterType="map" resultMap="zTreeDTO">
SELECT
*
FROM
data_area
WHERE
is_delete = 0
<if test="areaParentId != null and areaParentId != ''">
AND
area_parent_id = #{areaParentId}
</if>
</select>
<!-- ztree列表 -->
<select id="listAreaZTree" parameterType="map" resultMap="areaZTreeDTO">
SELECT
*
FROM

View File

@ -62,6 +62,11 @@ public class GridRouteController {
return new ModelAndView("grid/grid/default/list-select");
}
@GetMapping("list-selected")
public ModelAndView listSelected() {
return new ModelAndView("grid/grid/default/list-selected");
}
private void setConfig(ModelAndView modelAndView) {
EnvManager envManager = EnvManager.getInstance();
Map<String, Object> baiduMapProperties = new HashMap<>(5);

View File

@ -31,6 +31,9 @@ public interface IGridRelationService {
*/
void save(String token, String gridId, List<String> relationIdArray);
void save(List<String> gridIds, String relationId);
/**
* 删除网格关联
*
@ -148,4 +151,5 @@ public interface IGridRelationService {
* @return
*/
GridRelationDTO getByGridIdAndRelationId(String gridId, String relationId);
}

View File

@ -56,6 +56,21 @@ public class GridRelationServiceImpl extends DefaultBaseService implements IGrid
}
}
@Override
public void save(List<String> gridIds, String relationId) {
deleteByRelationId(relationId);
gridIds.forEach(gridId -> {
Map<String, Object> params = getHashMap(4);
params.put("gridId", gridId);
params.put("relationId", relationId);
setSaveInfo(params);
gridRelationDao.save(params);
});
if (gridRelationSaveAfterHandler != null) {
gridRelationSaveAfterHandler.handle(Arrays.asList(relationId));
}
}
@Override
public void delete(String gridId) {
List<String> relationIds = listRelationId(gridId);

View File

@ -247,6 +247,10 @@
map_grid t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND
t1.grid_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="gridIds != null and gridIds.size > 0">
AND
t1.grid_id IN

View File

@ -9,6 +9,11 @@
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.table-select-area {position: relative; width: 200px;}
.table-select-area #areaName {width: 64%}
.table-select-area .select-btn {position: absolute; top: 0px; right: 0px; width: 36%; border-color: #e6e6e6;}
</style>
</head>
<body>
<div class="layui-anim layui-anim-fadein">
@ -20,8 +25,21 @@
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
</div>
<div id="selectArea" class="layui-inline table-select-area" style="display: none;">
<input type="hidden" id="areaCode">
<input type="text" id="areaName" class="layui-input search-item search-item-width-300" placeholder="选择地区" readonly>
<div class="layui-btn-group select-btn">
<button type="button" id="areaSelectBtn" class="layui-btn layui-btn-sm layui-btn-primary" title="选择区域">
<i class="fa fa-circle-thin"></i>
</button>
<button type="button" id="areaCleanBtn" class="layui-btn layui-btn-sm layui-btn-primary" title="删除区域">
<i class="fa fa-times-circle"></i>
</button>
</div>
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
<button type="button" id="showGrid" class="layui-btn layui-btn-sm">查看网格</button>
</button>
<button type="button" id="confirm" class="layui-btn layui-btn-normal layui-btn-sm" style="float: right;">确定</button>
</div>
@ -58,7 +76,14 @@
var newSelectedGridList = [];
var tableData = [];
var tableUrl = 'api/grid/listpage/area-code/{areaCode}';
var tableUrl = null;
if(areaCode) {
tableUrl = 'api/grid/listpage/area-code/{areaCode}';
$('#selectArea').hide();
} else {
tableUrl = 'api/grid/listpage';
$('#selectArea').show();
}
// 初始化选择列表
function initNewSelectedGridList() {
@ -76,10 +101,10 @@
id: 'dataTable',
url: top.restAjax.path(tableUrl, [areaCode]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
toolbar: false,
request: {
pageName: 'page',
limitName: 'rows'
@ -180,6 +205,7 @@
],
page: true,
parseData: function(data) {
console.log(newSelectedGridList);
for(var i = 0, item; item = data.rows[i++];) {
if(!newSelectedGridList) {
item.checked = false;
@ -215,13 +241,13 @@
url: top.restAjax.path(tableUrl, [areaCode]),
where: {
keywords: $('#keywords').val(),
areaCodeLike: $('#areaCode').val() ? $('#areaCode').val() : '',
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
height: $win.height() - 90,
});
}
initTable();
@ -289,6 +315,46 @@
}
});
$(document).on('click', '#showGrid', function() {
top.dialog.open({
url: top.restAjax.path('route/grid/show-grid?areaCode={areaCode}', [areaCode ? areaCode : $('#areaCode').val()]),
title: '查看网格',
width: '80%',
height: '80%',
onClose: function() {}
});
});
// 地区选择事件
$(document).on('click', '#areaSelectBtn', function() {
top.dialog.open({
title: '选择地区',
url: top.restAjax.path('route/area/get-select', []),
width: '600px',
height: '225px',
onClose: function() {
var selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
var areaCode = '';
var areaName = '';
if(selectedAreaArray.length > 0) {
areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
for(var i = 0, item; item = selectedAreaArray[i++];) {
if(areaName) {
areaName += ' / ';
}
areaName += item.areaName;
}
$('#areaCode').val(areaCode);
$('#areaName').val(areaName);
}
}
})
});
$(document).on('click', '#areaCleanBtn', function () {
$('#areaCode').val('');
$('#areaName').val('');
})
table.on('radio(dataTable)', function(obj) {
newSelectedGridList.splice(0, newSelectedGridList.length);
addGridSelected(obj.data);

View File

@ -2,6 +2,7 @@ package ink.wgink.service.core.controller.api.manage;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
@ -40,6 +41,7 @@ public class CoreManageController extends DefaultBaseController {
@PostMapping("save-user")
@CheckRequestBodyAnnotation
public SuccessResult saveUser(@RequestBody CoreManageUserVO coreManageUserVO) {
checkParams(coreManageUserVO);
UserUtil.checkParams(coreManageUserVO);
coreManageService.saveUser(coreManageUserVO);
return new SuccessResult();
@ -61,11 +63,18 @@ public class CoreManageController extends DefaultBaseController {
@PutMapping("update-user/{userId}")
@CheckRequestBodyAnnotation
public SuccessResult updateUser(@PathVariable("userId") String userId, @RequestBody CoreManageUserVO coreManageUserVO) {
checkParams(coreManageUserVO);
UserUtil.checkParams(coreManageUserVO);
coreManageService.updateUser(userId, coreManageUserVO);
return new SuccessResult();
}
private void checkParams(CoreManageUserVO coreManageUserVO) {
if (coreManageUserVO.getDepartmentIds() == null || coreManageUserVO.getDepartmentIds().isEmpty()) {
throw new ParamsException("组织部门不能为空");
}
}
@ApiOperation(value = "用户详情", notes = "用户详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path")

View File

@ -19,7 +19,6 @@ import java.util.List;
public class CoreManageUserVO extends UserVO {
@ApiModelProperty(name = "departmentIds", value = "部门ID列表")
@CheckListAnnotation(name = "部门ID列表")
private List<String> departmentIds;
@ApiModelProperty(name = "roleIds", value = "角色ID列表")
private List<String> roleIds;

View File

@ -636,7 +636,6 @@
form.on('checkbox(noDepartmentFilter)', function(data) {
noDepartment = data.elem.checked;
console.log(1)
});
form.on('checkbox(noRoleFilter)', function(data) {