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