forked from dyf/fys-Multi-tenant
角色管理员
This commit is contained in:
@ -40,7 +40,9 @@ import com.fuyuanshen.equipment.service.DeviceAssignmentsService;
|
|||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeGrantsService;
|
import com.fuyuanshen.equipment.service.DeviceTypeGrantsService;
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
||||||
import com.fuyuanshen.system.service.ISysOssService;
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
|
import com.fuyuanshen.system.service.ISysRoleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -67,6 +69,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
public static final String USER_ID_SEPARATOR = ":";
|
public static final String USER_ID_SEPARATOR = ":";
|
||||||
|
|
||||||
|
private final ISysRoleService roleService;
|
||||||
|
|
||||||
@Value("${file.device.pic}")
|
@Value("${file.device.pic}")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
@Value("${file.device.ip}")
|
@Value("${file.device.ip}")
|
||||||
@ -109,6 +113,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
if (username.equals("admin")) {
|
if (username.equals("admin")) {
|
||||||
criteria.setIsAdmin(true);
|
criteria.setIsAdmin(true);
|
||||||
}
|
}
|
||||||
|
// 角色管理员
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
List<SysRoleVo> roles = roleService.selectRolesAuthByUserId(userId);
|
||||||
|
if (CollectionUtil.isNotEmpty(roles)) {
|
||||||
|
for (SysRoleVo role : roles) {
|
||||||
|
if (role.getRoleKey().equals("admin")) {
|
||||||
|
criteria.setIsAdmin(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,8 @@ import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
|||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
||||||
|
import com.fuyuanshen.system.service.ISysRoleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -43,6 +45,8 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||||
|
|
||||||
|
private final ISysRoleService roleService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询设备类型
|
* 分页查询设备类型
|
||||||
@ -54,8 +58,23 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
@Override
|
@Override
|
||||||
public TableDataInfo<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<DeviceType> page) {
|
public TableDataInfo<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<DeviceType> page) {
|
||||||
// 管理员
|
// 管理员
|
||||||
String username = LoginHelper.getUsername();
|
// String username = LoginHelper.getUsername();
|
||||||
if (!username.equals("admin")) {
|
// if (!username.equals("admin")) {
|
||||||
|
// criteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
// }
|
||||||
|
// 角色管理员
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
List<SysRoleVo> roles = roleService.selectRolesAuthByUserId(userId);
|
||||||
|
boolean isAdmin = false;
|
||||||
|
if (CollectionUtil.isNotEmpty(roles)) {
|
||||||
|
for (SysRoleVo role : roles) {
|
||||||
|
if (role.getRoleKey().contains("admin")) {
|
||||||
|
isAdmin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isAdmin) {
|
||||||
criteria.setCustomerId(LoginHelper.getUserId());
|
criteria.setCustomerId(LoginHelper.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user