优化角色和按钮权限
This commit is contained in:
@@ -32,12 +32,13 @@ public class DepotHeadComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String subType = StringUtil.getInfo(search, "subType");
|
||||
String roleType = StringUtil.getInfo(search, "roleType");
|
||||
String number = StringUtil.getInfo(search, "number");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
||||
return depotHeadService.select(type, subType, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
return depotHeadService.select(type, subType, roleType, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,12 +46,13 @@ public class DepotHeadComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String subType = StringUtil.getInfo(search, "subType");
|
||||
String roleType = StringUtil.getInfo(search, "roleType");
|
||||
String number = StringUtil.getInfo(search, "number");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
||||
return depotHeadService.countDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds);
|
||||
return depotHeadService.countDepotHead(type, subType, roleType, number, beginTime, endTime, materialParam, depotIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,12 +79,17 @@ public class DepotHeadService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime,
|
||||
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds, int offset, int rows)throws Exception {
|
||||
Long handsPersonId = null;
|
||||
User user = userService.getCurrentUser();
|
||||
if("个人数据".equals(roleType)) {
|
||||
handsPersonId = user.getId();
|
||||
}
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list=null;
|
||||
try{
|
||||
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds, offset, rows);
|
||||
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -118,13 +123,16 @@ public class DepotHeadService {
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime,
|
||||
public Long countDepotHead(String type, String subType, String roleType,String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds) throws Exception{
|
||||
Long handsPersonId = null;
|
||||
User user = userService.getCurrentUser();
|
||||
if("个人数据".equals(roleType)) {
|
||||
handsPersonId = user.getId();
|
||||
}
|
||||
Long result=null;
|
||||
try{
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds);
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.jsh.erp.service.user;
|
||||
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.service.role.RoleService;
|
||||
import org.springframework.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.OrgaUserRel;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserEx;
|
||||
import com.jsh.erp.datasource.entities.UserExample;
|
||||
import com.jsh.erp.datasource.mappers.UserMapper;
|
||||
import com.jsh.erp.datasource.mappers.UserMapperEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNodeEx;
|
||||
@@ -61,6 +59,8 @@ public class UserService {
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
public User getUser(long id)throws Exception {
|
||||
User result=null;
|
||||
@@ -675,4 +675,35 @@ public class UserService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id查询角色类型
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public String getRoleTypeByUserId(long userId) throws Exception {
|
||||
List<UserBusiness> list = userBusinessService.getBasicData(String.valueOf(userId), "UserRole");
|
||||
UserBusiness ub = null;
|
||||
if(list.size() > 0) {
|
||||
ub = list.get(0);
|
||||
String values = ub.getValue();
|
||||
String roleId = null;
|
||||
if(values!=null) {
|
||||
values = values.replaceAll("\\[\\]",",").replace("[","").replace("]","");
|
||||
}
|
||||
String [] valueArray=values.split(",");
|
||||
if(valueArray.length>0) {
|
||||
roleId = valueArray[0];
|
||||
}
|
||||
Role role = roleService.getRole(Long.parseLong(roleId));
|
||||
if(role!=null) {
|
||||
return role.getType();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user