forked from dyf/fys-Multi-tenant
Merge branch 'main' into dyf-device
# Conflicts: # fys-modules/pom.xml # pom.xml
This commit is contained in:
@ -105,6 +105,13 @@
|
|||||||
<artifactId>fys-workflow</artifactId>
|
<artifactId>fys-workflow</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- app模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-app</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
|||||||
@ -0,0 +1,161 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.fuyuanshen.app.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceVo {
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
private String deviceType;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@ -0,0 +1,188 @@
|
|||||||
|
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 roleService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账户密码错误次数 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
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
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
# 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
|
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
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: 1fys@QWER..
|
||||||
# # 从库数据源
|
# # 从库数据源
|
||||||
# slave:
|
# slave:
|
||||||
# lazy: true
|
# lazy: true
|
||||||
@ -98,13 +98,13 @@ spring:
|
|||||||
spring.data:
|
spring.data:
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: 123.207.99.140
|
host: 120.79.224.186
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 26379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 2
|
database: 2
|
||||||
# redis 密码必须配置
|
# redis 密码必须配置
|
||||||
password: ccxx11234
|
password: 1fys@QWER..
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# 是否开启ssl
|
# 是否开启ssl
|
||||||
|
|||||||
@ -127,6 +127,9 @@ tenant:
|
|||||||
- sys_user_role
|
- sys_user_role
|
||||||
- sys_client
|
- sys_client
|
||||||
- sys_oss_config
|
- sys_oss_config
|
||||||
|
- app_menu
|
||||||
|
- app_user_role
|
||||||
|
- app_role_menu
|
||||||
|
|
||||||
# MyBatisPlus配置
|
# MyBatisPlus配置
|
||||||
# https://baomidou.com/config/
|
# https://baomidou.com/config/
|
||||||
|
|||||||
@ -0,0 +1,148 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,12 +2,15 @@ package com.fuyuanshen.common.satoken.core.service;
|
|||||||
|
|
||||||
import cn.dev33.satoken.stp.StpInterface;
|
import cn.dev33.satoken.stp.StpInterface;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.domain.model.LoginUser;
|
||||||
import com.fuyuanshen.common.core.enums.UserType;
|
import com.fuyuanshen.common.core.enums.UserType;
|
||||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
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.service.PermissionService;
|
||||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -25,6 +28,24 @@ public class SaPermissionImpl implements StpInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
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 实现类不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserType userType = UserType.getUserType(loginUser.getUserType());
|
||||||
|
if (userType == UserType.APP_USER) {
|
||||||
|
// 其他端 自行根据业务编写
|
||||||
|
}
|
||||||
|
// SYS_USER 默认返回权限
|
||||||
|
return new ArrayList<>(loginUser.getMenuPermission());
|
||||||
|
}else {
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
if (ObjectUtil.isNull(loginUser) || !loginUser.getLoginId().equals(loginId)) {
|
if (ObjectUtil.isNull(loginUser) || !loginUser.getLoginId().equals(loginId)) {
|
||||||
PermissionService permissionService = getPermissionService();
|
PermissionService permissionService = getPermissionService();
|
||||||
@ -43,6 +64,8 @@ public class SaPermissionImpl implements StpInterface {
|
|||||||
return new ArrayList<>(loginUser.getMenuPermission());
|
return new ArrayList<>(loginUser.getMenuPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色权限列表
|
* 获取角色权限列表
|
||||||
*/
|
*/
|
||||||
@ -74,4 +97,12 @@ public class SaPermissionImpl implements StpInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AppPermissionService getAppPermissionService() {
|
||||||
|
try {
|
||||||
|
return SpringUtils.getBean(AppPermissionService.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,217 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
105
fys-modules/fys-app/pom.xml
Normal file
105
fys-modules/fys-app/pom.xml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<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>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-modules</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>fys-app</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
app模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<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-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-ratelimiter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-translation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-sensitive</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-encrypt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,127 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,142 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<?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>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
<?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>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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>
|
||||||
@ -17,6 +17,7 @@
|
|||||||
<module>fys-workflow</module>
|
<module>fys-workflow</module>
|
||||||
<module>fys-equipment</module>
|
<module>fys-equipment</module>
|
||||||
<module>fys-customer</module>
|
<module>fys-customer</module>
|
||||||
|
<module>fys-app</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>fys-modules</artifactId>
|
<artifactId>fys-modules</artifactId>
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@ -370,6 +370,12 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-app</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
<artifactId>fys-demo</artifactId>
|
<artifactId>fys-demo</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user