优化注释

cloud-master
面包骑士 2024-09-23 22:36:18 +08:00
parent 4078efaf92
commit 2d64aa8eb5
61 changed files with 738 additions and 203 deletions

View File

@ -16,23 +16,10 @@
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.muyu</groupId>-->
<!-- <artifactId>cloud-common-saas</artifactId>-->
<!-- </dependency>-->
<!-- SpringBoot Web -->
<dependency>
@ -58,6 +45,48 @@
<artifactId>cloud-common-api-doc</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-log</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -1,5 +1,8 @@
package com.muyu.auth;
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -10,8 +13,15 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
*
* @author muyu
*/
@EnableCustomConfig
@EnableMyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@SpringBootApplication(
exclude = {
DataSourceAutoConfiguration.class,
DruidDataSourceAutoConfigure.class,
DynamicDataSourceAutoConfiguration.class
}
)
public class CloudAuthApplication {
public static void main (String[] args) {
SpringApplication.run(CloudAuthApplication.class, args);

View File

@ -10,7 +10,7 @@ import com.muyu.common.security.auth.AuthUtil;
import com.muyu.common.security.service.TokenService;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -25,10 +25,10 @@ import jakarta.servlet.http.HttpServletRequest;
*/
@RestController
public class TokenController {
@Autowired
@Resource
private TokenService tokenService;
@Autowired
@Resource
private SysLoginService sysLoginService;
@PostMapping("login")

View File

@ -13,12 +13,16 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.ip.IpUtils;
import com.muyu.common.redis.service.RedisService;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.remote.RemoteSaasService;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
*
*
@ -26,18 +30,21 @@ import org.springframework.stereotype.Component;
*/
@Component
public class SysLoginService {
@Autowired
@Resource
private RemoteUserService remoteUserService;
@Autowired
@Resource
private SysPasswordService passwordService;
@Autowired
@Resource
private SysRecordLogService recordLogService;
@Autowired
@Resource
private RedisService redisService;
@Resource
private RemoteSaasService remoteSaasService;
/**
*
*/
@ -69,7 +76,7 @@ public class SysLoginService {
throw new ServiceException("很遗憾访问IP已被列入系统黑名单");
}
// 查询用户信息
Result<LoginUser> userResult = remoteUserService.getUserInfo(firmCode, username, SecurityConstants.INNER);
Result<SysUser> userResult = remoteSaasService.getUserInfo(firmCode, username, SecurityConstants.INNER);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
@ -80,8 +87,7 @@ public class SysLoginService {
throw new ServiceException(userResult.getMsg());
}
LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser();
SysUser user = userResult.getData();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
@ -92,7 +98,16 @@ public class SysLoginService {
}
passwordService.validate(user, password);
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
return userInfo;
// 角色集合
Set<String> roles = remoteUserService.getRolePermission(user);
// 权限集合
Set<String> permissions = remoteUserService.getMenuPermission(user);
LoginUser sysUserVo = new LoginUser();
sysUserVo.setSysUser(user);
sysUserVo.setRoles(roles);
sysUserVo.setPermissions(permissions);
return sysUserVo;
}
public void logout (String loginName) {

View File

@ -6,7 +6,7 @@ import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.redis.service.RedisService;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
@ -18,14 +18,14 @@ import java.util.concurrent.TimeUnit;
*/
@Component
public class SysPasswordService {
@Autowired
@Resource
private RedisService redisService;
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
@Autowired
@Resource
private SysRecordLogService recordLogService;
/**

View File

@ -6,7 +6,7 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.ip.IpUtils;
import com.muyu.common.system.remote.RemoteLogService;
import com.muyu.common.system.domain.SysLogininfor;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
/**
@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
*/
@Component
public class SysRecordLogService {
@Autowired
@Resource
private RemoteLogService remoteLogService;
/**

View File

@ -27,4 +27,6 @@ public class ServiceNameConstants {
public static final String SMART_SERVICE = "cloud-smart-car";
public static final String ENT_SERVICE = "cloud-ent";
public static final String SAAS_SERVICE = "cloud-system-saas";
}

View File

@ -18,7 +18,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
@ -48,7 +48,7 @@ public class LogAspect {
*/
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
@Autowired
@Resource
private AsyncLogService asyncLogService;
/**

View File

@ -3,7 +3,7 @@ package com.muyu.common.log.service;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.system.remote.RemoteLogService;
import com.muyu.common.system.domain.SysOperLog;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
*/
@Service
public class AsyncLogService {
@Autowired
@Resource
private RemoteLogService remoteLogService;
/**

View File

@ -2,7 +2,7 @@ package com.muyu.common.rabbit;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
@ -16,7 +16,7 @@ public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit
}
//以下配置RabbitMQ消息服务
@Autowired
@Resource
public ConnectionFactory connectionFactory;

View File

@ -1,6 +1,6 @@
package com.muyu.common.redis.service;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
@SuppressWarnings(value = {"unchecked", "rawtypes"})
@Component
public class RedisService {
@Autowired
@Resource
public RedisTemplate redisTemplate;
/**

View File

@ -1,10 +1,8 @@
package com.muyu.cloud.common.many.datasource;
import cn.hutool.json.JSONObject;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
import com.muyu.cloud.common.saas.domain.model.EntInfo;
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
@ -12,30 +10,17 @@ import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
import com.muyu.cloud.common.saas.exception.SaaSException;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.SpringUtils;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.domain.SysFirmUser;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteEntService;
import com.muyu.common.system.remote.RemoteUserService;
import lombok.extern.log4j.Log4j2;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Author: DongZeLiang
@ -83,7 +68,7 @@ public class ManyDataSource implements ApplicationRunner{
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
// 企业列表 企业CODE端口IP
Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceInfoList()
Objects.requireNonNull(dataSourceInfoList())
.stream()
.map(DataSourceInfo::hostAndPortBuild)
.forEach(dataSourceInfo -> {

View File

@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import java.util.List;
@ -19,6 +20,7 @@ import java.util.Map;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class DynamicDataSource extends AbstractRoutingDataSource {
@ -42,8 +44,12 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
* @param value
*/
public void put(String key, DruidDataSource value) {
defineTargetDataSources.put(key, value);
this.afterPropertiesSet();
if (value!=null) {
defineTargetDataSources.put(key, value);
this.afterPropertiesSet();
}else{
log.warn("Key为 {} 的数据源为空!",key);
}
}
/**

View File

@ -12,7 +12,7 @@ public class WebMvcSaaSConfig implements WebMvcConfigurer {
/**
*
*/
public static final String[] EXCLUDE_URLS = {"/dept/**", "/login", "/logout", "/refresh"};
public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh"};
@Override
public void addInterceptors (InterceptorRegistry registry) {

View File

@ -12,7 +12,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
@ -34,7 +34,7 @@ public class TokenService {
private final static long expireTime = CacheConstants.EXPIRATION;
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
@Autowired
@Resource
private RedisService redisService;
/**

View File

@ -1,23 +0,0 @@
package com.muyu.common.system.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.remote.factory.RemoteEntFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
*
*
* @author muyu
*/
@FeignClient(contextId = "remoteEntService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteEntFallbackFactory.class)
public interface RemoteEntService {
}

View File

@ -0,0 +1,32 @@
package com.muyu.common.system.remote;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
*
* @author muyu
*/
@FeignClient(contextId = "remoteSaasService", value = ServiceNameConstants.SAAS_SERVICE, fallbackFactory = RemoteSaasFallbackFactory.class)
public interface RemoteSaasService {
/**
*
*
* @param firmCode
* @param username
* @param source
* @return
*/
@GetMapping("/user/info")
public Result<SysUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

View File

@ -13,6 +13,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
/**
*
@ -21,16 +22,6 @@ import java.util.List;
*/
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
/**
*
*
* @param username
* @param source
*
* @return
*/
@GetMapping("/user/info")
public Result<LoginUser> getUserInfo (@RequestParam("firmCode") String firmCode,@RequestParam("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
@ -48,4 +39,24 @@ public interface RemoteUserService {
@PostMapping("/ent/list")
public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt);
/**
*
*
* @param user
*
* @return
*/
@PostMapping("/permission/getRole")
public Set<String> getRolePermission (@RequestBody SysUser user);
/**
*
*
* @param user
*
* @return
*/
@PostMapping("/permission/getMenu")
public Set<String> getMenuPermission (@RequestBody SysUser user);
}

View File

@ -9,13 +9,11 @@ package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.remote.RemoteEntService;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteSaasService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author:
* @Name: RemoteEntFallbackFactory
@ -24,11 +22,15 @@ import java.util.List;
* @FilePath: com.muyu.common.system.remote
*/
@Component
public class RemoteEntFallbackFactory implements FallbackFactory<RemoteEntService> {
public class RemoteSaasFallbackFactory implements FallbackFactory<RemoteSaasService> {
@Override
public RemoteEntService create(Throwable cause) {
return new RemoteEntService() {
public RemoteSaasService create(Throwable cause) {
return new RemoteSaasService() {
@Override
public Result<SysUser> getUserInfo(String firmCode, String username, String source) {
return Result.error("获取用户失败:" + cause.getMessage());
}
};
}
}

View File

@ -13,6 +13,7 @@ import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/**
*
@ -28,11 +29,6 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteUserService() {
@Override
public Result<LoginUser> getUserInfo(String firmCode, String username, String source) {
return Result.error("获取用户失败:" + throwable.getMessage());
}
@Override
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
return Result.error("注册用户失败:" + throwable.getMessage());
@ -48,6 +44,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
return Result.error("获取企业列表失败:" + throwable.getMessage());
}
@Override
public Set<String> getRolePermission(SysUser user) {
return Set.of();
}
@Override
public Set<String> getMenuPermission(SysUser user) {
return Set.of();
}
};
}
}

View File

@ -1,4 +1,4 @@
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
com.muyu.common.system.remote.factory.RemoteEntFallbackFactory
com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory

View File

@ -1,7 +1,7 @@
package com.muyu.gateway.config;
import com.muyu.gateway.handler.ValidateCodeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
@ -16,7 +16,7 @@ import org.springframework.web.reactive.function.server.RouterFunctions;
*/
@Configuration
public class RouterFunctionConfiguration {
@Autowired
@Resource
private ValidateCodeHandler validateCodeHandler;
@SuppressWarnings("rawtypes")

View File

@ -12,7 +12,7 @@ import com.muyu.gateway.config.properties.IgnoreWhiteProperties;
import io.jsonwebtoken.Claims;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
@ -31,10 +31,10 @@ public class AuthFilter implements GlobalFilter, Ordered {
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
// 排除过滤的 uri 地址nacos自行添加
@Autowired
@Resource
private IgnoreWhiteProperties ignoreWhite;
@Autowired
@Resource
private RedisService redisService;

View File

@ -6,7 +6,7 @@ import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.gateway.config.properties.CaptchaProperties;
import com.muyu.gateway.service.ValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.core.io.buffer.DataBuffer;
@ -29,9 +29,9 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
private static final String CODE = "code";
private static final String UUID = "uuid";
@Autowired
@Resource
private ValidateCodeService validateCodeService;
@Autowired
@Resource
private CaptchaProperties captchaProperties;
@Override

View File

@ -4,7 +4,7 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.html.EscapeUtil;
import com.muyu.gateway.config.properties.XssProperties;
import io.netty.buffer.ByteBufAllocator;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets;
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
public class XssFilter implements GlobalFilter, Ordered {
// 跨站脚本的 xss 配置nacos自行添加
@Autowired
@Resource
private XssProperties xss;
@Override

View File

@ -3,7 +3,7 @@ package com.muyu.gateway.handler;
import com.muyu.common.core.exception.CaptchaException;
import com.muyu.common.core.domain.Result;
import com.muyu.gateway.service.ValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
@ -21,7 +21,7 @@ import java.io.IOException;
*/
@Component
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
@Autowired
@Resource
private ValidateCodeService validateCodeService;
@Override

View File

@ -12,7 +12,7 @@ import com.muyu.common.redis.service.RedisService;
import com.muyu.gateway.config.properties.CaptchaProperties;
import com.muyu.gateway.model.resp.CaptchaCodeResp;
import com.muyu.gateway.service.ValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.FastByteArrayOutputStream;
@ -35,10 +35,10 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
@Resource
private RedisService redisService;
@Autowired
@Resource
private CaptchaProperties captchaProperties;
/**

View File

@ -6,7 +6,7 @@ import com.muyu.file.service.ISysFileService;
import com.muyu.common.system.domain.SysFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
@ -21,7 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
public class SysFileController {
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
@Autowired
@Resource
private ISysFileService sysFileService;
/**

View File

@ -5,7 +5,7 @@ import com.muyu.file.config.MinioConfig;
import com.muyu.file.utils.FileUploadUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -18,10 +18,10 @@ import java.io.InputStream;
*/
@Service
public class MinioSysFileServiceImpl implements ISysFileService {
@Autowired
@Resource
private MinioConfig minioConfig;
@Autowired
@Resource
private MinioClient client;
/**

View File

@ -22,6 +22,12 @@
<groupId>com.muyu</groupId>
<artifactId>cloud-common-saas</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-system</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
@ -76,12 +82,6 @@
<artifactId>cloud-common-api-doc</artifactId>
</dependency>
<!-- XllJob定时任务 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-xxl</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,45 @@
package com.muyu.system.saas.controller;
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.security.annotation.InnerAuth;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.common.system.domain.SysUser;
import com.muyu.system.saas.service.SysUserService;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
/**
* @Author:
* @Name: SysUser
* @Description:
* @CreatedDate: 2024/9/23 8:55
* @FilePath: com.muyu.system.saas.controller
*/
@Slf4j
@RestController
@RequestMapping("/user")
public class SysUserController {
@Resource
private SysUserService userService;
@InnerAuth
@GetMapping("/info")
public Result<SysUser> info (
@RequestParam("firmCode") String firmCode,
@RequestParam("userName") String userName) {
DynamicDataSourceHolder.setDynamicDataSourceKey(firmCode);
SysUser sysUser = userService.selectUserByUserName(userName);
if (StringUtils.isNull(sysUser)) {
return Result.error("用户名或密码错误");
}
return Result.success(sysUser);
}
}

View File

@ -0,0 +1,22 @@
package com.muyu.system.saas.mapper;
import com.muyu.common.system.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Author:
* @Name: SysUser
* @Description:
* @CreatedDate: 2024/9/23 8:53
* @FilePath: com.muyu.system.saas.mapper
*/
@Repository
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
SysUser selectUserByUserName(@Param("userName") String userName);
}

View File

@ -0,0 +1,18 @@
package com.muyu.system.saas.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.system.domain.SysUser;
/**
* @Author:
* @Name: SysUser
* @Description:
* @CreatedDate: 2024/9/23 8:55
* @FilePath: com.muyu.system.saas.service.impl
*/
public interface SysUserService extends IService<SysUser> {
SysUser selectUserByUserName(String userName);
}

View File

@ -0,0 +1,33 @@
package com.muyu.system.saas.service.impl;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.common.system.domain.SysUser;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.system.saas.mapper.SysUserMapper;
import com.muyu.system.saas.service.SysUserService;
/**
* @Author:
* @Name: SysUser
* @Description:
* @CreatedDate: 2024/9/23 8:55
* @FilePath: com.muyu.system.saas.service.impl
*/
@Slf4j
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
implements SysUserService {
@Resource
private SysUserMapper userMapper;
@Override
public SysUser selectUserByUserName(String userName) {
return userMapper.selectUserByUserName(userName);
}
}

View File

@ -0,0 +1,287 @@
<?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.muyu.system.saas.mapper.SysUserMapper">
<resultMap type="com.muyu.common.system.domain.SysUser" id="SysUserResult">
<id property="userId" column="user_id"/>
<result property="isAdmin" column="is_admin"/>
<result property="deptId" column="dept_id"/>
<result property="firmCode" column="firm_code"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="email" column="email"/>
<result property="phonenumber" column="phonenumber"/>
<result property="sex" column="sex"/>
<result property="avatar" column="avatar"/>
<result property="password" column="password"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="loginIp" column="login_ip"/>
<result property="loginDate" column="login_date"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<association property="dept" javaType="com.muyu.common.system.domain.SysDept" resultMap="deptResult"/>
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
</resultMap>
<resultMap id="deptResult" type="com.muyu.common.system.domain.SysDept">
<id property="deptId" column="dept_id"/>
<result property="parentId" column="parent_id"/>
<result property="deptName" column="dept_name"/>
<result property="ancestors" column="ancestors"/>
<result property="orderNum" column="order_num"/>
<result property="leader" column="leader"/>
<result property="status" column="dept_status"/>
</resultMap>
<resultMap id="RoleResult" type="com.muyu.common.system.domain.SysRole">
<id property="roleId" column="role_id"/>
<result property="roleName" column="role_name"/>
<result property="roleKey" column="role_key"/>
<result property="roleSort" column="role_sort"/>
<result property="dataScope" column="data_scope"/>
<result property="status" column="role_status"/>
</resultMap>
<sql id="selectUserVo">
select u.user_id,
u.is_admin,
u.dept_id,
u.firm_code,
u.user_name,
u.nick_name,
u.email,
u.avatar,
u.phonenumber,
u.password,
u.sex,
u.status,
u.del_flag,
u.login_ip,
u.login_date,
u.create_by,
u.create_time,
u.remark,
d.dept_id,
d.parent_id,
d.ancestors,
d.dept_name,
d.order_num,
d.leader,
d.status as dept_status,
r.role_id,
r.role_name,
r.role_key,
r.role_sort,
r.data_scope,
r.status as role_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
</sql>
<select id="selectUserList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id,u.is_admin, u.nick_name,u.firm_code, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.del_flag,u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user
u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
</if>
<if test="firmCode != null and firmCode != '' and firmCode != 'FIRM'">
AND u.firm_code like concat('%', #{firmCode}, '%')
</if>
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
ancestors) ))
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectAllocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id,u.is_admin, u.dept_id,u.firm_code, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and r.role_id = #{roleId}
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUnallocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id,u.is_admin, u.dept_id,u.firm_code, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
ur.role_id = #{roleId})
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select user_id, user_name
from sys_user
where user_name = #{userName}
and del_flag = '0'
limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber
from sys_user
where phonenumber = #{phonenumber}
and del_flag = '0'
limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email
from sys_user
where email = #{email}
and del_flag = '0'
limit 1
</select>
<select id="selectCompanyList" resultType="com.muyu.common.system.domain.SysUser">
select * from sys_user
</select>
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="isAdmin != null and isAdmin != 0">is_admin,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="firmCode != null and firmCode != ''">firm_code,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="isAdmin != null and isAdmin != ''">#{isAdmin},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="firmCode != null and firmCode != ''">#{firmCode},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
update sys_user
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="firmCode != null and firmCode != ''">firm_code = #{firmCode},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where user_id = #{userId}
</update>
<update id="updateUserStatus" parameterType="com.muyu.common.system.domain.SysUser">
update sys_user
set status = #{status}
where user_id = #{userId}
</update>
<update id="updateUserAvatar" parameterType="com.muyu.common.system.domain.SysUser">
update sys_user
set avatar = #{avatar}
where user_name = #{userName}
</update>
<update id="resetUserPwd" parameterType="com.muyu.common.system.domain.SysUser">
update sys_user
set password = #{password}
where user_name = #{userName}
</update>
<delete id="deleteUserById" parameterType="Long">
update sys_user
set del_flag = '2'
where user_id = #{userId}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>

View File

@ -13,7 +13,7 @@ import com.muyu.system.service.SysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -30,7 +30,7 @@ import java.util.List;
@Tag(name = "SysConfigController", description = "系统参数配置")
public class SysConfigController extends BaseController {
@Autowired
@Resource
private SysConfigService configService;
/**

View File

@ -11,7 +11,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysDept;
import com.muyu.system.service.SysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -26,7 +26,7 @@ import java.util.List;
@RequestMapping("/dept")
public class SysDeptController extends BaseController {
@Autowired
@Resource
private SysDeptService deptService;
/**

View File

@ -12,7 +12,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysDictData;
import com.muyu.system.service.SysDictDataService;
import com.muyu.system.service.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -28,10 +28,10 @@ import java.util.List;
@RestController
@RequestMapping("/dict/data")
public class SysDictDataController extends BaseController {
@Autowired
@Resource
private SysDictDataService dictDataService;
@Autowired
@Resource
private SysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:list")

View File

@ -10,7 +10,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysDictType;
import com.muyu.system.service.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/dict/type")
public class SysDictTypeController extends BaseController {
@Autowired
@Resource
private SysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:list")

View File

@ -12,7 +12,7 @@ import com.muyu.common.security.annotation.InnerAuth;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.system.domain.SysLogininfor;
import com.muyu.system.service.SysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
@ -26,10 +26,10 @@ import java.util.List;
@RestController
@RequestMapping("/logininfor")
public class SysLogininforController extends BaseController {
@Autowired
@Resource
private SysLogininforService logininforService;
@Autowired
@Resource
private RedisService redisService;
@RequiresPermissions("system:logininfor:list")

View File

@ -11,7 +11,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.SysMenu;
import com.muyu.system.domain.resp.RoleMenuTreeResp;
import com.muyu.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/menu")
public class SysMenuController extends BaseController {
@Autowired
@Resource
private SysMenuService menuService;
/**

View File

@ -9,7 +9,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -23,7 +23,7 @@ import java.util.List;
@RestController
@RequestMapping("/notice")
public class SysNoticeController extends BaseController {
@Autowired
@Resource
private SysNoticeService noticeService;
/**

View File

@ -10,7 +10,7 @@ import com.muyu.common.security.annotation.InnerAuth;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.system.domain.SysOperLog;
import com.muyu.system.service.SysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
@ -24,7 +24,7 @@ import java.util.List;
@RestController
@RequestMapping("/operlog")
public class SysOperlogController extends BaseController {
@Autowired
@Resource
private SysOperLogService operLogService;
@RequiresPermissions("system:operlog:list")

View File

@ -0,0 +1,55 @@
package com.muyu.system.controller;
import com.muyu.common.system.domain.SysUser;
import com.muyu.system.service.SysPermissionService;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
import java.util.HashSet;
import java.util.Set;
/**
* @Author:
* @Name: SysPermission
* @Description:
* @CreatedDate: 2024/9/23 8:58
* @FilePath: com.muyu.system.controller
*/
@Slf4j
@RestController
@RequestMapping("/permission")
public class SysPermissionController {
@Resource
private SysPermissionService permissionService;
/**
*
*
* @param user
*
* @return
*/
@PostMapping("/getRole")
public Set<String> getRolePermission (@RequestBody SysUser user) {
return permissionService.getRolePermission(user);
}
/**
*
*
* @param user
*
* @return
*/
@PostMapping("/getMenu")
public Set<String> getMenuPermission (@RequestBody SysUser user) {
return permissionService.getMenuPermission(user);
}
}

View File

@ -10,7 +10,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.SysPost;
import com.muyu.system.service.SysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/post")
public class SysPostController extends BaseController {
@Autowired
@Resource
private SysPostService postService;
/**

View File

@ -17,7 +17,7 @@ import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.resp.ProfileResp;
import com.muyu.system.service.SysUserService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -32,10 +32,10 @@ import java.util.Arrays;
@RestController
@RequestMapping("/user/profile")
public class SysProfileController extends BaseController {
@Autowired
@Resource
private SysUserService userService;
@Autowired
@Resource
private TokenService tokenService;
@Resource

View File

@ -16,7 +16,7 @@ import com.muyu.system.domain.resp.DeptTreeResp;
import com.muyu.system.service.SysDeptService;
import com.muyu.system.service.SysRoleService;
import com.muyu.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -31,13 +31,13 @@ import java.util.List;
@RestController
@RequestMapping("/role")
public class SysRoleController extends BaseController {
@Autowired
@Resource
private SysRoleService roleService;
@Autowired
@Resource
private SysUserService userService;
@Autowired
@Resource
private SysDeptService deptService;
@RequiresPermissions("system:role:list")

View File

@ -20,7 +20,7 @@ import com.muyu.system.domain.resp.UserInfoResp;
import com.muyu.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -39,22 +39,22 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/user")
public class SysUserController extends BaseController {
@Autowired
@Resource
private SysUserService userService;
@Autowired
@Resource
private SysRoleService roleService;
@Autowired
@Resource
private SysDeptService deptService;
@Autowired
@Resource
private SysPostService postService;
@Autowired
@Resource
private SysPermissionService permissionService;
@Autowired
@Resource
private SysConfigService configService;
/**

View File

@ -12,7 +12,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.SysUserOnline;
import com.muyu.system.service.SysUserOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@ -28,10 +28,10 @@ import java.util.List;
@RestController
@RequestMapping("/online")
public class SysUserOnlineController extends BaseController {
@Autowired
@Resource
private SysUserOnlineService userOnlineService;
@Autowired
@Resource
private RedisService redisService;
@RequiresPermissions("monitor:online:list")

View File

@ -8,7 +8,7 @@
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import javax.annotation.Resource;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
@ -18,7 +18,7 @@
//@RequestMapping("/rabbit/test")
//public class RabbitTest {
//
// @Autowired
// @Resource
// private RabbitTemplate rabbitTemplate;
//
// @Bean

View File

@ -47,6 +47,7 @@ public interface SysUserService extends IService<SysUser> {
*/
public SysUser selectUserByUserName (String firmCode, String userName);
/**
* ID
*
@ -227,5 +228,4 @@ public interface SysUserService extends IService<SysUser> {
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
List<SysUser> selectCompanyList();
}

View File

@ -8,7 +8,7 @@ import com.muyu.common.redis.service.RedisService;
import com.muyu.system.domain.SysConfig;
import com.muyu.system.mapper.SysConfigMapper;
import com.muyu.system.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -26,7 +26,7 @@ import java.util.Objects;
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig>
implements SysConfigService {
@Autowired
@Resource
private RedisService redisService;
@Override

View File

@ -15,7 +15,7 @@ import com.muyu.system.domain.vo.TreeSelect;
import com.muyu.system.mapper.SysDeptMapper;
import com.muyu.system.mapper.SysRoleMapper;
import com.muyu.system.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -31,10 +31,10 @@ import java.util.stream.Collectors;
*/
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
@Autowired
@Resource
private SysDeptMapper deptMapper;
@Autowired
@Resource
private SysRoleMapper roleMapper;
/**

View File

@ -5,7 +5,7 @@ import com.muyu.common.security.utils.DictUtils;
import com.muyu.common.system.domain.SysDictData;
import com.muyu.system.mapper.SysDictDataMapper;
import com.muyu.system.service.SysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -17,7 +17,7 @@ import java.util.List;
*/
@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements SysDictDataService {
@Autowired
@Resource
private SysDictDataMapper dictDataMapper;
/**

View File

@ -10,7 +10,7 @@ import com.muyu.common.system.domain.SysDictType;
import com.muyu.system.mapper.SysDictDataMapper;
import com.muyu.system.mapper.SysDictTypeMapper;
import com.muyu.system.service.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -27,10 +27,10 @@ import java.util.stream.Collectors;
*/
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
@Autowired
@Resource
private SysDictTypeMapper dictTypeMapper;
@Autowired
@Resource
private SysDictDataMapper dictDataMapper;
/**

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.system.domain.SysLogininfor;
import com.muyu.system.mapper.SysLogininforMapper;
import com.muyu.system.service.SysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -17,7 +17,7 @@ import java.util.List;
@Service
public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, SysLogininfor> implements SysLogininforService {
@Autowired
@Resource
private SysLogininforMapper logininforMapper;
/**

View File

@ -15,7 +15,7 @@ import com.muyu.system.mapper.SysMenuMapper;
import com.muyu.system.mapper.SysRoleMapper;
import com.muyu.system.mapper.SysRoleMenuMapper;
import com.muyu.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.*;
@ -30,13 +30,13 @@ import java.util.stream.Collectors;
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
@Autowired
@Resource
private SysMenuMapper menuMapper;
@Autowired
@Resource
private SysRoleMapper roleMapper;
@Autowired
@Resource
private SysRoleMenuMapper roleMenuMapper;
/**

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.mapper.SysNoticeMapper;
import com.muyu.system.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -16,7 +16,7 @@ import java.util.List;
*/
@Service
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {
@Autowired
@Resource
private SysNoticeMapper noticeMapper;
/**

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.system.domain.SysOperLog;
import com.muyu.system.mapper.SysOperLogMapper;
import com.muyu.system.service.SysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -16,7 +16,7 @@ import java.util.List;
*/
@Service
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements SysOperLogService {
@Autowired
@Resource
private SysOperLogMapper operLogMapper;
/**

View File

@ -6,7 +6,7 @@ import com.muyu.common.system.domain.SysUser;
import com.muyu.system.service.SysMenuService;
import com.muyu.system.service.SysPermissionService;
import com.muyu.system.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -21,10 +21,10 @@ import java.util.Set;
*/
@Service
public class SysPermissionServiceImpl implements SysPermissionService {
@Autowired
@Resource
private SysRoleService roleService;
@Autowired
@Resource
private SysMenuService menuService;
/**

View File

@ -8,7 +8,7 @@ import com.muyu.system.domain.SysPost;
import com.muyu.system.mapper.SysPostMapper;
import com.muyu.system.mapper.SysUserPostMapper;
import com.muyu.system.service.SysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -20,10 +20,10 @@ import java.util.List;
*/
@Service
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements SysPostService {
@Autowired
@Resource
private SysPostMapper postMapper;
@Autowired
@Resource
private SysUserPostMapper userPostMapper;
/**