update
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.maibu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.maibu.core.business.Device;
|
||||
import com.maibu.core.domain.entity.SysRole;
|
||||
import com.maibu.core.domain.entity.SysSite;
|
||||
import com.maibu.core.domain.model.LoginUser;
|
||||
import com.maibu.exception.ServiceException;
|
||||
import com.maibu.mapper.SysRegionMapper;
|
||||
import com.maibu.mapper.SysSiteMapper;
|
||||
@@ -14,6 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -25,6 +29,9 @@ public class SysSiteService {
|
||||
@Autowired
|
||||
private SysRegionService sysRegionService;
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
public List<SysSite> list(SysSite site) {
|
||||
LambdaQueryWrapper<SysSite> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (site != null && !StringUtils.isEmpty(site.getSiteName())) {
|
||||
@@ -72,4 +79,25 @@ public class SysSiteService {
|
||||
return sysSiteMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public List<SysSite> selectByUserId(LoginUser loginUser) {
|
||||
SysRole sysRole = roleService.selectRoleById(loginUser.getRoleId());
|
||||
if (sysRole != null) {
|
||||
String roleKey = sysRole.getRoleKey();
|
||||
LambdaQueryWrapper<SysSite> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (!StringUtils.isEmpty(roleKey)) {
|
||||
if ("manager".equals(roleKey)) {
|
||||
queryWrapper.eq(SysSite::getOrgId, loginUser.getOrgId());
|
||||
} else if ("siteManager".equals(roleKey)) {
|
||||
queryWrapper.eq(SysSite::getId, loginUser.getSiteId());
|
||||
} else if ("admin".equals(roleKey)) {
|
||||
|
||||
} else {
|
||||
queryWrapper.eq(SysSite::getId, loginUser.getSiteId());
|
||||
}
|
||||
return sysSiteMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user