first commit
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
package com.starry.admin.modules.monitor.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.monitor.entity.Cache;
|
||||
import com.starry.common.constant.CacheConstants;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* 缓存监控
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/cache")
|
||||
public class CacheController {
|
||||
|
||||
private final static List<Cache> CACHES = new ArrayList<>();
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
{
|
||||
CACHES.add(new Cache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
||||
CACHES.add(new Cache(CacheConstants.SYS_DICT_KEY, "数据字典"));
|
||||
CACHES.add(new Cache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@GetMapping()
|
||||
public R getInfo() throws Exception {
|
||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
|
||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
result.put("info", info);
|
||||
result.put("dbSize", dbSize);
|
||||
List<Map<String, String>> pieList = new ArrayList<>();
|
||||
commandStats.stringPropertyNames().forEach(key -> {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
String property = commandStats.getProperty(key);
|
||||
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||
pieList.add(data);
|
||||
});
|
||||
result.put("commandStats", pieList);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getNames")
|
||||
public R cache() {
|
||||
return R.ok(CACHES);
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getKeys/{cacheName}")
|
||||
public R getCacheKeys(@PathVariable String cacheName) {
|
||||
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
return R.ok(cacheKeys);
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||
public R getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
Cache cache = new Cache(cacheName, cacheKey, cacheValue);
|
||||
return R.ok(cache);
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public R clearCacheName(@PathVariable String cacheName) {
|
||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||
public R clearCacheKey(@PathVariable String cacheKey) {
|
||||
redisTemplate.delete(cacheKey);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public R clearCacheAll() {
|
||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.starry.admin.modules.monitor.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.monitor.entity.Server;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* 服务器监控
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/server")
|
||||
public class ServerController {
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
public R getInfo() throws Exception {
|
||||
Server server = new Server();
|
||||
server.setServeInfo();
|
||||
return R.ok(server);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.starry.admin.modules.monitor.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.monitor.entity.UserOnline;
|
||||
import com.starry.admin.modules.monitor.service.UserOnlineService;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.constant.CacheConstants;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* 在线用户监控
|
||||
* @since 2022/10/18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class UserOnlineController {
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
@Resource
|
||||
private UserOnlineService userOnlineService;
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:online:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(String ipaddr, String userName) {
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
List<UserOnline> userOnlineList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
} else {
|
||||
userOnlineList.add(userOnlineService.setUserOnline(user));
|
||||
}
|
||||
}
|
||||
IPage<UserOnline> page = new Page<>();
|
||||
page.setRecords(userOnlineList);
|
||||
page.setTotal(userOnlineList.size());
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public R forceLogout(@PathVariable String tokenId) {
|
||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 缓存信息
|
||||
* @since 2022/10/18
|
||||
*/
|
||||
@Data
|
||||
public class Cache {
|
||||
|
||||
/**
|
||||
* 缓存名称
|
||||
*/
|
||||
private String cacheName = "";
|
||||
|
||||
/**
|
||||
* 缓存键名
|
||||
*/
|
||||
private String cacheKey = "";
|
||||
|
||||
/**
|
||||
* 缓存内容
|
||||
*/
|
||||
private String cacheValue = "";
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark = "";
|
||||
|
||||
public Cache() {
|
||||
|
||||
}
|
||||
|
||||
public Cache(String cacheName, String remark) {
|
||||
this.cacheName = cacheName;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Cache(String cacheName, String cacheKey, String cacheValue) {
|
||||
this.cacheName = StringUtils.replace(cacheName, ":", "");
|
||||
this.cacheKey = StringUtils.replace(cacheKey, cacheName, "");
|
||||
this.cacheValue = cacheValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import com.starry.common.utils.Arith;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* cpu相关信息
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@Data
|
||||
public class Cpu {
|
||||
|
||||
/**
|
||||
* 核心数
|
||||
*/
|
||||
private int cpuNum;
|
||||
|
||||
/**
|
||||
* CPU总的使用率
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* CPU系统使用率
|
||||
*/
|
||||
private double sys;
|
||||
|
||||
/**
|
||||
* CPU用户使用率
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* CPU当前等待率
|
||||
*/
|
||||
private double wait;
|
||||
|
||||
/**
|
||||
* CPU当前空闲率
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public int getCpuNum() {
|
||||
return cpuNum;
|
||||
}
|
||||
|
||||
public void setCpuNum(int cpuNum) {
|
||||
this.cpuNum = cpuNum;
|
||||
}
|
||||
|
||||
public double getTotal() {
|
||||
return Arith.round(Arith.mul(total, 100), 2);
|
||||
}
|
||||
|
||||
public void setTotal(double total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getSys() {
|
||||
return Arith.round(Arith.mul(sys / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setSys(double sys) {
|
||||
this.sys = sys;
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return Arith.round(Arith.mul(used / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setUsed(double used) {
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public double getWait() {
|
||||
return Arith.round(Arith.mul(wait / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setWait(double wait) {
|
||||
this.wait = wait;
|
||||
}
|
||||
|
||||
public double getFree() {
|
||||
return Arith.round(Arith.mul(free / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setFree(double free) {
|
||||
this.free = free;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.starry.common.utils.Arith;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 虚拟机相关信息
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
|
||||
public class Jvm {
|
||||
|
||||
/**
|
||||
* 当前JVM占用的内存总数(M)
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* JVM最大可用内存总数(M)
|
||||
*/
|
||||
private double max;
|
||||
|
||||
/**
|
||||
* JVM空闲内存(M)
|
||||
*/
|
||||
private double free;
|
||||
|
||||
/**
|
||||
* JDK版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* JDK路径
|
||||
*/
|
||||
private String home;
|
||||
|
||||
public double getTotal() {
|
||||
return Arith.div(total, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setTotal(double total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return Arith.div(max, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setMax(double max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public double getFree() {
|
||||
return Arith.div(free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setFree(double free) {
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return Arith.div(total - free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getUsage() {
|
||||
return Arith.mul(Arith.div(total - free, total, 4), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JDK名称
|
||||
*/
|
||||
public String getName() {
|
||||
return ManagementFactory.getRuntimeMXBean().getVmName();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getHome() {
|
||||
return home;
|
||||
}
|
||||
|
||||
public void setHome(String home) {
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK启动时间
|
||||
*/
|
||||
public String getStartTime() {
|
||||
return DateUtil.format(new Date(ManagementFactory.getRuntimeMXBean().getStartTime()), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK运行时间
|
||||
*/
|
||||
public String getRunTime() {
|
||||
return DateUtil.formatBetween(new Date(), new Date(ManagementFactory.getRuntimeMXBean().getStartTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行参数
|
||||
*/
|
||||
public String getInputArgs() {
|
||||
return ManagementFactory.getRuntimeMXBean().getInputArguments().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import com.starry.common.utils.Arith;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 内存相关信息
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@Data
|
||||
public class Mem {
|
||||
|
||||
/**
|
||||
* 内存总量
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* 已用内存
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* 剩余内存
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public double getTotal() {
|
||||
return Arith.div(total, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return Arith.div(used, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setUsed(long used) {
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public double getFree() {
|
||||
return Arith.div(free, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setFree(long free) {
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public double getUsage() {
|
||||
return Arith.mul(Arith.div(used, total, 4), 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
|
||||
import com.starry.common.utils.Arith;
|
||||
import com.starry.common.utils.ip.IpUtils;
|
||||
import lombok.Data;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.software.os.FileSystem;
|
||||
import oshi.software.os.OSFileStore;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.Util;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 服务器相关信息
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@Data
|
||||
public class Server {
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*/
|
||||
private Cpu cpu = new Cpu();
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*/
|
||||
private Mem mem = new Mem();
|
||||
|
||||
/**
|
||||
* JVM相关信息
|
||||
*/
|
||||
private Jvm jvm = new Jvm();
|
||||
|
||||
/**
|
||||
* 系统相关信息
|
||||
*/
|
||||
private Sys sys = new Sys();
|
||||
|
||||
/**
|
||||
* 磁盘相关信息
|
||||
*/
|
||||
private List<SysFile> sysFiles = new LinkedList<>();
|
||||
|
||||
public void setServeInfo() throws Exception {
|
||||
// 系统信息
|
||||
SystemInfo si = new SystemInfo();
|
||||
// 获取硬件抽象层
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
setCpuInfo(hal.getProcessor());
|
||||
setMemInfo(hal.getMemory());
|
||||
setSysInfo();
|
||||
setJvmInfo();
|
||||
setSysFiles(si.getOperatingSystem());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置CPU信息
|
||||
*/
|
||||
private void setCpuInfo(CentralProcessor processor) {
|
||||
// CPU信息
|
||||
long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
Util.sleep(1000);
|
||||
long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
|
||||
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
|
||||
long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
|
||||
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
|
||||
long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
|
||||
long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
|
||||
long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
|
||||
long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
|
||||
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
|
||||
cpu.setCpuNum(processor.getLogicalProcessorCount());
|
||||
cpu.setTotal(totalCpu);
|
||||
cpu.setSys(cSys);
|
||||
cpu.setUsed(user);
|
||||
cpu.setWait(iowait);
|
||||
cpu.setFree(idle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置内存信息
|
||||
*/
|
||||
private void setMemInfo(GlobalMemory memory) {
|
||||
mem.setTotal(memory.getTotal());
|
||||
mem.setUsed(memory.getTotal() - memory.getAvailable());
|
||||
mem.setFree(memory.getAvailable());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置服务器信息
|
||||
*/
|
||||
private void setSysInfo() {
|
||||
Properties properties = System.getProperties();
|
||||
sys.setComputerName(IpUtils.getHostName());
|
||||
sys.setComputerIp(IpUtils.getHostIp());
|
||||
sys.setOsName(properties.getProperty("os.name"));
|
||||
sys.setOsArch(properties.getProperty("os.arch"));
|
||||
sys.setUserDir(properties.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Java虚拟机
|
||||
*/
|
||||
private void setJvmInfo() throws UnknownHostException {
|
||||
Properties props = System.getProperties();
|
||||
jvm.setTotal(Runtime.getRuntime().totalMemory());
|
||||
jvm.setMax(Runtime.getRuntime().maxMemory());
|
||||
jvm.setFree(Runtime.getRuntime().freeMemory());
|
||||
jvm.setVersion(props.getProperty("java.version"));
|
||||
jvm.setHome(props.getProperty("java.home"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置磁盘信息
|
||||
*/
|
||||
private void setSysFiles(OperatingSystem os) {
|
||||
FileSystem fileSystem = os.getFileSystem();
|
||||
List<OSFileStore> fsArray = fileSystem.getFileStores();
|
||||
for (OSFileStore fs : fsArray) {
|
||||
long free = fs.getUsableSpace();
|
||||
long total = fs.getTotalSpace();
|
||||
long used = total - free;
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setDirName(fs.getMount());
|
||||
sysFile.setSysTypeName(fs.getType());
|
||||
sysFile.setTypeName(fs.getName());
|
||||
sysFile.setTotal(convertFileSize(total));
|
||||
sysFile.setFree(convertFileSize(free));
|
||||
sysFile.setUsed(convertFileSize(used));
|
||||
sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
|
||||
sysFiles.add(sysFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节转换
|
||||
*
|
||||
* @param size 字节大小
|
||||
* @return 转换后值
|
||||
*/
|
||||
public String convertFileSize(long size) {
|
||||
long kb = 1024;
|
||||
long mb = kb * 1024;
|
||||
long gb = mb * 1024;
|
||||
if (size >= gb) {
|
||||
return String.format("%.1f GB", (float) size / gb);
|
||||
} else if (size >= mb) {
|
||||
float f = (float) size / mb;
|
||||
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
|
||||
} else if (size >= kb) {
|
||||
float f = (float) size / kb;
|
||||
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
|
||||
} else {
|
||||
return String.format("%d B", size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 系统相关信息
|
||||
* @since 2022/10/17
|
||||
*/
|
||||
@Data
|
||||
public class Sys {
|
||||
|
||||
/**
|
||||
* 服务器名称
|
||||
*/
|
||||
private String computerName;
|
||||
|
||||
/**
|
||||
* 服务器Ip
|
||||
*/
|
||||
private String computerIp;
|
||||
|
||||
/**
|
||||
* 项目路径
|
||||
*/
|
||||
private String userDir;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 系统架构
|
||||
*/
|
||||
private String osArch;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 系统文件相关信息
|
||||
*/
|
||||
@Data
|
||||
public class SysFile {
|
||||
|
||||
/**
|
||||
* 盘符路径
|
||||
*/
|
||||
private String dirName;
|
||||
|
||||
/**
|
||||
* 盘符类型
|
||||
*/
|
||||
private String sysTypeName;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 总大小
|
||||
*/
|
||||
private String total;
|
||||
|
||||
/**
|
||||
* 剩余大小
|
||||
*/
|
||||
private String free;
|
||||
|
||||
/**
|
||||
* 已经使用量
|
||||
*/
|
||||
private String used;
|
||||
|
||||
/**
|
||||
* 资源的使用率
|
||||
*/
|
||||
private double usage;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.starry.admin.modules.monitor.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 当前在线会话
|
||||
*/
|
||||
@Data
|
||||
public class UserOnline {
|
||||
/**
|
||||
* 会话编号
|
||||
*/
|
||||
private String tokenId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地址
|
||||
*/
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private Long loginTime;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.starry.admin.modules.monitor.service;
|
||||
|
||||
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.monitor.entity.UserOnline;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2022/10/18
|
||||
*/
|
||||
public interface UserOnlineService {
|
||||
|
||||
/**
|
||||
* 通过登录地址/用户名称查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
UserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过登录地址查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
UserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名称查询信息
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
UserOnline selectOnlineByUserName(String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 设置在线用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
UserOnline setUserOnline(LoginUser user);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.starry.admin.modules.monitor.service.impl;
|
||||
|
||||
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.monitor.entity.UserOnline;
|
||||
import com.starry.admin.modules.monitor.service.UserOnlineService;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2022/10/18
|
||||
*/
|
||||
@Service
|
||||
public class UserOnlineServiceImpl implements UserOnlineService {
|
||||
|
||||
@Override
|
||||
public UserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||
return setUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
return setUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOnline selectOnlineByUserName(String userName, LoginUser user) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
return setUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOnline setUserOnline(LoginUser user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) {
|
||||
return null;
|
||||
}
|
||||
UserOnline userOnline = new UserOnline();
|
||||
userOnline.setTokenId(user.getToken());
|
||||
userOnline.setUserName(user.getUsername());
|
||||
userOnline.setIpaddr(user.getIpaddr());
|
||||
userOnline.setLoginLocation(user.getLoginLocation());
|
||||
userOnline.setBrowser(user.getBrowser());
|
||||
userOnline.setOs(user.getOs());
|
||||
userOnline.setLoginTime(user.getLoginTime());
|
||||
if (StringUtils.isNotNull(user.getUser().getDept())) {
|
||||
userOnline.setDeptName(user.getUser().getDept().getDeptName());
|
||||
}
|
||||
return userOnline;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.starry.admin.modules.platform.controller;
|
||||
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantAddVo;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantQueryVo;
|
||||
import com.starry.admin.utils.ExcelUtils;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
/**
|
||||
* 租户表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/platform/tenant")
|
||||
public class SysTenantController {
|
||||
@Resource
|
||||
private ISysTenantService sysTenantService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增租户表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:create')")
|
||||
@Log(title = "租户表", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@Valid @RequestBody SysTenantAddVo vo) {
|
||||
SysTenantEntity entity = ConvertUtil.entityToVo(vo, SysTenantEntity.class);
|
||||
return sysTenantService.addTenant(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询租户表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysTenantQueryVo vo) {
|
||||
return R.ok(sysTenantService.selectSysTenantList(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租户表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:export')")
|
||||
@Log(title = "租户表", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysTenantQueryVo sysTenantEntity) {
|
||||
ExcelUtils.exportEasyExcel(response, SysTenantEntity.class, sysTenantService.selectSysTenantList(sysTenantEntity).getRecords(), "租户表数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:query')")
|
||||
@GetMapping(value = "/{tenantId}")
|
||||
public R getInfo(@PathVariable("tenantId") String tenantId) {
|
||||
return R.ok(sysTenantService.selectSysTenantByTenantId(tenantId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改租户表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:edit')")
|
||||
@Log(title = "租户表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{tenantId}")
|
||||
public R update(@PathVariable String tenantId, @RequestBody SysTenantEntity sysTenantEntity) {
|
||||
return sysTenantService.updateTenant(sysTenantEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:tenant:remove')")
|
||||
@Log(title = "租户表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{tenantIds}")
|
||||
public R remove(@PathVariable String[] tenantIds) {
|
||||
return R.ok(sysTenantService.deleteSysTenantByTenantIds(tenantIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.starry.admin.modules.platform.controller;
|
||||
|
||||
import com.starry.admin.modules.platform.entity.SysTenantPackageEntity;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantPackageService;
|
||||
import com.starry.admin.modules.platform.vo.SimplePackage;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantPackageVo;
|
||||
import com.starry.admin.utils.ExcelUtils;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 租户套餐表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/platform/package")
|
||||
public class SysTenantPackageController {
|
||||
@Resource
|
||||
private ISysTenantPackageService SysTenantPackageService;
|
||||
|
||||
/**
|
||||
* 查询租户套餐表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysTenantPackageVo sysTenantPackageEntity) {
|
||||
return R.ok(SysTenantPackageService.selectSysTenantPackageList(sysTenantPackageEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租户套餐表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:export')")
|
||||
@Log(title = "租户套餐表", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysTenantPackageVo sysTenantPackageEntity) {
|
||||
ExcelUtils.exportEasyExcel(response, SysTenantPackageEntity.class, SysTenantPackageService.selectSysTenantPackageList(sysTenantPackageEntity).getRecords(), "租户套餐表数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户套餐表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:query')")
|
||||
@GetMapping(value = "/{packageId}")
|
||||
public R getInfo(@PathVariable("packageId") String packageId) {
|
||||
return R.ok(SysTenantPackageService.selectSysTenantPackageByPackageId(packageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户套餐表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:create')")
|
||||
@Log(title = "租户套餐表", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody SysTenantPackageEntity vo) {
|
||||
SysTenantPackageEntity entity = ConvertUtil.entityToVo(vo, SysTenantPackageEntity.class);
|
||||
boolean success = SysTenantPackageService.create(entity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户套餐表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:edit')")
|
||||
@Log(title = "租户套餐表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{packageId}")
|
||||
public R update(@PathVariable String packageId, @RequestBody SysTenantPackageEntity sysTenantPackageEntity) {
|
||||
|
||||
sysTenantPackageEntity.setPackageId(packageId);
|
||||
boolean success = SysTenantPackageService.update(sysTenantPackageEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户套餐表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('platform:package:remove')")
|
||||
@Log(title = "租户套餐表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{packageIds}")
|
||||
public R remove(@PathVariable String[] packageIds) {
|
||||
return R.ok(SysTenantPackageService.deleteSysTenantPackageByPackageIds(packageIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户套餐精简列表
|
||||
*/
|
||||
@GetMapping("/get-simple-list")
|
||||
public R getSimpleList() {
|
||||
List<SimplePackage> list = SysTenantPackageService.getSimpleList();
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.starry.admin.modules.platform.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 租户表对象 sys_tenant
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_tenant")
|
||||
public class SysTenantEntity extends BaseEntity<SysTenantEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "tenant_id", type = IdType.AUTO)
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 租户类型;0:公司;1:部门;2:个人;3:其他
|
||||
*/
|
||||
private String tenantType;
|
||||
|
||||
/**
|
||||
* 用户状态;0:正常,1:停用
|
||||
*/
|
||||
private String tenantStatus;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* logo图
|
||||
*/
|
||||
private String tenantLogo;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long sortOrder;
|
||||
|
||||
/**
|
||||
* 官方地址
|
||||
*/
|
||||
private String homeUrl;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
private String fax;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 管理员账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 管理员密码
|
||||
*/
|
||||
private String userPwd;
|
||||
|
||||
/**
|
||||
* 租户套餐
|
||||
*/
|
||||
private String packageId;
|
||||
|
||||
/**
|
||||
* 租赁到期时间
|
||||
*/
|
||||
private Date tenantTime;
|
||||
|
||||
/**
|
||||
* 微信公众号ID
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
|
||||
/**
|
||||
* 微信公众号的app secret
|
||||
*/
|
||||
private String secret;
|
||||
|
||||
/**
|
||||
* 设置微信公众号的token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 设置微信公众号的EncodingAESKey
|
||||
*/
|
||||
private String aesKey;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.starry.admin.modules.platform.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 租户套餐表对象 sys_tenant_package
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_tenant_package")
|
||||
public class SysTenantPackageEntity extends BaseEntity<SysTenantPackageEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 套餐id
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "package_id", type = IdType.AUTO)
|
||||
private String packageId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 关联菜单id
|
||||
*/
|
||||
private String menuIds;
|
||||
|
||||
/**
|
||||
* 状态;0:正常,1:停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.starry.admin.modules.platform.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantQueryVo;
|
||||
import com.starry.admin.modules.platform.vo.TenantResultVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 租户表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
public interface SysTenantMapper extends BaseMapper<SysTenantEntity> {
|
||||
/**
|
||||
* 查询租户表
|
||||
*
|
||||
* @param tenantId 租户表主键
|
||||
* @return 租户表
|
||||
*/
|
||||
SysTenantEntity selectSysTenantByTenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* 查询租户表列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 租户表集合
|
||||
*/
|
||||
IPage<TenantResultVo> selectSysTenantList(Page<TenantResultVo> page, @Param("vo") SysTenantQueryVo sysTenantEntity);
|
||||
|
||||
/**
|
||||
* 批量删除租户管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTenantByIds(String[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.starry.admin.modules.platform.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantPackageEntity;
|
||||
import com.starry.admin.modules.platform.vo.SimplePackage;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantPackageVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户套餐表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface SysTenantPackageMapper extends BaseMapper<SysTenantPackageEntity> {
|
||||
/**
|
||||
* 查询租户套餐表
|
||||
*
|
||||
* @param packageId 租户套餐表主键
|
||||
* @return 租户套餐表
|
||||
*/
|
||||
SysTenantPackageEntity selectSysTenantPackageByPackageId(String packageId);
|
||||
|
||||
/**
|
||||
* 查询租户套餐表列表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 租户套餐表集合
|
||||
*/
|
||||
IPage<SysTenantPackageEntity> selectSysTenantPackageList(Page<SysTenantPackageEntity> page, @Param("vo") SysTenantPackageVo sysTenantPackageEntity);
|
||||
|
||||
/**
|
||||
* 查询租户套餐
|
||||
*
|
||||
* @return 租户套餐
|
||||
*/
|
||||
List<SimplePackage> getSimpleList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.starry.admin.modules.platform.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantPackageEntity;
|
||||
import com.starry.admin.modules.platform.vo.SimplePackage;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantPackageVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户套餐表Service接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysTenantPackageService extends IService<SysTenantPackageEntity> {
|
||||
/**
|
||||
* 查询租户套餐表
|
||||
*
|
||||
* @param packageId 租户套餐表主键
|
||||
* @return 租户套餐表
|
||||
*/
|
||||
SysTenantPackageEntity selectSysTenantPackageByPackageId(String packageId);
|
||||
|
||||
/**
|
||||
* 查询租户套餐表列表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 租户套餐表集合
|
||||
*/
|
||||
IPage<SysTenantPackageEntity> selectSysTenantPackageList(SysTenantPackageVo sysTenantPackageEntity);
|
||||
|
||||
/**
|
||||
* 新增租户套餐表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysTenantPackageEntity sysTenantPackageEntity);
|
||||
|
||||
/**
|
||||
* 修改租户套餐表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(SysTenantPackageEntity sysTenantPackageEntity);
|
||||
|
||||
/**
|
||||
* 批量删除租户套餐表
|
||||
*
|
||||
* @param packageIds 需要删除的租户套餐表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTenantPackageByPackageIds(String[] packageIds);
|
||||
|
||||
/**
|
||||
* 删除租户套餐表信息
|
||||
*
|
||||
* @param packageId 租户套餐表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTenantPackageByPackageId(Long packageId);
|
||||
|
||||
/**
|
||||
* 查询租户套餐
|
||||
*
|
||||
* @return 租户套餐
|
||||
*/
|
||||
List<SimplePackage> getSimpleList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.starry.admin.modules.platform.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantQueryVo;
|
||||
import com.starry.admin.modules.platform.vo.TenantResultVo;
|
||||
import com.starry.common.result.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户表Service接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysTenantService extends IService<SysTenantEntity> {
|
||||
/**
|
||||
* 查询租户表
|
||||
*
|
||||
* @param tenantId 租户表主键
|
||||
* @return 租户表
|
||||
*/
|
||||
SysTenantEntity selectSysTenantByTenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* 查询租户表列表
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 租户表集合
|
||||
*/
|
||||
IPage<TenantResultVo> selectSysTenantList(SysTenantQueryVo sysTenantEntity);
|
||||
|
||||
/**
|
||||
* 新增租户表
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysTenantEntity sysTenantEntity);
|
||||
|
||||
/**
|
||||
* 修改租户表
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(SysTenantEntity sysTenantEntity);
|
||||
|
||||
/**
|
||||
* 批量删除租户表
|
||||
*
|
||||
* @param tenantIds 需要删除的租户表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTenantByTenantIds(String[] tenantIds);
|
||||
|
||||
/**
|
||||
* 删除租户表信息
|
||||
*
|
||||
* @param tenantId 租户表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTenantByTenantId(Long tenantId);
|
||||
|
||||
/**
|
||||
* 新增租户
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
R addTenant(SysTenantEntity sysTenantEntity);
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
R updateTenant(SysTenantEntity sysTenantEntity);
|
||||
|
||||
|
||||
/**
|
||||
* 根据套餐ID查询租户
|
||||
* @param packageId 套餐ID
|
||||
* @return
|
||||
*/
|
||||
List<SysTenantEntity> queryByPackage(String packageId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.starry.admin.modules.platform.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantPackageEntity;
|
||||
import com.starry.admin.modules.platform.mapper.SysTenantPackageMapper;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantPackageService;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.platform.vo.SimplePackage;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantPackageVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户套餐表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysTenantPackageServiceImpl extends ServiceImpl<SysTenantPackageMapper, SysTenantPackageEntity> implements ISysTenantPackageService {
|
||||
@Resource
|
||||
private SysTenantPackageMapper sysTenantPackageMapper;
|
||||
|
||||
@Resource
|
||||
private ISysTenantService tenantService;
|
||||
|
||||
/**
|
||||
* 查询租户套餐表
|
||||
*
|
||||
* @param packageId 租户套餐表主键
|
||||
* @return 租户套餐表
|
||||
*/
|
||||
@Override
|
||||
public SysTenantPackageEntity selectSysTenantPackageByPackageId(String packageId) {
|
||||
return this.baseMapper.selectById(packageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户套餐表列表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 租户套餐表
|
||||
*/
|
||||
@Override
|
||||
public IPage<SysTenantPackageEntity> selectSysTenantPackageList(SysTenantPackageVo sysTenantPackageEntity) {
|
||||
return sysTenantPackageMapper.selectSysTenantPackageList(new Page<>(sysTenantPackageEntity.getPageNum(), sysTenantPackageEntity.getPageSize()), sysTenantPackageEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户套餐表
|
||||
*
|
||||
* @param entity 租户套餐表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysTenantPackageEntity entity) {
|
||||
if (StrUtil.isBlankIfStr(entity.getPackageId())) {
|
||||
entity.setPackageId(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
return save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户套餐表
|
||||
*
|
||||
* @param sysTenantPackageEntity 租户套餐表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(SysTenantPackageEntity sysTenantPackageEntity) {
|
||||
return updateById(sysTenantPackageEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除租户套餐表
|
||||
*
|
||||
* @param packageIds 需要删除的租户套餐表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysTenantPackageByPackageIds(String[] packageIds) {
|
||||
//删除前,看套餐是否被租户引用
|
||||
for (String packageId : packageIds) {
|
||||
if (!tenantService.queryByPackage(packageId).isEmpty()) {
|
||||
throw new CustomException("套餐背应用,无法删除");
|
||||
}
|
||||
}
|
||||
return sysTenantPackageMapper.deleteBatchIds(Arrays.asList(packageIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户套餐表信息
|
||||
*
|
||||
* @param packageId 租户套餐表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysTenantPackageByPackageId(Long packageId) {
|
||||
return sysTenantPackageMapper.deleteById(packageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SimplePackage> getSimpleList() {
|
||||
return sysTenantPackageMapper.getSimpleList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package com.starry.admin.modules.platform.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantPackageEntity;
|
||||
import com.starry.admin.modules.platform.mapper.SysTenantMapper;
|
||||
import com.starry.admin.modules.platform.mapper.SysTenantPackageMapper;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.platform.vo.SysTenantQueryVo;
|
||||
import com.starry.admin.modules.platform.vo.TenantResultVo;
|
||||
import com.starry.admin.modules.system.entity.*;
|
||||
import com.starry.admin.modules.system.mapper.*;
|
||||
import com.starry.admin.modules.system.service.SysRoleMenuService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.CacheConstants;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 租户表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
@Service
|
||||
public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenantEntity> implements ISysTenantService {
|
||||
@Resource
|
||||
private SysTenantMapper sysTenantMapper;
|
||||
@Resource
|
||||
private SysTenantPackageMapper tenantPackageMapper;
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Resource
|
||||
private SysDeptMapper deptMapper;
|
||||
@Resource
|
||||
private SysRoleMapper roleMapper;
|
||||
@Resource
|
||||
private SysRoleMenuService roleMenuService;
|
||||
@Resource
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
@Resource
|
||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 查询租户表
|
||||
*
|
||||
* @param tenantId 租户表主键
|
||||
* @return 租户表
|
||||
*/
|
||||
@Override
|
||||
public SysTenantEntity selectSysTenantByTenantId(String tenantId) {
|
||||
return this.baseMapper.selectById(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户表列表
|
||||
*
|
||||
* @param vo 租户表
|
||||
* @return 租户表
|
||||
*/
|
||||
@Override
|
||||
public IPage<TenantResultVo> selectSysTenantList(SysTenantQueryVo vo) {
|
||||
LambdaQueryWrapper<SysTenantEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(vo.getTenantStatus())) {
|
||||
wrapper.eq(SysTenantEntity::getTenantStatus, vo.getTenantStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getTenantName())) {
|
||||
wrapper.like(SysTenantEntity::getTenantName, vo.getTenantName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getBeginTime())) {
|
||||
wrapper.ge(SysTenantEntity::getTenantTime, vo.getBeginTime());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getEndTime())) {
|
||||
wrapper.le(SysTenantEntity::getTenantTime, vo.getEndTime());
|
||||
}
|
||||
return sysTenantMapper.selectSysTenantList(new Page<>(vo.getPageNum(), vo.getPageSize()), vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户表
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysTenantEntity sysTenantEntity) {
|
||||
return save(sysTenantEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户表
|
||||
*
|
||||
* @param sysTenantEntity 租户表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(SysTenantEntity sysTenantEntity) {
|
||||
return updateById(sysTenantEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除租户表
|
||||
*
|
||||
* @param tenantIds 需要删除的租户表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteSysTenantByTenantIds(String[] tenantIds) {
|
||||
int num = sysTenantMapper.deleteTenantByIds(tenantIds);
|
||||
if (num > 0) {
|
||||
// 下面才会进行子模块数据的删除
|
||||
// 部门模块
|
||||
deptMapper.deleteDeptByTenantId(tenantIds);
|
||||
// 权限
|
||||
roleMapper.deleteRoleByTenantId(tenantIds);
|
||||
sysRoleMenuMapper.deleteRoleMenuByTenantIds(tenantIds);
|
||||
// 账号
|
||||
sysUserMapper.deleteUserByTenantId(tenantIds);
|
||||
userRoleMapper.deleteUserRoleByTenantId(tenantIds);
|
||||
} else {
|
||||
throw new RuntimeException("当前租户已被删除不存在!");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户表信息
|
||||
*
|
||||
* @param tenantId 租户表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysTenantByTenantId(Long tenantId) {
|
||||
return sysTenantMapper.deleteById(tenantId);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public R addTenant(SysTenantEntity sysTenantEntity) {
|
||||
if (StrUtil.isBlankIfStr(sysTenantEntity.getTenantId())) {
|
||||
sysTenantEntity.setTenantId(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
if (StrUtil.isBlankIfStr(sysTenantEntity.getTenantCode())) {
|
||||
sysTenantEntity.setTenantCode(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
// 判断账号是否存在
|
||||
if (sysUserMapper.checkUserNameUnique(sysTenantEntity.getUserName()) > 0) {
|
||||
return R.error("管理员账号已存在,请重新设置!");
|
||||
}
|
||||
// 创建租户
|
||||
sysTenantMapper.insert(sysTenantEntity);
|
||||
// 创建默认部门--部门默认名称以租户名称
|
||||
Long deptId = createDept(sysTenantEntity);
|
||||
// 创建默认角色--角色默认为租户名称+管理员
|
||||
Long roleId = createRole(sysTenantEntity);
|
||||
// 创建默认账号
|
||||
createUser(sysTenantEntity, deptId, roleId);
|
||||
return R.ok("租户创建成功!");
|
||||
}
|
||||
|
||||
private Long createDept(SysTenantEntity sysTenantEntity) {
|
||||
// 创建部门
|
||||
SysDeptEntity dept = new SysDeptEntity();
|
||||
dept.setParentId(0L);
|
||||
dept.setAncestors("0");
|
||||
dept.setDeptName(sysTenantEntity.getTenantName());
|
||||
dept.setSort(0);
|
||||
dept.setLeader(sysTenantEntity.getTenantName() + "管理员");
|
||||
dept.setPhone(sysTenantEntity.getPhone());
|
||||
dept.setEmail(sysTenantEntity.getEmail());
|
||||
dept.setTenantId(sysTenantEntity.getTenantId());
|
||||
deptMapper.insert(dept);
|
||||
return dept.getDeptId();
|
||||
}
|
||||
|
||||
private Long createRole(SysTenantEntity sysTenantEntity) {
|
||||
// 创建角色
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
role.setRoleName(sysTenantEntity.getTenantName() + "管理员");
|
||||
role.setRoleKey("admin");
|
||||
role.setDataScope("1");
|
||||
role.setMenuCheckStrictly(true);
|
||||
role.setDeptCheckStrictly(true);
|
||||
role.setDescription("租户管理员");
|
||||
role.setTenantId(sysTenantEntity.getTenantId());
|
||||
roleMapper.insert(role);
|
||||
// 根据租户套餐ids查出套餐编码塞入角色-菜单表
|
||||
createRoleMenu(sysTenantEntity, role);
|
||||
return role.getRoleId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 目前为单套餐,跟租户绑定,解耦防止套餐变动影响多个租户
|
||||
**/
|
||||
private void createRoleMenu(SysTenantEntity sysTenantEntity, SysRoleEntity role) {
|
||||
SysTenantPackageEntity sysTenantPackage = tenantPackageMapper.selectById(sysTenantEntity.getPackageId());
|
||||
List<String> subMeuns = Arrays.asList(sysTenantPackage.getMenuIds().split(","));
|
||||
|
||||
List<SysRoleMenuEntity> roleMenuList = subMeuns.stream().map(menuid -> {
|
||||
SysRoleMenuEntity entity = new SysRoleMenuEntity();
|
||||
entity.setRoleId(role.getRoleId());
|
||||
entity.setMenuId(Long.valueOf(menuid));
|
||||
entity.setTenantId(sysTenantEntity.getTenantId());
|
||||
return entity;
|
||||
}).collect(Collectors.toList());
|
||||
roleMenuService.saveBatch(roleMenuList);
|
||||
}
|
||||
|
||||
private void createUser(SysTenantEntity sysTenant, Long deptId, Long roleId) {
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setDeptId(deptId);
|
||||
user.setUserCode(sysTenant.getUserName());
|
||||
user.setRealName(sysTenant.getTenantName());
|
||||
user.setUserNickname(sysTenant.getTenantName());
|
||||
user.setUserType(1);
|
||||
user.setUserEmail(sysTenant.getEmail());
|
||||
user.setMobile(sysTenant.getPhone());
|
||||
String password = SecurityUtils.encryptPassword(sysTenant.getUserPwd());
|
||||
user.setPassWord(password);
|
||||
user.setTenantId(sysTenant.getTenantId());
|
||||
user.setUserId(IdUtil.fastSimpleUUID());
|
||||
sysUserMapper.insert(user);
|
||||
createUserRole(sysTenant.getTenantId(), user.getUserId(), roleId);
|
||||
}
|
||||
|
||||
private void createUserRole(String tenantId, String userId, Long roleId) {
|
||||
SysUserRoleEntity userRole = new SysUserRoleEntity();
|
||||
userRole.setUserId(userId);
|
||||
userRole.setRoleId(roleId);
|
||||
userRole.setTenantId(tenantId);
|
||||
userRoleMapper.insert(userRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateTenant(SysTenantEntity sysTenantEntity) {
|
||||
// 判断最新的租户套餐是否改变 重新授权 租户二级管理员账号需重新分配三级账号权限
|
||||
SysTenantEntity newTenant = sysTenantMapper.selectById(sysTenantEntity.getTenantId());
|
||||
if (sysTenantEntity.getPackageId() != null && !sysTenantEntity.getPackageId().equals(newTenant.getPackageId())) {
|
||||
List<SysRoleEntity> roleList = roleMapper.queryAdminRole(sysTenantEntity.getTenantId());
|
||||
// 正常逻辑下每个租户只有一个二级管理员账号
|
||||
SysRoleEntity tRole = roleList.get(0);
|
||||
if (tRole != null) {
|
||||
// 删除原租户下所有的角色-菜单信息
|
||||
sysRoleMenuMapper.deleteRoleMenuByTenantId(sysTenantEntity.getTenantId());
|
||||
// 新增默认角色-菜单信息
|
||||
createRoleMenu(sysTenantEntity, tRole);
|
||||
// 原登录租户账号退出重登
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
if (CollectionUtil.isNotEmpty(keys)) {
|
||||
for (String key : keys) {
|
||||
LoginUser onlineUser = redisCache.getCacheObject(key);
|
||||
if (onlineUser.getUser().getTenantId() != null && onlineUser.getUser().getTenantId().equals(sysTenantEntity.getTenantId())) {
|
||||
redisCache.deleteObject(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sysTenantMapper.updateById(sysTenantEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysTenantEntity> queryByPackage(String packageId) {
|
||||
LambdaQueryWrapper<SysTenantEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysTenantEntity::getTenantId, packageId);
|
||||
return this.baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2023/3/5 20:53
|
||||
*/
|
||||
@ApiModel("管理后台 - 租户套餐精简信息")
|
||||
@Data
|
||||
public class SimplePackage {
|
||||
|
||||
@ApiModelProperty(value = "套餐编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "套餐名称", required = true, example = "希留")
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 租户表对象 sys_tenant
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysTenantAddVo extends BaseEntity<SysTenantAddVo> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 租户类型;0:公司;1:部门;2:个人;3:其他
|
||||
*/
|
||||
@NotBlank(message = "租户类型不能为空")
|
||||
private String tenantType;
|
||||
|
||||
/**
|
||||
* 用户状态;0:正常,1:停用
|
||||
*/
|
||||
@NotBlank(message = "租户状态不能为空")
|
||||
private String tenantStatus;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank(message = "租户名称不能为空")
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* logo图
|
||||
*/
|
||||
private String tenantLogo;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private String sortOrder;
|
||||
|
||||
/**
|
||||
* 官方地址
|
||||
*/
|
||||
private String homeUrl;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
private String fax;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 管理员账号
|
||||
*/
|
||||
@NotBlank(message = "管理员账号不能为空")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 管理员密码
|
||||
*/
|
||||
@NotBlank(message = "管理员账号密码不能为空")
|
||||
private String userPwd;
|
||||
|
||||
/**
|
||||
* 租户套餐
|
||||
*/
|
||||
private String packageId;
|
||||
|
||||
/**
|
||||
* 租赁到期时间
|
||||
*/
|
||||
@NotNull(message = "租赁到期时间不能为空")
|
||||
private Date tenantTime;
|
||||
|
||||
/**
|
||||
* 微信公众号ID
|
||||
*/
|
||||
@NotBlank(message = "微信公众号ID不能为空")
|
||||
private String appId;
|
||||
|
||||
|
||||
/**
|
||||
* 微信公众号的app secret
|
||||
*/
|
||||
@NotBlank(message = "微信公众号secret不能为空")
|
||||
private String secret;
|
||||
|
||||
|
||||
/**
|
||||
* 设置微信公众号的token
|
||||
*/
|
||||
@NotBlank(message = "微信公众号token不能为空")
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 设置微信公众号的EncodingAESKey
|
||||
*/
|
||||
@NotBlank(message = "微信公众号aesKey不能为空")
|
||||
private String aesKey;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 租户套餐表对象 sys_tenant_package
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysTenantPackageAddVo extends BaseEntity<SysTenantPackageAddVo> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank(message = "套餐名称不能为空")
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 关联菜单id
|
||||
*/
|
||||
private String menuIds;
|
||||
|
||||
/**
|
||||
* 状态;0:正常,1:停用
|
||||
*/
|
||||
@NotBlank(message = "套餐状态不能为空")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 租户套餐表对象 sys_tenant_package
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysTenantPackageVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 套餐id
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "package_id", type = IdType.AUTO)
|
||||
private Long packageId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 关联菜单id
|
||||
*/
|
||||
private String menuIds;
|
||||
|
||||
/**
|
||||
* 状态;0:正常,1:停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 租户表对象 sys_tenant
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysTenantQueryVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
|
||||
/**
|
||||
* 用户状态;0:正常,1:停用
|
||||
*/
|
||||
private String tenantStatus;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.starry.admin.modules.platform.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 租户列表返回结果VO
|
||||
* @since 2023/3/7
|
||||
*/
|
||||
@ApiModel("管理后台 - 租户列表返回信息")
|
||||
@Data
|
||||
public class TenantResultVo {
|
||||
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 租户类型;0:公司;1:部门;2:个人;3:其他
|
||||
*/
|
||||
private String tenantType;
|
||||
|
||||
/**
|
||||
* 用户状态;0:正常,1:停用
|
||||
*/
|
||||
private String tenantStatus;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* logo图
|
||||
*/
|
||||
private String tenantLogo;
|
||||
|
||||
/**
|
||||
* 管理员账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 租户套餐Id
|
||||
*/
|
||||
private String packageId;
|
||||
|
||||
/**
|
||||
* 租赁到期时间
|
||||
*/
|
||||
private Date tenantTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.starry.admin.common.component.JwtToken;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.system.entity.SysMenuEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.service.LoginService;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
import com.starry.admin.modules.system.vo.LoginVo;
|
||||
import com.starry.admin.modules.system.vo.RouterVo;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.redis.CaptchaService;
|
||||
import com.starry.common.result.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Api(tags = "登录管理")
|
||||
@RestController
|
||||
public class LoginController {
|
||||
|
||||
@Value("${jwt.tokenHead}")
|
||||
private String tokenHead;
|
||||
@Value(value = "${xl.login.authCode.enable}")
|
||||
private boolean needAuthCode;
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
@Resource
|
||||
private CaptchaService captchaService;
|
||||
@Resource
|
||||
private JwtToken jwtToken;
|
||||
|
||||
@ApiOperation(value = "登录")
|
||||
@PostMapping(value = "old-login")
|
||||
public R login(@RequestBody LoginVo loginVo) {
|
||||
// 只有开启了验证码功能才需要验证
|
||||
if (needAuthCode) {
|
||||
String msg = captchaService.checkImageCode(loginVo.getNonceStr(), loginVo.getValue());
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
return R.error(msg);
|
||||
}
|
||||
}
|
||||
String token = loginService.login(loginVo.getUserName(), loginVo.getPassWord());
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return R.error("用户名或密码错误");
|
||||
}
|
||||
Map<String, String> tokenMap = new HashMap<>();
|
||||
tokenMap.put("token", token);
|
||||
tokenMap.put("tokenHead", tokenHead);
|
||||
return R.ok(tokenMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录后获取用户信息")
|
||||
@GetMapping("get-info")
|
||||
public R getInfo() {
|
||||
SysUserEntity user = SecurityUtils.getLoginUser().getUser();
|
||||
if (user == null) {
|
||||
return R.unauthorized();
|
||||
}
|
||||
// 权限集合
|
||||
Set<String> permissions = loginService.getMenuPermission(user);
|
||||
// 角色集合
|
||||
Set<String> roles = loginService.getRolePermission(user);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("userCode", user.getUserCode());
|
||||
data.put("name", user.getRealName());
|
||||
data.put("avatar", user.getAvatar());
|
||||
data.put("roles", roles);
|
||||
data.put("permissions", permissions);
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录后获取路由信息")
|
||||
@GetMapping("get-routers")
|
||||
public R getRoutes() {
|
||||
List<SysMenuEntity> menus = menuService.selectMenuTreeByUserId(SecurityUtils.getUserId());
|
||||
List<RouterVo> routerVos = menuService.buildMenus(menus);
|
||||
return R.ok(routerVos);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录")
|
||||
@PostMapping(value = "login")
|
||||
public R newLogin(@RequestBody LoginVo loginVo) {
|
||||
// 只有开启了验证码功能才需要验证
|
||||
if (needAuthCode) {
|
||||
String msg = captchaService.checkImageCode(loginVo.getNonceStr(), loginVo.getValue());
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
return R.error(msg);
|
||||
}
|
||||
}
|
||||
// 用户登录
|
||||
LoginUser userInfo = loginService.newLogin(loginVo.getUserName(), loginVo.getPassWord());
|
||||
Map<String, Object> tokenMap = jwtToken.createToken(userInfo);
|
||||
return R.ok(tokenMap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
import com.starry.admin.modules.system.service.SysDeptService;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.result.R;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ucenter/dept")
|
||||
public class SysDeptController {
|
||||
|
||||
@Resource
|
||||
private SysDeptService deptService;
|
||||
|
||||
@ApiOperation("获取部门列表")
|
||||
@PreAuthorize("@customSs.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysDeptEntity dept) {
|
||||
List<SysDeptEntity> depts = deptService.selectDeptList(dept);
|
||||
return R.ok(depts);
|
||||
}
|
||||
|
||||
@ApiOperation("添加部门")
|
||||
@PreAuthorize("@customSs.hasPermi('system:dept:create')")
|
||||
@PostMapping("/create")
|
||||
public R creat(@RequestBody SysDeptEntity dept) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return R.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
boolean success = deptService.create(dept);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改部门")
|
||||
@PreAuthorize("@customSs.hasPermi('system:dept:edit')")
|
||||
@PostMapping("/update/{id}")
|
||||
public R update(@PathVariable Long id, @RequestBody SysDeptEntity dept) {
|
||||
dept.setDeptId(id);
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return R.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
} else if (dept.getParentId().equals(id)) {
|
||||
return R.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
}
|
||||
boolean success = deptService.update(dept);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除部门")
|
||||
@PreAuthorize("@customSs.hasPermi('system:dept:delete')")
|
||||
@PostMapping(value = "/delete/{id}")
|
||||
public R delete(@PathVariable("id") Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return R.error("存在下级部门,不允许删除");
|
||||
}
|
||||
boolean success = deptService.delete(Collections.singletonList(deptId));
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("获取部门下拉树列表")
|
||||
@GetMapping("/treeselect")
|
||||
public R treeselect(SysDeptEntity dept) {
|
||||
List<SysDeptEntity> list = deptService.selectDeptList(dept);
|
||||
List<TreeSelect> treeList = deptService.buildDeptTreeSelect(list);
|
||||
return R.ok(treeList);
|
||||
}
|
||||
|
||||
@ApiOperation("根据id获取详细信息")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public R getInfo(@PathVariable Long deptId) {
|
||||
return R.ok(deptService.getById(deptId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysDictEntity;
|
||||
import com.starry.admin.modules.system.service.ISysDictService;
|
||||
import com.starry.admin.modules.system.vo.SysDictVo;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 字典表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict")
|
||||
public class SysDictController {
|
||||
@Resource
|
||||
private ISysDictService xlDictService;
|
||||
|
||||
/**
|
||||
* 查询字典表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysDictVo dictVo) {
|
||||
Page<SysDictEntity> list = xlDictService.selectXlDictList(dictVo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public R getInfo(@PathVariable("dictId") Long dictId) {
|
||||
return R.ok(xlDictService.selectXlDictByDictId(dictId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:create')")
|
||||
@Log(title = "字典表", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody SysDictEntity sysDictEntity) {
|
||||
boolean success = xlDictService.create(sysDictEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{dictId}")
|
||||
public R update(@PathVariable Long dictId, @RequestBody SysDictEntity sysDictEntity) {
|
||||
sysDictEntity.setDictId(dictId);
|
||||
boolean success = xlDictService.update(sysDictEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public R remove(@PathVariable Long[] dictIds) {
|
||||
return R.ok(xlDictService.deleteXlDictByDictIds(dictIds));
|
||||
}
|
||||
|
||||
@GetMapping("/optionselect")
|
||||
public R optionselect() {
|
||||
List<SysDictEntity> list = xlDictService.selectDictTypeAll();
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新字典缓存
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public R refreshCache() {
|
||||
xlDictService.resetDictCache();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.starry.admin.modules.system.entity.SysDictDataEntity;
|
||||
import com.starry.admin.modules.system.service.ISysDictDataService;
|
||||
import com.starry.admin.modules.system.vo.SysDictDataVo;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController {
|
||||
@Resource
|
||||
private ISysDictDataService xlDictDataService;
|
||||
|
||||
/**
|
||||
* 查询字典数据表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysDictDataVo sysDictDataEntity) {
|
||||
return R.ok(xlDictDataService.selectXlDictDataList(sysDictDataEntity));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典数据表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictDataId}")
|
||||
public R getInfo(@PathVariable("dictDataId") Long dictDataId) {
|
||||
return R.ok(xlDictDataService.selectXlDictDataByDictDataId(dictDataId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典数据表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:create')")
|
||||
@Log(title = "字典数据表", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody SysDictDataEntity sysDictDataEntity) {
|
||||
boolean success = xlDictDataService.create(sysDictDataEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{dictDataId}")
|
||||
public R update(@PathVariable Long dictDataId, @RequestBody SysDictDataEntity sysDictDataEntity) {
|
||||
sysDictDataEntity.setDictDataId(dictDataId);
|
||||
boolean success = xlDictDataService.update(sysDictDataEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典数据表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictDataIds}")
|
||||
public R remove(@PathVariable Long[] dictDataIds) {
|
||||
return R.ok(xlDictDataService.deleteXlDictDataByDictDataIds(dictDataIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R getDictDataByType(@PathVariable String dictType) {
|
||||
List<SysDictDataEntity> list = xlDictDataService.selectDictDataByType(dictType);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogEntity;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogVo;
|
||||
import com.starry.admin.modules.system.service.ISysLoginLogService;
|
||||
import com.starry.admin.utils.ExcelUtils;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
* 系统访问日志表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/loginlog")
|
||||
public class SysLoginLogController {
|
||||
@Resource
|
||||
private ISysLoginLogService xlLoginLogService;
|
||||
|
||||
/**
|
||||
* 查询系统访问日志表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:loginlog:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysLoginLogVo vo) {
|
||||
IPage<SysLoginLogEntity> list = xlLoginLogService.selectXlLoginLogList(vo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出系统访问日志表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:loginlog:export')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysLoginLogVo vo) {
|
||||
IPage<SysLoginLogEntity> list = xlLoginLogService.selectXlLoginLogList(vo);
|
||||
ExcelUtils.exportEasyExcel(response, SysLoginLogEntity.class, list.getRecords(), "系统访问日志表数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统访问日志表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:log:query')")
|
||||
@GetMapping(value = "/{loginId}")
|
||||
public R getInfo(@PathVariable("loginId") Long loginId) {
|
||||
return R.ok(xlLoginLogService.selectXlLoginLogByLoginId(loginId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统访问日志表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:loginlog:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{loginIds}")
|
||||
public R remove(@PathVariable Long[] loginIds) {
|
||||
return R.ok(xlLoginLogService.deleteXlLoginLogByLoginIds(loginIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('monitor:logininfor:clean')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public R clean() {
|
||||
xlLoginLogService.cleanLoginlog();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysMenuEntity;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
import com.starry.admin.modules.system.vo.SimpleMenu;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.result.R;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-03
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ucenter/menu")
|
||||
public class SysMenuController {
|
||||
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
|
||||
|
||||
@ApiOperation("获取菜单列表")
|
||||
@PreAuthorize("@customSs.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysMenuEntity menu) {
|
||||
// 获取登录人的userId;
|
||||
String userId = SecurityUtils.getUserId();
|
||||
List<SysMenuEntity> menus = menuService.selectMenuList(menu, userId);
|
||||
return R.ok(menus);
|
||||
}
|
||||
|
||||
@ApiOperation("分页获取菜单列表")
|
||||
@GetMapping("/list-page")
|
||||
public R listPage(@RequestParam(value = "menu", required = false) SysMenuEntity menu,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
Page<SysMenuEntity> pageMenu = menuService.listPage(menu, SecurityUtils.getUserId(), pageSize, pageNum);
|
||||
return R.ok(pageMenu);
|
||||
}
|
||||
|
||||
@ApiOperation("添加菜单")
|
||||
@PreAuthorize("@customSs.hasPermi('system:menu:create')")
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody SysMenuEntity menu) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return R.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StrUtil.startWithAny(menu.getPath(), "http://", "https://")) {
|
||||
return R.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
boolean success = menuService.create(menu);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改菜单")
|
||||
@PreAuthorize("@customSs.hasPermi('system:menu:edit')")
|
||||
@PostMapping("/update/{id}")
|
||||
public R update(@PathVariable Long id, @RequestBody SysMenuEntity menu) {
|
||||
menu.setMenuId(id);
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return R.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StrUtil.startWithAny(menu.getPath(), "http://", "https://")) {
|
||||
return R.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||
return R.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||
}
|
||||
boolean success = menuService.updateById(menu);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
@PreAuthorize("@customSs.hasPermi('system:menu:delete')")
|
||||
@PostMapping(value = "/delete/{id}")
|
||||
public R delete(@PathVariable("id") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return R.error("存在子菜单,不允许删除");
|
||||
}
|
||||
boolean success = menuService.removeByIds(Collections.singletonList(menuId));
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("获取菜单下拉树列表")
|
||||
@GetMapping("/treeselect")
|
||||
public R treeselect(SysMenuEntity menu) {
|
||||
List<SysMenuEntity> menus = menuService.selectMenuList(menu, SecurityUtils.getUserId());
|
||||
List<TreeSelect> tree = menuService.buildMenuTreeSelect(menus);
|
||||
return R.ok(tree);
|
||||
}
|
||||
|
||||
@PreAuthorize("@customSs.hasPermi('system:menu:query')")
|
||||
@ApiOperation("根据菜单编号获取详细信息")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public R getInfo(@PathVariable Long menuId) {
|
||||
return R.ok(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
@ApiOperation("获取对应角色菜单列表树")
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public R roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
List<SysMenuEntity> menus = menuService.selectMenuList(SecurityUtils.getUserId());
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
resultMap.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
return R.ok(resultMap);
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获取菜单精简信息列表", notes = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" +
|
||||
"在多租户的场景下,会只返回租户所在套餐有的菜单")
|
||||
public R getSimpleMenus() {
|
||||
// 获得菜单列表,只要开启状态的
|
||||
List<SimpleMenu> menus = menuService.selectSimpleMenuList();
|
||||
return R.ok(menus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.system.entity.SysOperationLogEntity;
|
||||
import com.starry.admin.modules.system.service.ISysOperationLogService;
|
||||
import com.starry.admin.modules.system.vo.SysOperationLogVo;
|
||||
import com.starry.admin.utils.ExcelUtils;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志表Controller
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/operlog")
|
||||
public class SysOperationLogController {
|
||||
|
||||
@Resource
|
||||
private ISysOperationLogService xlOperLogService;
|
||||
|
||||
/**
|
||||
* 查询操作日志表列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(SysOperationLogVo sysOperationLogEntity) {
|
||||
return R.ok(xlOperLogService.selectXlOperLogList(sysOperationLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取操作日志表详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:query')")
|
||||
@GetMapping(value = "/{operId}")
|
||||
public R getInfo(@PathVariable("operId") Long operId) {
|
||||
return R.ok(xlOperLogService.selectXlOperLogByOperId(operId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增操作日志表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:create')")
|
||||
@Log(title = "操作日志表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R create(@RequestBody SysOperationLogEntity sysOperationLogEntity) {
|
||||
boolean success = xlOperLogService.create(sysOperationLogEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改操作日志表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:edit')")
|
||||
@Log(title = "操作日志表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{operId}")
|
||||
public R update(@PathVariable Long operId, @RequestBody SysOperationLogEntity sysOperationLogEntity) {
|
||||
sysOperationLogEntity.setOperId(operId);
|
||||
boolean success = xlOperLogService.updateXlOperLog(sysOperationLogEntity);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除操作日志表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:remove')")
|
||||
@Log(title = "操作日志表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{operIds}")
|
||||
public R remove(@PathVariable Long[] operIds) {
|
||||
return R.ok(xlOperLogService.deleteXlOperLogByOperIds(operIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出操作日志表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:operlog:export')")
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysOperationLogVo sysOperationLogEntity) {
|
||||
ExcelUtils.exportEasyExcel(response, SysOperationLogEntity.class, xlOperLogService.selectXlOperLogList(sysOperationLogEntity).getRecords(), "系统操作日志表数据");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
import com.starry.admin.modules.system.service.SysDeptService;
|
||||
import com.starry.admin.modules.system.service.SysRoleService;
|
||||
import com.starry.admin.modules.system.service.SysUserService;
|
||||
import com.starry.admin.modules.system.vo.RoleUserResultVo;
|
||||
import com.starry.admin.modules.system.vo.SysRoleAddVo;
|
||||
import com.starry.admin.modules.system.vo.SysUserQueryVo;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-01
|
||||
*/
|
||||
@Api(tags = "角色管理")
|
||||
@RestController
|
||||
@RequestMapping("/ucenter/role")
|
||||
public class SysRoleController {
|
||||
|
||||
@Resource
|
||||
private SysRoleService roleService;
|
||||
@Resource
|
||||
private SysDeptService deptService;
|
||||
@Resource
|
||||
private SysUserService userService;
|
||||
|
||||
@ApiOperation("添加角色")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:create')")
|
||||
@PostMapping("/create")
|
||||
public R create(@Valid @RequestBody SysRoleAddVo roleAddVo) {
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
BeanUtils.copyProperties(roleAddVo, role);
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||
return R.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||
return R.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
boolean success = roleService.create(role);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:edit')")
|
||||
@PostMapping("/update/{id}")
|
||||
public R update(@PathVariable Long id, @RequestBody SysRoleEntity role) {
|
||||
role.setRoleId(id);
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||
return R.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||
return R.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
boolean success = roleService.updateById(role);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除角色")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:remove')")
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R delete(@PathVariable Long[] roleIds) {
|
||||
boolean success = roleService.delete(roleIds);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有角色")
|
||||
@GetMapping("/list-all")
|
||||
public R listAll() {
|
||||
List<SysRoleEntity> list = roleService.list();
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@ApiOperation("根据角色名称分页获取角色列表")
|
||||
@GetMapping("/list-page")
|
||||
public R listPage(@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
Page<SysRoleEntity> rolePage = roleService.list(keyword, pageSize, pageNum);
|
||||
return R.ok(rolePage);
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色状态")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:edit')")
|
||||
@PostMapping("/update-status/{id}")
|
||||
public R updateStatus(@PathVariable Long id, @RequestParam(value = "status") Integer status) {
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
role.setRoleId(id);
|
||||
role.setStatus(status);
|
||||
boolean success = roleService.updateById(role);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("分配菜单权限")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:auth')")
|
||||
@PostMapping("/auth-role-menu")
|
||||
public R authRoleMenu(@RequestBody SysRoleEntity role) {
|
||||
boolean success = roleService.authRoleMenu(role);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("分配失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public R getInfo(@PathVariable Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return R.ok(roleService.getById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色部门树列表
|
||||
*/
|
||||
@ApiOperation("获取对应角色部门树列表")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/deptTree/{roleId}")
|
||||
public R deptTree(@PathVariable("roleId") Long roleId) {
|
||||
Map<String, Object> resultMap = new HashMap<>(8);
|
||||
resultMap.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
resultMap.put("depts", deptService.selectDeptTreeList(new SysDeptEntity()));
|
||||
return R.ok(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存数据权限
|
||||
*/
|
||||
@ApiOperation("修改保存数据权限")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:query')")
|
||||
@Log(title = "角色管理-保存数据权限", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/dataScope")
|
||||
public R dataScope(@RequestBody SysRoleEntity role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
return R.ok(roleService.authDataScope(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@ApiOperation("查询已分配用户角色列表")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public R allocatedList(SysUserQueryVo user) {
|
||||
IPage<RoleUserResultVo> list = userService.selectAllocatedList(user);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@ApiOperation("查询未分配用户角色列表")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public R unallocatedList(SysUserQueryVo user) {
|
||||
return R.ok(userService.selectUnallocatedList(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
@ApiOperation("取消授权用户")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public R cancelAuthUser(@RequestBody SysUserRoleEntity userRole) {
|
||||
return R.ok(roleService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*/
|
||||
@ApiOperation("批量取消授权用户")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public R cancelAuthUserAll(Long roleId, String[] userIds) {
|
||||
return R.ok(roleService.deleteAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*/
|
||||
@ApiOperation("批量选择用户授权")
|
||||
@PreAuthorize("@customSs.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public R selectAuthUserAll(Long roleId, String[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return R.ok(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.starry.admin.modules.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.admin.common.component.JwtToken;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.service.SysRoleService;
|
||||
import com.starry.admin.modules.system.service.SysUserService;
|
||||
import com.starry.admin.modules.system.vo.UserQueryVo;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.file.CosClientUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 后台用户表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2021-09-03
|
||||
*/
|
||||
@Api(tags = "用户管理")
|
||||
@RestController
|
||||
@RequestMapping("/ucenter/user")
|
||||
public class SysUserController {
|
||||
|
||||
@Resource
|
||||
private SysUserService userService;
|
||||
@Resource
|
||||
private SysRoleService roleService;
|
||||
@Resource
|
||||
private JwtToken tokenService;
|
||||
|
||||
@ApiOperation(value = "注册用户")
|
||||
@PostMapping(value = "register")
|
||||
public R register(@RequestBody SysUserEntity user) {
|
||||
SysUserEntity sysUserEntity = userService.register(user);
|
||||
if (sysUserEntity == null) {
|
||||
return R.error("注册失败,用户名已存在");
|
||||
}
|
||||
return R.ok(sysUserEntity);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页用户列表")
|
||||
@GetMapping(value = "/list-page")
|
||||
public R listPage(UserQueryVo queryVo) {
|
||||
IPage<SysUserEntity> page = userService.listMemberPage(queryVo);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加用户")
|
||||
@PostMapping(value = "add")
|
||||
public R add(@RequestBody SysUserEntity user) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserCode()))) {
|
||||
return R.error("新增用户'" + user.getUserCode() + "'失败,登录账号已存在");
|
||||
}
|
||||
boolean success = userService.create(user);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户")
|
||||
@PostMapping(value = "/update/{id}")
|
||||
public R update(@PathVariable("id") String id, @RequestBody SysUserEntity user) {
|
||||
user.setUserId(id);
|
||||
boolean flag = userService.update(user);
|
||||
if (flag) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户")
|
||||
@PostMapping(value = "/delete/{id}")
|
||||
public R delete(@PathVariable("id") String id) {
|
||||
boolean flag = userService.delete(Collections.singletonList(id));
|
||||
if (flag) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登出功能")
|
||||
@PostMapping(value = "logout")
|
||||
public R logout() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据用户id获取详细信息")
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public R getInfo(@PathVariable(value = "userId", required = false) String userId) {
|
||||
Map<String, Object> map = new HashMap<>(8);
|
||||
List<SysRoleEntity> roles = roleService.selectRoleList(new SysRoleEntity());
|
||||
map.put("roles", SysUserEntity.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
if (userId != null) {
|
||||
SysUserEntity user = userService.selectUserById(userId);
|
||||
map.put("roleIds", user.getRoles().stream().map(SysRoleEntity::getRoleId).collect(Collectors.toList()));
|
||||
map.put("user", user);
|
||||
}
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取个人信息")
|
||||
@GetMapping(value = "/profile")
|
||||
public R getProfile() {
|
||||
Map<String, Object> map = new HashMap<>(8);
|
||||
SysUserEntity loginUser = userService.selectUserById(SecurityUtils.getUserId());
|
||||
map.put("user", loginUser);
|
||||
map.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUserId()));
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户头像上传")
|
||||
@Log(title = "用户头像上传", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/profile/avatar")
|
||||
public R uploadAvatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
|
||||
if (!file.isEmpty()) {
|
||||
String avatar = CosClientUtils.upload(file, "avatar");
|
||||
if (userService.updateUserAvatar(SecurityUtils.getUserId(), avatar)) {
|
||||
// 更新缓存用户头像
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
loginUser.getUser().setAvatar(avatar);
|
||||
tokenService.refreshToken(loginUser);
|
||||
return R.ok(avatar);
|
||||
}
|
||||
}
|
||||
return R.error("上传头像异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("sys_dept")
|
||||
@ApiModel(value = "XlDept对象", description = "部门表")
|
||||
public class SysDeptEntity extends BaseEntity<SysDeptEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "dept_id", type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty("父部门id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("祖级列表")
|
||||
private String ancestors;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty("显示顺序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
private String leader;
|
||||
|
||||
@ApiModelProperty("联系电话")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("部门状态(0正常 1停用)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("部门级别")
|
||||
private Integer deptLevel;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 子部门
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysDeptEntity> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 字典数据表对象 sys_dict_data
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_dict_data")
|
||||
public class SysDictDataEntity extends BaseEntity<SysDictDataEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "dict_data_id", type = IdType.AUTO)
|
||||
private Long dictDataId;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long sort;
|
||||
|
||||
/**
|
||||
* 是否默认(Y是 N否)
|
||||
*/
|
||||
private String isDefault;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 字典表对象 sys_dict
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-08-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_dict")
|
||||
public class SysDictEntity extends BaseEntity<SysDictEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "dict_id", type = IdType.AUTO)
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.admin.modules.system.vo.StatusConverter;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 系统访问日志表对象 sys_login_log
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
@Data
|
||||
@TableName("sys_login_log")
|
||||
@ApiModel(value = "XlLoginLog对象", description = "登录日志表")
|
||||
public class SysLoginLogEntity extends BaseEntity<SysLoginLogEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "login_id", type = IdType.AUTO)
|
||||
private Long loginId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@ExcelProperty(value = "用户账号")
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
@ExcelProperty(value = "登录IP地址")
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
@ExcelProperty(value = "登录地点")
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
@ExcelProperty(value = "浏览器类型")
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
@ExcelProperty(value = "操作系统")
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 登录状态(0成功 1失败)
|
||||
*/
|
||||
@ExcelProperty(value = "登录状态", converter = StatusConverter.class)
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 访问时间
|
||||
*/
|
||||
private Date loginTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.starry.admin.modules.system.vo.StatusConverter;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 系统访问日志表对象 sys_login_log
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysLoginLogVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "login_id", type = IdType.AUTO)
|
||||
private Long loginId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@ExcelProperty(value = "用户账号")
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
@ExcelProperty(value = "登录IP地址")
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
@ExcelProperty(value = "登录地点")
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
@ExcelProperty(value = "浏览器类型")
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
@ExcelProperty(value = "操作系统")
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 登录状态(0成功 1失败)
|
||||
*/
|
||||
@ExcelProperty(value = "登录状态", converter = StatusConverter.class)
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 访问时间
|
||||
*/
|
||||
private Date loginTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-03
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_menu")
|
||||
@ApiModel(value = "XlMenu对象", description = "菜单表")
|
||||
public class SysMenuEntity extends BaseEntity<SysMenuEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("菜单ID")
|
||||
@TableId(value = "menu_id", type = IdType.AUTO)
|
||||
private Long menuId;
|
||||
|
||||
@ApiModelProperty("菜单名")
|
||||
private String menuName;
|
||||
|
||||
@ApiModelProperty("菜单编码")
|
||||
private String menuCode;
|
||||
|
||||
@ApiModelProperty("权限字符串")
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty("图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty("菜单级别")
|
||||
private Long menuLevel;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("父ID")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("菜单类型;0:目录,1:菜单,2:按钮")
|
||||
private String menuType;
|
||||
|
||||
@ApiModelProperty("菜单状态;0正常 1停用")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("路由地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty("组件路径")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty("路由参数")
|
||||
private String routerQuery;
|
||||
|
||||
@ApiModelProperty("是否为外链(0否 1是)")
|
||||
private Integer isFrame;
|
||||
|
||||
@ApiModelProperty("菜单状态;0:隐藏 1:显示")
|
||||
private Integer visible;
|
||||
|
||||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysMenuEntity> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志表对象 sys_operation_log
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
@Data
|
||||
@TableName("sys_operation_log")
|
||||
@ApiModel(value = "SysOperationLog对象", description = "操作日志表")
|
||||
public class SysOperationLogEntity extends BaseEntity<SysOperationLogEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "oper_id", type = IdType.AUTO)
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 模块标题
|
||||
*/
|
||||
@ExcelProperty(value = "系统模块")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 业务类型(0其它 1新增 2修改 3删除)
|
||||
*/
|
||||
private Integer businessType;
|
||||
|
||||
/**
|
||||
* 业务类型数组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Integer[] businessTypes;
|
||||
|
||||
/**
|
||||
* 方法名称
|
||||
*/
|
||||
@ExcelProperty(value = "方法名称")
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String requestMethod;
|
||||
|
||||
/**
|
||||
* 操作类别(0其它 1后台用户 2手机端用户)
|
||||
*/
|
||||
private Integer operatorType;
|
||||
|
||||
/**
|
||||
* 操作人员
|
||||
*/
|
||||
private String operName;
|
||||
|
||||
/**
|
||||
* 请求URL
|
||||
*/
|
||||
private String operUrl;
|
||||
|
||||
/**
|
||||
* 主机地址
|
||||
*/
|
||||
private String operIp;
|
||||
|
||||
/**
|
||||
* 操作地点
|
||||
*/
|
||||
private String operLocation;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String operParam;
|
||||
|
||||
/**
|
||||
* 返回参数
|
||||
*/
|
||||
private String jsonResult;
|
||||
|
||||
/**
|
||||
* 操作状态(0正常 1异常)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Date operTime;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 角色部门表对象 sys_dict_data
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_role_dept")
|
||||
public class SysRoleDeptEntity extends BaseEntity<SysRoleDeptEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "role_dept_id", type = IdType.AUTO)
|
||||
private Long roleDeptId;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty("菜单ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-01
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("sys_role")
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "XlRole对象", description = "角色表")
|
||||
public class SysRoleEntity extends BaseEntity<SysRoleEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
@TableId(value = "role_id", type = IdType.AUTO)
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("角色描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty("状态;0正常 1停用")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) ")
|
||||
private String dataScope;
|
||||
|
||||
@ApiModelProperty("菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)")
|
||||
private boolean menuCheckStrictly;
|
||||
|
||||
@ApiModelProperty("部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )")
|
||||
private boolean deptCheckStrictly;
|
||||
|
||||
@ApiModelProperty("角色权限")
|
||||
private String roleKey;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 菜单组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] menuIds;
|
||||
|
||||
/**
|
||||
* 部门组(数据权限)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] deptIds;
|
||||
|
||||
/**
|
||||
* 角色菜单权限
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Set<String> permissions;
|
||||
|
||||
public SysRoleEntity(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long roleId) {
|
||||
return roleId != null && 1L == roleId;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.roleId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色和菜单关联表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_role_menu")
|
||||
@ApiModel(value = "SysRoleMenu对象", description = "角色和菜单关联表")
|
||||
public class SysRoleMenuEntity extends BaseEntity<SysRoleMenuEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(value = "role_menu_id", type = IdType.AUTO)
|
||||
private Long roleMenuId;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty("菜单ID")
|
||||
private Long menuId;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "SysUser对象", description = "用户表")
|
||||
@TableName("sys_user")
|
||||
public class SysUserEntity extends BaseEntity<SysUserEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@TableId(value = "user_id", type = IdType.AUTO)
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型;1:admin;2:会员")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userCode;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String passWord;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String userNickname;
|
||||
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String userEmail;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "中国手机不带国家代码,国际手机号格式为:国家代码-手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "性别 0:未知;1:男;2:女")
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "出生年月")
|
||||
private Date birthday;
|
||||
|
||||
@ApiModelProperty(value = "用户状态;0正常 1停用")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "最后登录时间")
|
||||
private Date lastLoginTime;
|
||||
|
||||
@ApiModelProperty(value = "最后登录ip")
|
||||
private String lastLoginIp;
|
||||
|
||||
@ApiModelProperty(value = "所属部门id")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysRoleEntity> roles;
|
||||
|
||||
/**
|
||||
* 角色组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] roleIds;
|
||||
|
||||
/**
|
||||
* 部门对象
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private SysDeptEntity dept;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long roleId;
|
||||
|
||||
public static boolean isAdmin(String userId) {
|
||||
return "6dcb2da45fef4768a6511f9c14e18072".equals(userId);
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.starry.admin.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-08
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_user_role")
|
||||
@ApiModel(value = "SysUserRole对象", description = "用户角色关联表")
|
||||
public class SysUserRoleEntity extends BaseEntity<SysUserRoleEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "user_role_id", type = IdType.AUTO)
|
||||
private Long userRoleId;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-12
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDeptMapper extends BaseMapper<SysDeptEntity> {
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
List<SysDeptEntity> selectDeptList(@Param(value = "dept") SysDeptEntity dept);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDeptEntity> selectChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 删除部门信息-根据租户ID
|
||||
*
|
||||
* @param ids 租户id
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteDeptByTenantId(String[] ids);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param deptCheckStrictly 部门树选择项是否关联显示
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysDictDataEntity;
|
||||
import com.starry.admin.modules.system.vo.SysDictDataVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictDataEntity> {
|
||||
/**
|
||||
* 查询字典数据表
|
||||
*
|
||||
* @param dictDataId 字典数据表主键
|
||||
* @return 字典数据表
|
||||
*/
|
||||
SysDictDataEntity selectXlDictDataByDictDataId(Long dictDataId);
|
||||
|
||||
/**
|
||||
* 查询字典数据表列表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 字典数据表集合
|
||||
*/
|
||||
IPage<SysDictDataEntity> selectXlDictDataList(Page<SysDictDataEntity> page, @Param("vo") SysDictDataVo sysDictDataEntity);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictDataEntity> selectDictDataByType(String dictType);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysDictEntity;
|
||||
import com.starry.admin.modules.system.vo.SysDictVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 字典表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictMapper extends BaseMapper<SysDictEntity> {
|
||||
/**
|
||||
* 查询字典表
|
||||
*
|
||||
* @param dictId 字典表主键
|
||||
* @return 字典表
|
||||
*/
|
||||
SysDictEntity selectXlDictByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 查询字典表列表
|
||||
*
|
||||
* @param sysDictEntity 字典表
|
||||
* @return 字典表集合
|
||||
*/
|
||||
Page<SysDictEntity> selectXlDictList(IPage<SysDictEntity> page, @Param(value = "sysDictVo") SysDictVo sysDictEntity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogEntity;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 系统访问日志表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLoginLogMapper extends BaseMapper<SysLoginLogEntity> {
|
||||
/**
|
||||
* 查询系统访问日志表
|
||||
*
|
||||
* @param loginId 系统访问日志表主键
|
||||
* @return 系统访问日志表
|
||||
*/
|
||||
SysLoginLogEntity selectXlLoginLogByLoginId(Long loginId);
|
||||
|
||||
/**
|
||||
* 查询系统访问日志表列表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 系统访问日志表集合
|
||||
*/
|
||||
IPage<SysLoginLogEntity> selectXlLoginLogList(Page<SysLoginLogEntity> page, @Param("vo") SysLoginLogVo sysLoginLogEntity);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
int cleanLoginlog();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysMenuEntity;
|
||||
import com.starry.admin.modules.system.vo.SimpleMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenuEntity> {
|
||||
|
||||
List<SysMenuEntity> selectMenuListByUserId(@Param(value = "menu") SysMenuEntity menu, @Param(value = "userId") String userId, Page page);
|
||||
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuList(SysMenuEntity menu);
|
||||
|
||||
List<SysMenuEntity> selectMenuListByUserId(@Param(value = "menu") SysMenuEntity menu, @Param(value = "userId") String userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
List<String> selectMenuPermsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询菜单
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuTreeAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuTreeByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询所有开启状态菜单精简信息
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SimpleMenu> selectSimpleMenuList();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysOperationLogEntity;
|
||||
import com.starry.admin.modules.system.vo.SysOperationLogVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 操作日志表Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysOperationLogMapper extends BaseMapper<SysOperationLogEntity> {
|
||||
/**
|
||||
* 查询操作日志表
|
||||
*
|
||||
* @param operId 操作日志表主键
|
||||
* @return 操作日志表
|
||||
*/
|
||||
SysOperationLogEntity selectXlOperLogByOperId(Long operId);
|
||||
|
||||
/**
|
||||
* 查询操作日志表列表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 操作日志表集合
|
||||
*/
|
||||
IPage<SysOperationLogEntity> selectXlOperLogList(Page<SysOperationLogEntity> page, @Param("vo") SysOperationLogVo sysOperationLogEntity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.system.entity.SysRoleDeptEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色和部门关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-06
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleDeptMapper extends BaseMapper<SysRoleDeptEntity> {
|
||||
|
||||
/**
|
||||
* 通过租户ID删除角色和部门关联
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteRoleDeptByTenantId(Long tenantId);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色和部门关联
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleDeptByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量新增角色部门信息
|
||||
*
|
||||
* @param roleDeptList 角色部门列表
|
||||
* @return 结果
|
||||
*/
|
||||
int batchRoleDept(List<SysRoleDeptEntity> roleDeptList);
|
||||
|
||||
/**
|
||||
* 批量删除角色部门关联信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleDept(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMapper extends BaseMapper<SysRoleEntity> {
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
SysRoleEntity selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param roleName 角色名称
|
||||
* @return 角色信息
|
||||
*/
|
||||
SysRoleEntity checkRoleNameUnique(String roleName);
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param roleKey 角色权限
|
||||
* @return 角色信息
|
||||
*/
|
||||
SysRoleEntity checkRoleKeyUnique(String roleKey);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<SysRoleEntity> selectRolePermissionByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
List<SysRoleEntity> selectRoleList(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 根据租户ID查询默认管理员角色
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return 角色
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
List<SysRoleEntity> queryAdminRole(String tenantId);
|
||||
|
||||
/**
|
||||
* 批量删除角色信息-根据租户
|
||||
*
|
||||
* @param ids 需要删除的租户id
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteRoleByTenantId(String[] ids);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int countUserRoleByRoleId(Long roleId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.system.entity.SysRoleMenuEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色和菜单关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-06
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenuEntity> {
|
||||
|
||||
/**
|
||||
* 通过租户ID删除角色和菜单关联
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteRoleMenuByTenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* 通过租户ID删除角色和菜单关联
|
||||
*
|
||||
* @param ids 租户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteRoleMenuByTenantIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单关联信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleMenu(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.vo.RoleUserResultVo;
|
||||
import com.starry.admin.modules.system.vo.SysUserQueryVo;
|
||||
import com.starry.admin.modules.system.vo.UserQueryVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 后台用户表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2021-09-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUserEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserEntity selectUserById(String userId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param queryVo 条件信息
|
||||
* @param page 分页信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
IPage<SysUserEntity> selectUserList(IPage<SysUserEntity> page, @Param("user") UserQueryVo queryVo);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
SysUserEntity selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 批量删除用户信息-根据租户
|
||||
*
|
||||
* @param ids 需要删除的租户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteUserByTenantId(String[] ids);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
IPage<RoleUserResultVo> selectAllocatedList(Page<RoleUserResultVo> page, @Param("query") SysUserQueryVo user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
IPage<RoleUserResultVo> selectUnallocatedList(Page<RoleUserResultVo> page, @Param("query") SysUserQueryVo user);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.starry.admin.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-08
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRoleEntity> {
|
||||
|
||||
/**
|
||||
* 批量删除用户和角色关联-根据租户
|
||||
*
|
||||
* @param ids 需要删除的用户租户id
|
||||
* @return 结果
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
int deleteUserRoleByTenantId(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除用户和角色关联信息
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteUserRoleInfo(SysUserRoleEntity userRole);
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") String[] userIds);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysDictDataEntity;
|
||||
import com.starry.admin.modules.system.vo.SysDictDataVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据表Service接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysDictDataService extends IService<SysDictDataEntity> {
|
||||
/**
|
||||
* 查询字典数据表
|
||||
*
|
||||
* @param dictDataId 字典数据表主键
|
||||
* @return 字典数据表
|
||||
*/
|
||||
SysDictDataEntity selectXlDictDataByDictDataId(Long dictDataId);
|
||||
|
||||
/**
|
||||
* 查询字典数据表列表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 字典数据表集合
|
||||
*/
|
||||
IPage<SysDictDataEntity> selectXlDictDataList(SysDictDataVo sysDictDataEntity);
|
||||
|
||||
/**
|
||||
* 新增字典数据表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysDictDataEntity sysDictDataEntity);
|
||||
|
||||
/**
|
||||
* 修改字典数据表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(SysDictDataEntity sysDictDataEntity);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据表
|
||||
*
|
||||
* @param dictDataIds 需要删除的字典数据表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlDictDataByDictDataIds(Long[] dictDataIds);
|
||||
|
||||
/**
|
||||
* 删除字典数据表信息
|
||||
*
|
||||
* @param dictDataId 字典数据表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlDictDataByDictDataId(Long dictDataId);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictDataEntity> selectDictDataByType(String dictType);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysDictEntity;
|
||||
import com.starry.admin.modules.system.vo.SysDictVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典表Service接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-08-09
|
||||
*/
|
||||
public interface ISysDictService extends IService<SysDictEntity> {
|
||||
/**
|
||||
* 查询字典表
|
||||
*
|
||||
* @param dictId 字典表主键
|
||||
* @return 字典表
|
||||
*/
|
||||
SysDictEntity selectXlDictByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 查询字典表列表
|
||||
*
|
||||
* @param sysDictVo 字典表
|
||||
* @return 字典表集合
|
||||
*/
|
||||
Page<SysDictEntity> selectXlDictList(SysDictVo sysDictVo);
|
||||
|
||||
/**
|
||||
* 新增字典表
|
||||
*
|
||||
* @param sysDictEntity 字典表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysDictEntity sysDictEntity);
|
||||
|
||||
/**
|
||||
* 修改字典表
|
||||
*
|
||||
* @param sysDictEntity 字典表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(SysDictEntity sysDictEntity);
|
||||
|
||||
/**
|
||||
* 批量删除字典表
|
||||
*
|
||||
* @param dictIds 需要删除的字典表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlDictByDictIds(Long[] dictIds);
|
||||
|
||||
/**
|
||||
* 删除字典表信息
|
||||
*
|
||||
* @param dictId 字典表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlDictByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 根据所有字典类型
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
List<SysDictEntity> selectDictTypeAll();
|
||||
|
||||
/**
|
||||
* 加载字典缓存数据
|
||||
*/
|
||||
void loadingDictCache();
|
||||
|
||||
/**
|
||||
* 清空字典缓存数据
|
||||
*/
|
||||
void clearDictCache();
|
||||
|
||||
/**
|
||||
* 重置字典缓存数据
|
||||
*/
|
||||
void resetDictCache();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogEntity;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogVo;
|
||||
|
||||
/**
|
||||
* 系统访问日志表Service接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysLoginLogService extends IService<SysLoginLogEntity> {
|
||||
/**
|
||||
* 查询系统访问日志表
|
||||
*
|
||||
* @param loginId 系统访问日志表主键
|
||||
* @return 系统访问日志表
|
||||
*/
|
||||
SysLoginLogEntity selectXlLoginLogByLoginId(Long loginId);
|
||||
|
||||
/**
|
||||
* 查询系统访问日志表列表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 系统访问日志表集合
|
||||
*/
|
||||
IPage<SysLoginLogEntity> selectXlLoginLogList(SysLoginLogVo sysLoginLogEntity);
|
||||
|
||||
/**
|
||||
* 新增系统访问日志表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysLoginLogEntity sysLoginLogEntity);
|
||||
|
||||
/**
|
||||
* 修改系统访问日志表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(SysLoginLogEntity sysLoginLogEntity);
|
||||
|
||||
/**
|
||||
* 批量删除系统访问日志表
|
||||
*
|
||||
* @param loginIds 需要删除的系统访问日志表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlLoginLogByLoginIds(Long[] loginIds);
|
||||
|
||||
/**
|
||||
* 删除系统访问日志表信息
|
||||
*
|
||||
* @param loginId 系统访问日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlLoginLogByLoginId(Long loginId);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*/
|
||||
void cleanLoginlog();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysOperationLogEntity;
|
||||
import com.starry.admin.modules.system.vo.SysOperationLogVo;
|
||||
|
||||
/**
|
||||
* 操作日志表Service接口
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysOperationLogService extends IService<SysOperationLogEntity> {
|
||||
/**
|
||||
* 查询操作日志表
|
||||
*
|
||||
* @param operId 操作日志表主键
|
||||
* @return 操作日志表
|
||||
*/
|
||||
SysOperationLogEntity selectXlOperLogByOperId(Long operId);
|
||||
|
||||
/**
|
||||
* 查询操作日志表列表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 操作日志表集合
|
||||
*/
|
||||
IPage<SysOperationLogEntity> selectXlOperLogList(SysOperationLogVo sysOperationLogEntity);
|
||||
|
||||
/**
|
||||
* 新增操作日志表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(SysOperationLogEntity sysOperationLogEntity);
|
||||
|
||||
/**
|
||||
* 修改操作日志表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 结果
|
||||
*/
|
||||
boolean updateXlOperLog(SysOperationLogEntity sysOperationLogEntity);
|
||||
|
||||
/**
|
||||
* 批量删除操作日志表
|
||||
*
|
||||
* @param operIds 需要删除的操作日志表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlOperLogByOperIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 删除操作日志表信息
|
||||
*
|
||||
* @param operId 操作日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteXlOperLogByOperId(Long operId);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
public interface LoginService {
|
||||
|
||||
/**
|
||||
* 登录功能
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return 生成的JWT的token
|
||||
*/
|
||||
String login(String username, String password);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
Set<String> getMenuPermission(SysUserEntity user);
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
Set<String> getRolePermission(SysUserEntity user);
|
||||
|
||||
/**
|
||||
* 登录功能
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return 生成的JWT的token
|
||||
*/
|
||||
LoginUser newLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 新登录功能,增加租户相关
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 获取信息
|
||||
*/
|
||||
LoginUser getLoginUserInfo(String userName);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-12
|
||||
*/
|
||||
public interface SysDeptService extends IService<SysDeptEntity> {
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
List<SysDeptEntity> selectDeptList(SysDeptEntity dept);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
String checkDeptNameUnique(SysDeptEntity dept);
|
||||
|
||||
/**
|
||||
* 添加部门
|
||||
*
|
||||
* @param dept
|
||||
* @return boolean
|
||||
**/
|
||||
boolean create(SysDeptEntity dept);
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*
|
||||
* @param dept
|
||||
* @return boolean
|
||||
**/
|
||||
boolean update(SysDeptEntity dept);
|
||||
|
||||
/**
|
||||
* 批量删除部门
|
||||
*
|
||||
* @param ids
|
||||
* @return boolean
|
||||
**/
|
||||
boolean delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 是否存在部门子节点
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
boolean hasChildByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param depts 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
List<TreeSelect> buildDeptTreeSelect(List<SysDeptEntity> depts);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
List<Long> selectDeptListByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 查询部门树结构信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门树信息集合
|
||||
*/
|
||||
List<TreeSelect> selectDeptTreeList(SysDeptEntity dept);
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysMenuEntity;
|
||||
import com.starry.admin.modules.system.vo.RouterVo;
|
||||
import com.starry.admin.modules.system.vo.SimpleMenu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-03
|
||||
*/
|
||||
public interface SysMenuService extends IService<SysMenuEntity> {
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*
|
||||
* @param menu
|
||||
* @return boolean
|
||||
**/
|
||||
boolean create(SysMenuEntity menu);
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单
|
||||
* @param userId 用户ID
|
||||
* @param pageSize 页大小
|
||||
* @param pageNum 页数
|
||||
* @return 分页菜单列表
|
||||
*/
|
||||
Page<SysMenuEntity> listPage(SysMenuEntity menu, String userId, Integer pageSize, Integer pageNum);
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuList(SysMenuEntity menu, String userId);
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuList(String userId);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
String checkMenuNameUnique(SysMenuEntity menu);
|
||||
|
||||
/**
|
||||
* 是否存在菜单子节点
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
boolean hasChildByMenuId(Long menuId);
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
List<TreeSelect> buildMenuTreeSelect(List<SysMenuEntity> menus);
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
SysMenuEntity selectMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
Set<String> selectMenuPermsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单树信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenuEntity> selectMenuTreeByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @return 路由列表
|
||||
*/
|
||||
List<RouterVo> buildMenus(List<SysMenuEntity> menus);
|
||||
|
||||
/**
|
||||
* 查询所有开启状态菜单精简信息
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SimpleMenu> selectSimpleMenuList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysRoleMenuEntity;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色和菜单关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-06
|
||||
*/
|
||||
public interface SysRoleMenuService extends IService<SysRoleMenuEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-01
|
||||
*/
|
||||
public interface SysRoleService extends IService<SysRoleEntity> {
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
String checkRoleNameUnique(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
String checkRoleKeyUnique(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
*
|
||||
* @param role
|
||||
* @return boolean
|
||||
**/
|
||||
boolean create(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 修改角色
|
||||
*
|
||||
* @param role
|
||||
* @return boolean
|
||||
**/
|
||||
boolean updateRole(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int countUserRoleByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色
|
||||
*
|
||||
* @param roleIds
|
||||
* @return boolean
|
||||
**/
|
||||
boolean delete(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 分页获取角色列表
|
||||
*
|
||||
* @param keyword
|
||||
* @param pageSize
|
||||
* @param pageNum
|
||||
* @return Page
|
||||
**/
|
||||
Page<SysRoleEntity> list(String keyword, Integer pageSize, Integer pageNum);
|
||||
|
||||
/**
|
||||
* 分配菜单权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean authRoleMenu(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
Set<String> selectRolePermissionByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
List<SysRoleEntity> selectRoleList(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 校验角色是否允许操作
|
||||
*
|
||||
* @param role 角色信息
|
||||
*/
|
||||
void checkRoleAllowed(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
void checkRoleDataScope(Long roleId);
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
int authDataScope(SysRoleEntity role);
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteAuthUser(SysUserRoleEntity userRole);
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要取消授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteAuthUsers(Long roleId, String[] userIds);
|
||||
|
||||
/**
|
||||
* 批量选择授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int insertAuthUsers(Long roleId, String[] userIds);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-08
|
||||
*/
|
||||
public interface SysUserRoleService extends IService<SysUserRoleEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.starry.admin.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.vo.RoleUserResultVo;
|
||||
import com.starry.admin.modules.system.vo.SysUserQueryVo;
|
||||
import com.starry.admin.modules.system.vo.UserQueryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 后台用户表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2021-09-03
|
||||
*/
|
||||
public interface SysUserService extends IService<SysUserEntity> {
|
||||
|
||||
/**
|
||||
* 注册功能
|
||||
*
|
||||
* @param user
|
||||
* @return SysUserEntity
|
||||
*/
|
||||
SysUserEntity register(SysUserEntity user);
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param userCode
|
||||
* @return SysUserEntity
|
||||
*/
|
||||
SysUserEntity getUserByCode(String userCode);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserEntity selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 获取列表。分页
|
||||
*
|
||||
* @param queryVo 查询参数
|
||||
* @return page
|
||||
*/
|
||||
IPage<SysUserEntity> listMemberPage(UserQueryVo queryVo);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
String checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
*
|
||||
* @param user
|
||||
* @return boolean
|
||||
**/
|
||||
boolean create(SysUserEntity user);
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*
|
||||
* @param user
|
||||
* @return boolean
|
||||
**/
|
||||
boolean update(SysUserEntity user);
|
||||
|
||||
/**
|
||||
* 批量删除用户
|
||||
*
|
||||
* @param ids
|
||||
* @return boolean
|
||||
**/
|
||||
boolean delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserEntity selectUserById(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户所属角色组
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 结果
|
||||
*/
|
||||
String selectUserRoleGroup(String userId);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
boolean updateUserAvatar(String userId, String avatar);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
IPage<RoleUserResultVo> selectAllocatedList(SysUserQueryVo user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
IPage<RoleUserResultVo> selectUnallocatedList(SysUserQueryVo user);
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.starry.admin.common.component.JwtToken;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.admin.common.security.entity.JwtUser;
|
||||
import com.starry.admin.manager.AsyncManager;
|
||||
import com.starry.admin.manager.factory.AsyncFactory;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.service.LoginService;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
import com.starry.admin.modules.system.service.SysRoleService;
|
||||
import com.starry.admin.modules.system.service.SysUserService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.Constants;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
|
||||
@Resource
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Resource
|
||||
private UserDetailsService userDetailsService;
|
||||
@Resource
|
||||
private JwtToken jwtTokenUtil;
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
@Resource
|
||||
private SysRoleService roleService;
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private ISysTenantService SysTenantService;
|
||||
|
||||
@Override
|
||||
public String login(String username, String password) {
|
||||
String token = null;
|
||||
try {
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
|
||||
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
|
||||
throw new BadCredentialsException("密码不正确");
|
||||
}
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
// 登录成功记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_SUCCESS, "登录成功"));
|
||||
JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
|
||||
token = jwtTokenUtil.createToken(jwtUser);
|
||||
} catch (AuthenticationException e) {
|
||||
log.warn("登录异常:{}", e.getMessage());
|
||||
// 登录失败记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMenuPermission(SysUserEntity user) {
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 超级管理员拥有所有权限
|
||||
if (SecurityUtils.isAdmin(user.getUserId())) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
perms = menuService.selectMenuPermsByUserId(user.getUserId());
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRolePermission(SysUserEntity user) {
|
||||
Set<String> roles = new HashSet<>();
|
||||
// 超级管理员拥有所有权限
|
||||
if (SecurityUtils.isAdmin(user.getUserId())) {
|
||||
roles.add("admin");
|
||||
} else {
|
||||
roles = roleService.selectRolePermissionByUserId(user.getUserId());
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser newLogin(String username, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户名/密码必须填写"));
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"));
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
// 用户名不在指定范围内 错误
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户名不在指定范围"));
|
||||
throw new ServiceException("用户名不在指定范围");
|
||||
}
|
||||
LoginUser userInfo = this.getLoginUserInfo(username);
|
||||
if (userInfo == null) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户名不存在"));
|
||||
throw new ServiceException("用户名不存在");
|
||||
}
|
||||
SysUserEntity user = userInfo.getUser();
|
||||
if (!SecurityUtils.matchesPassword(password, user.getPassWord())) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "密码错误"));
|
||||
throw new ServiceException("密码错误");
|
||||
}
|
||||
// 线程塞入租户ID
|
||||
SecurityUtils.setTenantId(Convert.toStr(user.getTenantId()));
|
||||
if (user.getStatus() == 1) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"));
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用,请联系管理员");
|
||||
}
|
||||
// 先查询是否被停用了租户
|
||||
if (userInfo.getTenantStatus() != null && userInfo.getTenantStatus() == 1) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "当前租户已经被停用,请联系管理员"));
|
||||
throw new ServiceException("当前租户已经被停用,请联系管理员");
|
||||
}
|
||||
if (userInfo.getTenantEndDate() != null && userInfo.getTenantEndDate().compareTo(new Date()) < 0) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "当前租户已超过租赁日期,请联系管理员"));
|
||||
throw new ServiceException("当前租户已超过租赁日期,请联系管理员");
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_SUCCESS, "登录成功"));
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getLoginUserInfo(String userName) {
|
||||
SysUserEntity sysUser = sysUserService.selectUserByUserName(userName);
|
||||
if (StringUtils.isNotNull(sysUser)) {
|
||||
// 角色集合
|
||||
Set<String> roles = this.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
Set<String> permissions = this.getMenuPermission(sysUser);
|
||||
// 查询租户信息
|
||||
SysTenantEntity tenant = SysTenantService.selectSysTenantByTenantId(sysUser.getTenantId());
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setUser(sysUser);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setPermissions(permissions);
|
||||
if (tenant != null) {
|
||||
sysUserVo.setTenantEndDate(tenant.getTenantTime());
|
||||
sysUserVo.setTenantStatus(Integer.valueOf(tenant.getTenantStatus()));
|
||||
}
|
||||
return sysUserVo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysDeptMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMapper;
|
||||
import com.starry.admin.modules.system.service.SysDeptService;
|
||||
import com.starry.common.annotation.DataScope;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-12
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDeptEntity> implements SysDeptService {
|
||||
|
||||
@Resource
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysDeptEntity> selectDeptList(SysDeptEntity dept) {
|
||||
return baseMapper.selectDeptList(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkDeptNameUnique(SysDeptEntity dept) {
|
||||
Long deptId = dept.getDeptId() == null ? -1L : dept.getDeptId();
|
||||
List<SysDeptEntity> infos = list(new LambdaQueryWrapper<SysDeptEntity>()
|
||||
.eq(SysDeptEntity::getDeptName, dept.getDeptName())
|
||||
.eq(SysDeptEntity::getParentId, dept.getParentId()));
|
||||
// 查出有数据 并且不是自己,则不唯一
|
||||
if (CollectionUtil.isNotEmpty(infos) && infos.get(0).getDeptId().longValue() != deptId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(SysDeptEntity dept) {
|
||||
SysDeptEntity info = getById(dept.getParentId());
|
||||
// 若父节点不为正常状态,则不允许新增子节点
|
||||
if (!UserConstants.DEPT_NORMAL.equals(String.valueOf(info.getStatus()))) {
|
||||
throw new RuntimeException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
dept.setDeptLevel(info.getDeptLevel() == null ? 0 : info.getDeptLevel() + 1);
|
||||
return save(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(SysDeptEntity dept) {
|
||||
// 新的上级部门
|
||||
SysDeptEntity newParentDept = getById(dept.getParentId());
|
||||
// 当前部门
|
||||
SysDeptEntity oldDept = getById(dept.getDeptId());
|
||||
if (newParentDept != null && oldDept != null) {
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
return updateById(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(List<Long> ids) {
|
||||
return removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildByDeptId(Long deptId) {
|
||||
List<SysDeptEntity> list = baseMapper.selectList(new LambdaQueryWrapper<SysDeptEntity>().eq(SysDeptEntity::getParentId, deptId));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelect> buildDeptTreeSelect(List<SysDeptEntity> depts) {
|
||||
List<SysDeptEntity> deptList = buildDeptTree(depts);
|
||||
// 转换成树结构的list
|
||||
return deptList.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysDeptEntity> buildDeptTree(List<SysDeptEntity> depts) {
|
||||
List<SysDeptEntity> returnList = new ArrayList<>();
|
||||
// 所有部门id
|
||||
List<Long> tempList = new ArrayList<>();
|
||||
for (SysDeptEntity dept : depts) {
|
||||
tempList.add(dept.getDeptId());
|
||||
}
|
||||
for (SysDeptEntity dept : depts) {
|
||||
// 如若是顶级节点,遍历该父节点下的所有子节点
|
||||
if (!tempList.contains(dept.getParentId())) {
|
||||
recursionFn(depts, dept);
|
||||
returnList.add(dept);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(returnList)) {
|
||||
returnList = depts;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param deptId 被修改的部门ID
|
||||
* @param newAncestors 新的父ID集合
|
||||
* @param oldAncestors 旧的父ID集合
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
||||
List<SysDeptEntity> childrens = baseMapper.selectChildrenDeptById(deptId);
|
||||
if (CollectionUtil.isNotEmpty(childrens)) {
|
||||
for (SysDeptEntity child : childrens) {
|
||||
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||
updateById(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<SysDeptEntity> list, SysDeptEntity t) {
|
||||
List<SysDeptEntity> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (SysDeptEntity tChild : childList) {
|
||||
if (hasChild(list, tChild)) {
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysDeptEntity> getChildList(List<SysDeptEntity> list, SysDeptEntity t) {
|
||||
List<SysDeptEntity> tList = new ArrayList<>();
|
||||
for (SysDeptEntity n : list) {
|
||||
if (n.getParentId() != null && n.getParentId().longValue() == t.getDeptId().longValue()) {
|
||||
tList.add(n);
|
||||
}
|
||||
}
|
||||
return tList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否还有子节点
|
||||
*/
|
||||
private boolean hasChild(List<SysDeptEntity> list, SysDeptEntity t) {
|
||||
return !getChildList(list, t).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectDeptListByRoleId(Long roleId) {
|
||||
SysRoleEntity role = roleMapper.selectRoleById(roleId);
|
||||
return baseMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门树结构信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门树信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> selectDeptTreeList(SysDeptEntity dept) {
|
||||
List<SysDeptEntity> depts = this.selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysDictDataEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysDictDataMapper;
|
||||
import com.starry.admin.modules.system.service.ISysDictDataService;
|
||||
import com.starry.admin.modules.system.vo.SysDictDataVo;
|
||||
import com.starry.admin.utils.DictUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictDataEntity> implements ISysDictDataService {
|
||||
@Resource
|
||||
private SysDictDataMapper sysDictDataMapper;
|
||||
|
||||
/**
|
||||
* 查询字典数据表
|
||||
*
|
||||
* @param dictDataId 字典数据表主键
|
||||
* @return 字典数据表
|
||||
*/
|
||||
@Override
|
||||
public SysDictDataEntity selectXlDictDataByDictDataId(Long dictDataId) {
|
||||
return sysDictDataMapper.selectXlDictDataByDictDataId(dictDataId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据表列表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 字典数据表
|
||||
*/
|
||||
@Override
|
||||
public IPage<SysDictDataEntity> selectXlDictDataList(SysDictDataVo sysDictDataEntity) {
|
||||
return sysDictDataMapper.selectXlDictDataList(new Page<>(sysDictDataEntity.getPageNum(), sysDictDataEntity.getPageSize()), sysDictDataEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典数据表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysDictDataEntity sysDictDataEntity) {
|
||||
return save(sysDictDataEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据表
|
||||
*
|
||||
* @param sysDictDataEntity 字典数据表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(SysDictDataEntity sysDictDataEntity) {
|
||||
return updateById(sysDictDataEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典数据表
|
||||
*
|
||||
* @param dictDataIds 需要删除的字典数据表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlDictDataByDictDataIds(Long[] dictDataIds) {
|
||||
return sysDictDataMapper.deleteBatchIds(Arrays.asList(dictDataIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据表信息
|
||||
*
|
||||
* @param dictDataId 字典数据表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlDictDataByDictDataId(Long dictDataId) {
|
||||
return sysDictDataMapper.deleteById(dictDataId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictDataEntity> selectDictDataByType(String dictType) {
|
||||
List<SysDictDataEntity> dictDataList = DictUtils.getDictCache(dictType);
|
||||
if (CollectionUtil.isNotEmpty(dictDataList)) {
|
||||
return dictDataList;
|
||||
}
|
||||
dictDataList = sysDictDataMapper.selectDictDataByType(dictType);
|
||||
if (CollectionUtil.isNotEmpty(dictDataList)) {
|
||||
DictUtils.setDictCache(dictType, dictDataList);
|
||||
return dictDataList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysDictDataEntity;
|
||||
import com.starry.admin.modules.system.entity.SysDictEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysDictDataMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysDictMapper;
|
||||
import com.starry.admin.modules.system.service.ISysDictService;
|
||||
import com.starry.admin.modules.system.vo.SysDictDataVo;
|
||||
import com.starry.admin.modules.system.vo.SysDictVo;
|
||||
import com.starry.admin.utils.DictUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDictEntity> implements ISysDictService {
|
||||
@Resource
|
||||
private SysDictMapper sysDictMapper;
|
||||
@Resource
|
||||
private SysDictDataMapper sysDictDataMapper;
|
||||
|
||||
/**
|
||||
* 查询字典表
|
||||
*
|
||||
* @param dictId 字典表主键
|
||||
* @return 字典表
|
||||
*/
|
||||
@Override
|
||||
public SysDictEntity selectXlDictByDictId(Long dictId) {
|
||||
return sysDictMapper.selectXlDictByDictId(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典表列表
|
||||
*
|
||||
* @param sysDictVo 字典表
|
||||
* @return 字典表
|
||||
*/
|
||||
@Override
|
||||
public Page<SysDictEntity> selectXlDictList(SysDictVo sysDictVo) {
|
||||
return sysDictMapper.selectXlDictList(new Page<>(sysDictVo.getPageNum(), sysDictVo.getPageSize()), sysDictVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典表
|
||||
*
|
||||
* @param sysDictEntity 字典表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysDictEntity sysDictEntity) {
|
||||
return save(sysDictEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典表
|
||||
*
|
||||
* @param sysDictEntity 字典表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(SysDictEntity sysDictEntity) {
|
||||
return updateById(sysDictEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典表
|
||||
*
|
||||
* @param dictIds 需要删除的字典表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlDictByDictIds(Long[] dictIds) {
|
||||
return sysDictMapper.deleteBatchIds(Arrays.asList(dictIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典表信息
|
||||
*
|
||||
* @param dictId 字典表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlDictByDictId(Long dictId) {
|
||||
return sysDictMapper.deleteById(dictId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictEntity> selectDictTypeAll() {
|
||||
return sysDictMapper.selectList(new LambdaQueryWrapper<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载字典缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void loadingDictCache() {
|
||||
SysDictDataVo dictData = new SysDictDataVo();
|
||||
dictData.setStatus(0);
|
||||
// 按字典编码分组,不分页,size < 0
|
||||
IPage<SysDictDataEntity> iPage = sysDictDataMapper.selectXlDictDataList(new Page<>(1, -1), dictData);
|
||||
Map<String, List<SysDictDataEntity>> dictDataMap = iPage.getRecords().stream().collect(Collectors.groupingBy(SysDictDataEntity::getDictType));
|
||||
for (Map.Entry<String, List<SysDictDataEntity>> entry : dictDataMap.entrySet()) {
|
||||
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictDataEntity::getSort)).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void clearDictCache() {
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置字典缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void resetDictCache() {
|
||||
clearDictCache();
|
||||
loadingDictCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogEntity;
|
||||
import com.starry.admin.modules.system.entity.SysLoginLogVo;
|
||||
import com.starry.admin.modules.system.mapper.SysLoginLogMapper;
|
||||
import com.starry.admin.modules.system.service.ISysLoginLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 系统访问日志表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLogEntity> implements ISysLoginLogService {
|
||||
@Resource
|
||||
private SysLoginLogMapper xlLoginLogMapper;
|
||||
|
||||
/**
|
||||
* 查询系统访问日志表
|
||||
*
|
||||
* @param loginId 系统访问日志表主键
|
||||
* @return 系统访问日志表
|
||||
*/
|
||||
@Override
|
||||
public SysLoginLogEntity selectXlLoginLogByLoginId(Long loginId) {
|
||||
return xlLoginLogMapper.selectXlLoginLogByLoginId(loginId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统访问日志表列表
|
||||
*
|
||||
* @param vo 系统访问日志表
|
||||
* @return 系统访问日志表
|
||||
*/
|
||||
@Override
|
||||
public IPage<SysLoginLogEntity> selectXlLoginLogList(SysLoginLogVo vo) {
|
||||
return xlLoginLogMapper.selectXlLoginLogList(new Page<>(vo.getPageNum(), vo.getPageSize()), vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增系统访问日志表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysLoginLogEntity sysLoginLogEntity) {
|
||||
return save(sysLoginLogEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改系统访问日志表
|
||||
*
|
||||
* @param sysLoginLogEntity 系统访问日志表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(SysLoginLogEntity sysLoginLogEntity) {
|
||||
return updateById(sysLoginLogEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除系统访问日志表
|
||||
*
|
||||
* @param loginIds 需要删除的系统访问日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlLoginLogByLoginIds(Long[] loginIds) {
|
||||
return xlLoginLogMapper.deleteBatchIds(Arrays.asList(loginIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统访问日志表信息
|
||||
*
|
||||
* @param loginId 系统访问日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlLoginLogByLoginId(Long loginId) {
|
||||
return xlLoginLogMapper.deleteById(loginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanLoginlog() {
|
||||
xlLoginLogMapper.cleanLoginlog();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.common.domain.TreeSelect;
|
||||
import com.starry.admin.modules.system.entity.SysMenuEntity;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysMenuMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMapper;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
import com.starry.admin.modules.system.vo.MetaVo;
|
||||
import com.starry.admin.modules.system.vo.RouterVo;
|
||||
import com.starry.admin.modules.system.vo.SimpleMenu;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.Constants;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-03
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuEntity> implements SysMenuService {
|
||||
|
||||
@Resource
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Override
|
||||
public boolean create(SysMenuEntity menu) {
|
||||
return save(menu);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<SysMenuEntity> listPage(SysMenuEntity menu, String userId, Integer pageSize, Integer pageNum) {
|
||||
Page<SysMenuEntity> page = new Page<>(pageNum, pageSize);
|
||||
// 超级管理员显示所有菜单信息
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
return baseMapper.selectPage(page, new LambdaQueryWrapper<SysMenuEntity>().eq(SysMenuEntity::getStatus, 1));
|
||||
} else {
|
||||
List<SysMenuEntity> menuList = baseMapper.selectMenuListByUserId(menu, userId, page);
|
||||
return page.setRecords(menuList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuEntity> selectMenuList(SysMenuEntity menu, String userId) {
|
||||
List<SysMenuEntity> menuList;
|
||||
// 超级管理员显示所有菜单信息
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menuList = baseMapper.selectMenuList(menu);
|
||||
} else {
|
||||
menuList = baseMapper.selectMenuListByUserId(menu, userId);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuEntity> selectMenuList(String userId) {
|
||||
return selectMenuList(new SysMenuEntity(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkMenuNameUnique(SysMenuEntity menu) {
|
||||
long menuId = menu.getMenuId() == null ? -1L : menu.getMenuId();
|
||||
List<SysMenuEntity> menus = baseMapper.selectList(new LambdaQueryWrapper<SysMenuEntity>()
|
||||
.eq(SysMenuEntity::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenuEntity::getParentId, menu.getParentId()));
|
||||
if (CollectionUtil.isNotEmpty(menus) && menus.get(0).getMenuId() != menuId) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
Long result = baseMapper.selectCount(new LambdaQueryWrapper<SysMenuEntity>().eq(SysMenuEntity::getParentId, menuId));
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenuEntity> menus) {
|
||||
List<SysMenuEntity> returnList = new ArrayList<>();
|
||||
List<Long> tempList = new ArrayList<>();
|
||||
for (SysMenuEntity menu : menus) {
|
||||
tempList.add(menu.getMenuId());
|
||||
}
|
||||
for (SysMenuEntity menu : menus) {
|
||||
// 如果是顶级节点,遍历该父节点所有的子节点
|
||||
if (!tempList.contains(menu.getParentId())) {
|
||||
recursionList(menus, menu);
|
||||
returnList.add(menu);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(returnList)) {
|
||||
returnList = menus;
|
||||
}
|
||||
return returnList.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMenuEntity selectMenuById(Long menuId) {
|
||||
return baseMapper.selectById(menuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> selectMenuListByRoleId(Long roleId) {
|
||||
SysRoleEntity role = roleMapper.selectRoleById(roleId);
|
||||
return baseMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(String userId) {
|
||||
// 获取菜单权限集合
|
||||
List<String> perms = baseMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StrUtil.isNotEmpty(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuEntity> selectMenuTreeByUserId(String userId) {
|
||||
List<SysMenuEntity> menus;
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menus = baseMapper.selectMenuTreeAll();
|
||||
} else {
|
||||
menus = baseMapper.selectMenuTreeByUserId(userId);
|
||||
}
|
||||
return getChildPerms(menus, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouterVo> buildMenus(List<SysMenuEntity> menus) {
|
||||
List<RouterVo> routers = new LinkedList<>();
|
||||
for (SysMenuEntity menu : menus) {
|
||||
RouterVo router = new RouterVo();
|
||||
// 0:隐藏
|
||||
router.setHidden("0".equals(menu.getVisible()));
|
||||
router.setName(getRouteName(menu));
|
||||
router.setPath(getRouterPath(menu));
|
||||
router.setComponent(getComponent(menu));
|
||||
router.setRouterQuery(menu.getRouterQuery());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), false, menu.getPath()));
|
||||
List<SysMenuEntity> cMenus = menu.getChildren();
|
||||
// 有子路由
|
||||
if (CollectionUtil.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(String.valueOf(menu.getMenuType()))) {
|
||||
router.setAlwaysShow(true);
|
||||
router.setRedirect("noRedirect");
|
||||
router.setChildren(buildMenus(cMenus));
|
||||
} else if (isMenuFrame(menu)) {
|
||||
// 菜单内部跳转
|
||||
router.setMeta(null);
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
children.setPath(menu.getPath());
|
||||
children.setComponent(menu.getComponent());
|
||||
children.setName(StringUtils.capitalize(menu.getPath()));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), false, menu.getPath()));
|
||||
children.setRouterQuery(menu.getRouterQuery());
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
router.setPath("/");
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||
children.setPath(routerPath);
|
||||
children.setComponent(UserConstants.INNER_LINK);
|
||||
children.setName(StringUtils.capitalize(routerPath));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
}
|
||||
routers.add(router);
|
||||
}
|
||||
return routers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SimpleMenu> selectSimpleMenuList() {
|
||||
return baseMapper.selectSimpleMenuList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*
|
||||
* @param menus
|
||||
* @param t
|
||||
*/
|
||||
private void recursionList(List<SysMenuEntity> menus, SysMenuEntity t) {
|
||||
// 得到子节点
|
||||
List<SysMenuEntity> childList = getChildList(menus, t);
|
||||
t.setChildren(childList);
|
||||
for (SysMenuEntity tChild : childList) {
|
||||
if (hasChild(menus, tChild)) {
|
||||
recursionList(menus, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysMenuEntity> getChildList(List<SysMenuEntity> list, SysMenuEntity t) {
|
||||
List<SysMenuEntity> tList = new ArrayList<>();
|
||||
for (SysMenuEntity n : list) {
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
||||
tList.add(n);
|
||||
}
|
||||
}
|
||||
return tList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<SysMenuEntity> list, SysMenuEntity t) {
|
||||
return !getChildList(list, t).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由名称
|
||||
*/
|
||||
private String getRouteName(SysMenuEntity menu) {
|
||||
// 首字母大写
|
||||
String routerName = StringUtils.capitalize(menu.getPath());
|
||||
// 非外链并且是一级目录(类型为菜单)
|
||||
if (isMenuFrame(menu)) {
|
||||
routerName = StringUtils.EMPTY;
|
||||
}
|
||||
return routerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由地址
|
||||
*/
|
||||
private String getRouterPath(SysMenuEntity menu) {
|
||||
String routerPath = menu.getPath();
|
||||
// 内链打开外网方式
|
||||
if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
// 内链域名特殊字符替换
|
||||
routerPath = innerLinkReplaceEach(routerPath);
|
||||
}
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (menu.getParentId().intValue() == 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
||||
&& UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
|
||||
routerPath = "/" + menu.getPath();
|
||||
} else if (isMenuFrame(menu)) {
|
||||
routerPath = "/";
|
||||
}
|
||||
return routerPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为菜单内部跳转
|
||||
*/
|
||||
private boolean isMenuFrame(SysMenuEntity menu) {
|
||||
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为内链组件
|
||||
*/
|
||||
private boolean isInnerLink(SysMenuEntity menu) {
|
||||
// 判断是否为http(s)://开头
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为parent_view组件 (有多级的菜单)
|
||||
*/
|
||||
private boolean isParentView(SysMenuEntity menu) {
|
||||
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 内链域名特殊字符替换
|
||||
*/
|
||||
private String innerLinkReplaceEach(String path) {
|
||||
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS},
|
||||
new String[]{"", ""});
|
||||
}
|
||||
|
||||
private List<SysMenuEntity> getChildPerms(List<SysMenuEntity> list, int parentId) {
|
||||
List<SysMenuEntity> returnList = new ArrayList<>();
|
||||
for (SysMenuEntity menu : list) {
|
||||
if (menu.getParentId() == parentId) {
|
||||
recursionList(list, menu);
|
||||
returnList.add(menu);
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组件信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 组件信息
|
||||
*/
|
||||
public String getComponent(SysMenuEntity menu) {
|
||||
String component = UserConstants.LAYOUT;
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||
component = menu.getComponent();
|
||||
} else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
component = UserConstants.INNER_LINK;
|
||||
} else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
|
||||
component = UserConstants.PARENT_VIEW;
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysOperationLogEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysOperationLogMapper;
|
||||
import com.starry.admin.modules.system.service.ISysOperationLogService;
|
||||
import com.starry.admin.modules.system.vo.SysOperationLogVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 操作日志表Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysOperationLogServiceImpl extends ServiceImpl<SysOperationLogMapper, SysOperationLogEntity> implements ISysOperationLogService {
|
||||
|
||||
@Resource
|
||||
private SysOperationLogMapper sysOperationLogMapper;
|
||||
|
||||
/**
|
||||
* 查询操作日志表
|
||||
*
|
||||
* @param operId 操作日志表主键
|
||||
* @return 操作日志表
|
||||
*/
|
||||
@Override
|
||||
public SysOperationLogEntity selectXlOperLogByOperId(Long operId) {
|
||||
return sysOperationLogMapper.selectXlOperLogByOperId(operId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作日志表列表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 操作日志表
|
||||
*/
|
||||
@Override
|
||||
public IPage<SysOperationLogEntity> selectXlOperLogList(SysOperationLogVo sysOperationLogEntity) {
|
||||
return sysOperationLogMapper.selectXlOperLogList(new Page<>(sysOperationLogEntity.getPageNum(), sysOperationLogEntity.getPageSize()), sysOperationLogEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增操作日志表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(SysOperationLogEntity sysOperationLogEntity) {
|
||||
return save(sysOperationLogEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改操作日志表
|
||||
*
|
||||
* @param sysOperationLogEntity 操作日志表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateXlOperLog(SysOperationLogEntity sysOperationLogEntity) {
|
||||
return updateById(sysOperationLogEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除操作日志表
|
||||
*
|
||||
* @param operIds 需要删除的操作日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlOperLogByOperIds(Long[] operIds) {
|
||||
return sysOperationLogMapper.deleteBatchIds(Arrays.asList(operIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除操作日志表信息
|
||||
*
|
||||
* @param operId 操作日志表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteXlOperLogByOperId(Long operId) {
|
||||
return sysOperationLogMapper.deleteById(operId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysRoleMenuEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMenuMapper;
|
||||
import com.starry.admin.modules.system.service.SysRoleMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色和菜单关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-06
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenuEntity> implements SysRoleMenuService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.admin.modules.system.entity.*;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleDeptMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMenuMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysUserRoleMapper;
|
||||
import com.starry.admin.modules.system.service.SysRoleMenuService;
|
||||
import com.starry.admin.modules.system.service.SysRoleService;
|
||||
import com.starry.admin.modules.system.service.SysUserRoleService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-01
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity> implements SysRoleService {
|
||||
|
||||
@Resource
|
||||
private SysRoleMenuService roleMenuService;
|
||||
@Resource
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
@Resource
|
||||
private SysRoleMenuMapper roleMenuMapper;
|
||||
@Resource
|
||||
private SysUserRoleService userRoleService;
|
||||
@Resource
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleNameUnique(SysRoleEntity role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
SysRoleEntity info = baseMapper.checkRoleNameUnique(role.getRoleName());
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色权限是否唯一
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleKeyUnique(SysRoleEntity role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
SysRoleEntity info = baseMapper.checkRoleKeyUnique(role.getRoleKey());
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean create(SysRoleEntity role) {
|
||||
// 先新增角色
|
||||
save(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateRole(SysRoleEntity role) {
|
||||
// 先修改角色
|
||||
updateById(role);
|
||||
// 再删除角色菜单信息
|
||||
roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenuEntity>().eq(SysRoleMenuEntity::getRoleId, role.getRoleId()));
|
||||
// 再新增
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countUserRoleByRoleId(Long roleId) {
|
||||
return baseMapper.countUserRoleByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(Long[] roleIds) {
|
||||
for (Long roleId : roleIds) {
|
||||
checkRoleAllowed(new SysRoleEntity(roleId));
|
||||
checkRoleDataScope(roleId);
|
||||
SysRoleEntity role = getById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDept(roleIds);
|
||||
return removeByIds(Arrays.asList(roleIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SysRoleEntity> list(String keyword, Integer pageSize, Integer pageNum) {
|
||||
Page<SysRoleEntity> page = new Page<>(pageNum, pageSize);
|
||||
LambdaQueryWrapper<SysRoleEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(keyword)) {
|
||||
wrapper.like(SysRoleEntity::getRoleName, keyword);
|
||||
}
|
||||
return page(page, wrapper);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean authRoleMenu(SysRoleEntity role) {
|
||||
// 先删除
|
||||
roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenuEntity>().eq(SysRoleMenuEntity::getRoleId, role.getRoleId()));
|
||||
// 在新增
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(String userId) {
|
||||
List<SysRoleEntity> list = baseMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (SysRoleEntity role : list) {
|
||||
permsSet.addAll(Arrays.asList(role.getRoleKey().trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRoleEntity> selectRoleList(SysRoleEntity role) {
|
||||
return baseMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色菜单信息
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public boolean insertRoleMenu(SysRoleEntity role) {
|
||||
// 新增角色与菜单管理
|
||||
List<SysRoleMenuEntity> list = new ArrayList<>();
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
SysRoleMenuEntity rm = new SysRoleMenuEntity();
|
||||
rm.setRoleId(role.getRoleId());
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
return roleMenuService.saveBatch(list);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色是否允许操作
|
||||
*
|
||||
* @param role 角色信息
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleAllowed(SysRoleEntity role) {
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId) {
|
||||
if (!SysUserEntity.isAdmin(SecurityUtils.getUserId())) {
|
||||
SysRoleEntity role = new SysRoleEntity();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRoleEntity> roles = this.selectRoleList(role);
|
||||
if (CollectionUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int authDataScope(SysRoleEntity role) {
|
||||
// 修改角色信息
|
||||
this.updateById(role);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
|
||||
// 新增角色和部门信息(数据权限)
|
||||
return insertRoleDept(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色部门信息(数据权限)
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleDept(SysRoleEntity role) {
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDeptEntity> list = new ArrayList<>();
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
SysRoleDeptEntity rd = new SysRoleDeptEntity();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
rows = roleDeptMapper.batchRoleDept(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRoleEntity userRole) {
|
||||
return userRoleMapper.deleteUserRoleInfo(userRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要取消授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, String[] userIds) {
|
||||
return userRoleMapper.deleteUserRoleInfos(roleId, userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAuthUsers(Long roleId, String[] userIds) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRoleEntity> list = new ArrayList<>();
|
||||
for (String userId : userIds) {
|
||||
SysUserRoleEntity ur = new SysUserRoleEntity();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
return userRoleService.saveBatch(list) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysUserRoleMapper;
|
||||
import com.starry.admin.modules.system.service.SysUserRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2022-07-08
|
||||
*/
|
||||
@Service
|
||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRoleEntity> implements SysUserRoleService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package com.starry.admin.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserRoleEntity;
|
||||
import com.starry.admin.modules.system.mapper.SysRoleMapper;
|
||||
import com.starry.admin.modules.system.mapper.SysUserMapper;
|
||||
import com.starry.admin.modules.system.service.SysUserRoleService;
|
||||
import com.starry.admin.modules.system.service.SysUserService;
|
||||
import com.starry.admin.modules.system.vo.RoleUserResultVo;
|
||||
import com.starry.admin.modules.system.vo.SysUserQueryVo;
|
||||
import com.starry.admin.modules.system.vo.UserQueryVo;
|
||||
import com.starry.common.annotation.DataScope;
|
||||
import com.starry.common.constant.UserConstants;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 后台用户表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author admin
|
||||
* @since 2021-09-03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements SysUserService {
|
||||
|
||||
@Resource
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Resource
|
||||
private SysUserRoleService userRoleService;
|
||||
@Resource
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public SysUserEntity register(SysUserEntity user) {
|
||||
SysUserEntity newSysUserEntity = new SysUserEntity();
|
||||
BeanUtils.copyProperties(user, newSysUserEntity);
|
||||
// 查询是否有相同用户名的用户
|
||||
List<SysUserEntity> sysUserEntities = this.baseMapper.selectList(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUserCode, newSysUserEntity.getUserCode()));
|
||||
if (CollectionUtil.isNotEmpty(sysUserEntities)) {
|
||||
return null;
|
||||
}
|
||||
// 将密码进行加密操作
|
||||
String encodePassword = passwordEncoder.encode(user.getPassWord());
|
||||
newSysUserEntity.setPassWord(encodePassword);
|
||||
this.baseMapper.insert(newSysUserEntity);
|
||||
return newSysUserEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity getUserByCode(String userCode) {
|
||||
List<SysUserEntity> users = baseMapper.selectList(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUserCode, userCode));
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
return users.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity selectUserByUserName(String userName) {
|
||||
return baseMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUserEntity> listMemberPage(UserQueryVo queryVo) {
|
||||
Page<SysUserEntity> page = new Page<>(queryVo.getPageNum(), queryVo.getPageSize());
|
||||
return baseMapper.selectUserList(page, queryVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkUserNameUnique(String userCode) {
|
||||
// 查询是否有相同用户名的用户
|
||||
List<SysUserEntity> userList = this.baseMapper.selectList(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUserCode, userCode));
|
||||
if (CollectionUtil.isNotEmpty(userList)) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean create(SysUserEntity user) {
|
||||
// 将密码进行加密操作
|
||||
String encodePassword = passwordEncoder.encode(user.getPassWord());
|
||||
user.setPassWord(encodePassword);
|
||||
if (StrUtil.isBlankIfStr(user.getUserId())) {
|
||||
user.setUserId(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
boolean flag = save(user);
|
||||
if (flag) {
|
||||
// 新增用户角色信息
|
||||
flag = insertUserRole(user);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysUserEntity user) {
|
||||
boolean flag = updateById(user);
|
||||
if (flag) {
|
||||
// 删除用户角色信息
|
||||
userRoleService.remove(new LambdaQueryWrapper<SysUserRoleEntity>().eq(SysUserRoleEntity::getUserId, user.getUserId()));
|
||||
// 新增用户角色信息
|
||||
flag = insertUserRole(user);
|
||||
}
|
||||
return flag;
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean delete(List<String> ids) {
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
boolean flag = this.removeBatchByIds(ids);
|
||||
if (flag) {
|
||||
// 删除用户角色表
|
||||
userRoleService.remove(new LambdaQueryWrapper<SysUserRoleEntity>().in(SysUserRoleEntity::getUserId, ids));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity selectUserById(String userId) {
|
||||
return baseMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userId) {
|
||||
List<SysRoleEntity> list = sysRoleMapper.selectRolePermissionByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysRoleEntity::getRoleName).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userId, String avatar) {
|
||||
SysUserEntity user = getById(userId);
|
||||
if (user != null) {
|
||||
user.setAvatar(avatar);
|
||||
return updateById(user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public boolean insertUserRole(SysUserEntity user) {
|
||||
if (user.getRoleIds() != null && user.getRoleIds().length > 0) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRoleEntity> list = new ArrayList<>(user.getRoleIds().length);
|
||||
for (Long roleId : user.getRoleIds()) {
|
||||
SysUserRoleEntity ur = new SysUserRoleEntity();
|
||||
ur.setUserId(user.getUserId());
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
return userRoleService.saveBatch(list);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
* @param userQueryVo 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public IPage<RoleUserResultVo> selectAllocatedList(SysUserQueryVo userQueryVo) {
|
||||
return baseMapper.selectAllocatedList(new Page<>(userQueryVo.getPageNum(), userQueryVo.getPageSize()), userQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public IPage<RoleUserResultVo> selectUnallocatedList(SysUserQueryVo user) {
|
||||
return baseMapper.selectUnallocatedList(new Page<>(user.getPageNum(), user.getPageSize()), user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* @since 2021/9/6
|
||||
*/
|
||||
@Data
|
||||
public class LoginVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String passWord;
|
||||
|
||||
@ApiModelProperty(value = "验证码随机字符串")
|
||||
private String nonceStr;
|
||||
|
||||
@ApiModelProperty(value = "验证值")
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2021/9/2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MemberQueryVo extends BasePageEntity {
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
|
||||
import com.starry.common.constant.Constants;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 路由显示信息
|
||||
* @since 2022/7/6
|
||||
*/
|
||||
@Data
|
||||
public class MetaVo {
|
||||
|
||||
/**
|
||||
* 设置该路由在侧边栏和面包屑中展示的名字
|
||||
*/
|
||||
@ApiModelProperty(value = "设置该路由在侧边栏和面包屑中展示的名字")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 设置该路由的图标,对应路径src/assets/icons/svg
|
||||
*/
|
||||
@ApiModelProperty(value = "设置该路由的图标,对应路径src/assets/icons/svg")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 设置为true,则不会被 <keep-alive>缓存
|
||||
*/
|
||||
@ApiModelProperty(value = "设置为true,则不会被 <keep-alive>缓存")
|
||||
private boolean noCache;
|
||||
|
||||
/**
|
||||
* 内链地址(http(s)://开头)
|
||||
*/
|
||||
@ApiModelProperty(value = "内链地址(http(s)://开头)")
|
||||
private String link;
|
||||
|
||||
public MetaVo(String title, String icon) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public MetaVo(String title, String icon, String link) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
public MetaVo(String title, String icon, boolean noCache, String link) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.noCache = noCache;
|
||||
if (StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS)) {
|
||||
this.link = link;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 角色分配用户精简信息Vo
|
||||
* @since 2023/3/10
|
||||
*/
|
||||
@ApiModel("管理后台 - 角色分配用户返回信息")
|
||||
@Data
|
||||
public class RoleUserResultVo {
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型;1:admin;2:会员")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userCode;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String userNickname;
|
||||
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String userEmail;
|
||||
|
||||
@ApiModelProperty(value = "中国手机不带国家代码,国际手机号格式为:国家代码-手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "用户状态;0正常 1停用")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "所属部门id")
|
||||
private Long deptId;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createdTime;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 路由配置信息
|
||||
* @since 2022/7/6
|
||||
*/
|
||||
@Data
|
||||
public class RouterVo {
|
||||
|
||||
@ApiModelProperty(value = "路由名字")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "路由地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现")
|
||||
private boolean hidden;
|
||||
|
||||
@ApiModelProperty(value = "重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击")
|
||||
private String redirect;
|
||||
|
||||
@ApiModelProperty(value = "组件地址")
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数:如 {"id": 1, "name": "ry"}
|
||||
*/
|
||||
private String routerQuery;
|
||||
|
||||
@ApiModelProperty(value = "当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面")
|
||||
private Boolean alwaysShow;
|
||||
|
||||
@ApiModelProperty(value = "其他元素")
|
||||
private MetaVo meta;
|
||||
|
||||
@ApiModelProperty(value = "子路由")
|
||||
private List<RouterVo> children;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@ApiModel("管理后台 - 菜单精简信息")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SimpleMenu {
|
||||
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "菜单名称", required = true, example = "菜单管理")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "父菜单 ID", required = true, example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 MenuTypeEnum 枚举类")
|
||||
@NotNull(message = "菜单类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.CellData;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* 状态字符串处理
|
||||
* @since 2022/10/25
|
||||
*/
|
||||
public class StatusConverter implements Converter<Integer> {
|
||||
|
||||
@Override
|
||||
public Class supportJavaTypeKey() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
return "失败".equals(cellData.getStringValue()) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||
return new CellData(0 == value ? "成功" : "失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 字典数据表对象 sys_dict_data
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public class SysDictDataVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "dict_data_id", type = IdType.AUTO)
|
||||
private Long dictDataId;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long sort;
|
||||
|
||||
/**
|
||||
* 是否默认(Y是 N否)
|
||||
*/
|
||||
private String isDefault;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2024/3/15 13:58
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysDictVo extends BasePageEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志表对象 sys_operation_log
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysOperationLogVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ApiModelProperty("主键ID")
|
||||
@TableId(value = "oper_id", type = IdType.AUTO)
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 模块标题
|
||||
*/
|
||||
@ExcelProperty(value = "系统模块")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 业务类型(0其它 1新增 2修改 3删除)
|
||||
*/
|
||||
private Integer businessType;
|
||||
|
||||
/**
|
||||
* 业务类型数组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Integer[] businessTypes;
|
||||
|
||||
/**
|
||||
* 方法名称
|
||||
*/
|
||||
@ExcelProperty(value = "方法名称")
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String requestMethod;
|
||||
|
||||
/**
|
||||
* 操作类别(0其它 1后台用户 2手机端用户)
|
||||
*/
|
||||
private Integer operatorType;
|
||||
|
||||
/**
|
||||
* 操作人员
|
||||
*/
|
||||
private String operName;
|
||||
|
||||
/**
|
||||
* 请求URL
|
||||
*/
|
||||
private String operUrl;
|
||||
|
||||
/**
|
||||
* 主机地址
|
||||
*/
|
||||
private String operIp;
|
||||
|
||||
/**
|
||||
* 操作地点
|
||||
*/
|
||||
private String operLocation;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String operParam;
|
||||
|
||||
/**
|
||||
* 返回参数
|
||||
*/
|
||||
private String jsonResult;
|
||||
|
||||
/**
|
||||
* 操作状态(0正常 1异常)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Date operTime;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysRoleAddVo extends BaseEntity<SysRoleEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private Long roleId;
|
||||
|
||||
@NotBlank(message = "角色名称不能为空")
|
||||
private String roleName;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String dataScope;
|
||||
|
||||
private boolean menuCheckStrictly;
|
||||
|
||||
private boolean deptCheckStrictly;
|
||||
|
||||
private String roleKey;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 菜单组
|
||||
*/
|
||||
private Long[] menuIds;
|
||||
|
||||
/**
|
||||
* 部门组(数据权限)
|
||||
*/
|
||||
private Long[] deptIds;
|
||||
|
||||
/**
|
||||
* 角色菜单权限
|
||||
*/
|
||||
private Set<String> permissions;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import com.starry.admin.modules.system.entity.SysDeptEntity;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户查询对象
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserQueryVo extends BasePageEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Integer userType;
|
||||
|
||||
private String userCode;
|
||||
|
||||
private String passWord;
|
||||
|
||||
private String realName;
|
||||
|
||||
private String userNickname;
|
||||
|
||||
private String userEmail;
|
||||
|
||||
|
||||
private String avatar;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private Integer sex;
|
||||
|
||||
private Date birthday;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Date lastLoginTime;
|
||||
|
||||
private String lastLoginIp;
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private List<SysRoleEntity> roles;
|
||||
|
||||
private Long[] roleIds;
|
||||
|
||||
|
||||
private SysDeptEntity dept;
|
||||
|
||||
private Long roleId;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2021/9/26
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserQueryVo extends BasePageEntity {
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userCode;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String realName;
|
||||
}
|
||||
Reference in New Issue
Block a user