解决权限bug

This commit is contained in:
季圣华
2018-12-23 21:53:22 +08:00
parent c554e24e56
commit b163bc1d4a
10 changed files with 174 additions and 37 deletions

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Functions;
import com.jsh.erp.service.functions.FunctionsService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
@@ -232,4 +233,41 @@ public class FunctionsController {
}
return arr;
}
/**
* 根据id列表查找功能信息
* @param functionsIds
* @param request
* @return
*/
@GetMapping(value = "/findByIds")
public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<Functions> dataList = functionsService.findByIds(functionsIds);
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Functions functions : dataList) {
JSONObject item = new JSONObject();
item.put("Id", functions.getId());
item.put("Name", functions.getName());
item.put("PushBtn", functions.getPushbtn());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}

View File

@@ -209,4 +209,51 @@ public class SupplierController {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 用户对应客户显示
* @param type
* @param keyId
* @param request
* @return
*/
@PostMapping(value = "/findUserCustomer")
public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) {
JSONArray arr = new JSONArray();
try {
List<Supplier> dataList = supplierService.findUserCustomer();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "客户列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Supplier supplier : dataList) {
JSONObject item = new JSONObject();
item.put("id", supplier.getId());
item.put("text", supplier.getSupplier());
//勾选判断1
Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + supplier.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + type + " KeyId为 " + keyId + " 存在异常!");
}
if (flag == true) {
item.put("checked", true);
}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
arr.add(outer);
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
}

View File

@@ -57,4 +57,30 @@ public class UserBusinessController {
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 更新角色的按钮权限
* @param userBusinessId
* @param btnStr
* @param request
* @return
*/
@PostMapping(value = "/updateBtnStr")
public BaseResponseInfo updateBtnStr(@RequestParam(value ="userBusinessId", required = false) Long userBusinessId,
@RequestParam(value ="btnStr", required = false) String btnStr,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
try {
int back = userBusinessService.updateBtnStr(userBusinessId, btnStr);
if(back > 0) {
res.code = 200;
res.data = "成功";
}
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "查询权限失败";
}
return res;
}
}

View File

@@ -81,4 +81,13 @@ public class FunctionsService {
List<Functions> list = functionsMapper.selectByExample(example);
return list;
}
public List<Functions> findByIds(String functionsIds){
List<Long> idList = StringUtil.strToLongList(functionsIds);
FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andIdIn(idList);
example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example);
return list;
}
}

View File

@@ -108,4 +108,12 @@ public class SupplierService {
example.createCriteria().andIdIn(ids);
return supplierMapper.updateByExampleSelective(supplier, example);
}
public List<Supplier> findUserCustomer(){
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeEqualTo("客户");
example.setOrderByClause("id desc");
List<Supplier> list = supplierMapper.selectByExample(example);
return list;
}
}

View File

@@ -89,4 +89,12 @@ public class UserBusinessService {
}
}
public int updateBtnStr(Long userBusinessId, String btnStr) {
UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnstr(btnStr);
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdEqualTo(userBusinessId);
return userBusinessMapper.updateByExampleSelective(userBusiness, example);
}
}