优化角色和按钮权限
This commit is contained in:
@@ -368,7 +368,7 @@ public class DepotHeadController {
|
||||
String updated = body.getUpdated();
|
||||
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null);
|
||||
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
|
||||
if(count>= billsNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
||||
|
||||
@@ -106,6 +106,8 @@ public class UserController {
|
||||
//验证通过 ,可以登录,放入session,记录登录日志
|
||||
user = userService.getUserByLoginName(loginName);
|
||||
request.getSession().setAttribute("user",user);
|
||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||
request.getSession().setAttribute("roleType",roleType);
|
||||
if(user.getTenantId()!=null) {
|
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||
if(tenant!=null) {
|
||||
@@ -346,4 +348,19 @@ public class UserController {
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
@GetMapping("/getRoleTypeByUserId")
|
||||
public BaseResponseInfo getRoleTypeByUserId(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("roleType", request.getSession().getAttribute("roleType"));
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public interface DepotHeadMapperEx {
|
||||
List<DepotHeadVo4List> selectByConditionDepotHead(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("handsPersonId") Long handsPersonId,
|
||||
@Param("number") String number,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@@ -32,6 +33,7 @@ public interface DepotHeadMapperEx {
|
||||
Long countsByDepotHead(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("handsPersonId") Long handsPersonId,
|
||||
@Param("number") String number,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
<if test="subType != null">
|
||||
and dh.sub_type='${subType}'
|
||||
</if>
|
||||
<if test="handsPersonId != null">
|
||||
and dh.hands_person_id='${handsPersonId}'
|
||||
</if>
|
||||
<if test="number != null">
|
||||
and dh.number like '%${number}%'
|
||||
</if>
|
||||
@@ -89,6 +92,9 @@
|
||||
<if test="subType != null">
|
||||
and sub_type='${subType}'
|
||||
</if>
|
||||
<if test="handsPersonId != null">
|
||||
and hands_person_id='${handsPersonId}'
|
||||
</if>
|
||||
<if test="number != null">
|
||||
and number like '%${number}%'
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user