增加分配按钮的功能
This commit is contained in:
parent
8d9a055799
commit
909af32e60
@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua jshERP
|
||||
@ -186,32 +188,52 @@ public class FunctionController {
|
||||
|
||||
/**
|
||||
* 根据id列表查找功能信息
|
||||
* @param functionsIds
|
||||
* @param roleId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByIds")
|
||||
public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds,
|
||||
@GetMapping(value = "/findRoleFunctionsById")
|
||||
public BaseResponseInfo findByIds(@RequestParam("roleId") Long roleId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<Function> dataList = functionService.findByIds(functionsIds);
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", dataList.size());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (Function function : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", function.getId());
|
||||
item.put("name", function.getName());
|
||||
item.put("pushBtn", function.getPushBtn());
|
||||
dataArray.add(item);
|
||||
List<UserBusiness> list = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
|
||||
if(null!=list && list.size()>0) {
|
||||
//按钮
|
||||
Map<Long,String> btnMap = new HashMap<>();
|
||||
String btnStr = list.get(0).getBtnStr();
|
||||
if(StringUtil.isNotEmpty(btnStr)) {
|
||||
JSONArray btnArr = JSONArray.parseArray(btnStr);
|
||||
for(Object obj: btnArr) {
|
||||
JSONObject btnObj = JSONObject.parseObject(obj.toString());
|
||||
if(btnObj.get("funId")!=null && btnObj.get("btnStr")!=null) {
|
||||
btnMap.put(btnObj.getLong("funId"), btnObj.getString("btnStr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
//菜单
|
||||
String funIds = list.get(0).getValue();
|
||||
funIds = funIds.substring(1, funIds.length() - 1);
|
||||
funIds = funIds.replace("][",",");
|
||||
List<Function> dataList = functionService.findByIds(funIds);
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", dataList.size());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (Function function : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", function.getId());
|
||||
item.put("name", function.getName());
|
||||
item.put("pushBtn", function.getPushBtn());
|
||||
item.put("btnStr", btnMap.get(function.getId()));
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = outer;
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = outer;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
|
||||
@ -8,6 +8,7 @@ import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -68,18 +69,20 @@ public class UserBusinessController {
|
||||
|
||||
/**
|
||||
* 更新角色的按钮权限
|
||||
* @param userBusinessId
|
||||
* @param btnStr
|
||||
* @param jsonObject
|
||||
* @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)throws Exception {
|
||||
public BaseResponseInfo updateBtnStr(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
int back = userBusinessService.updateBtnStr(userBusinessId, btnStr);
|
||||
String roleId = jsonObject.getString("roleId");
|
||||
String btnStr = jsonObject.getString("btnStr");
|
||||
String keyId = roleId;
|
||||
String type = "RoleFunctions";
|
||||
int back = userBusinessService.updateBtnStr(keyId, type, btnStr);
|
||||
if(back > 0) {
|
||||
res.code = 200;
|
||||
res.data = "成功";
|
||||
@ -87,7 +90,7 @@ public class UserBusinessController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "查询权限失败";
|
||||
res.data = "更新权限失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -179,14 +179,14 @@ public class UserBusinessService {
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateBtnStr(Long userBusinessId, String btnStr) throws Exception{
|
||||
public int updateBtnStr(String keyId, String type, String btnStr) throws Exception{
|
||||
logService.insertLog("关联关系",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userBusinessId).toString(),
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(type).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
UserBusiness userBusiness = new UserBusiness();
|
||||
userBusiness.setBtnStr(btnStr);
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
example.createCriteria().andIdEqualTo(userBusinessId);
|
||||
example.createCriteria().andKeyIdEqualTo(keyId).andTypeEqualTo(type);
|
||||
int result=0;
|
||||
try{
|
||||
result= userBusinessMapper.updateByExampleSelective(userBusiness, example);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user