新增仓库时给当前用户自动授权

This commit is contained in:
季圣华
2021-11-17 23:11:48 +08:00
parent 08f2ccdd5a
commit 31fd1b65fa

View File

@@ -128,6 +128,26 @@ public class DepotService {
depot.setType(0);
depot.setIsDefault(false);
result=depotMapper.insertSelective(depot);
//新增仓库时给当前用户自动授权
Long userId = userService.getUserId(request);
Long depotId = getIdByName(depot.getName());
String ubKey = "[" + depotId + "]";
List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserDepot");
if(ubList ==null || ubList.size() == 0) {
JSONObject ubObj = new JSONObject();
ubObj.put("type", "UserDepot");
ubObj.put("keyId", userId);
ubObj.put("value", ubKey);
userBusinessService.insertUserBusiness(ubObj, request);
} else {
UserBusiness ubInfo = ubList.get(0);
JSONObject ubObj = new JSONObject();
ubObj.put("id", ubInfo.getId());
ubObj.put("type", ubInfo.getType());
ubObj.put("keyId", ubInfo.getKeyId());
ubObj.put("value", ubInfo.getValue() + ubKey);
userBusinessService.updateUserBusiness(ubObj, request);
}
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
}catch(Exception e){