给客户和仓库增加权限控制
This commit is contained in:
@@ -10,6 +10,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
|
|||||||
import com.jsh.erp.service.depot.DepotService;
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
import com.jsh.erp.service.material.MaterialService;
|
import com.jsh.erp.service.material.MaterialService;
|
||||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||||
|
import com.jsh.erp.service.user.UserService;
|
||||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
import com.jsh.erp.utils.*;
|
import com.jsh.erp.utils.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -36,6 +37,9 @@ public class DepotController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DepotService depotService;
|
private DepotService depotService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserBusinessService userBusinessService;
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
@@ -113,18 +117,18 @@ public class DepotController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户拥有权限的仓库列表
|
* 获取当前用户拥有权限的仓库列表
|
||||||
* @param type
|
|
||||||
* @param keyId
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/findDepotByUserId")
|
@GetMapping(value = "/findDepotByCurrentUser")
|
||||||
public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throws Exception{
|
||||||
HttpServletRequest request) throws Exception{
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
JSONArray arr = new JSONArray();
|
|
||||||
try {
|
try {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
String type = "UserDepot";
|
||||||
|
Long userId = userService.getUserId(request);
|
||||||
List<Depot> dataList = depotService.findUserDepot();
|
List<Depot> dataList = depotService.findUserDepot();
|
||||||
//开始拼接json数据
|
//开始拼接json数据
|
||||||
if (null != dataList) {
|
if (null != dataList) {
|
||||||
@@ -134,9 +138,9 @@ public class DepotController {
|
|||||||
//勾选判断1
|
//勾选判断1
|
||||||
Boolean flag = false;
|
Boolean flag = false;
|
||||||
try {
|
try {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
|
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
||||||
} catch (DataAccessException e) {
|
} catch (DataAccessException e) {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
||||||
}
|
}
|
||||||
if (!depotFlag || flag) {
|
if (!depotFlag || flag) {
|
||||||
item.put("id", depot.getId());
|
item.put("id", depot.getId());
|
||||||
@@ -145,10 +149,14 @@ public class DepotController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = arr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
}
|
}
|
||||||
return arr;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/updateIsDefault")
|
@PostMapping(value = "/updateIsDefault")
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ public class SupplierController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/findBySelect_cus")
|
@PostMapping(value = "/findBySelect_cus")
|
||||||
public JSONArray findBySelectCus(@RequestParam(value = "UBType", required = false) String ubType,
|
public JSONArray findBySelectCus(HttpServletRequest request) {
|
||||||
@RequestParam(value = "UBKeyId", required = false) String ubKeyId,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
|
String type = "UserCustomer";
|
||||||
|
Long userId = userService.getUserId(request);
|
||||||
List<Supplier> supplierList = supplierService.findBySelectCus();
|
List<Supplier> supplierList = supplierService.findBySelectCus();
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != supplierList) {
|
if (null != supplierList) {
|
||||||
@@ -92,7 +92,7 @@ public class SupplierController {
|
|||||||
//勾选判断1
|
//勾选判断1
|
||||||
Boolean flag = false;
|
Boolean flag = false;
|
||||||
try {
|
try {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(ubType, ubKeyId, "[" + supplier.getId().toString() + "]");
|
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + supplier.getId().toString() + "]");
|
||||||
} catch (DataAccessException e) {
|
} catch (DataAccessException e) {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.Depot;
|
import com.jsh.erp.datasource.entities.Depot;
|
||||||
|
import com.jsh.erp.datasource.entities.SystemConfig;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.depot.DepotService;
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||||
@@ -84,4 +85,26 @@ public class SystemConfigController {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前租户的配置信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getCurrentInfo")
|
||||||
|
public BaseResponseInfo getCurrentInfo(HttpServletRequest request) throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try{
|
||||||
|
List<SystemConfig> list = systemConfigService.getSystemConfig();
|
||||||
|
if(list.size()>0) {
|
||||||
|
res.code = 200;
|
||||||
|
res.data = list.get(0);
|
||||||
|
}
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user