| | |
| | | import com.core.controller.AbstractBaseController; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.crm.system.entity.Dept; |
| | | import com.zy.crm.system.entity.Role; |
| | | import com.zy.crm.system.service.DeptService; |
| | | import com.zy.crm.system.service.RoleService; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.zy.crm.manager.entity.Node; |
| | |
| | | private DeptService deptService; |
| | | @Autowired |
| | | private UserLoginService userLoginService; |
| | | @Autowired |
| | | private RoleService roleService; |
| | | |
| | | protected Long getHostId(){ |
| | | if (getUserId() == 9527) { |
| | |
| | | return Long.parseLong(String.valueOf(request.getAttribute("userId"))); |
| | | } |
| | | |
| | | protected Long getUserId(String token){ |
| | | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("token", token)); |
| | | return userLogin.getUserId(); |
| | | } |
| | | |
| | | protected User getUser(){ |
| | | User user = userService.selectById(getUserId()); |
| | | if (null == user) { |
| | |
| | | return user; |
| | | } |
| | | |
| | | protected User getUser(String token){ |
| | | User user = userService.selectById(getUserId(token)); |
| | | if (null == user) { |
| | | throw new CoolException(BaseRes.DENIED); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | protected Long getDeptId() { |
| | | return getUser().getDeptId(); |
| | | } |
| | | |
| | | protected Role getRole(){ |
| | | Role role = roleService.selectById(getUser().getRoleId()); |
| | | if (null == role) { |
| | | throw new CoolException(BaseRes.DENIED); |
| | | } |
| | | return role; |
| | | } |
| | | |
| | | protected String getComment(Class<?> cls, String fieldName){ |
| | |
| | | wrapper.like(columns.get(i), condition); |
| | | } |
| | | } |
| | | |
| | | //获取当前登录用户,对应权限下所有用户id。(普通职员获取自己,领导获取自己及下属,超级管理员全部) |
| | | protected ArrayList<Long> getUserRoleBelongsToUserId() { |
| | | User user = getUser(); |
| | | ArrayList<Long> userIds = new ArrayList<>(); |
| | | if (user.getRoleCode().equals("boss")) { |
| | | //全部权限 |
| | | userIds = null; |
| | | } else if (user.getRoleCode().equals("manager")) { |
| | | //自己及下属权限 |
| | | userIds.add(getUserId()); |
| | | EntityWrapper<User> entityWrapper = new EntityWrapper<>(); |
| | | entityWrapper.eq("dept_id", user.getDeptId()); |
| | | List<User> userList = userService.selectList(entityWrapper); |
| | | for (User item : userList) { |
| | | userIds.add(item.getId()); |
| | | } |
| | | }else{ |
| | | //自己权限 |
| | | userIds.add(getUserId()); |
| | | } |
| | | |
| | | return userIds; |
| | | } |
| | | |
| | | protected ArrayList<Long> getUserRoleBelongsToUserId(String permission) { |
| | | User user = getUser(); |
| | | if (user.getDeptName().equals("平库规划组") || user.getDeptName().equals("核价组")) { |
| | | if (permission.equals("allopen")) { |
| | | //权限全部开放 |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | //返回默认选择方案 |
| | | return getUserRoleBelongsToUserId(); |
| | | } |
| | | } |