diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/api/helper/HelperController.java b/src/main/java/cn/com/tenlion/usercenter/controller/api/helper/HelperController.java new file mode 100644 index 0000000..35bdcd7 --- /dev/null +++ b/src/main/java/cn/com/tenlion/usercenter/controller/api/helper/HelperController.java @@ -0,0 +1,25 @@ +package cn.com.tenlion.usercenter.controller.api.helper; + +import cn.com.tenlion.usercenter.service.helper.HelperService; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.result.SuccessResult; +import ink.wgink.pojo.result.SuccessResultData; +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; + +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/helper") +public class HelperController { + + @Autowired + private HelperService helperService; + + @GetMapping("update-no-area-grid-user") + public SuccessResult updateNoAreaGridUser() throws Exception { + Integer updateCount = helperService.updateNoAreaGridUser(); + return new SuccessResultData<>(updateCount); + } + +} diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/route/area/user/AreaUserRouteController.java b/src/main/java/cn/com/tenlion/usercenter/controller/route/area/user/AreaUserRouteController.java index c3ce2a3..0ee3860 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/route/area/user/AreaUserRouteController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/route/area/user/AreaUserRouteController.java @@ -39,12 +39,24 @@ public class AreaUserRouteController { return mv; } + @GetMapping("save-area-user-admin") + public ModelAndView saveAreaUserAdmin() { + ModelAndView mv = new ModelAndView("area/user/save-area-user-admin"); + return mv; + } + @GetMapping("update-area-user") public ModelAndView updateAreaUser() { ModelAndView mv = new ModelAndView("area/user/update-area-user"); return mv; } + @GetMapping("update-area-user-admin") + public ModelAndView updateAreaUserAdmin() { + ModelAndView mv = new ModelAndView("area/user/update-area-user-admin"); + return mv; + } + @GetMapping("list-area") public ModelAndView listArea() { ModelAndView mv = new ModelAndView("area/user/list-area"); @@ -55,7 +67,9 @@ public class AreaUserRouteController { public ModelAndView listAreaAdmin() { ModelAndView mv = new ModelAndView("area/user/list-area-admin"); if (securityComponent.isAdmin()) { - mv.addObject("baseParentId", "0"); + mv.addObject("baseAreaParentId", "0"); + mv.addObject("baseAreaId", "110889"); + mv.addObject("baseAreaCode", "150900000000"); } else { UserExpandPO userExpandPO = securityComponent.getExpandData(UserExpandPO.class); if (userExpandPO == null) { diff --git a/src/main/java/cn/com/tenlion/usercenter/dao/helper/IHelperDao.java b/src/main/java/cn/com/tenlion/usercenter/dao/helper/IHelperDao.java new file mode 100644 index 0000000..0d37317 --- /dev/null +++ b/src/main/java/cn/com/tenlion/usercenter/dao/helper/IHelperDao.java @@ -0,0 +1,14 @@ +package cn.com.tenlion.usercenter.dao.helper; + +import org.apache.kafka.common.protocol.types.Field; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IHelperDao { + + List> listNoAreaGridUser(); + +} diff --git a/src/main/java/cn/com/tenlion/usercenter/service/helper/HelperService.java b/src/main/java/cn/com/tenlion/usercenter/service/helper/HelperService.java new file mode 100644 index 0000000..543a268 --- /dev/null +++ b/src/main/java/cn/com/tenlion/usercenter/service/helper/HelperService.java @@ -0,0 +1,48 @@ +package cn.com.tenlion.usercenter.service.helper; + +import cn.com.tenlion.usercenter.dao.helper.IHelperDao; +import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; +import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; +import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.module.dictionary.pojo.dtos.AreaDTO; +import ink.wgink.module.dictionary.service.IAreaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public class HelperService extends DefaultBaseService { + + @Autowired + private IHelperDao helperDao; + @Autowired + private IUserExpandService userExpandService; + @Autowired + private IAreaService areaService; + + public Integer updateNoAreaGridUser() throws Exception { + List> noAreaGridUsers = helperDao.listNoAreaGridUser(); + int updateCount = 0; + for (Map noAreaGridUser : noAreaGridUsers) { + String areaCode = noAreaGridUser.get("grid_area_code").toString(); + String areaName = noAreaGridUser.get("grid_area_name").toString(); + String userId = noAreaGridUser.get("user_id").toString(); + AreaDTO areaDTO = areaService.getByCode(areaCode); + if (areaDTO == null) { + continue; + } + // 更新 + UserExpandVO userExpandVO = new UserExpandVO(); + userExpandVO.setAreaCode(areaCode); + userExpandVO.setAreaName(areaName); + userExpandVO.setUserLevel(Integer.parseInt(areaDTO.getAreaLevel())); + userExpandService.update(userId, userExpandVO); + updateCount++; + } + return updateCount; + } + +} diff --git a/src/main/resources/mybatis/mapper/helper/helper-mapper.xml b/src/main/resources/mybatis/mapper/helper/helper-mapper.xml new file mode 100644 index 0000000..f07d491 --- /dev/null +++ b/src/main/resources/mybatis/mapper/helper/helper-mapper.xml @@ -0,0 +1,42 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/area/user/area-user-admin.js b/src/main/resources/static/assets/js/area/user/area-user-admin.js new file mode 100644 index 0000000..a3a19ea --- /dev/null +++ b/src/main/resources/static/assets/js/area/user/area-user-admin.js @@ -0,0 +1,299 @@ +/** + * 关闭窗口 + */ +function closeBox() { + parent.layer.close(parent.layer.getFrameIndex(window.name)); +} + +/** + * 初始化下拉树 + * @param $ + * @param layuiInputTree + */ +function initMultiSelectInputTree($, treeselect) { + /** + * 设置选择数据 + * @param ids + * @param names + */ + function setSelectedData(selectedDatas, ids, names) { + if (!ids) { + return; + } + ids = ids.split(','); + names = names.split(','); + $.each(ids, function (index, item) { + selectedDatas.push({ + id: item, + name: names[index] + }) + }) + } + + // 组织部门选择 + function initDepartmentSelect() { + treeselect.init({ + isSingle: false, + name: 'departmentIds', + explain: '组织部门', + url: 'api/department/listztree', + idsUrl: 'api/department/list/ids', + key: { + id: 'id', + name: 'name', + title: 'title', + pId: 'pId', + checked: 'checked', + children: 'children', + isParent: 'isParent', + isHidden: 'isHidden', + url: 'url' + }, + onInitSelectedDataFilter: function(selectedData) { + $.each(selectedData, function(i, item) { + item.id = item.departmentId; + item.name = item.departmentName; + }); + }, + onSelect: function(selectedNodeArray) { + }, + onDelete: function(selectedNodeArray) { + } + }) + } + + // 角色选择 + function initRoleSelect() { + treeselect.init({ + isSingle: false, + name: 'roleIds', + explain: '角色', + url: 'api/role/listztree', + idsUrl: 'api/role/list/role-ids', + key: { + id: 'id', + name: 'name', + title: 'title', + pId: 'pId', + checked: 'checked', + children: 'children', + isParent: 'isParent', + isHidden: 'isHidden', + url: 'url' + }, + onInitSelectedDataFilter: function(selectedData) { + $.each(selectedData, function(i, item) { + item.id = item.roleId; + item.name = item.roleName; + }); + }, + onSelect: function(selectedNodeArray) { + }, + onDelete: function(selectedNodeArray) { + } + }) + } + + // 职位选择 + function initPositionSelect() { + treeselect.init({ + isSingle: false, + name: 'positionIds', + explain: '职位', + url: 'api/position/listztree', + idsUrl: 'api/position/list/position-ids', + key: { + id: 'id', + name: 'name', + title: 'title', + pId: 'pId', + checked: 'checked', + children: 'children', + isParent: 'isParent', + isHidden: 'isHidden', + url: 'url' + }, + onInitSelectedDataFilter: function(selectedData) { + $.each(selectedData, function(i, item) { + item.id = item.positionId; + item.name = item.positionName; + }); + }, + onSelect: function(selectedNodeArray) { + }, + onDelete: function(selectedNodeArray) { + } + }) + } + + // 组选择 + function initGroupSelect() { + treeselect.init({ + isSingle: false, + name: 'groupIds', + explain: '组', + url: 'api/group/listztree', + idsUrl: 'api/group/list/group-ids', + key: { + id: 'id', + name: 'name', + title: 'title', + pId: 'pId', + checked: 'checked', + children: 'children', + isParent: 'isParent', + isHidden: 'isHidden', + url: 'url' + }, + onInitSelectedDataFilter: function(selectedData) { + $.each(selectedData, function(i, item) { + item.id = item.groupId; + item.name = item.groupName; + }); + }, + onSelect: function(selectedNodeArray) { + }, + onDelete: function(selectedNodeArray) { + } + }) + } + + // 组选择 + function initAreaSelect() { + treeselect.init({ + isSingle: true, + name: 'areaId', + explain: '地区', + url: 'api/area/list-area-ztree', + idsUrl: 'api/area/list/ids', + key: { + id: 'id', + name: 'name', + title: 'title', + pId: 'pId', + checked: 'checked', + children: 'children', + isParent: 'isParent', + isHidden: 'isHidden', + url: 'url' + }, + onInitSelectedDataFilter: function(selectedData) { + $.each(selectedData, function(i, item) { + item.id = item.areaId; + item.name = item.areaName; + }); + }, + onSelect: function(selectedNodeArray) { + $('#areaCode').val(selectedNodeArray[0].areaCode); + }, + onDelete: function(selectedNodeArray) { + $('#areaCode').val(''); + } + }) + } + + function initGridSelect() { + $('#gridIdsContainer').text($('#gridNames').val() ? $('#gridNames').val() : '选择网格'); + $('#gridIdsContainer').on('click', function() { + var areaCode = $('#areaCode').val(); + if(!areaCode) { + top.dialog.msg('请选选择区域') + return; + } + var oldGridIds = $('#gridIds').val() ? $('#gridIds').val().split(',') : []; + var oldGridNames = $('#gridNames').val() ? $('#gridNames').val().split(',') : []; + var oldGrids = []; + $.each(oldGridIds, function(index, item) { + oldGrids.push({ + gridId: item, + gridName: oldGridNames[index] + }) + }); + top.dialog.dialogData.oldSelectedGridList = oldGrids; + top.dialog.open({ + title: '选择网格', + url: top.restAjax.path('route/grid/list-select?selectType=checkbox&areaCode={areaCode}', [areaCode]), + width: '800px', + height: '80%', + onClose: function() { + var selectedGridList = top.dialog.dialogData.newSelectedGridList; + var gridIds = ''; + var gridNames = ''; + $.each(selectedGridList, function(index, item) { + if(gridIds) { + gridIds += ','; + gridNames += ','; + } + gridIds += item.gridId; + gridNames += item.gridName; + }) + $('#gridIds').val(gridIds); + $('#gridNames').val(gridNames); + $('#gridIdsContainer').text(gridNames ? gridNames : '选择网格'); + } + }) + }); + } + + initDepartmentSelect(); + initRoleSelect(); + initPositionSelect(); + initGroupSelect(); + initAreaSelect(); + initGridSelect(); +} + +/** + * + * @param laydate + */ +function initDate(laydate) { + laydate.render({ + elem: '#userExpiredDate', + trigger: 'click', + format: 'yyyy-MM-dd HH:mm:ss' + }); +} + +/** + * 设置ID列表 + * @param $ + * @param formDataField + */ +function setIds($, formDataField) { + var departmentIds = $('#departmentIds').val(); + if (departmentIds) { + departmentIds = departmentIds.split(','); + } else { + departmentIds = []; + } + var roleIds = $('#roleIds').val(); + if (roleIds) { + roleIds = roleIds.split(','); + } else { + roleIds = []; + } + var positionIds = $('#positionIds').val(); + if (positionIds) { + positionIds = positionIds.split(','); + } else { + positionIds = []; + } + var groupIds = $('#groupIds').val(); + if (groupIds) { + groupIds = groupIds.split(','); + } else { + groupIds = []; + } + var gridIds = $('#gridIds').val(); + if (gridIds) { + gridIds = gridIds.split(','); + } else { + gridIds = []; + } + formDataField.departmentIds = departmentIds; + formDataField.roleIds = roleIds; + formDataField.positionIds = positionIds; + formDataField.groupIds = groupIds; + formDataField.gridIds = gridIds; +} \ No newline at end of file diff --git a/src/main/resources/static/assets/js/area/user/area-user.js b/src/main/resources/static/assets/js/area/user/area-user.js index d66ecbe..8ee30bd 100644 --- a/src/main/resources/static/assets/js/area/user/area-user.js +++ b/src/main/resources/static/assets/js/area/user/area-user.js @@ -164,7 +164,7 @@ function initMultiSelectInputTree($, treeselect) { isSingle: true, name: 'areaId', explain: '地区', - url: 'api/area/listztree', + url: 'api/area/list-area-ztree', idsUrl: 'api/area/list/ids', key: { id: 'id', @@ -205,7 +205,7 @@ function initMultiSelectInputTree($, treeselect) { top.dialog.dialogData.oldSelectedGridList = oldGrids; top.dialog.open({ title: '选择网格', - url: top.restAjax.path('route/grid/list-select?selectType=checkbox', []), + url: top.restAjax.path('route/grid/list-select?selectType=checkbox&areaCode={areaCode}', [areaCode]), width: '800px', height: '80%', onClose: function() { diff --git a/src/main/resources/templates/area/user/list-area-user-admin.html b/src/main/resources/templates/area/user/list-area-user-admin.html index 3e55b02..ebd5c9d 100644 --- a/src/main/resources/templates/area/user/list-area-user-admin.html +++ b/src/main/resources/templates/area/user/list-area-user-admin.html @@ -29,7 +29,6 @@
@@ -597,7 +596,7 @@ area: ['100%', '100%'], shadeClose: true, anim: 2, - content: top.restAjax.path('route/area/user/save-area-user', []), + content: top.restAjax.path('route/area/user/save-area-user-admin', []), end: function() { reloadTable(); } @@ -615,7 +614,7 @@ area: ['100%', '100%'], shadeClose: true, anim: 2, - content: top.restAjax.path('route/area/user/update-area-user?userId={id}', [checkDatas[0].userId]), + content: top.restAjax.path('route/area/user/update-area-user-admin?userId={id}', [checkDatas[0].userId]), end: function() { reloadTable(); } diff --git a/src/main/resources/templates/area/user/save-area-user-admin.html b/src/main/resources/templates/area/user/save-area-user-admin.html new file mode 100644 index 0000000..cb8208a --- /dev/null +++ b/src/main/resources/templates/area/user/save-area-user-admin.html @@ -0,0 +1,248 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + + +
+
+
+
类型说明
+
系统用户:具有后台登录权限且参与后台、APP业务的用户
+
普通用户:具有APP登录权限且参与APP业务的用户
+
公共用户:来自小程序、公众号等公共平台自动创建且参与此类业务的的用户
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
请选择组织部门
+
+
+ + +
+ +
+ +
请选择角色
+
+
+ + +
+ +
+ +
请选择职位
+
+
+ + +
+ +
+ +
请选择组
+
+
+ + +
+ +
+ + +
请选择区域
+
+
+ + +
+ +
+ + +
选择网格
+
+
+ +
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/area/user/save-area-user.html b/src/main/resources/templates/area/user/save-area-user.html index 356c7c3..eea18ea 100644 --- a/src/main/resources/templates/area/user/save-area-user.html +++ b/src/main/resources/templates/area/user/save-area-user.html @@ -131,6 +131,7 @@
+
请选择区域
@@ -165,7 +166,7 @@ - + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/area/user/update-area-user.html b/src/main/resources/templates/area/user/update-area-user.html index 273ac89..22e66ad 100644 --- a/src/main/resources/templates/area/user/update-area-user.html +++ b/src/main/resources/templates/area/user/update-area-user.html @@ -129,6 +129,7 @@
+
请选择区域
@@ -163,7 +164,7 @@ - +