Browse Source

添加仓库对外开放功能

lwx_dev
erdanergou 3 years ago
parent
commit
6e9c4038b2
  1. 35
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java
  2. 8
      src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java
  3. 17
      src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml
  4. 8
      src/main/java/com/dreamchaser/depository_manage/service/RoleService.java
  5. 40
      src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java
  6. 23
      src/main/resources/templates/pages/authorization/depositoryOpen.html
  7. 17
      target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml

35
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") @GetMapping("/allBarCodeImgForDepository")
public void allBarCodeImgForDepository(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) { public void allBarCodeImgForDepository(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
// 获取当前仓库id // 获取当前仓库id
@ -1523,6 +1529,31 @@ public class DepositoryController {
} }
/**
* 用于设置仓库可见范围权限
* @param map 存储数据
* @param request 请求
* @return
*/
@PostMapping("/setWarehouseVisiblePermission")
public RestResponse setWarehouseVisiblePermission(@RequestBody Map<String,Object> 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; return productData;
} }
} }
} }

8
src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java

@ -174,4 +174,12 @@ public interface RoleMapper {
*/ */
Integer deleteRoleAndMaterialTypeById(Integer id); Integer deleteRoleAndMaterialTypeById(Integer id);
/**
* 用于添加添加仓库可见范围
* @param map 添加具体数据
* @return
*/
Integer addWarehouseVisiblePermission(Map<String,Object> map);
} }

17
src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml

@ -264,6 +264,23 @@
delete from mtanduserrole WHERE id = #{id} delete from mtanduserrole WHERE id = #{id}
</delete> </delete>
<insert id="addWarehouseVisiblePermission">
insert into depositoryopenrole (id,did,uid,`type`,state,`time`,userId)
values
<foreach collection="depositoryIdList" item="did" index="index" separator=",">
(
#{id},
#{did},
#{uid},
#{type},
#{state},
#{time},
#{userId}
)
</foreach>
ON duplicate KEY UPDATE time=values(time),userId=values(userId)
</insert>
</mapper> </mapper>

8
src/main/java/com/dreamchaser/depository_manage/service/RoleService.java

@ -153,4 +153,12 @@ public interface RoleService {
*/ */
List<RoleAndDepository> findRoleAndDepositoryByDid(Integer did); List<RoleAndDepository> findRoleAndDepositoryByDid(Integer did);
/**
* 用于添加添加仓库可见范围
* @param map 添加具体数据
* @return
*/
Integer addWarehouseVisiblePermission(Map<String,Object> map);
} }

40
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.Depository;
import com.dreamchaser.depository_manage.entity.MaterialType; 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.DepositoryMapper;
import com.dreamchaser.depository_manage.mapper.MaterialTypeMapper; import com.dreamchaser.depository_manage.mapper.MaterialTypeMapper;
import com.dreamchaser.depository_manage.mapper.RoleMapper; import com.dreamchaser.depository_manage.mapper.RoleMapper;
@ -95,6 +96,7 @@ public class RoleServiceImpl implements RoleService {
/** /**
* 根据仓库获取userId * 根据仓库获取userId
*
* @param did * @param did
* @return * @return
*/ */
@ -105,6 +107,7 @@ public class RoleServiceImpl implements RoleService {
/** /**
* 根据类型id获取userId * 根据类型id获取userId
*
* @param mtId * @param mtId
* @return * @return
*/ */
@ -188,6 +191,7 @@ public class RoleServiceImpl implements RoleService {
/** /**
* 查询当前物料类型的管理人员 * 查询当前物料类型的管理人员
*
* @param mtId 待查询类型id * @param mtId 待查询类型id
* @return * @return
*/ */
@ -266,6 +270,42 @@ public class RoleServiceImpl implements RoleService {
return roleMapper.findRoleAndDepositoryByCondition(map); return roleMapper.findRoleAndDepositoryByCondition(map);
} }
/**
* 用于添加添加仓库可见范围
*
* @param map 添加具体数据
* @return
*/
@Override
public Integer addWarehouseVisiblePermission(Map<String, Object> map) {
// 获取当前赋值的权限类型
String type = (String) map.get("type");
// 定义返回结果
Integer result = 0;
// 用于插入权限列表
Map<String, Object> 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<Object> userIds = (List<Object>) 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;
}
/** /**
* 获取当前仓库的子仓库 * 获取当前仓库的子仓库

23
src/main/resources/templates/pages/authorization/depositoryOpen.html

@ -232,9 +232,28 @@
} }
// 获取选中的仓库树id // 获取选中的仓库树id
let allTreeId = getAllTreeId(treeData); 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)
}; };

17
target/classes/com/dreamchaser/depository_manage/mapper/RoleMapper.xml

@ -264,6 +264,23 @@
delete from mtanduserrole WHERE id = #{id} delete from mtanduserrole WHERE id = #{id}
</delete> </delete>
<insert id="addWarehouseVisiblePermission">
insert into depositoryopenrole (id,did,uid,`type`,state,`time`,userId)
values
<foreach collection="depositoryIdList" item="did" index="index" separator=",">
(
#{id},
#{did},
#{uid},
#{type},
#{state},
#{time},
#{userId}
)
</foreach>
ON duplicate KEY UPDATE time=values(time),userId=values(userId)
</insert>
</mapper> </mapper>

Loading…
Cancel
Save