From 6e9c4038b292d30799d63f97941ea7902e0089bf Mon Sep 17 00:00:00 2001 From: erdanergou Date: Thu, 13 Apr 2023 09:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=93=E5=BA=93=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E5=BC=80=E6=94=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DepositoryController.java | 35 ++++++++++++++++ .../depository_manage/mapper/RoleMapper.java | 8 ++++ .../depository_manage/mapper/RoleMapper.xml | 17 ++++++++ .../service/RoleService.java | 8 ++++ .../service/impl/RoleServiceImpl.java | 42 ++++++++++++++++++- .../pages/authorization/depositoryOpen.html | 23 +++++++++- .../depository_manage/mapper/RoleMapper.xml | 17 ++++++++ 7 files changed, 147 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java index 72f38ca5..84c0333b 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java @@ -1489,6 +1489,12 @@ public class DepositoryController { } } + /** + * 用于打印图片 + * @param map + * @param request + * @param response + */ @GetMapping("/allBarCodeImgForDepository") public void allBarCodeImgForDepository(@RequestParam Map map, HttpServletRequest request, HttpServletResponse response) { // 获取当前仓库id @@ -1523,6 +1529,31 @@ public class DepositoryController { } + /** + * 用于设置仓库可见范围权限 + * @param map 存储数据 + * @param request 请求 + * @return + */ + @PostMapping("/setWarehouseVisiblePermission") + public RestResponse setWarehouseVisiblePermission(@RequestBody Map map,HttpServletRequest request){ + if(map.containsKey("type")){ + // 获取当前登录的用户 + String token = request.getHeader("user-token"); + if (token == null) { + token = (String) request.getSession().getAttribute("userToken"); + } + UserByPort userToken = AuthenticationTokenPool.getUserToken(token); + map.put("userId",userToken.getId()); + Integer integer = roleService.addWarehouseVisiblePermission(map); + Integer count = ObjectFormatUtil.toInteger(map.get("count")); + return CrudUtil.insertHandle(count,integer); + }else{ + throw new MyException("缺少必要参数"); + } + } + + /** * 用于获取当前仓库的所有子类 * @@ -1767,4 +1798,8 @@ public class DepositoryController { return productData; } } + + + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java index 4c91d4c4..1b7f8f84 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java @@ -174,4 +174,12 @@ public interface RoleMapper { */ Integer deleteRoleAndMaterialTypeById(Integer id); + + /** + * 用于添加添加仓库可见范围 + * @param map 添加具体数据 + * @return + */ + Integer addWarehouseVisiblePermission(Map map); + } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml index ee8dce17..14ed22d3 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml @@ -264,6 +264,23 @@ delete from mtanduserrole WHERE id = #{id} + + insert into depositoryopenrole (id,did,uid,`type`,state,`time`,userId) + values + + ( + #{id}, + #{did}, + #{uid}, + #{type}, + #{state}, + #{time}, + #{userId} + ) + + ON duplicate KEY UPDATE time=values(time),userId=values(userId) + + diff --git a/src/main/java/com/dreamchaser/depository_manage/service/RoleService.java b/src/main/java/com/dreamchaser/depository_manage/service/RoleService.java index 6638e11d..080d0d44 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/RoleService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/RoleService.java @@ -153,4 +153,12 @@ public interface RoleService { */ List findRoleAndDepositoryByDid(Integer did); + + /** + * 用于添加添加仓库可见范围 + * @param map 添加具体数据 + * @return + */ + Integer addWarehouseVisiblePermission(Map map); + } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java index 96a5f622..7175f0e0 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java @@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.service.impl; import com.dreamchaser.depository_manage.entity.Depository; import com.dreamchaser.depository_manage.entity.MaterialType; +import com.dreamchaser.depository_manage.exception.MyException; import com.dreamchaser.depository_manage.mapper.DepositoryMapper; import com.dreamchaser.depository_manage.mapper.MaterialTypeMapper; import com.dreamchaser.depository_manage.mapper.RoleMapper; @@ -95,6 +96,7 @@ public class RoleServiceImpl implements RoleService { /** * 根据仓库获取userId + * * @param did * @return */ @@ -105,6 +107,7 @@ public class RoleServiceImpl implements RoleService { /** * 根据类型id获取userId + * * @param mtId * @return */ @@ -188,13 +191,14 @@ public class RoleServiceImpl implements RoleService { /** * 查询当前物料类型的管理人员 + * * @param mtId 待查询类型id * @return */ @Override public List findRoleAndMaterialTypeByMtId(Long mtId) { Map map = new HashMap<>(); - map.put("mtid",mtId); + map.put("mtid", mtId); return roleMapper.findRoleAndMaterialTypeByCondition(map); } @@ -266,6 +270,42 @@ public class RoleServiceImpl implements RoleService { return roleMapper.findRoleAndDepositoryByCondition(map); } + /** + * 用于添加添加仓库可见范围 + * + * @param map 添加具体数据 + * @return + */ + @Override + public Integer addWarehouseVisiblePermission(Map map) { + // 获取当前赋值的权限类型 + String type = (String) map.get("type"); + // 定义返回结果 + Integer result = 0; + // 用于插入权限列表 + Map paramForInsert = new HashMap<>(); + paramForInsert.put("userId", map.get("userId")); + paramForInsert.put("time", System.currentTimeMillis()); + paramForInsert.put("depositoryIdList", map.get("depositoryIds")); + paramForInsert.put("state", 1); + List userIds = (List) map.get("userIds"); + if ("person".equals(type)) { + // 如果是对人员赋权 + paramForInsert.put("type", 1); + } else if ("post".equals(type)) { + // 如果是对岗位赋权 + paramForInsert.put("type", 2); + } else { + throw new MyException("未知参数错误"); + } + for (Object userId : userIds + ) { + paramForInsert.put("uid", userId); + result += roleMapper.addWarehouseVisiblePermission(paramForInsert); + } + return result; + } + /** * 获取当前仓库的子仓库 diff --git a/src/main/resources/templates/pages/authorization/depositoryOpen.html b/src/main/resources/templates/pages/authorization/depositoryOpen.html index 1a16349c..414adfd5 100644 --- a/src/main/resources/templates/pages/authorization/depositoryOpen.html +++ b/src/main/resources/templates/pages/authorization/depositoryOpen.html @@ -232,9 +232,28 @@ } // 获取选中的仓库树id let allTreeId = getAllTreeId(treeData); + if(userIds.length > 0){ + let req = {}; + req.userIds = userIds; + req.depositoryIds = allTreeId; + req.type = tabType; + req.count = userIds.length * allTreeId.length; + $.ajax({ + url:"/repository/setWarehouseVisiblePermission", + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(req), + success :function() { + } + }) + }else{ + layer.msg("请选中赋权岗位或人员",{ + icon:5, + time:1000 + }) + } - console.log(userIds) - console.log(allTreeId) }; diff --git a/target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml b/target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml index ee8dce17..14ed22d3 100644 --- a/target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml +++ b/target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml @@ -264,6 +264,23 @@ delete from mtanduserrole WHERE id = #{id} + + insert into depositoryopenrole (id,did,uid,`type`,state,`time`,userId) + values + + ( + #{id}, + #{did}, + #{uid}, + #{type}, + #{state}, + #{time}, + #{userId} + ) + + ON duplicate KEY UPDATE time=values(time),userId=values(userId) + +