Compare commits
6 Commits
APP权限登录改造
...
0969a7cd1f
| Author | SHA1 | Date | |
|---|---|---|---|
| 0969a7cd1f | |||
| 20f3edaeec | |||
| 4add59d197 | |||
| b89d962a50 | |||
| f9f5569504 | |||
| 1d286634c0 |
@ -65,6 +65,12 @@
|
||||
<artifactId>fys-common-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 设备管理模块 -->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-equipment</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-system</artifactId>
|
||||
@ -93,12 +99,6 @@
|
||||
<artifactId>fys-workflow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- app模块 -->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-app</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
|
||||
@ -1,161 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.domain.model.RegisterBody;
|
||||
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
|
||||
import com.fuyuanshen.common.core.utils.*;
|
||||
import com.fuyuanshen.common.encrypt.annotation.ApiEncrypt;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.system.domain.bo.SysTenantBo;
|
||||
import com.fuyuanshen.system.domain.vo.SysClientVo;
|
||||
import com.fuyuanshen.system.domain.vo.SysTenantVo;
|
||||
import com.fuyuanshen.system.service.ISysClientService;
|
||||
import com.fuyuanshen.system.service.ISysConfigService;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import com.fuyuanshen.web.service.SysRegisterService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP认证
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/auth")
|
||||
public class AppAuthController {
|
||||
|
||||
private final AppLoginService loginService;
|
||||
private final SysRegisterService registerService;
|
||||
private final ISysConfigService configService;
|
||||
private final ISysTenantService tenantService;
|
||||
private final ISysClientService clientService;
|
||||
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
// @ApiEncrypt
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody AppSmsLoginBody appSmsLoginBody) {
|
||||
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||
LoginHelper.getLoginUser();
|
||||
ValidatorUtils.validate(appSmsLoginBody);
|
||||
SmsLoginBody loginBody = new SmsLoginBody();
|
||||
loginBody.setPhonenumber(appSmsLoginBody.getPhonenumber());
|
||||
loginBody.setSmsCode(appSmsLoginBody.getSmsCode());
|
||||
loginBody.setTenantId(appSmsLoginBody.getTenantId());
|
||||
loginBody.setClientId("ca839698e245d60aa2f0e59bd52b34f8");
|
||||
loginBody.setGrantType("appSms");
|
||||
// 授权类型和客户端id
|
||||
String clientId = loginBody.getClientId();
|
||||
String grantType = loginBody.getGrantType();
|
||||
SysClientVo client = clientService.queryByClientId(clientId);
|
||||
// 查询不到 client 或 client 内不包含 grantType
|
||||
if (ObjectUtil.isNull(client) || !StringUtils.contains(client.getGrantType(), grantType)) {
|
||||
log.info("客户端id: {} 认证类型:{} 异常!.", clientId, grantType);
|
||||
return R.fail(MessageUtils.message("auth.grant.type.error"));
|
||||
} else if (!SystemConstants.NORMAL.equals(client.getStatus())) {
|
||||
return R.fail(MessageUtils.message("auth.grant.type.blocked"));
|
||||
}
|
||||
// 校验租户
|
||||
loginService.checkTenant(loginBody.getTenantId());
|
||||
// 登录
|
||||
String body = JsonUtils.toJsonString(loginBody);
|
||||
LoginVo loginVo = IAuthStrategy.login(body, client, grantType);
|
||||
return R.ok(loginVo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public R<Void> logout() {
|
||||
// loginService.logout();
|
||||
return R.ok("退出成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
@ApiEncrypt
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
if (!configService.selectRegisterEnabled(user.getTenantId())) {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
registerService.register(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录页面租户下拉框
|
||||
*
|
||||
* @return 租户列表
|
||||
*/
|
||||
@GetMapping("/tenant/list")
|
||||
public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception {
|
||||
// 返回对象
|
||||
LoginTenantVo result = new LoginTenantVo();
|
||||
boolean enable = TenantHelper.isEnable();
|
||||
result.setTenantEnabled(enable);
|
||||
// 如果未开启租户这直接返回
|
||||
if (!enable) {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo());
|
||||
List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class);
|
||||
try {
|
||||
// 如果只超管返回所有租户
|
||||
if (LoginHelper.isSuperAdmin()) {
|
||||
result.setVoList(voList);
|
||||
return R.ok(result);
|
||||
}
|
||||
} catch (NotLoginException ignored) {
|
||||
}
|
||||
|
||||
// 获取域名
|
||||
String host;
|
||||
String referer = request.getHeader("referer");
|
||||
if (StringUtils.isNotBlank(referer)) {
|
||||
// 这里从referer中取值是为了本地使用hosts添加虚拟域名,方便本地环境调试
|
||||
host = referer.split("//")[1].split("/")[0];
|
||||
} else {
|
||||
host = new URL(request.getRequestURL().toString()).getHost();
|
||||
}
|
||||
// 根据域名进行筛选
|
||||
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
|
||||
StringUtils.equalsIgnoreCase(vo.getDomain(), host));
|
||||
result.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.vo.DeviceVo;
|
||||
import com.fuyuanshen.app.service.DeviceService;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP 设备信息管理
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/device")
|
||||
public class AppDeviceController extends BaseController {
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
/**
|
||||
* 查询设备信息列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<DeviceVo> list(AppUserBo bo, PageQuery pageQuery) {
|
||||
return deviceService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceVo {
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String deviceType;
|
||||
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.fuyuanshen.app.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppSmsLoginBody {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 短信code
|
||||
*/
|
||||
@NotBlank(message = "{sms.code.not.blank}")
|
||||
private String smsCode;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@NotBlank(message = "租户ID不能为空")
|
||||
private String tenantId;
|
||||
}
|
||||
@ -1,188 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.domain.dto.RoleDTO;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.ServletUtils;
|
||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.log.event.LogininforEvent;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.exception.TenantException;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.system.domain.vo.SysTenantVo;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppLoginService {
|
||||
|
||||
@Value("${user.password.maxRetryCount}")
|
||||
private Integer maxRetryCount;
|
||||
|
||||
@Value("${user.password.lockTime}")
|
||||
private Integer lockTime;
|
||||
|
||||
private final ISysTenantService tenantService;
|
||||
private final IAppRoleService appRoleService;
|
||||
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
String PWD_ERR_CNT_KEY = "app_pwd_err_cnt:";
|
||||
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
/*public void logout() {
|
||||
try {
|
||||
AppLoginUser loginUser = AppLoginHelper.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
return;
|
||||
}
|
||||
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
|
||||
// 超级管理员 登出清除动态租户
|
||||
TenantHelper.clearDynamic();
|
||||
}
|
||||
recordLogininfor(loginUser.getTenantId(), loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
} catch (NotLoginException ignored) {
|
||||
} finally {
|
||||
try {
|
||||
StpUtil.logout();
|
||||
} catch (NotLoginException ignored) {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public void recordLogininfor(String tenantId, String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
public AppLoginUser buildLoginUser(AppUserVo user) {
|
||||
AppLoginUser loginUser = new AppLoginUser();
|
||||
Long userId = user.getUserId();
|
||||
loginUser.setTenantId(user.getTenantId());
|
||||
loginUser.setUserId(userId);
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setNickname(user.getNickName());
|
||||
loginUser.setUserType(user.getUserType());
|
||||
Set<String> perms = new HashSet<>();
|
||||
loginUser.setMenuPermission(perms);
|
||||
loginUser.setRolePermission(perms);
|
||||
loginUser.setRoles(new ArrayList<>());
|
||||
/* List<AppRoleVo> roles = appRoleService.selectRolesByUserId(userId);
|
||||
loginUser.setRoles(BeanUtil.copyToList(roles, RoleDTO.class));*/
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录校验
|
||||
*/
|
||||
public void checkLogin(LoginType loginType, String tenantId, String username, Supplier<Boolean> supplier) {
|
||||
String errorKey = PWD_ERR_CNT_KEY + username;
|
||||
String loginFail = Constants.LOGIN_FAIL;
|
||||
|
||||
// 获取用户登录错误次数,默认为0 (可自定义限制策略 例如: key + username + ip)
|
||||
int errorNumber = ObjectUtil.defaultIfNull(RedisUtils.getCacheObject(errorKey), 0);
|
||||
// 锁定时间内登录 则踢出
|
||||
if (errorNumber >= maxRetryCount) {
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime);
|
||||
}
|
||||
|
||||
if (supplier.get()) {
|
||||
// 错误次数递增
|
||||
errorNumber++;
|
||||
RedisUtils.setCacheObject(errorKey, errorNumber, Duration.ofMinutes(lockTime));
|
||||
// 达到规定错误次数 则锁定登录
|
||||
if (errorNumber >= maxRetryCount) {
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime);
|
||||
} else {
|
||||
// 未达到规定错误次数
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitCount(), errorNumber));
|
||||
throw new UserException(loginType.getRetryLimitCount(), errorNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// 登录成功 清空错误次数
|
||||
RedisUtils.deleteObject(errorKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验租户
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
public void checkTenant(String tenantId) {
|
||||
if (!TenantHelper.isEnable()) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isBlank(tenantId)) {
|
||||
throw new TenantException("tenant.number.not.blank");
|
||||
}
|
||||
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||
return;
|
||||
}
|
||||
SysTenantVo tenant = tenantService.queryByTenantId(tenantId);
|
||||
if (ObjectUtil.isNull(tenant)) {
|
||||
log.info("登录租户:{} 不存在.", tenantId);
|
||||
throw new TenantException("tenant.not.exists");
|
||||
} else if (SystemConstants.DISABLE.equals(tenant.getStatus())) {
|
||||
log.info("登录租户:{} 已被停用.", tenantId);
|
||||
throw new TenantException("tenant.blocked");
|
||||
} else if (ObjectUtil.isNotNull(tenant.getExpireTime())
|
||||
&& new Date().after(tenant.getExpireTime())) {
|
||||
log.info("登录租户:{} 已超过有效期.", tenantId);
|
||||
throw new TenantException("tenant.expired");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.vo.DeviceVo;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.domain.dto.RoleDTO;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.ServletUtils;
|
||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.log.event.LogininforEvent;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.exception.TenantException;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.system.domain.vo.SysTenantVo;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DeviceService {
|
||||
|
||||
|
||||
public TableDataInfo<DeviceVo> queryPageList(AppUserBo bo, PageQuery pageQuery) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -144,6 +144,10 @@ public class CaptchaController {
|
||||
Expression exp = parser.parseExpression(StringUtils.remove(code, "="));
|
||||
code = exp.getValue(String.class);
|
||||
}
|
||||
|
||||
log.info("图片验证码:{}", code);
|
||||
log.info("图片验证码uuid:{}", uuid);
|
||||
|
||||
RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
CaptchaVo captchaVo = new CaptchaVo();
|
||||
captchaVo.setUuid(uuid);
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.ServletUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.core.utils.ValidatorUtils;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.system.domain.vo.SysClientVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 短信认证策略
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("appSms" + IAuthStrategy.BASE_NAME)
|
||||
@RequiredArgsConstructor
|
||||
public class AppSmsAuthStrategy implements IAuthStrategy {
|
||||
|
||||
private final AppLoginService loginService;
|
||||
private final AppUserMapper appUserMapper;
|
||||
private final RestClient.Builder builder;
|
||||
|
||||
@Override
|
||||
public LoginVo login(String body, SysClientVo client) {
|
||||
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||
ValidatorUtils.validate(loginBody);
|
||||
String tenantId = loginBody.getTenantId();
|
||||
String phonenumber = loginBody.getPhonenumber();
|
||||
String smsCode = loginBody.getSmsCode();
|
||||
AppLoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, phonenumber, () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
AppUserVo user = loadUserByPhonenumber(phonenumber);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
//新增Appuser
|
||||
addAppUser(tenantId, phonenumber);
|
||||
|
||||
user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhonenumber, phonenumber));
|
||||
// loginService.recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.not.exists", phonenumber));
|
||||
// throw new UserException("user.not.exists", phonenumber);
|
||||
}
|
||||
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||
model.setTimeout(client.getTimeout());
|
||||
model.setActiveTimeout(client.getActiveTimeout());
|
||||
model.setExtra(AppLoginHelper.CLIENT_KEY, client.getClientId());
|
||||
// 生成token
|
||||
AppLoginHelper.login(loginUser, model);
|
||||
|
||||
LoginVo loginVo = new LoginVo();
|
||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||
loginVo.setClientId(client.getClientId());
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
private void addAppUser(String tenantId, String phonenumber) {
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setPhonenumber(phonenumber);
|
||||
appUser.setUserName(phonenumber);
|
||||
appUser.setStatus("0");
|
||||
appUser.setLoginDate(new Date());
|
||||
appUser.setLoginIp(ServletUtils.getClientIP());
|
||||
appUser.setTenantId(tenantId);
|
||||
appUserMapper.insert(appUser);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
*/
|
||||
private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) {
|
||||
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber);
|
||||
if (StringUtils.isBlank(code)) {
|
||||
loginService.recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
|
||||
private AppUserVo loadUserByPhonenumber(String phonenumber) {
|
||||
AppUserVo user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhonenumber, phonenumber));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phonenumber);
|
||||
// throw new UserException("user.not.exists", phonenumber);
|
||||
// 新增AppUser用户
|
||||
return null;
|
||||
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
||||
throw new UserException("user.blocked", phonenumber);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
@ -49,9 +49,9 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 1fys@QWER..
|
||||
password: root
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
@ -98,13 +98,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 120.79.224.186
|
||||
host: 123.207.99.140
|
||||
# 端口,默认为6379
|
||||
port: 26379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 2
|
||||
# redis 密码必须配置
|
||||
password: 1fys@QWER..
|
||||
password: ccxx11234
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
|
||||
272
fys-admin/src/main/resources/application-test.yml
Normal file
272
fys-admin/src/main/resources/application-test.yml
Normal file
@ -0,0 +1,272 @@
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: @monitor.username@
|
||||
password: @monitor.password@
|
||||
|
||||
--- # snail-job 配置
|
||||
snail-job:
|
||||
enabled: false
|
||||
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
|
||||
group: "fys_group"
|
||||
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config` 表
|
||||
token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
|
||||
server:
|
||||
host: 127.0.0.1
|
||||
port: 17888
|
||||
# 命名空间UUID 详见 script/sql/ry_job.sql `sj_namespace`表`unique_id`字段
|
||||
namespace: ${spring.profiles.active}
|
||||
# 随主应用端口漂移
|
||||
port: 2${server.port}
|
||||
# 客户端ip指定
|
||||
host:
|
||||
# RPC类型: netty, grpc
|
||||
rpc-type: grpc
|
||||
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: true
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://localhost:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: root
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
# username:
|
||||
# password:
|
||||
# oracle:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: oracle.jdbc.OracleDriver
|
||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
||||
# username: ROOT
|
||||
# password: root
|
||||
# postgres:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
# username: root
|
||||
# password: root
|
||||
# sqlserver:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
||||
# username: SA
|
||||
# password: root
|
||||
hikari:
|
||||
# 最大连接池数量
|
||||
maxPoolSize: 20
|
||||
# 最小空闲线程数量
|
||||
minIdle: 10
|
||||
# 配置获取连接等待超时的时间
|
||||
connectionTimeout: 30000
|
||||
# 校验超时时间
|
||||
validationTimeout: 5000
|
||||
# 空闲连接存活最大时间,默认10分钟
|
||||
idleTimeout: 600000
|
||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||
maxLifetime: 1800000
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 123.207.99.140
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 2
|
||||
# redis 密码必须配置
|
||||
password: ccxx11234
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl.enabled: false
|
||||
|
||||
# redisson 配置
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称 不能用中文
|
||||
clientName: fys-Vue-Plus
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 8
|
||||
# 连接池大小
|
||||
connectionPoolSize: 32
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
--- # mail 邮件发送
|
||||
mail:
|
||||
enabled: false
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
# 是否需要用户名密码验证
|
||||
auth: true
|
||||
# 发送方,遵循RFC-822标准
|
||||
from: xxx@163.com
|
||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
||||
user: xxx@163.com
|
||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置密码,详情查看相关帮助)
|
||||
pass: xxxxxxxxxx
|
||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
||||
starttlsEnable: true
|
||||
# 使用SSL安全连接
|
||||
sslEnable: true
|
||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
||||
timeout: 0
|
||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
||||
connectionTimeout: 0
|
||||
|
||||
--- # sms 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
|
||||
# https://sms4j.com/doc3/ 差异配置文档地址 支持单厂商多配置,可以配置多个同时使用
|
||||
sms:
|
||||
# 配置源类型用于标定配置来源(interface,yaml)
|
||||
config-type: yaml
|
||||
# 用于标定yml中的配置是否开启短信拦截,接口配置不受此限制
|
||||
restricted: true
|
||||
# 短信拦截限制单手机号每分钟最大发送,只对开启了拦截的配置有效
|
||||
minute-max: 1
|
||||
# 短信拦截限制单手机号每日最大发送量,只对开启了拦截的配置有效
|
||||
account-max: 30
|
||||
# 以下配置来自于 com.fuyuanshen.sms4j.provider.config.BaseConfig类中
|
||||
blends:
|
||||
# 唯一ID 用于发送短信寻找具体配置 随便定义别用中文即可
|
||||
# 可以同时存在两个相同厂商 例如: ali1 ali2 两个不同的阿里短信账号 也可用于区分租户
|
||||
config1:
|
||||
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
supplier: alibaba
|
||||
# 有些称为accessKey有些称之为apiKey,也有称为sdkKey或者appId。
|
||||
access-key-id: 您的accessKey
|
||||
# 称为accessSecret有些称之为apiSecret
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
supplier: tencent
|
||||
access-key-id: 您的accessKey
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
|
||||
|
||||
--- # 三方授权
|
||||
justauth:
|
||||
# 前端外网访问地址
|
||||
address: http://localhost:80
|
||||
type:
|
||||
maxkey:
|
||||
# maxkey 服务器地址
|
||||
# 注意 如下均配置均不需要修改 maxkey 已经内置好了数据
|
||||
server-url: http://sso.maxkey.top
|
||||
client-id: 876892492581044224
|
||||
client-secret: x1Y5MTMwNzIwMjMxNTM4NDc3Mzche8
|
||||
redirect-uri: ${justauth.address}/social-callback?source=maxkey
|
||||
topiam:
|
||||
# topiam 服务器地址
|
||||
server-url: http://127.0.0.1:1898/api/v1/authorize/y0q************spq***********8ol
|
||||
client-id: 449c4*********937************759
|
||||
client-secret: ac7***********1e0************28d
|
||||
redirect-uri: ${justauth.address}/social-callback?source=topiam
|
||||
scopes: [openid, email, phone, profile]
|
||||
qq:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=qq
|
||||
union-id: false
|
||||
weibo:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=weibo
|
||||
gitee:
|
||||
client-id: 91436b7940090d09c72c7daf85b959cfd5f215d67eea73acbf61b6b590751a98
|
||||
client-secret: 02c6fcfd70342980cd8dd2f2c06c1a350645d76c754d7a264c4e125f9ba915ac
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitee
|
||||
dingtalk:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=dingtalk
|
||||
baidu:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=baidu
|
||||
csdn:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=csdn
|
||||
coding:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=coding
|
||||
coding-group-name: xx
|
||||
oschina:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=oschina
|
||||
alipay_wallet:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=alipay_wallet
|
||||
alipay-public-key: MIIB**************DAQAB
|
||||
wechat_open:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_open
|
||||
wechat_mp:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_mp
|
||||
wechat_enterprise:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_enterprise
|
||||
agent-id: 1000002
|
||||
gitlab:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
||||
gitea:
|
||||
# 前端改动 https://gitee.com/JavaLionLi/plus-ui/pulls/204
|
||||
# gitea 服务器地址
|
||||
server-url: https://demo.gitea.com
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitea
|
||||
@ -127,9 +127,6 @@ tenant:
|
||||
- sys_user_role
|
||||
- sys_client
|
||||
- sys_oss_config
|
||||
- app_menu
|
||||
- app_user_role
|
||||
- app_role_menu
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
@ -211,6 +208,8 @@ springdoc:
|
||||
packages-to-scan: com.fuyuanshen.generator
|
||||
- group: 5.工作流模块
|
||||
packages-to-scan: com.fuyuanshen.workflow
|
||||
- group: 设备管理模块
|
||||
packages-to-scan: com.fuyuanshen.equipment
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
|
||||
@ -93,6 +93,12 @@
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-core</artifactId>
|
||||
<version>3.5.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.fuyuanshen.common.core.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页结果封装类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
* @param <T>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
private List<T> content;
|
||||
|
||||
private long totalElements;
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.fuyuanshen.common.core.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 返回体
|
||||
* @Author: WY
|
||||
* @Date: 2025/6/2
|
||||
**/
|
||||
@Data
|
||||
public class ResponseVO<T> {
|
||||
|
||||
private Integer code; // 成功:0 失败:-1
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public ResponseVO(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResponseVO(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
// 静态方法,用于创建成功的响应
|
||||
public static <T> ResponseVO<T> success() {
|
||||
return new ResponseVO<>(0, "操作成功", null);
|
||||
}
|
||||
|
||||
public static <T> ResponseVO<T> success(T data) {
|
||||
return new ResponseVO<>(0, "操作成功", data);
|
||||
}
|
||||
|
||||
public static <T> ResponseVO<T> success(String msg, T data) {
|
||||
return new ResponseVO<>(0, msg, data);
|
||||
}
|
||||
|
||||
// 静态方法,用于创建失败的响应
|
||||
public static <T> ResponseVO<T> fail(String msg) {
|
||||
return new ResponseVO<>(-1, msg, null);
|
||||
}
|
||||
|
||||
public static <T> ResponseVO<T> fail(String msg, T data) {
|
||||
return new ResponseVO<>(-1, msg, data);
|
||||
}
|
||||
|
||||
// 链式方法 - 添加泛型支持
|
||||
public <R> ResponseVO<R> withData(R data) {
|
||||
return new ResponseVO<>(this.code, this.msg, data);
|
||||
}
|
||||
|
||||
public ResponseVO<T> withMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseVO<T> withCode(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,148 +0,0 @@
|
||||
package com.fuyuanshen.common.core.domain.model;
|
||||
|
||||
import com.fuyuanshen.common.core.domain.dto.PostDTO;
|
||||
import com.fuyuanshen.common.core.domain.dto.RoleDTO;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录用户身份权限
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class AppLoginUser implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 部门类别编码
|
||||
*/
|
||||
private String deptCategory;
|
||||
|
||||
/**
|
||||
* 部门名
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private Long loginTime;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Long expireTime;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 菜单权限
|
||||
*/
|
||||
private Set<String> menuPermission;
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
private Set<String> rolePermission;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
private List<RoleDTO> roles;
|
||||
|
||||
/**
|
||||
* 岗位对象
|
||||
*/
|
||||
private List<PostDTO> posts;
|
||||
|
||||
/**
|
||||
* 数据权限 当前角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*/
|
||||
private String clientKey;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 获取登录id
|
||||
*/
|
||||
public String getLoginId() {
|
||||
if (userType == null) {
|
||||
throw new IllegalArgumentException("用户类型不能为空");
|
||||
}
|
||||
if (userId == null) {
|
||||
throw new IllegalArgumentException("用户ID不能为空");
|
||||
}
|
||||
return userType + ":" + userId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.fuyuanshen.common.core.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface AppPermissionService {
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
Set<String> getRolePermission(Long userId);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
Set<String> getMenuPermission(Long userId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.common.core.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页工具
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-10
|
||||
*/
|
||||
public class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||
|
||||
/**
|
||||
* List 分页
|
||||
*/
|
||||
public static <T> List<T> paging(int page, int size , List<T> list) {
|
||||
int fromIndex = page * size;
|
||||
int toIndex = page * size + size;
|
||||
if(fromIndex > list.size()){
|
||||
return Collections.emptyList();
|
||||
} else if(toIndex >= list.size()) {
|
||||
return list.subList(fromIndex,list.size());
|
||||
} else {
|
||||
return list.subList(fromIndex,toIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page 数据处理
|
||||
*/
|
||||
public static <T> PageResult<T> toPage(IPage<T> page) {
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
public static <T> PageResult<T> toPage(List<T> list) {
|
||||
return new PageResult<>(list, list.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回空数据
|
||||
*/
|
||||
public static <T> PageResult<T> noData () {
|
||||
return new PageResult<>(null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
public static <T> PageResult<T> toPage(List<T> list, long totalElements) {
|
||||
return new PageResult<>(list, totalElements);
|
||||
}
|
||||
}
|
||||
@ -26,6 +26,11 @@
|
||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.therapi</groupId>
|
||||
<artifactId>therapi-runtime-javadoc</artifactId>
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.fuyuanshen.common.encrypt.utils;
|
||||
|
||||
import com.fuyuanshen.common.core.domain.model.LoginBody;
|
||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
||||
|
||||
/**
|
||||
* 登录测试
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-3014:29
|
||||
*/
|
||||
public class EncryptUtilsTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// System.out.println(EncryptUtils.encryptByBase64("123456"));
|
||||
|
||||
System.out.println(EncryptUtils.encryptByBase64("1234567890abcdef"));
|
||||
|
||||
String g = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
|
||||
String s = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
|
||||
|
||||
|
||||
String s1 = EncryptUtils.encryptByRsa("MTIzNDU2Nzg5MGFiY2RlZg==", g);
|
||||
System.out.println(s1);
|
||||
String s2 = EncryptUtils.decryptByRsa("jJPaW7hgFXD/gjdkrfBOEUdXpPZnQg/LZUASoOJAOLU/XRVXO/5666CzyALjw7neK1ujvRuys4MdKCvr9cRARw==", s);
|
||||
System.out.println(s2);
|
||||
|
||||
String s3 = EncryptUtils.decryptByBase64(s2);
|
||||
System.out.println(s3);
|
||||
|
||||
String s4 = EncryptUtils.encryptByAes("123456", s3);
|
||||
System.out.println(s4);
|
||||
|
||||
String s5 = EncryptUtils.decryptByAes(s4, s3);
|
||||
System.out.println(s5);
|
||||
|
||||
|
||||
// 1. 构造 LoginBody 对象
|
||||
PasswordLoginBody loginBody = new PasswordLoginBody();
|
||||
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
|
||||
loginBody.setGrantType("password");
|
||||
loginBody.setTenantId("000000");
|
||||
loginBody.setCode("9");
|
||||
loginBody.setUuid("04ab60c877ae4bb19e3c09ff5cb2a638");
|
||||
loginBody.setUsername("admin");
|
||||
loginBody.setPassword("admin123");
|
||||
|
||||
// 2. 使用更清晰的方式拼接 JSON 字符串
|
||||
String jsonLoginBody = String.format(
|
||||
"{"
|
||||
+ "\"clientId\":\"%s\","
|
||||
+ "\"grantType\":\"%s\","
|
||||
+ "\"tenantId\":\"%s\","
|
||||
+ "\"code\":\"%s\","
|
||||
+ "\"uuid\":\"%s\","
|
||||
+ "\"username\":\"%s\","
|
||||
+ "\"password\":\"%s\""
|
||||
+ "}",
|
||||
loginBody.getClientId(),
|
||||
loginBody.getGrantType(),
|
||||
loginBody.getTenantId(),
|
||||
loginBody.getCode(),
|
||||
loginBody.getUuid(),
|
||||
loginBody.getUsername(),
|
||||
loginBody.getPassword()
|
||||
);
|
||||
|
||||
|
||||
String S5 = EncryptUtils.encryptByAes(jsonLoginBody, s3);
|
||||
System.out.println(S5);
|
||||
|
||||
String S6 = EncryptUtils.decryptByAes(S5, s3);
|
||||
System.out.println(S6);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,15 +2,12 @@ package com.fuyuanshen.common.satoken.core.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.enums.UserType;
|
||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||
import com.fuyuanshen.common.core.service.AppPermissionService;
|
||||
import com.fuyuanshen.common.core.service.PermissionService;
|
||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -28,42 +25,22 @@ public class SaPermissionImpl implements StpInterface {
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
if(loginId.toString().startsWith(UserType.APP_USER.getUserType())){
|
||||
AppLoginUser loginUser = AppLoginHelper.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser) || !loginUser.getLoginId().equals(loginId)) {
|
||||
AppPermissionService permissionService = getAppPermissionService();
|
||||
if (ObjectUtil.isNotNull(permissionService)) {
|
||||
List<String> list = StringUtils.splitList(loginId.toString(), ":");
|
||||
return new ArrayList<>(permissionService.getMenuPermission(Long.parseLong(list.get(1))));
|
||||
} else {
|
||||
throw new ServiceException("PermissionService 实现类不存在");
|
||||
}
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser) || !loginUser.getLoginId().equals(loginId)) {
|
||||
PermissionService permissionService = getPermissionService();
|
||||
if (ObjectUtil.isNotNull(permissionService)) {
|
||||
List<String> list = StringUtils.splitList(loginId.toString(), ":");
|
||||
return new ArrayList<>(permissionService.getMenuPermission(Long.parseLong(list.get(1))));
|
||||
} else {
|
||||
throw new ServiceException("PermissionService 实现类不存在");
|
||||
}
|
||||
UserType userType = UserType.getUserType(loginUser.getUserType());
|
||||
if (userType == UserType.APP_USER) {
|
||||
// 其他端 自行根据业务编写
|
||||
}
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
}else {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser) || !loginUser.getLoginId().equals(loginId)) {
|
||||
PermissionService permissionService = getPermissionService();
|
||||
if (ObjectUtil.isNotNull(permissionService)) {
|
||||
List<String> list = StringUtils.splitList(loginId.toString(), ":");
|
||||
return new ArrayList<>(permissionService.getMenuPermission(Long.parseLong(list.get(1))));
|
||||
} else {
|
||||
throw new ServiceException("PermissionService 实现类不存在");
|
||||
}
|
||||
}
|
||||
UserType userType = UserType.getUserType(loginUser.getUserType());
|
||||
if (userType == UserType.APP_USER) {
|
||||
// 其他端 自行根据业务编写
|
||||
}
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
}
|
||||
|
||||
UserType userType = UserType.getUserType(loginUser.getUserType());
|
||||
if (userType == UserType.APP_USER) {
|
||||
// 其他端 自行根据业务编写
|
||||
}
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,12 +74,4 @@ public class SaPermissionImpl implements StpInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private AppPermissionService getAppPermissionService() {
|
||||
try {
|
||||
return SpringUtils.getBean(AppPermissionService.class);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,217 +0,0 @@
|
||||
package com.fuyuanshen.common.satoken.utils;
|
||||
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.enums.UserType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* 登录鉴权助手
|
||||
* <p>
|
||||
* user_type 为 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
|
||||
* deivce 为 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
|
||||
* 可以组成 用户类型与设备类型多对多的 权限灵活控制
|
||||
* <p>
|
||||
* 多用户体系 针对 多种用户类型 但权限控制不一致
|
||||
* 可以组成 多用户类型表与多设备类型 分别控制权限
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AppLoginHelper {
|
||||
|
||||
public static final String LOGIN_USER_KEY = "appLoginUser";
|
||||
public static final String TENANT_KEY = "tenantId";
|
||||
public static final String USER_KEY = "userId";
|
||||
public static final String USER_NAME_KEY = "userName";
|
||||
public static final String DEPT_KEY = "deptId";
|
||||
public static final String DEPT_NAME_KEY = "deptName";
|
||||
public static final String DEPT_CATEGORY_KEY = "deptCategory";
|
||||
public static final String CLIENT_KEY = "clientid";
|
||||
|
||||
/**
|
||||
* 登录系统 基于 设备类型
|
||||
* 针对相同用户体系不同设备
|
||||
*
|
||||
* @param loginUser 登录用户信息
|
||||
* @param model 配置参数
|
||||
*/
|
||||
public static void login(AppLoginUser loginUser, SaLoginParameter model) {
|
||||
model = ObjectUtil.defaultIfNull(model, new SaLoginParameter());
|
||||
StpUtil.login(loginUser.getLoginId(),
|
||||
model.setExtra(TENANT_KEY, loginUser.getTenantId())
|
||||
.setExtra(USER_KEY, loginUser.getUserId())
|
||||
.setExtra(USER_NAME_KEY, loginUser.getUsername())
|
||||
.setExtra(DEPT_KEY, loginUser.getDeptId())
|
||||
.setExtra(DEPT_NAME_KEY, loginUser.getDeptName())
|
||||
.setExtra(DEPT_CATEGORY_KEY, loginUser.getDeptCategory())
|
||||
);
|
||||
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户(多级缓存)
|
||||
*/
|
||||
@SuppressWarnings("unchecked cast")
|
||||
public static <T extends AppLoginUser> T getLoginUser() {
|
||||
SaSession session = StpUtil.getTokenSession();
|
||||
if (ObjectUtil.isNull(session)) {
|
||||
return null;
|
||||
}
|
||||
return (T) session.get(LOGIN_USER_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户基于token
|
||||
*/
|
||||
@SuppressWarnings("unchecked cast")
|
||||
public static <T extends AppLoginUser> T getLoginUser(String token) {
|
||||
SaSession session = StpUtil.getTokenSessionByToken(token);
|
||||
if (ObjectUtil.isNull(session)) {
|
||||
return null;
|
||||
}
|
||||
return (T) session.get(LOGIN_USER_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*/
|
||||
public static Long getUserId() {
|
||||
return Convert.toLong(getExtra(USER_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*/
|
||||
public static String getUserIdStr() {
|
||||
return Convert.toStr(getExtra(USER_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
*/
|
||||
public static String getUsername() {
|
||||
return Convert.toStr(getExtra(USER_NAME_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户ID
|
||||
*/
|
||||
public static String getTenantId() {
|
||||
return Convert.toStr(getExtra(TENANT_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
*/
|
||||
public static Long getDeptId() {
|
||||
return Convert.toLong(getExtra(DEPT_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门名
|
||||
*/
|
||||
public static String getDeptName() {
|
||||
return Convert.toStr(getExtra(DEPT_NAME_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门类别编码
|
||||
*/
|
||||
public static String getDeptCategory() {
|
||||
return Convert.toStr(getExtra(DEPT_CATEGORY_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Token 的扩展信息
|
||||
*
|
||||
* @param key 键值
|
||||
* @return 对应的扩展数据
|
||||
*/
|
||||
private static Object getExtra(String key) {
|
||||
try {
|
||||
return StpUtil.getExtra(key);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户类型
|
||||
*/
|
||||
public static UserType getUserType() {
|
||||
String loginType = StpUtil.getLoginIdAsString();
|
||||
return UserType.getUserType(loginType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isSuperAdmin(Long userId) {
|
||||
return SystemConstants.SUPER_ADMIN_ID.equals(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isSuperAdmin() {
|
||||
return isSuperAdmin(getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为租户管理员
|
||||
*
|
||||
* @param rolePermission 角色权限标识组
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isTenantAdmin(Set<String> rolePermission) {
|
||||
if (CollUtil.isEmpty(rolePermission)) {
|
||||
return false;
|
||||
}
|
||||
return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为租户管理员
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isTenantAdmin() {
|
||||
AppLoginUser loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return false;
|
||||
}
|
||||
return Convert.toBool(isTenantAdmin(loginUser.getRolePermission()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前用户是否已登录
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isLogin() {
|
||||
try {
|
||||
return getLoginUser() != null;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleBo;
|
||||
import com.fuyuanshen.app.service.IAppRoleService;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/role")
|
||||
public class AppRoleController extends BaseController {
|
||||
|
||||
private final IAppRoleService appRoleService;
|
||||
|
||||
/**
|
||||
* 查询角色信息列表
|
||||
*/
|
||||
@SaCheckPermission("app:role:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppRoleVo> list(AppRoleBo bo, PageQuery pageQuery) {
|
||||
return appRoleService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出角色信息列表
|
||||
*/
|
||||
@SaCheckPermission("app:role:export")
|
||||
@Log(title = "角色信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(AppRoleBo bo, HttpServletResponse response) {
|
||||
List<AppRoleVo> list = appRoleService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "角色信息", AppRoleVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色信息详细信息
|
||||
*
|
||||
* @param roleId 主键
|
||||
*/
|
||||
@SaCheckPermission("app:role:query")
|
||||
@GetMapping("/{roleId}")
|
||||
public R<AppRoleVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long roleId) {
|
||||
return R.ok(appRoleService.queryById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色信息
|
||||
*/
|
||||
@SaCheckPermission("app:role:add")
|
||||
@Log(title = "角色信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppRoleBo bo) {
|
||||
return toAjax(appRoleService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*/
|
||||
@SaCheckPermission("app:role:edit")
|
||||
@Log(title = "角色信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppRoleBo bo) {
|
||||
return toAjax(appRoleService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色信息
|
||||
*
|
||||
* @param roleIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("app:role:remove")
|
||||
@Log(title = "角色信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] roleIds) {
|
||||
return toAjax(appRoleService.deleteWithValidByIds(List.of(roleIds), true));
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleMenuVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleMenuBo;
|
||||
import com.fuyuanshen.app.service.IAppRoleMenuService;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/roleMenu")
|
||||
public class AppRoleMenuController extends BaseController {
|
||||
|
||||
private final IAppRoleMenuService appRoleMenuService;
|
||||
|
||||
/**
|
||||
* 查询角色和菜单关联列表
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppRoleMenuVo> list(AppRoleMenuBo bo, PageQuery pageQuery) {
|
||||
return appRoleMenuService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出角色和菜单关联列表
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:export")
|
||||
@Log(title = "角色和菜单关联", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(AppRoleMenuBo bo, HttpServletResponse response) {
|
||||
List<AppRoleMenuVo> list = appRoleMenuService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "角色和菜单关联", AppRoleMenuVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色和菜单关联详细信息
|
||||
*
|
||||
* @param roleId 主键
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:query")
|
||||
@GetMapping("/{roleId}")
|
||||
public R<AppRoleMenuVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long roleId) {
|
||||
return R.ok(appRoleMenuService.queryById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色和菜单关联
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:add")
|
||||
@Log(title = "角色和菜单关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppRoleMenuBo bo) {
|
||||
return toAjax(appRoleMenuService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色和菜单关联
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:edit")
|
||||
@Log(title = "角色和菜单关联", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppRoleMenuBo bo) {
|
||||
return toAjax(appRoleMenuService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色和菜单关联
|
||||
*
|
||||
* @param roleIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("app:roleMenu:remove")
|
||||
@Log(title = "角色和菜单关联", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] roleIds) {
|
||||
return toAjax(appRoleMenuService.deleteWithValidByIds(List.of(roleIds), true));
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* APP用户信息
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
public class AppUserController extends BaseController {
|
||||
|
||||
private final IAppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 查询APP用户信息列表
|
||||
*/
|
||||
// @SaCheckPermission("app:user:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppUserVo> list(AppUserBo bo, PageQuery pageQuery) {
|
||||
return appUserService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出APP用户信息列表
|
||||
*/
|
||||
@SaCheckPermission("app:user:export")
|
||||
@Log(title = "APP用户信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(AppUserBo bo, HttpServletResponse response) {
|
||||
List<AppUserVo> list = appUserService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "APP用户信息", AppUserVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APP用户信息详细信息
|
||||
*
|
||||
* @param userId 主键
|
||||
*/
|
||||
@SaCheckPermission("app:user:query")
|
||||
@GetMapping("/{userId}")
|
||||
public R<AppUserVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long userId) {
|
||||
return R.ok(appUserService.queryById(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增APP用户信息
|
||||
*/
|
||||
@SaCheckPermission("app:user:add")
|
||||
@Log(title = "APP用户信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppUserBo bo) {
|
||||
return toAjax(appUserService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改APP用户信息
|
||||
*/
|
||||
@SaCheckPermission("app:user:edit")
|
||||
@Log(title = "APP用户信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppUserBo bo) {
|
||||
return toAjax(appUserService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除APP用户信息
|
||||
*
|
||||
* @param userIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("app:user:remove")
|
||||
@Log(title = "APP用户信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] userIds) {
|
||||
return toAjax(appUserService.deleteWithValidByIds(List.of(userIds), true));
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserRoleVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserRoleBo;
|
||||
import com.fuyuanshen.app.service.IAppUserRoleService;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 用户和角色关联
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/userRole")
|
||||
public class AppUserRoleController extends BaseController {
|
||||
|
||||
private final IAppUserRoleService appUserRoleService;
|
||||
|
||||
/**
|
||||
* 查询用户和角色关联列表
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppUserRoleVo> list(AppUserRoleBo bo, PageQuery pageQuery) {
|
||||
return appUserRoleService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户和角色关联列表
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:export")
|
||||
@Log(title = "用户和角色关联", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(AppUserRoleBo bo, HttpServletResponse response) {
|
||||
List<AppUserRoleVo> list = appUserRoleService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "用户和角色关联", AppUserRoleVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户和角色关联详细信息
|
||||
*
|
||||
* @param userId 主键
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:query")
|
||||
@GetMapping("/{userId}")
|
||||
public R<AppUserRoleVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long userId) {
|
||||
return R.ok(appUserRoleService.queryById(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户和角色关联
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:add")
|
||||
@Log(title = "用户和角色关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppUserRoleBo bo) {
|
||||
return toAjax(appUserRoleService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户和角色关联
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:edit")
|
||||
@Log(title = "用户和角色关联", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppUserRoleBo bo) {
|
||||
return toAjax(appUserRoleService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户和角色关联
|
||||
*
|
||||
* @param userIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("app:userRole:remove")
|
||||
@Log(title = "用户和角色关联", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] userIds) {
|
||||
return toAjax(appUserRoleService.deleteWithValidByIds(List.of(userIds), true));
|
||||
}
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 菜单权限对象 app_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("app_menu")
|
||||
public class AppMenu extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@TableId(value = "menu_id")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long orderNum;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
*/
|
||||
private Long isFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存(0缓存 1不缓存)
|
||||
*/
|
||||
private Long isCache;
|
||||
|
||||
/**
|
||||
* 菜单类型(M目录 C菜单 F按钮)
|
||||
*/
|
||||
private String menuType;
|
||||
|
||||
/**
|
||||
* 显示状态(0显示 1隐藏)
|
||||
*/
|
||||
private String visible;
|
||||
|
||||
/**
|
||||
* 菜单状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 角色信息对象 app_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("app_role")
|
||||
public class AppRole extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId(value = "role_id")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限字符串
|
||||
*/
|
||||
private String roleKey;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long roleSort;
|
||||
|
||||
/**
|
||||
* 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限 5:仅本人数据权限 6:部门及以下或本人数据权限)
|
||||
*/
|
||||
private String dataScope;
|
||||
|
||||
/**
|
||||
* 菜单树选择项是否关联显示
|
||||
*/
|
||||
private Long menuCheckStrictly;
|
||||
|
||||
/**
|
||||
* 部门树选择项是否关联显示
|
||||
*/
|
||||
private Long deptCheckStrictly;
|
||||
|
||||
/**
|
||||
* 角色状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联对象 app_role_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("app_role_menu")
|
||||
public class AppRoleMenu extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId(value = "role_id")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
private Long menuId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* APP用户信息对象 app_user
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("app_user")
|
||||
public class AppUser extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户类型(app_user系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户和角色关联对象 app_user_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("app_user_role")
|
||||
public class AppUserRole extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.bo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppMenu;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 菜单权限业务对象 app_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = AppMenu.class, reverseConvertGenerate = false)
|
||||
public class AppMenuBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@NotNull(message = "菜单ID不能为空", groups = { EditGroup.class })
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@NotBlank(message = "菜单名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Long orderNum;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
*/
|
||||
private Long isFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存(0缓存 1不缓存)
|
||||
*/
|
||||
private Long isCache;
|
||||
|
||||
/**
|
||||
* 菜单类型(M目录 C菜单 F按钮)
|
||||
*/
|
||||
private String menuType;
|
||||
|
||||
/**
|
||||
* 显示状态(0显示 1隐藏)
|
||||
*/
|
||||
private String visible;
|
||||
|
||||
/**
|
||||
* 菜单状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.bo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRole;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 角色信息业务对象 app_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = AppRole.class, reverseConvertGenerate = false)
|
||||
public class AppRoleBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@NotNull(message = "角色ID不能为空", groups = { EditGroup.class })
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@NotBlank(message = "角色名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限字符串
|
||||
*/
|
||||
@NotBlank(message = "角色权限字符串不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String roleKey;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@NotNull(message = "显示顺序不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long roleSort;
|
||||
|
||||
/**
|
||||
* 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限 5:仅本人数据权限 6:部门及以下或本人数据权限)
|
||||
*/
|
||||
private String dataScope;
|
||||
|
||||
/**
|
||||
* 菜单树选择项是否关联显示
|
||||
*/
|
||||
private Long menuCheckStrictly;
|
||||
|
||||
/**
|
||||
* 部门树选择项是否关联显示
|
||||
*/
|
||||
private Long deptCheckStrictly;
|
||||
|
||||
/**
|
||||
* 角色状态(0正常 1停用)
|
||||
*/
|
||||
@NotBlank(message = "角色状态(0正常 1停用)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.bo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRoleMenu;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联业务对象 app_role_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = AppRoleMenu.class, reverseConvertGenerate = false)
|
||||
public class AppRoleMenuBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@NotNull(message = "角色ID不能为空", groups = { EditGroup.class })
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@NotNull(message = "菜单ID不能为空", groups = { EditGroup.class })
|
||||
private Long menuId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,94 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.bo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* APP用户信息业务对象 app_user
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = AppUser.class, reverseConvertGenerate = false)
|
||||
public class AppUserBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空", groups = { EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@NotBlank(message = "用户账号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@NotBlank(message = "用户昵称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户类型(app_user系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.bo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppUserRole;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 用户和角色关联业务对象 app_user_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = AppUserRole.class, reverseConvertGenerate = false)
|
||||
public class AppUserRoleBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空", groups = { EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@NotNull(message = "角色ID不能为空", groups = { EditGroup.class })
|
||||
private Long roleId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,127 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppMenu;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 菜单权限视图对象 app_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = AppMenu.class)
|
||||
public class AppMenuVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@ExcelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@ExcelProperty(value = "菜单名称")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
@ExcelProperty(value = "父菜单ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@ExcelProperty(value = "显示顺序")
|
||||
private Long orderNum;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
@ExcelProperty(value = "路由地址")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
@ExcelProperty(value = "组件路径")
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
@ExcelProperty(value = "路由参数")
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
*/
|
||||
@ExcelProperty(value = "是否为外链", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=是,1=否")
|
||||
private Long isFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存(0缓存 1不缓存)
|
||||
*/
|
||||
@ExcelProperty(value = "是否缓存", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=缓存,1=不缓存")
|
||||
private Long isCache;
|
||||
|
||||
/**
|
||||
* 菜单类型(M目录 C菜单 F按钮)
|
||||
*/
|
||||
@ExcelProperty(value = "菜单类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "M=目录,C=菜单,F=按钮")
|
||||
private String menuType;
|
||||
|
||||
/**
|
||||
* 显示状态(0显示 1隐藏)
|
||||
*/
|
||||
@ExcelProperty(value = "显示状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=显示,1=隐藏")
|
||||
private String visible;
|
||||
|
||||
/**
|
||||
* 菜单状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "菜单状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
@ExcelProperty(value = "权限标识")
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@ExcelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRoleMenu;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 角色和菜单关联视图对象 app_role_menu
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = AppRoleMenu.class)
|
||||
public class AppRoleMenuVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@ExcelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@ExcelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRole;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 角色信息视图对象 app_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = AppRole.class)
|
||||
public class AppRoleVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@ExcelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@ExcelProperty(value = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限字符串
|
||||
*/
|
||||
@ExcelProperty(value = "角色权限字符串")
|
||||
private String roleKey;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@ExcelProperty(value = "显示顺序")
|
||||
private Long roleSort;
|
||||
|
||||
/**
|
||||
* 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限 5:仅本人数据权限 6:部门及以下或本人数据权限)
|
||||
*/
|
||||
@ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "1=:全部数据权限,2=:自定数据权限,3=:本部门数据权限,4=:本部门及以下数据权限,5=:仅本人数据权限,6=:部门及以下或本人数据权限")
|
||||
private String dataScope;
|
||||
|
||||
/**
|
||||
* 菜单树选择项是否关联显示
|
||||
*/
|
||||
@ExcelProperty(value = "菜单树选择项是否关联显示")
|
||||
private Long menuCheckStrictly;
|
||||
|
||||
/**
|
||||
* 部门树选择项是否关联显示
|
||||
*/
|
||||
@ExcelProperty(value = "部门树选择项是否关联显示")
|
||||
private Long deptCheckStrictly;
|
||||
|
||||
/**
|
||||
* 角色状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppUserRole;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户和角色关联视图对象 app_user_role
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = AppUserRole.class)
|
||||
public class AppUserRoleVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@ExcelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@ExcelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,123 +0,0 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* APP用户信息视图对象 app_user
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = AppUser.class)
|
||||
public class AppUserVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@ExcelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@ExcelProperty(value = "用户账号")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@ExcelProperty(value = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户类型(app_user系统用户)
|
||||
*/
|
||||
@ExcelProperty(value = "用户类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "a=pp_user系统用户")
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@ExcelProperty(value = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ExcelProperty(value = "手机号码")
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
@ExcelProperty(value = "用户性别", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
@ExcelProperty(value = "头像地址")
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ExcelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@ExcelProperty(value = "最后登录IP")
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
@ExcelProperty(value = "最后登录时间")
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppMenu;
|
||||
import com.fuyuanshen.app.domain.vo.AppMenuVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单权限Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface AppMenuMapper extends BaseMapperPlus<AppMenu, AppMenuVo> {
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByUserId(Long userId);
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRole;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.common.mybatis.annotation.DataColumn;
|
||||
import com.fuyuanshen.common.mybatis.annotation.DataPermission;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色信息Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface AppRoleMapper extends BaseMapperPlus<AppRole, AppRoleVo> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<AppRoleVo> selectRolesByUserId(Long userId);
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppRoleMenu;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleMenuVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface AppRoleMenuMapper extends BaseMapperPlus<AppRoleMenu, AppRoleMenuVo> {
|
||||
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* APP用户信息Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.fuyuanshen.app.domain.AppUserRole;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserRoleVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 用户和角色关联Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface AppUserRoleMapper extends BaseMapperPlus<AppUserRole, AppUserRoleVo> {
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单权限Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IAppMenuService {
|
||||
Set<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface IAppPermissionService {
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
Set<String> getRolePermission(Long userId);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
Set<String> getMenuPermission(Long userId);
|
||||
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleMenuVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleMenuBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IAppRoleMenuService {
|
||||
|
||||
/**
|
||||
* 查询角色和菜单关联
|
||||
*
|
||||
* @param roleId 主键
|
||||
* @return 角色和菜单关联
|
||||
*/
|
||||
AppRoleMenuVo queryById(Long roleId);
|
||||
|
||||
/**
|
||||
* 分页查询角色和菜单关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色和菜单关联分页列表
|
||||
*/
|
||||
TableDataInfo<AppRoleMenuVo> queryPageList(AppRoleMenuBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的角色和菜单关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 角色和菜单关联列表
|
||||
*/
|
||||
List<AppRoleMenuVo> queryList(AppRoleMenuBo bo);
|
||||
|
||||
/**
|
||||
* 新增角色和菜单关联
|
||||
*
|
||||
* @param bo 角色和菜单关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(AppRoleMenuBo bo);
|
||||
|
||||
/**
|
||||
* 修改角色和菜单关联
|
||||
*
|
||||
* @param bo 角色和菜单关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(AppRoleMenuBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除角色和菜单关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色信息Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IAppRoleService {
|
||||
|
||||
/**
|
||||
* 查询角色信息
|
||||
*
|
||||
* @param roleId 主键
|
||||
* @return 角色信息
|
||||
*/
|
||||
AppRoleVo queryById(Long roleId);
|
||||
|
||||
/**
|
||||
* 分页查询角色信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色信息分页列表
|
||||
*/
|
||||
TableDataInfo<AppRoleVo> queryPageList(AppRoleBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的角色信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 角色信息列表
|
||||
*/
|
||||
List<AppRoleVo> queryList(AppRoleBo bo);
|
||||
|
||||
/**
|
||||
* 新增角色信息
|
||||
*
|
||||
* @param bo 角色信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(AppRoleBo bo);
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*
|
||||
* @param bo 角色信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(AppRoleBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除角色信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
Set<String> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<AppRoleVo> selectRolesByUserId(Long userId);
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppUserRoleVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserRoleBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户和角色关联Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IAppUserRoleService {
|
||||
|
||||
/**
|
||||
* 查询用户和角色关联
|
||||
*
|
||||
* @param userId 主键
|
||||
* @return 用户和角色关联
|
||||
*/
|
||||
AppUserRoleVo queryById(Long userId);
|
||||
|
||||
/**
|
||||
* 分页查询用户和角色关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 用户和角色关联分页列表
|
||||
*/
|
||||
TableDataInfo<AppUserRoleVo> queryPageList(AppUserRoleBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的用户和角色关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 用户和角色关联列表
|
||||
*/
|
||||
List<AppUserRoleVo> queryList(AppUserRoleBo bo);
|
||||
|
||||
/**
|
||||
* 新增用户和角色关联
|
||||
*
|
||||
* @param bo 用户和角色关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(AppUserRoleBo bo);
|
||||
|
||||
/**
|
||||
* 修改用户和角色关联
|
||||
*
|
||||
* @param bo 用户和角色关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(AppUserRoleBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除用户和角色关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP用户信息Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IAppUserService {
|
||||
|
||||
/**
|
||||
* 查询APP用户信息
|
||||
*
|
||||
* @param userId 主键
|
||||
* @return APP用户信息
|
||||
*/
|
||||
AppUserVo queryById(Long userId);
|
||||
|
||||
/**
|
||||
* 分页查询APP用户信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return APP用户信息分页列表
|
||||
*/
|
||||
TableDataInfo<AppUserVo> queryPageList(AppUserBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的APP用户信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return APP用户信息列表
|
||||
*/
|
||||
List<AppUserVo> queryList(AppUserBo bo);
|
||||
|
||||
/**
|
||||
* 新增APP用户信息
|
||||
*
|
||||
* @param bo APP用户信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(AppUserBo bo);
|
||||
|
||||
/**
|
||||
* 修改APP用户信息
|
||||
*
|
||||
* @param bo APP用户信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(AppUserBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除APP用户信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.mapper.AppRoleMapper;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppMenuBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppMenuVo;
|
||||
import com.fuyuanshen.app.domain.AppMenu;
|
||||
import com.fuyuanshen.app.mapper.AppMenuMapper;
|
||||
import com.fuyuanshen.app.service.IAppMenuService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 菜单权限Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppMenuServiceImpl implements IAppMenuService {
|
||||
|
||||
private final AppMenuMapper baseMapper;
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = baseMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.fuyuanshen.app.service.IAppMenuService;
|
||||
import com.fuyuanshen.app.service.IAppPermissionService;
|
||||
import com.fuyuanshen.app.service.IAppRoleService;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.service.AppPermissionService;
|
||||
import com.fuyuanshen.common.core.service.PermissionService;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*
|
||||
* @author fys
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppPermissionServiceImpl implements IAppPermissionService, AppPermissionService {
|
||||
|
||||
private final IAppRoleService roleService;
|
||||
private final IAppMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getRolePermission(Long userId) {
|
||||
Set<String> roles = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
roles.add(TenantConstants.SUPER_ADMIN_ROLE_KEY);
|
||||
} else {
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(userId));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getMenuPermission(Long userId) {
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(userId));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
@ -1,131 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleMenuBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleMenuVo;
|
||||
import com.fuyuanshen.app.domain.AppRoleMenu;
|
||||
import com.fuyuanshen.app.mapper.AppRoleMenuMapper;
|
||||
import com.fuyuanshen.app.service.IAppRoleMenuService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppRoleMenuServiceImpl implements IAppRoleMenuService {
|
||||
|
||||
private final AppRoleMenuMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询角色和菜单关联
|
||||
*
|
||||
* @param roleId 主键
|
||||
* @return 角色和菜单关联
|
||||
*/
|
||||
@Override
|
||||
public AppRoleMenuVo queryById(Long roleId){
|
||||
return baseMapper.selectVoById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询角色和菜单关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色和菜单关联分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<AppRoleMenuVo> queryPageList(AppRoleMenuBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<AppRoleMenu> lqw = buildQueryWrapper(bo);
|
||||
Page<AppRoleMenuVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的角色和菜单关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 角色和菜单关联列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppRoleMenuVo> queryList(AppRoleMenuBo bo) {
|
||||
LambdaQueryWrapper<AppRoleMenu> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppRoleMenu> buildQueryWrapper(AppRoleMenuBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AppRoleMenu> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AppRoleMenu::getRoleId);
|
||||
lqw.orderByAsc(AppRoleMenu::getMenuId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色和菜单关联
|
||||
*
|
||||
* @param bo 角色和菜单关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(AppRoleMenuBo bo) {
|
||||
AppRoleMenu add = MapstructUtils.convert(bo, AppRoleMenu.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setRoleId(add.getRoleId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色和菜单关联
|
||||
*
|
||||
* @param bo 角色和菜单关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(AppRoleMenuBo bo) {
|
||||
AppRoleMenu update = MapstructUtils.convert(bo, AppRoleMenu.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(AppRoleMenu entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除角色和菜单关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -1,160 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppRoleBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.AppRole;
|
||||
import com.fuyuanshen.app.mapper.AppRoleMapper;
|
||||
import com.fuyuanshen.app.service.IAppRoleService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 角色信息Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppRoleServiceImpl implements IAppRoleService {
|
||||
|
||||
private final AppRoleMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询角色信息
|
||||
*
|
||||
* @param roleId 主键
|
||||
* @return 角色信息
|
||||
*/
|
||||
@Override
|
||||
public AppRoleVo queryById(Long roleId){
|
||||
return baseMapper.selectVoById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询角色信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<AppRoleVo> queryPageList(AppRoleBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<AppRole> lqw = buildQueryWrapper(bo);
|
||||
Page<AppRoleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的角色信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 角色信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppRoleVo> queryList(AppRoleBo bo) {
|
||||
LambdaQueryWrapper<AppRole> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppRole> buildQueryWrapper(AppRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AppRole> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AppRole::getRoleId);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRoleName()), AppRole::getRoleName, bo.getRoleName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRoleKey()), AppRole::getRoleKey, bo.getRoleKey());
|
||||
lqw.eq(bo.getRoleSort() != null, AppRole::getRoleSort, bo.getRoleSort());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDataScope()), AppRole::getDataScope, bo.getDataScope());
|
||||
lqw.eq(bo.getMenuCheckStrictly() != null, AppRole::getMenuCheckStrictly, bo.getMenuCheckStrictly());
|
||||
lqw.eq(bo.getDeptCheckStrictly() != null, AppRole::getDeptCheckStrictly, bo.getDeptCheckStrictly());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), AppRole::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色信息
|
||||
*
|
||||
* @param bo 角色信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(AppRoleBo bo) {
|
||||
AppRole add = MapstructUtils.convert(bo, AppRole.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setRoleId(add.getRoleId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*
|
||||
* @param bo 角色信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(AppRoleBo bo) {
|
||||
AppRole update = MapstructUtils.convert(bo, AppRole.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(AppRole entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除角色信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId) {
|
||||
List<AppRoleVo> perms = baseMapper.selectRolesByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (AppRoleVo perm : perms) {
|
||||
if (ObjectUtil.isNotNull(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppRoleVo> selectRolesByUserId(Long userId) {
|
||||
return baseMapper.selectRolesByUserId(userId);
|
||||
}
|
||||
}
|
||||
@ -1,131 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserRoleBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserRoleVo;
|
||||
import com.fuyuanshen.app.domain.AppUserRole;
|
||||
import com.fuyuanshen.app.mapper.AppUserRoleMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserRoleService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 用户和角色关联Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppUserRoleServiceImpl implements IAppUserRoleService {
|
||||
|
||||
private final AppUserRoleMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询用户和角色关联
|
||||
*
|
||||
* @param userId 主键
|
||||
* @return 用户和角色关联
|
||||
*/
|
||||
@Override
|
||||
public AppUserRoleVo queryById(Long userId){
|
||||
return baseMapper.selectVoById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户和角色关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 用户和角色关联分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<AppUserRoleVo> queryPageList(AppUserRoleBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<AppUserRole> lqw = buildQueryWrapper(bo);
|
||||
Page<AppUserRoleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的用户和角色关联列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 用户和角色关联列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppUserRoleVo> queryList(AppUserRoleBo bo) {
|
||||
LambdaQueryWrapper<AppUserRole> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppUserRole> buildQueryWrapper(AppUserRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AppUserRole> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AppUserRole::getUserId);
|
||||
lqw.orderByAsc(AppUserRole::getRoleId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户和角色关联
|
||||
*
|
||||
* @param bo 用户和角色关联
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(AppUserRoleBo bo) {
|
||||
AppUserRole add = MapstructUtils.convert(bo, AppUserRole.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setUserId(add.getUserId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户和角色关联
|
||||
*
|
||||
* @param bo 用户和角色关联
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(AppUserRoleBo bo) {
|
||||
AppUserRole update = MapstructUtils.convert(bo, AppUserRole.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(AppUserRole entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除用户和角色关联信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -1,142 +0,0 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppUserServiceImpl implements IAppUserService {
|
||||
|
||||
private final AppUserMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询APP用户信息
|
||||
*
|
||||
* @param userId 主键
|
||||
* @return APP用户信息
|
||||
*/
|
||||
@Override
|
||||
public AppUserVo queryById(Long userId){
|
||||
return baseMapper.selectVoById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询APP用户信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return APP用户信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<AppUserVo> queryPageList(AppUserBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<AppUser> lqw = buildQueryWrapper(bo);
|
||||
Page<AppUserVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的APP用户信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return APP用户信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<AppUserVo> queryList(AppUserBo bo) {
|
||||
LambdaQueryWrapper<AppUser> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppUser> buildQueryWrapper(AppUserBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<AppUser> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(AppUser::getUserId);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUserName()), AppUser::getUserName, bo.getUserName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getNickName()), AppUser::getNickName, bo.getNickName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUserType()), AppUser::getUserType, bo.getUserType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getEmail()), AppUser::getEmail, bo.getEmail());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), AppUser::getPhonenumber, bo.getPhonenumber());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSex()), AppUser::getSex, bo.getSex());
|
||||
lqw.eq(bo.getAvatar() != null, AppUser::getAvatar, bo.getAvatar());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPassword()), AppUser::getPassword, bo.getPassword());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), AppUser::getStatus, bo.getStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLoginIp()), AppUser::getLoginIp, bo.getLoginIp());
|
||||
lqw.eq(bo.getLoginDate() != null, AppUser::getLoginDate, bo.getLoginDate());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增APP用户信息
|
||||
*
|
||||
* @param bo APP用户信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(AppUserBo bo) {
|
||||
AppUser add = MapstructUtils.convert(bo, AppUser.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setUserId(add.getUserId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改APP用户信息
|
||||
*
|
||||
* @param bo APP用户信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(AppUserBo bo) {
|
||||
AppUser update = MapstructUtils.convert(bo, AppUser.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(AppUser entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除APP用户信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppMenuMapper">
|
||||
|
||||
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from app_menu m
|
||||
left join app_role_menu rm on m.menu_id = rm.menu_id and m.status = '0'
|
||||
left join app_role r on r.role_id = rm.role_id and r.status = '0'
|
||||
where r.role_id in (select role_id from app_user_role where user_id = #{userId})
|
||||
</select>
|
||||
</mapper>
|
||||
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppRoleMapper">
|
||||
|
||||
<select id="selectRolesByUserId" resultType="com.fuyuanshen.app.domain.vo.AppRoleVo">
|
||||
select r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.status
|
||||
from app_role r
|
||||
WHERE r.del_flag = '0' and r.role_id in (select role_id from app_user_role where user_id = #{userId})
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppRoleMenuMapper">
|
||||
|
||||
</mapper>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppUserMapper">
|
||||
|
||||
</mapper>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppUserRoleMapper">
|
||||
|
||||
</mapper>
|
||||
@ -1,20 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>fys-app</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fys-equipment</artifactId>
|
||||
|
||||
<description>
|
||||
app模块
|
||||
富源晟设备管理
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
@ -26,41 +28,44 @@
|
||||
<artifactId>fys-common-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-sms</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-translation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- OSS功能模块 -->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-oss</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- excel-->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SMS功能模块 -->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-sms</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-security</artifactId>
|
||||
@ -73,12 +78,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-ratelimiter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-translation</artifactId>
|
||||
<artifactId>fys-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -93,13 +93,16 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-tenant</artifactId>
|
||||
<artifactId>fys-common-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-websocket</artifactId>
|
||||
<artifactId>fys-common-sse</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,206 @@
|
||||
package com.fuyuanshen.equipment.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Slf4j
|
||||
// @Api(tags = "设备:设备管理")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/device")
|
||||
public class DeviceController {
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
|
||||
@GetMapping
|
||||
public ResponseVO<PageResult<Device>> queryDevice(DeviceQueryCriteria criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
PageResult<Device> devices = null;
|
||||
try {
|
||||
devices = deviceService.queryAll(criteria, page);
|
||||
} catch (IOException e) {
|
||||
log.error("queryDevice error: " + e.getMessage());
|
||||
return ResponseVO.fail("");
|
||||
}
|
||||
return ResponseVO.success(devices);
|
||||
}
|
||||
|
||||
//
|
||||
// @Log("新增设备")
|
||||
// @ApiOperation("新增设备")
|
||||
// @PostMapping(value = "/add")
|
||||
// public ResponseVO<Object> addDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
// try {
|
||||
// deviceService.addDevice(deviceForm);
|
||||
// } catch (Exception e) {
|
||||
// log.error("addDevice error: " + e.getMessage());
|
||||
// return ResponseVO.fail(e.getMessage());
|
||||
// }
|
||||
// return ResponseVO.success(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @param deviceForm
|
||||
// * @return
|
||||
// * @ModelAttribute 主要用于将请求参数绑定到 Java 对象上,它会从 HTTP 请求的查询参数(Query Parameters)
|
||||
// * 或表单数据(Form Data)中提取值,并自动填充到指定的对象属性中。
|
||||
// */
|
||||
// @Log("解绑设备")
|
||||
// @ApiOperation("解绑设备")
|
||||
// @PostMapping(value = "/unbind")
|
||||
// public ResponseVO<Object> unbindDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
// deviceService.unbindDevice(deviceForm);
|
||||
// return ResponseVO.success("解绑成功!!!");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Log("修改设备")
|
||||
// @ApiOperation("修改设备")
|
||||
// @PutMapping(value = "/update")
|
||||
// public ResponseVO<Object> updateDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
// try {
|
||||
// deviceService.update(deviceForm);
|
||||
// } catch (Exception e) {
|
||||
// log.error("updateDevice error: " + e.getMessage());
|
||||
// return ResponseVO.fail("出错了");
|
||||
// }
|
||||
// return ResponseVO.success(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Log("分配客户")
|
||||
// @ApiOperation("分配客户")
|
||||
// @PutMapping(value = "/assignCustomer")
|
||||
// public ResponseVO<Object> assignCustomer(@Validated @RequestBody CustomerVo customerVo) {
|
||||
// deviceService.assignCustomer(customerVo);
|
||||
// return ResponseVO.success(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Log("撤回设备")
|
||||
// @ApiOperation("撤回设备")
|
||||
// @PostMapping(value = "/withdraw")
|
||||
// public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
// try {
|
||||
// deviceService.withdrawDevice(deviceForm);
|
||||
// } catch (Exception e) {
|
||||
// log.error("updateDevice error: " + e.getMessage());
|
||||
// return ResponseVO.fail("出错了");
|
||||
// }
|
||||
// return ResponseVO.success(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ApiOperation("设备详情")
|
||||
// @GetMapping(value = "/detail/{id}")
|
||||
// public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
||||
// Device device = deviceService.getById(id);
|
||||
// return ResponseVO.success(device);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Log("删除设备")
|
||||
// @ApiOperation("删除设备")
|
||||
// @DeleteMapping(value = "/delete")
|
||||
// public ResponseVO<Object> deleteDevice(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||
// // deviceService.deleteAll(ids);
|
||||
// deviceService.deleteAssign(ids);
|
||||
// return ResponseVO.success(ResponseMessageConstants.DELETE_SUCCESS);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ApiOperation("导出数据设备")
|
||||
// @GetMapping(value = "/download")
|
||||
// public void exportDevice(HttpServletResponse response, DeviceQueryCriteria criteria) throws IOException {
|
||||
// // deviceService.download(deviceService.queryAll(criteria), response);
|
||||
// User onlineuser = userService.findByName(SecurityUtils.getCurrentUsername());
|
||||
//
|
||||
// // 只能看到自己的创建的设备,以及被分配的设备。
|
||||
// if (onlineuser.getTenantId() != null && !onlineuser.getTenantId().equals(UserConstants.SUPER_ADMIN_ID)) {
|
||||
// // criteria.setTenantId(onlineuser.getTenantId());
|
||||
// criteria.setCurrentOwnerId(onlineuser.getId());
|
||||
// }
|
||||
// exportService.export(deviceService.queryAll(criteria), response);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ApiOperation("设备定位")
|
||||
// @GetMapping(value = "/locateDevice")
|
||||
// public ResponseVO<Object> locateDevice(DeviceQueryCriteria criteria) throws IOException {
|
||||
// List<Device> devices = deviceService.queryAllDevices(criteria);
|
||||
// return ResponseVO.success(devices);
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("设备数据模板下载")
|
||||
// @GetMapping("/template")
|
||||
// public void download(HttpServletRequest request, HttpServletResponse response) throws IOException, URISyntaxException {
|
||||
// // String filePath = "resources" + File.separator + "template" + File.separator + "device_import.csv";
|
||||
// Path path = Paths.get(ClassLoader.getSystemResource("template/device_import.csv").toURI());
|
||||
// FileUtil.downloadFile(request, response, new File(path.toUri()), true);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ApiOperation("导入设备数据")
|
||||
// @PostMapping(value = "/import", consumes = "multipart/form-data")
|
||||
// public ResponseVO<ImportResult> importData(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file) {
|
||||
//
|
||||
// String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
||||
// if (!("xlsx".equalsIgnoreCase(suffix))) {
|
||||
// throw new BadRequestException("只能上传Excel——xlsx格式文件");
|
||||
// }
|
||||
//
|
||||
// ImportResult result = new ImportResult();
|
||||
// try {
|
||||
// User currentUser = userMapper.findByUsername(SecurityUtils.getCurrentUsername());
|
||||
// DeviceImportParams params = DeviceImportParams.builder().ip(ip).deviceService(deviceService).tenantId(currentUser.getTenantId()).file(file).filePath(filePath).deviceMapper(deviceMapper).deviceAssignmentsService(deviceAssignmentsService).deviceTypeMapper(deviceTypeMapper).userId(currentUser.getId()).userMapper(userMapper).build();
|
||||
// // 创建监听器
|
||||
// UploadDeviceDataListener listener = new UploadDeviceDataListener(params);
|
||||
// // 读取Excel
|
||||
// EasyExcel.read(file.getInputStream(), DeviceExcelImportDTO.class, listener).sheet().doRead();
|
||||
// // 获取导入结果
|
||||
// result = listener.getImportResult();
|
||||
// // 设置响应消息
|
||||
// String message = String.format("成功导入 %d 条数据,失败 %d 条", result.getSuccessCount(), result.getFailureCount());
|
||||
// // 返回带有正确泛型的响应
|
||||
// return ResponseVO.<ImportResult>success(message, result);
|
||||
// } catch (Exception e) {
|
||||
// log.error("导入设备数据出错: {}", e.getMessage(), e);
|
||||
// // 在异常情况下,设置默认结果
|
||||
// String errorMessage = String.format("导入失败: %s。成功 %d 条,失败 %d 条", e.getMessage(), result.getSuccessCount(), result.getFailureCount());
|
||||
// // 使用新方法确保类型正确
|
||||
// return ResponseVO.<ImportResult>fail(errorMessage, result);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("下载导入错误报告")
|
||||
// @GetMapping("/download-import-errors")
|
||||
// public ResponseEntity<byte[]> downloadImportErrors(@RequestParam String errorData) {
|
||||
// try {
|
||||
// // 解码Base64字符串
|
||||
// byte[] data = Base64.getDecoder().decode(errorData);
|
||||
// return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"import_errors.xlsx\"").contentType(MediaType.APPLICATION_OCTET_STREAM).body(data);
|
||||
// } catch (Exception e) {
|
||||
// log.error("下载错误报告失败", e);
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
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.baomidou.mybatisplus.core.conditions.update.Update;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1308:57
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("customer_device")
|
||||
public class CustomerDevice extends TenantEntity {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "customer_id")
|
||||
private Long customerId;
|
||||
|
||||
@TableField(value = "device_id")
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0 失效
|
||||
* 1 正常
|
||||
*/
|
||||
@TableField(value = "assign_status")
|
||||
private Byte assignStatus;
|
||||
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
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.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 设备表
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Data
|
||||
@TableName("device")
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
||||
public class Device extends TenantEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
// @ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
// @ApiModelProperty(value = "设备记录ID")
|
||||
@TableField(exist = false)
|
||||
private Long assignId;
|
||||
|
||||
// @ApiModelProperty(value = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
// @ApiModelProperty(value = "设备类型名称")
|
||||
private String typeName;
|
||||
|
||||
// @ApiModelProperty(value = "客户号")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 当前所有者
|
||||
* current_owner_id
|
||||
*/
|
||||
// @ApiModelProperty(value = "当前所有者")
|
||||
private Long currentOwnerId;
|
||||
|
||||
/**
|
||||
* 原始所有者(创建者)
|
||||
* original_owner_id
|
||||
*/
|
||||
// @ApiModelProperty(value = "原始所有者(创建者)")
|
||||
private Long originalOwnerId;
|
||||
|
||||
// @ApiModelProperty(value = "所属客户")
|
||||
private String customerName;
|
||||
|
||||
/*@ApiModelProperty(value = "设备编号")
|
||||
private String deviceNo;*/
|
||||
|
||||
// @ApiModelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
// @ApiModelProperty(value = "设备图片")
|
||||
private String devicePic;
|
||||
|
||||
// @ApiModelProperty(value = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
// @ApiModelProperty(value = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
// @ApiModelProperty(value = "设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
// @ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
// @ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
// @ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
// @TableField(value = "tenant_id")
|
||||
// // @ApiModelProperty(hidden = true)
|
||||
// private Long tenantId;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0 失效
|
||||
* 1 正常
|
||||
*/
|
||||
// @ApiModelProperty(value = "设备状态")
|
||||
private Integer deviceStatus;
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
* 1 已绑定
|
||||
*/
|
||||
// @ApiModelProperty(value = "绑定状态")
|
||||
private Integer bindingStatus;
|
||||
|
||||
|
||||
public void copy(Device source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 设备分配记录表
|
||||
*
|
||||
* @TableName device_assignments
|
||||
*/
|
||||
@TableName(value = "device_assignments")
|
||||
@Data
|
||||
public class DeviceAssignments extends TenantEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 分配方
|
||||
*/
|
||||
private Long fromCustomerId;
|
||||
|
||||
/**
|
||||
* 接收方
|
||||
*/
|
||||
private Long toCustomerId;
|
||||
|
||||
/**
|
||||
* 分配者
|
||||
* assigner_name
|
||||
*/
|
||||
private Long assignerId;
|
||||
private String assignerName;
|
||||
|
||||
/**
|
||||
* 接收者
|
||||
* assignee_name
|
||||
*/
|
||||
private Long assigneeId;
|
||||
private String assigneeName;
|
||||
|
||||
/**
|
||||
* 分配时间
|
||||
*/
|
||||
private LocalDateTime assignedAt;
|
||||
|
||||
/**
|
||||
* 0 未授权
|
||||
* 1 已授权
|
||||
* 是否同步授权了设备类型
|
||||
*/
|
||||
private Integer deviceTypeGranted;
|
||||
|
||||
/**
|
||||
* 0 否
|
||||
* 1 是
|
||||
* 是否直接分配(用于父级显示)
|
||||
*/
|
||||
private Integer direct;
|
||||
|
||||
/**
|
||||
* 0 否
|
||||
* 1 是
|
||||
* 设备是否有效
|
||||
*/
|
||||
private Integer active;
|
||||
|
||||
/**
|
||||
* 分配等级(用于失效)
|
||||
*/
|
||||
private String lever;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/24
|
||||
**/
|
||||
@Data
|
||||
@TableName("device_log")
|
||||
public class DeviceLog extends TenantEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
// @ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
// @ApiModelProperty(value = "设备行为")
|
||||
private String deviceAction;
|
||||
|
||||
// @ApiModelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
// @ApiModelProperty(value = "数据来源")
|
||||
private String dataSource;
|
||||
|
||||
// @ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
public void copy(DeviceLog source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 设备类型
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/14
|
||||
**/
|
||||
@Data
|
||||
@TableName("device_type")
|
||||
public class DeviceType extends TenantEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
// @ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
// @ApiModelProperty(value = "客户号")
|
||||
private Long customerId;
|
||||
|
||||
// @ApiModelProperty(value = "创建该类型的客户")
|
||||
private Long ownerCustomerId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
// @TableField(value = "tenant_id")
|
||||
// @ApiModelProperty(hidden = true)
|
||||
// private Long tenantId;
|
||||
|
||||
@NotBlank(message = "设备类型名称不能为空")
|
||||
// @ApiModelProperty(value = "类型名称", required = true)
|
||||
private String typeName;
|
||||
|
||||
// @ApiModelProperty(value = "是否支持蓝牙")
|
||||
private Boolean isSupportBle;
|
||||
|
||||
// @ApiModelProperty(value = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
|
||||
private String locateMode;
|
||||
|
||||
// @ApiModelProperty(value = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||
private String networkWay;
|
||||
|
||||
// @ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private String communicationMode;
|
||||
|
||||
|
||||
public void copy(DeviceType source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备分配权限表 (解决跨客户共享)
|
||||
*
|
||||
* @TableName device_type_grants
|
||||
*/
|
||||
@TableName(value = "device_type_grants")
|
||||
@Data
|
||||
public class DeviceTypeGrants extends TenantEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private Long deviceTypeId;
|
||||
|
||||
/**
|
||||
* 被授权的客户
|
||||
*/
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 授权方客户
|
||||
*/
|
||||
private Long grantorCustomerId;
|
||||
|
||||
/**
|
||||
* 生成日期
|
||||
*/
|
||||
private Date grantedAt;
|
||||
|
||||
/**
|
||||
* 关联分配记录
|
||||
*/
|
||||
private Long assignmentId;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DeviceTypeGrants other = (DeviceTypeGrants) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getDeviceTypeId() == null ? other.getDeviceTypeId() == null : this.getDeviceTypeId().equals(other.getDeviceTypeId())) && (this.getCustomerId() == null ? other.getCustomerId() == null : this.getCustomerId().equals(other.getCustomerId())) && (this.getGrantorCustomerId() == null ? other.getGrantorCustomerId() == null : this.getGrantorCustomerId().equals(other.getGrantorCustomerId())) && (this.getGrantedAt() == null ? other.getGrantedAt() == null : this.getGrantedAt().equals(other.getGrantedAt())) && (this.getAssignmentId() == null ? other.getAssignmentId() == null : this.getAssignmentId().equals(other.getAssignmentId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getDeviceTypeId() == null) ? 0 : getDeviceTypeId().hashCode());
|
||||
result = prime * result + ((getCustomerId() == null) ? 0 : getCustomerId().hashCode());
|
||||
result = prime * result + ((getGrantorCustomerId() == null) ? 0 : getGrantorCustomerId().hashCode());
|
||||
result = prime * result + ((getGrantedAt() == null) ? 0 : getGrantedAt().hashCode());
|
||||
result = prime * result + ((getAssignmentId() == null) ? 0 : getAssignmentId().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", deviceTypeId=").append(deviceTypeId);
|
||||
sb.append(", customerId=").append(customerId);
|
||||
sb.append(", grantorCustomerId=").append(grantorCustomerId);
|
||||
sb.append(", grantedAt=").append(grantedAt);
|
||||
sb.append(", assignmentId=").append(assignmentId);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.fuyuanshen.equipment.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 设备查询参数
|
||||
*
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Data
|
||||
public class DeviceQueryCriteria {
|
||||
|
||||
// @ApiModelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
// @ApiModelProperty(value = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
// @ApiModelProperty(value = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
// @ApiModelProperty(value = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
// @ApiModelProperty(value = "设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0 失效
|
||||
* 1 正常
|
||||
*/
|
||||
// @ApiModelProperty(value = "设备状态 0 失效 1 正常 ")
|
||||
private Integer deviceStatus;
|
||||
|
||||
// @ApiModelProperty(value = "创建时间")
|
||||
private List<Timestamp> createTime;
|
||||
|
||||
// @ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
// @ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
|
||||
// @ApiModelProperty(value = "客户id")
|
||||
private Long customerId;
|
||||
private Set<Long> customerIds;
|
||||
|
||||
// @ApiModelProperty(value = "当前所有者")
|
||||
private Long currentOwnerId;
|
||||
|
||||
// @ApiModelProperty(value = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
// @ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private Integer communicationMode;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.fuyuanshen.equipment.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.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.DeviceQueryCriteria;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Mapper
|
||||
public interface DeviceMapper extends BaseMapper<Device> {
|
||||
|
||||
/**
|
||||
* 分页查询设备
|
||||
*
|
||||
* @param criteria
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
List<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
List<Device> findAllDevices(@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.DeviceQueryCriteria;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
public interface DeviceService extends IService<Device> {
|
||||
|
||||
/**
|
||||
* 查询设备数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return PageResult
|
||||
*/
|
||||
PageResult<Device> queryAll(DeviceQueryCriteria criteria, Page<Object> page) throws IOException;
|
||||
|
||||
// /**
|
||||
// * 查询所有数据不分页
|
||||
// *
|
||||
// * @param criteria 条件参数
|
||||
// * @return List<DeviceDto>
|
||||
// */
|
||||
// List<Device> queryAll(DeviceQueryCriteria criteria);
|
||||
//
|
||||
// /**
|
||||
// * 查询所有设备信息
|
||||
// *
|
||||
// * @param criteria
|
||||
// * @return
|
||||
// */
|
||||
// List<Device> queryAllDevices(DeviceQueryCriteria criteria);
|
||||
//
|
||||
// /**
|
||||
// * 创建
|
||||
// *
|
||||
// * @param resources /
|
||||
// */
|
||||
// void create(Device resources);
|
||||
//
|
||||
// /**
|
||||
// * 新增设备
|
||||
// *
|
||||
// * @param resources
|
||||
// */
|
||||
// void addDevice(DeviceForm resources) throws Exception;
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// *
|
||||
// * @param resources /
|
||||
// */
|
||||
// void update(DeviceForm resources) throws Exception;
|
||||
//
|
||||
// /**
|
||||
// * 分配客户
|
||||
// */
|
||||
// void assignCustomer(CustomerVo customerVo);
|
||||
//
|
||||
// void withdrawDevice(DeviceForm deviceForm);
|
||||
//
|
||||
// /**
|
||||
// * 多选删除
|
||||
// *
|
||||
// * @param ids /
|
||||
// */
|
||||
// void deleteAll(List<Long> ids);
|
||||
//
|
||||
// /**
|
||||
// * 删除设备分配记录
|
||||
// *
|
||||
// * @param ids
|
||||
// */
|
||||
// void deleteAssign(List<Long> ids);
|
||||
//
|
||||
// /**
|
||||
// * 导出数据
|
||||
// *
|
||||
// * @param all 待导出的数据
|
||||
// * @param response /
|
||||
// * @throws IOException /
|
||||
// */
|
||||
// void download(List<Device> all, HttpServletResponse response) throws IOException;
|
||||
//
|
||||
// /**
|
||||
// * 导入设备数据
|
||||
// *
|
||||
// * @param file
|
||||
// */
|
||||
// void importData(MultipartFile file) throws IOException;
|
||||
//
|
||||
// /**
|
||||
// * 解绑设备
|
||||
// *
|
||||
// * @param deviceForm
|
||||
// */
|
||||
// void unbindDevice(DeviceForm deviceForm);
|
||||
|
||||
}
|
||||
@ -0,0 +1,603 @@
|
||||
package com.fuyuanshen.equipment.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.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.core.utils.PageUtil;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService {
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询设备
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public PageResult<Device> queryAll(DeviceQueryCriteria criteria, Page<Object> page) throws IOException {
|
||||
|
||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||
|
||||
List<Device> records = devices.getRecords();
|
||||
for (Device record : records) {
|
||||
if (record.getDevicePic() == null) {
|
||||
record.setDevicePic("");
|
||||
}
|
||||
}
|
||||
|
||||
return PageUtil.toPage(devices);
|
||||
}
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public List<Device> queryAll(DeviceQueryCriteria criteria) {
|
||||
// return deviceMapper.findAll(criteria);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Device> queryAllDevices(DeviceQueryCriteria criteria) {
|
||||
// return deviceMapper.findAllDevices(criteria);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void create(Device resources) {
|
||||
// deviceMapper.insert(resources);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 新增设备
|
||||
// *
|
||||
// * @param deviceForm
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void addDevice(DeviceForm deviceForm) throws Exception {
|
||||
//
|
||||
// // 获取当前登录用户信息
|
||||
// // Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
// // String username1 = authentication.getName();
|
||||
// // 从缓存获取
|
||||
// // UserDetails currentUser = SecurityUtils.getCurrentUser();
|
||||
// // String username = currentUser.getUsername();
|
||||
// // JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
||||
// User currentUser = userMapper.findByUsername(SecurityUtils.getCurrentUsername());
|
||||
//
|
||||
// if (StringUtils.isNotEmpty(deviceForm.getDeviceMac())) {
|
||||
// QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("device_mac", deviceForm.getDeviceMac());
|
||||
// // queryWrapper.eq("tenant_id", currentUser.getTenantId());
|
||||
// if ((deviceMapper.selectOne(queryWrapper)) != null) {
|
||||
// throw new BadRequestException("设备 mac地址 有误,请仔细核对!!!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// QueryWrapper<DeviceTypeGrants> deviceTypeGrantsQueryWrapper = new QueryWrapper<>();
|
||||
// deviceTypeGrantsQueryWrapper.eq("customer_id", currentUser.getId());
|
||||
// deviceTypeGrantsQueryWrapper.eq("device_type_id", deviceForm.getDeviceType());
|
||||
// Long count = deviceTypeGrantsMapper.selectCount(deviceTypeGrantsQueryWrapper);
|
||||
// if (count <= 0) {
|
||||
// throw new BadRequestException("请先授权设备类型!!!");
|
||||
// }
|
||||
//
|
||||
// // 保存图片并获取URL
|
||||
// String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceMac());
|
||||
// // 设置图片路径
|
||||
// deviceForm.setDevicePic(imageUrl);
|
||||
//
|
||||
// // 转换对象并插入数据库
|
||||
// Device device = new Device();
|
||||
// BeanUtil.copyProperties(deviceForm, device, true);
|
||||
//
|
||||
// // 添加租户ID
|
||||
// device.setTenantId(currentUser.getTenantId());
|
||||
// // 默认状态正常
|
||||
// device.setDeviceStatus(DeviceStatusEnum.NORMAL.getCode());
|
||||
// // SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator();
|
||||
// // device.setId(snowflakeGenerator.next());
|
||||
// device.setCurrentOwnerId(currentUser.getId());
|
||||
// device.setOriginalOwnerId(currentUser.getId());
|
||||
// DeviceType deviceType = deviceTypeMapper.selectById(deviceForm.getDeviceType());
|
||||
// device.setTypeName(deviceType.getTypeName());
|
||||
//
|
||||
// deviceMapper.insert(device);
|
||||
//
|
||||
// // 新增设备类型记录
|
||||
// DeviceAssignments assignments = new DeviceAssignments();
|
||||
// assignments.setDeviceId(device.getId());
|
||||
// assignments.setAssignedAt(LocalDateTime.now());
|
||||
// // 分配者
|
||||
// assignments.setAssignerId(currentUser.getId());
|
||||
// assignments.setAssignerName(currentUser.getUsername());
|
||||
// // 接收者
|
||||
// assignments.setAssigneeId(currentUser.getId());
|
||||
// assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode());
|
||||
// String lever = currentUser.getId() + ":";
|
||||
// assignments.setLever(lever);
|
||||
// deviceAssignmentsService.save(assignments);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * 更新设备信息
|
||||
// *
|
||||
// * @param deviceForm /
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void update(DeviceForm deviceForm) throws Exception {
|
||||
// Device device = getById(deviceForm.getId());
|
||||
//
|
||||
// // 处理上传的图片
|
||||
// String imageUrl = saveDeviceImage(deviceForm.getFile(), device.getDeviceMac());
|
||||
// deviceForm.setDevicePic(imageUrl);
|
||||
//
|
||||
// // 更新字段
|
||||
// BeanUtil.copyProperties(deviceForm, device, true);
|
||||
// device.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
// deviceMapper.updateById(device);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 保存设备图片并返回访问路径
|
||||
// *
|
||||
// * @param file MultipartFile
|
||||
// * @param deviceMac 设备MAC用于生成唯一文件名
|
||||
// * @return 文件存储路径 URL 形式
|
||||
// */
|
||||
// private String saveDeviceImage(MultipartFile file, String deviceMac) throws IOException {
|
||||
// if (file == null || file.isEmpty()) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// String originalFileName = file.getOriginalFilename();
|
||||
// String fileExtension = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
|
||||
// String newFileName = "PS_" + deviceMac + "." + fileExtension;
|
||||
//
|
||||
// File newFile = new File(filePath + DeviceConstants.FILE_ACCESS_ISOLATION + File.separator + newFileName);
|
||||
//
|
||||
// if (!newFile.getParentFile().exists()) {
|
||||
// newFile.getParentFile().mkdirs();
|
||||
// }
|
||||
//
|
||||
// log.info("图片保存路径: {}", newFile.getAbsolutePath());
|
||||
// file.transferTo(newFile);
|
||||
//
|
||||
// return ip + DeviceConstants.FILE_ACCESS_PREFIX + "/" + DeviceConstants.FILE_ACCESS_ISOLATION + "/" + newFileName;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 分配客户 历史记录版本
|
||||
// *
|
||||
// * @param customerVo
|
||||
// */
|
||||
//
|
||||
// public void assignCustomer1(CustomerVo customerVo) {
|
||||
//
|
||||
// // 防止管理员误操作
|
||||
// User currentUser = userService.findById(SecurityUtils.getCurrentUserId());
|
||||
// if (currentUser.getTenantId().equals(UserConstants.SUPER_ADMIN_ID)) {
|
||||
// throw new BadRequestException(ExceptionMessages.ADMIN_OPERATION_NOT_ALLOWED);
|
||||
// }
|
||||
//
|
||||
// List<DeviceAssignments> assignments = new ArrayList<>();
|
||||
// List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
|
||||
// List<Device> devices = new ArrayList<>();
|
||||
// customerVo.getDeviceIds().forEach(deviceId -> {
|
||||
//
|
||||
// // 阻止重复分配
|
||||
// Device device = deviceMapper.selectById(deviceId);
|
||||
// if (device.getCustomerId() != null && device.getCustomerId().equals(customerVo.getCustomerId())) {
|
||||
// throw new BadRequestException("设备 " + device.getDeviceName() + " 已被分配给客户 " + device.getCustomerName());
|
||||
// }
|
||||
//
|
||||
// // 自定义16位id
|
||||
// Long generatedId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||
//
|
||||
// // -- 记录分配历史
|
||||
// DeviceAssignments deviceAssignments = new DeviceAssignments();
|
||||
// deviceAssignments.setId(generatedId);
|
||||
// deviceAssignments.setDeviceId(deviceId);
|
||||
// deviceAssignments.setFromCustomerId(currentUser.getId());
|
||||
// deviceAssignments.setToCustomerId(customerVo.getCustomerId());
|
||||
// deviceAssignments.setAssignedAt(LocalDateTime.now());
|
||||
// deviceAssignments.setDeviceTypeGranted(DeviceAuthorizationStatus.AUTHORIZED.getValue());
|
||||
// assignments.add(deviceAssignments);
|
||||
//
|
||||
// // -- 授权设备类型给客户
|
||||
// // QueryWrapper<DeviceTypeGrants> deviceTypeGrantsQueryWrapper = new QueryWrapper<>();
|
||||
// // Long count = deviceTypeGrantsMapper.selectCount(deviceTypeGrantsQueryWrapper);
|
||||
// DeviceTypeGrants deviceTypeGrant = new DeviceTypeGrants();
|
||||
// deviceTypeGrant.setGrantedAt(new Date());
|
||||
// // 设备类型
|
||||
// deviceTypeGrant.setDeviceTypeId(device.getDeviceType());
|
||||
// deviceTypeGrant.setAssignmentId(generatedId);
|
||||
// // 被授权的客户
|
||||
// deviceTypeGrant.setCustomerId(customerVo.getCustomerId());
|
||||
// // 授权方客户
|
||||
// deviceTypeGrant.setGrantorCustomerId(currentUser.getId());
|
||||
// deviceTypeGrants.add(deviceTypeGrant);
|
||||
//
|
||||
// // -- 更新设备所有者
|
||||
// device.setCurrentOwnerId(customerVo.getCustomerId());
|
||||
// devices.add(device);
|
||||
// });
|
||||
//
|
||||
// deviceAssignmentsService.saveBatch(assignments);
|
||||
// deviceTypeGrantsService.saveBatch(deviceTypeGrants);
|
||||
// this.updateBatchById(devices);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 分配客户
|
||||
// *
|
||||
// * @param customerVo
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void assignCustomer(CustomerVo customerVo) {
|
||||
//
|
||||
// // 获取当前登录用户
|
||||
// User currentUser = userService.findById(SecurityUtils.getCurrentUserId());
|
||||
// // 防止管理员误操作
|
||||
// AdminCheckUtil.checkIfSuperAdmin(currentUser);
|
||||
// // 获取分配用户信息
|
||||
// User assignUser = userService.findById(customerVo.getCustomerId());
|
||||
//
|
||||
// // 获取分配设备信息
|
||||
// List<Device> devices = deviceMapper.selectBatchIds(customerVo.getDeviceIds());
|
||||
//
|
||||
// // 批量更新设备状态
|
||||
// List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
|
||||
// for (Device device : devices) {
|
||||
//
|
||||
// // 如果设备已分配给需要分配的客户,则跳过
|
||||
// LambdaQueryWrapper<DeviceAssignments> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(DeviceAssignments::getDeviceId, device.getId()).eq(DeviceAssignments::getAssigneeId, customerVo.getCustomerId()).ne(DeviceAssignments::getActive, DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectList(wrapper);
|
||||
// if (CollectionUtil.isNotEmpty(deviceAssignments)) {
|
||||
// log.info("设备 {} 已分配给客户 {}", device.getDeviceName(), device.getCustomerName());
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // 更改分配客户
|
||||
// QueryWrapper<DeviceAssignments> q = new QueryWrapper<>();
|
||||
// q.eq("device_id", device.getId());
|
||||
// q.eq("assignee_id", currentUser.getId());
|
||||
// q.ne("active", DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// DeviceAssignments d = new DeviceAssignments();
|
||||
// d.setAssigneeName(assignUser.getUsername());
|
||||
// deviceAssignmentsMapper.update(d, q);
|
||||
//
|
||||
// // 设备失效
|
||||
// // 获取用户的设备记录
|
||||
// DeviceAssignments assignment = deviceAssignmentsMapper.selectOne(new LambdaQueryWrapper<DeviceAssignments>().eq(DeviceAssignments::getDeviceId, device.getId()).eq(DeviceAssignments::getAssigneeId, currentUser.getId()).eq(DeviceAssignments::getActive, DeviceActiveStatusEnum.ACTIVE.getCode()));
|
||||
//
|
||||
// LambdaQueryWrapper<DeviceAssignments> q1 = new LambdaQueryWrapper<>();
|
||||
// q1.eq(DeviceAssignments::getDeviceId, device.getId()).ne(DeviceAssignments::getAssigneeId, currentUser.getId()).like(DeviceAssignments::getLever, assignment.getLever());
|
||||
//
|
||||
// DeviceAssignments d1 = new DeviceAssignments();
|
||||
// d1.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// deviceAssignmentsMapper.update(d1, q1);
|
||||
//
|
||||
// // device.setCustomerId(assignUser.getId());
|
||||
// // device.setCustomerName(assignUser.getUsername());
|
||||
//
|
||||
// // 新增设备类型记录
|
||||
// DeviceAssignments assignments = new DeviceAssignments();
|
||||
// assignments.setDeviceId(device.getId());
|
||||
// assignments.setAssignedAt(LocalDateTime.now());
|
||||
// // 分配者
|
||||
// assignments.setAssignerId(currentUser.getId());
|
||||
// assignments.setAssignerName(currentUser.getUsername());
|
||||
// // 接收者
|
||||
// assignments.setAssigneeId(assignUser.getId());
|
||||
// // assignments.setAssigneeName(assignUser.getUsername());
|
||||
// assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode());
|
||||
// String lever = assignment.getLever() + ":" + assignUser.getId();
|
||||
// assignments.setLever(lever);
|
||||
// deviceAssignmentsService.save(assignments);
|
||||
//
|
||||
// // // 获取当前用户的所有祖先用户
|
||||
// // List<User> ancestorsById = userMapper.findAncestorsById(currentUser.getId());
|
||||
// // Set<Long> excludedTenantIds = new HashSet<>();
|
||||
// // if (CollectionUtil.isNotEmpty(ancestorsById)) {
|
||||
// // // 提取所有需要排除的 tenant_id
|
||||
// // excludedTenantIds = ancestorsById.stream().map(User::getTenantId).distinct().collect(Collectors.toSet());
|
||||
// // }
|
||||
// // excludedTenantIds.add(currentUser.getTenantId());
|
||||
// // // 构建查询条件:device_mac 相同,并且 tenant_id 不在 excludedTenantIds 列表中
|
||||
// // Wrapper<Device> wrapper = new QueryWrapper<Device>().eq("device_mac", device.getDeviceMac()).notIn("tenant_id", excludedTenantIds);
|
||||
// //
|
||||
// // // 构建要更新的数据
|
||||
// // Device updateDevice = new Device();
|
||||
// // updateDevice.setDeviceStatus(0);
|
||||
// // updateDevice.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
//
|
||||
// // 根据条件批量更新
|
||||
// // deviceMapper.update(updateDevice, wrapper);
|
||||
//
|
||||
// // 创建并保存设备类型授权记录
|
||||
// createAndSaveDeviceTypeGrants(device, currentUser, customerVo, deviceTypeGrants);
|
||||
// }
|
||||
//
|
||||
// this.updateBatchById(devices);
|
||||
//
|
||||
// deviceTypeGrantsService.saveBatch(deviceTypeGrants);
|
||||
//
|
||||
// //
|
||||
// // // 批量分配
|
||||
// // Set<DeviceType> deviceTypes = new HashSet<>();
|
||||
// // for (Device device : devices) {
|
||||
// // device.setId(null);
|
||||
// // device.setCustomerName(null);
|
||||
// // device.setCustomerId(null);
|
||||
// // device.setTenantId(user.getTenantId());
|
||||
// // device.setCreateTime(timestamp);
|
||||
// // device.setCreateBy(currentUser.getUsername());
|
||||
// // device.setUpdateTime(timestamp);
|
||||
// //
|
||||
// // // 查询设备类型
|
||||
// // DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||
// // // SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator();
|
||||
// // Long id = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||
// // deviceType.setId(id);
|
||||
// // deviceType.setCreateTime(timestamp);
|
||||
// // deviceType.setCreateBy(currentUser.getUsername());
|
||||
// // deviceType.setCustomerId(customerVo.getCustomerId());
|
||||
// // deviceTypes.add(deviceType);
|
||||
// //
|
||||
// // device.setDeviceType(deviceType.getId());
|
||||
// // }
|
||||
// // this.saveBatch(devices);
|
||||
// // deviceTypeService.saveBatch(deviceTypes);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 撤回设备
|
||||
// *
|
||||
// * @param deviceForm
|
||||
// */
|
||||
// @Override
|
||||
// public void withdrawDevice(DeviceForm deviceForm) {
|
||||
// DeviceAssignments assignment = deviceAssignmentsMapper.selectById(deviceForm.getAssignId());
|
||||
// // 接收者
|
||||
// assignment.setAssigneeName("");
|
||||
// deviceAssignmentsMapper.updateById(assignment);
|
||||
//
|
||||
// LambdaQueryWrapper<DeviceAssignments> q1 = new LambdaQueryWrapper<>();
|
||||
// q1.eq(DeviceAssignments::getAssignerId, assignment.getAssigneeId())
|
||||
// .like(DeviceAssignments::getLever, assignment.getLever())
|
||||
// .ne(DeviceAssignments::getId, assignment.getId());
|
||||
//
|
||||
// DeviceAssignments d1 = new DeviceAssignments();
|
||||
// d1.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// deviceAssignmentsMapper.update(d1, q1);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 创建并保存设备类型授权记录
|
||||
// *
|
||||
// * @param device 当前设备对象
|
||||
// * @param currentUser 当前登录用户
|
||||
// * @param customerVo 客户信息
|
||||
// * @param deviceTypeGrants 授权记录集合
|
||||
// */
|
||||
// private void createAndSaveDeviceTypeGrants(Device device, User currentUser, CustomerVo customerVo, List<DeviceTypeGrants> deviceTypeGrants) {
|
||||
// Long generatedId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||
// DeviceTypeGrants deviceTypeGrant = new DeviceTypeGrants();
|
||||
// deviceTypeGrant.setGrantedAt(new Date());
|
||||
// deviceTypeGrant.setDeviceTypeId(device.getDeviceType());
|
||||
// deviceTypeGrant.setAssignmentId(generatedId);
|
||||
// deviceTypeGrant.setCustomerId(customerVo.getCustomerId());
|
||||
// deviceTypeGrant.setGrantorCustomerId(currentUser.getId());
|
||||
// deviceTypeGrants.add(deviceTypeGrant);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 删除设备
|
||||
// *
|
||||
// * @param ids /
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void deleteAll(List<Long> ids) {
|
||||
//
|
||||
// SecurityUtils.getCurrentUserId();
|
||||
//
|
||||
// // Step 1: 查询所有传入的设备(根据 ID)
|
||||
// List<Device> allDevices = deviceMapper.selectBatchIds(ids);
|
||||
// // Step 2: 使用 Java Stream 过滤出 customer_id 不为 null 的设备
|
||||
// Set<Long> nonNullCustomerIds = allDevices.stream().filter(device -> device.getCustomerId() != null && device.getDeviceStatus() == 1).map(Device::getId).collect(Collectors.toSet());
|
||||
// // Step 3: 从原始 ids 中“去掉”这些非空 customer_id 的设备 ID
|
||||
// List<Long> remainingIds = ids.stream().filter(id -> !nonNullCustomerIds.contains(id)).collect(Collectors.toList());
|
||||
// if (CollectionUtil.isEmpty(remainingIds)) {
|
||||
// throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||
// }
|
||||
// List<Device> devices = deviceMapper.selectBatchIds(remainingIds);
|
||||
// for (Device device : devices) {
|
||||
// String devicePic = device.getDevicePic();
|
||||
// if (StringUtils.isNotBlank(devicePic)) {
|
||||
// File file = new File(devicePic);
|
||||
// if (file.exists()) {
|
||||
// if (file.delete()) {
|
||||
// log.info("设备图片删除成功");
|
||||
// } else {
|
||||
// log.error("设备图片删除失败");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// deviceMapper.deleteBatchIds(ids);
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * 删除设备分配记录(分配记录id)
|
||||
// *
|
||||
// * @param ids
|
||||
// */
|
||||
// public void deleteAssign1(List<Long> ids) {
|
||||
// Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
// // Step 1: 查询所有传入的设备(根据 ID)
|
||||
// // List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||
// QueryWrapper<DeviceAssignments> wrapper = new QueryWrapper<>();
|
||||
// // wrapper.eq("active", DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// wrapper.in("device_id", ids);
|
||||
// wrapper.eq("assigner_id", currentUserId);
|
||||
// List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectList(wrapper);
|
||||
// // Step 2: 使用 Java Stream 过滤出 customer_id 不为 null 的设备
|
||||
// Set<Long> nonNullCustomerIds = deviceAssignments.stream().filter(device -> !StringUtils.isNotEmpty(device.getAssigneeName())).map(DeviceAssignments::getId).collect(Collectors.toSet());
|
||||
// if (CollectionUtil.isEmpty(nonNullCustomerIds)) {
|
||||
// throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||
// }
|
||||
//
|
||||
// // QueryWrapper<DeviceAssignments> de = new QueryWrapper<>();
|
||||
// // wrapper.eq("active", DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
// // wrapper.in("device_id", ids);
|
||||
// // wrapper.eq("assignee_id", currentUserId);
|
||||
// // deviceAssignmentsMapper.delete(de);
|
||||
//
|
||||
// deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 删除设备分配记录(分配记录id)
|
||||
// *
|
||||
// * @param ids
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void deleteAssign(List<Long> ids) {
|
||||
// // Step 1: 查询所有传入的设备(根据 ID)
|
||||
// List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||
// // Step 2: 使用 Java Stream 过滤出 customer_id 不为 null 的设备
|
||||
// Set<Long> nonNullCustomerIds = deviceAssignments.stream()
|
||||
// .filter(device -> !StringUtils.isNotEmpty(device.getAssigneeName()))
|
||||
// .map(DeviceAssignments::getId).collect(Collectors.toSet());
|
||||
// if (CollectionUtil.isEmpty(nonNullCustomerIds)) {
|
||||
// throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||
// }
|
||||
//
|
||||
// deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
|
||||
// deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("assignment_id", nonNullCustomerIds));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void download(List<Device> all, HttpServletResponse response) throws IOException {
|
||||
// List<Map<String, Object>> list = new ArrayList<>();
|
||||
// for (Device device : all) {
|
||||
// Map<String, Object> map = new LinkedHashMap<>();
|
||||
// map.put("设备类型", device.getTypeName());
|
||||
// map.put("客户号", device.getCustomerId());
|
||||
// // map.put("设备编号", device.getDeviceNo());
|
||||
// map.put("设备名称", device.getDeviceName());
|
||||
// // map.put("设备图片", device.getDevicePic());
|
||||
// map.put("设备MAC", device.getDeviceMac());
|
||||
// map.put("设备SN", device.getDeviceSn());
|
||||
// map.put("创建者", device.getCreateBy());
|
||||
// map.put("更新者", device.getUpdateBy());
|
||||
// map.put("创建时间", device.getCreateTime());
|
||||
// map.put("更新时间", device.getUpdateTime());
|
||||
// list.add(map);
|
||||
// }
|
||||
// FileUtil.downloadExcel(list, response);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void importData(MultipartFile file) throws IOException {
|
||||
// String line = "";
|
||||
// String csvSplitBy = ",";
|
||||
// List<Device> devices = new ArrayList<>();
|
||||
// User currentUser = userService.findByName(SecurityUtils.getCurrentUsername());
|
||||
//
|
||||
// InputStream inputStream = file.getInputStream();
|
||||
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "GB2312");
|
||||
// BufferedReader br = new BufferedReader(inputStreamReader);
|
||||
//
|
||||
// // BufferedReader br = new BufferedReader(new FileReader((File) file));
|
||||
// br.readLine(); // 跳过第一行
|
||||
// while ((line = br.readLine()) != null) {
|
||||
// // 使用分隔符分割并存储到List中
|
||||
// String[] values = line.split(csvSplitBy);
|
||||
// Device device = new Device();
|
||||
// device.setDeviceName(values[0]);
|
||||
// device.setDeviceMac(values[1]);
|
||||
// device.setDeviceSn(values[2]);
|
||||
// device.setCreateBy(currentUser.getUsername());
|
||||
// device.setUpdateBy(currentUser.getUsername());
|
||||
// devices.add(device);
|
||||
// }
|
||||
//
|
||||
// this.saveBatch(devices);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 解绑设备
|
||||
// *
|
||||
// * @param deviceForm
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public void unbindDevice(DeviceForm deviceForm) {
|
||||
//
|
||||
// QueryWrapper<APPDevice> queryWrapper = new QueryWrapper<>();
|
||||
// if (StringUtils.isNotEmpty(deviceForm.getDeviceMac())) {
|
||||
// queryWrapper.eq("device_mac", deviceForm.getDeviceMac());
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(deviceForm.getDeviceImei())) {
|
||||
// queryWrapper.eq("device_imei", deviceForm.getDeviceImei());
|
||||
// }
|
||||
// appDeviceMapper.delete(queryWrapper);
|
||||
// Device device = new Device();
|
||||
// device.setId(deviceForm.getId());
|
||||
// device.setBindingStatus(BindingStatusEnum.UNBOUND.getCode());
|
||||
// deviceMapper.updateById(device);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceMapper">
|
||||
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.Device">
|
||||
<id column="id" property="id"/>
|
||||
<result column="device_type" property="deviceType"/>
|
||||
<result column="customer_id" property="customerId"/>
|
||||
<!--<result column="device_no" property="deviceNo"/>-->
|
||||
<result column="device_name" property="deviceName"/>
|
||||
<result column="device_pic" property="devicePic"/>
|
||||
<result column="device_mac" property="deviceMac"/>
|
||||
<result column="device_sn" property="deviceSn"/>
|
||||
<result column="device_status" property="deviceStatus"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="update_by" property="updateBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="binding_status" property="bindingStatus"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, device_type, customer_id, device_name, device_pic, device_mac, device_sn,
|
||||
remark, create_by, update_by, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<sql id="device_Column_List">
|
||||
d
|
||||
.
|
||||
id
|
||||
,d.device_type,
|
||||
d.customer_id, d.device_name, d.device_pic, d.device_mac,
|
||||
d.device_sn, d.remark, d.create_by, d.update_by, d.create_time, d.update_time,
|
||||
d.binding_status, d.device_status, d.current_owner_id, d.original_owner_id, d.customer_name,
|
||||
d.device_imei, d.longitude, d.latitude, d.tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询设备 -->
|
||||
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
select
|
||||
d.id,d.device_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
||||
d.update_time, d.device_type, d.remark, d.binding_status,t.type_name
|
||||
-- da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
||||
-- da.assigned_at AS create_time , da.assigner_name AS create_by , da.id AS assignId
|
||||
from device d
|
||||
LEFT JOIN device_type t ON d.device_type = t.id
|
||||
-- LEFT JOIN device_assignments da ON da.device_id = d.id
|
||||
<where>
|
||||
<!-- 时间范围等其他条件保持原样 -->
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceImei != null">
|
||||
and d.device_imei = #{criteria.deviceImei}
|
||||
</if>
|
||||
<if test="criteria.deviceType != null">
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.deviceStatus != null">
|
||||
-- and da.active = #{criteria.deviceStatus}
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
|
||||
<if test="criteria.tenantId != null">
|
||||
AND tenant_id = #{criteria.tenantId}
|
||||
</if>
|
||||
|
||||
<!-- 下面这两个条件只需满足一个 -->
|
||||
<!-- <if test="criteria.customerId != null"> -->
|
||||
<!-- AND ( -->
|
||||
<!-- tenant_id = #{criteria.tenantId} -->
|
||||
<!-- OR d.customer_id = #{criteria.customerId} -->
|
||||
<!-- ) -->
|
||||
<!-- </if> -->
|
||||
<!-- <if test="criteria.customerId == null"> -->
|
||||
<!-- AND tenant_id = #{criteria.tenantId} -->
|
||||
<!-- </if> -->
|
||||
</where>
|
||||
-- ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="findAll1" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
SELECT
|
||||
d.id, d.customer_id, d.customer_name, d.device_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.create_by, d.update_by,
|
||||
d.create_time, d.update_time, d.device_type, d.remark, d.device_status, t.type_name
|
||||
from device d
|
||||
left join device_type t
|
||||
on d.device_type = t.id
|
||||
<where>
|
||||
<!-- 时间范围等其他条件保持原样 -->
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceSn != null">
|
||||
and d.device_sn = #{criteria.deviceSn}
|
||||
</if>
|
||||
<if test="criteria.deviceType != null">
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
|
||||
<!-- 将两个客户相关条件合并成一个逻辑组 -->
|
||||
<if test="criteria.customerId != null or (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
||||
AND (
|
||||
<!-- 条件1: 用户或其下属创建,且 customer_id 为空 -->
|
||||
<if test="criteria.customerId != null">
|
||||
d.create_by IN (
|
||||
SELECT username FROM sys_user
|
||||
WHERE user_id = #{criteria.customerId} OR pid = #{criteria.customerId}
|
||||
) AND d.customer_id IS NULL
|
||||
</if>
|
||||
|
||||
<!-- 如果前面的条件不存在,则只保留第二个条件 -->
|
||||
<choose>
|
||||
<when test="criteria.customerId != null and (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
||||
OR
|
||||
</when>
|
||||
<when test="criteria.customerId == null and (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
||||
<!-- 仅当第一个条件不存在时才开始括号 -->
|
||||
</when>
|
||||
</choose>
|
||||
|
||||
<!-- 条件2: 客户ID在列表中 -->
|
||||
<if test="criteria.customerIds != null and !criteria.customerIds.isEmpty()">
|
||||
(d.customer_id IN
|
||||
<foreach item="customerId" collection="criteria.customerIds" open="(" separator="," close=")">
|
||||
#{customerId}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
order by d.id desc
|
||||
</select>
|
||||
|
||||
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
select
|
||||
d.id, d.customer_id, d.device_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.create_by, d.update_by,
|
||||
d.create_time, d.update_time, d.longitude, d.latitude, d.remark
|
||||
from device d
|
||||
<where>
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceType != null">
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
order by d.id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -15,7 +15,7 @@
|
||||
<module>fys-job</module>
|
||||
<module>fys-system</module>
|
||||
<module>fys-workflow</module>
|
||||
<module>fys-app</module>
|
||||
<module>fys-equipment</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>fys-modules</artifactId>
|
||||
|
||||
24
pom.xml
24
pom.xml
@ -152,6 +152,17 @@
|
||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.springdoc</groupId> -->
|
||||
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> -->
|
||||
<!-- <version>${springdoc.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-webmvc-ui -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.8.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.therapi</groupId>
|
||||
@ -333,6 +344,13 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 设备管理模块 -->
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-equipment</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-job</artifactId>
|
||||
@ -351,11 +369,7 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-app</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 工作流模块 -->
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user