This commit is contained in:
2025-10-24 17:12:18 +08:00
commit 9dead7a890
2004 changed files with 298646 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>pxdj-java</artifactId>
<groupId>com.pxdj</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>pxdj-admin</artifactId>
<description>
web服务入口
</description>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<!-- Apache Commons IOFileUpload 依赖此库 -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.pxdj</groupId>
<artifactId>pxdj-framework</artifactId>
</dependency>
<!-- 代码生成-->
<dependency>
<groupId>com.pxdj</groupId>
<artifactId>pxdj-generator</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<!-- <version>2.5.1.RELEASE</version>-->
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.18</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,23 @@
package com.pxdj;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 启动程序
*
* @author ruoyi
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableScheduling
public class RuoYiApplication {
public static void main(String[] args) {
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("ruoyi启动成功");
}
}

View File

@@ -0,0 +1,18 @@
package com.pxdj;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* web容器中进行部署
*
* @author ruoyi
*/
public class RuoYiServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(RuoYiApplication.class);
}
}

View File

@@ -0,0 +1,85 @@
package com.pxdj.web.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
import static com.google.code.kaptcha.Constants.*;
/**
* 验证码配置
*
* @author ruoyi
*/
@Configuration
public class CaptchaConfig
{
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean()
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno
properties.setProperty(KAPTCHA_BORDER, "yes");
// 验证码文本字符颜色 默认为Color.BLACK
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black");
// 验证码图片宽度 默认为200
properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160");
// 验证码图片高度 默认为50
properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
// 验证码文本字符大小 默认为40
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38");
// KAPTCHA_SESSION_KEY
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode");
// 验证码文本字符长度 默认为5
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath()
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno
properties.setProperty(KAPTCHA_BORDER, "yes");
// 边框颜色 默认为Color.BLACK
properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90");
// 验证码文本字符颜色 默认为Color.BLACK
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue");
// 验证码图片宽度 默认为200
properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160");
// 验证码图片高度 默认为50
properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
// 验证码文本字符大小 默认为40
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35");
// KAPTCHA_SESSION_KEY
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath");
// 验证码文本生成器
properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.pxdj.framework.config.KaptchaTextCreator");
// 验证码文本字符间距 默认为2
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3");
// 验证码文本字符长度 默认为5
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6");
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// 验证码噪点颜色 默认为Color.BLACK
properties.setProperty(KAPTCHA_NOISE_COLOR, "white");
// 干扰实现类
properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}

View File

@@ -0,0 +1,148 @@
package com.pxdj.web.config.security;
import com.pxdj.framework.config.properties.PermitAllUrlProperties;
import com.pxdj.web.config.security.filter.JwtAuthenticationTokenFilter;
import com.pxdj.web.config.security.handle.AuthenticationEntryPointImpl;
import com.pxdj.web.config.security.handle.LogoutSuccessHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.web.filter.CorsFilter;
/**
* spring security配置
*
* @author ruoyi
*/
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter
{
/**
* 自定义用户认证逻辑
*/
@Autowired
private UserDetailsService userDetailsService;
/**
* 认证失败处理类
*/
@Autowired
private AuthenticationEntryPointImpl unauthorizedHandler;
/**
* 退出处理类
*/
@Autowired
private LogoutSuccessHandlerImpl logoutSuccessHandler;
/**
* token认证过滤器
*/
@Autowired
private JwtAuthenticationTokenFilter authenticationTokenFilter;
/**
* 跨域过滤器
*/
@Autowired
private CorsFilter corsFilter;
/**
* 允许匿名访问的地址
*/
@Autowired
private PermitAllUrlProperties permitAllUrl;
/**
* 解决 无法直接注入 AuthenticationManager
*
* @return
* @throws Exception
*/
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception
{
return super.authenticationManagerBean();
}
/**
* anyRequest | 匹配所有请求路径
* access | SpringEl表达式结果为true时可以访问
* anonymous | 匿名可以访问
* denyAll | 用户不能访问
* fullyAuthenticated | 用户完全认证可以访问非remember-me下自动登录
* hasAnyAuthority | 如果有参数,参数表示权限,则其中任何一个权限可以访问
* hasAnyRole | 如果有参数,参数表示角色,则其中任何一个角色可以访问
* hasAuthority | 如果有参数,参数表示权限,则其权限可以访问
* hasIpAddress | 如果有参数参数表示IP地址如果用户IP和参数匹配则可以访问
* hasRole | 如果有参数,参数表示角色,则其角色可以访问
* permitAll | 用户可以任意访问
* rememberMe | 允许通过remember-me登录的用户访问
* authenticated | 用户登录后可访问
*/
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception
{
// 注解标记允许匿名访问的url
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = httpSecurity.authorizeRequests();
permitAllUrl.getUrls().forEach(url -> registry.antMatchers(url).permitAll());
httpSecurity
// CSRF禁用因为不使用session
.csrf().disable()
// 禁用HTTP响应标头
.headers().cacheControl().disable().and()
// 认证失败处理类
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// 基于token所以不需要session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// 过滤请求
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/file/**/**","/login", "/register","/admin/user/**","/captchaImage","/api/withdrawal/**","/system/examine/**","/system/merchant/apply/**").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()
.headers().frameOptions().disable();
// 添加Logout filter
httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
// 添加JWT filter
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
// 添加CORS filter
httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
}
/**
* 强散列哈希加密实现
*/
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder()
{
return new BCryptPasswordEncoder();
}
/**
* 身份认证接口
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
}
}

View File

@@ -0,0 +1,28 @@
package com.pxdj.web.config.security.context;
import org.springframework.security.core.Authentication;
/**
* 身份验证信息
*
* @author ruoyi
*/
public class AuthenticationContextHolder
{
private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>();
public static Authentication getContext()
{
return contextHolder.get();
}
public static void setContext(Authentication context)
{
contextHolder.set(context);
}
public static void clearContext()
{
contextHolder.remove();
}
}

View File

@@ -0,0 +1,27 @@
package com.pxdj.web.config.security.context;
import com.pxdj.common.core.text.Convert;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
/**
* 权限信息
*
* @author ruoyi
*/
public class PermissionContextHolder
{
private static final String PERMISSION_CONTEXT_ATTRIBUTES = "PERMISSION_CONTEXT";
public static void setContext(String permission)
{
RequestContextHolder.currentRequestAttributes().setAttribute(PERMISSION_CONTEXT_ATTRIBUTES, permission,
RequestAttributes.SCOPE_REQUEST);
}
public static String getContext()
{
return Convert.toStr(RequestContextHolder.currentRequestAttributes().getAttribute(PERMISSION_CONTEXT_ATTRIBUTES,
RequestAttributes.SCOPE_REQUEST));
}
}

View File

@@ -0,0 +1,45 @@
package com.pxdj.web.config.security.filter;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* token过滤器 验证token有效性
*
* @author ruoyi
*/
@Component
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
{
@Autowired
private TokenService tokenService;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException
{
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
{
tokenService.verifyToken(loginUser);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities());
authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
}
chain.doFilter(request, response);
}
}

View File

@@ -0,0 +1,35 @@
package com.pxdj.web.config.security.handle;
import com.alibaba.fastjson2.JSON;
import com.pxdj.common.constant.HttpStatus;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.utils.ServletUtils;
import com.pxdj.common.utils.StringUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
/**
* 认证失败处理类 返回未授权
*
* @author ruoyi
*/
@Component
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable
{
private static final long serialVersionUID = -8970718410437077606L;
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
throws IOException
{
int code = HttpStatus.UNAUTHORIZED;
String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
}
}

View File

@@ -0,0 +1,53 @@
package com.pxdj.web.config.security.handle;
import com.alibaba.fastjson2.JSON;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.utils.ServletUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.framework.manager.AsyncManager;
import com.pxdj.framework.manager.factory.AsyncFactory;
import com.pxdj.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 自定义退出处理类 返回成功
*
* @author ruoyi
*/
@Configuration
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
{
@Autowired
private TokenService tokenService;
/**
* 退出处理
*
* @return
*/
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException, ServletException
{
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser))
{
String userName = loginUser.getUsername();
// 删除用户缓存记录
tokenService.delLoginUser(loginUser.getToken());
// 记录用户退出日志
AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "退出成功"));
}
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.success("退出成功")));
}
}

View File

@@ -0,0 +1,95 @@
package com.pxdj.web.controller.common;
import com.google.code.kaptcha.Producer;
import com.pxdj.common.config.RuoYiConfig;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.sign.Base64;
import com.pxdj.common.utils.uuid.IdUtils;
import com.pxdj.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
* 验证码操作处理
*
* @author ruoyi
*/
@RestController
public class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
private ISysConfigService configService;
/**
* 生成验证码
*/
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled();
ajax.put("captchaEnabled", captchaEnabled);
if (!captchaEnabled)
{
return ajax;
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
// 生成验证码
String captchaType = RuoYiConfig.getCaptchaType();
if ("math".equals(captchaType))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
image = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(captchaType))
{
capStr = code = captchaProducer.createText();
image = captchaProducer.createImage(capStr);
}
RedisUtil.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
try
{
ImageIO.write(image, "jpg", os);
}
catch (IOException e)
{
return AjaxResult.error(e.getMessage());
}
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
}

View File

@@ -0,0 +1,164 @@
package com.pxdj.web.controller.common;
import com.pxdj.common.config.RuoYiConfig;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.file.FileUploadUtils;
import com.pxdj.common.utils.file.FileUtils;
import com.pxdj.framework.config.ServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* 通用请求处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/common")
public class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
private static final String FILE_DELIMETER = ",";
/**
* 通用下载请求
*
* @param fileName 文件名称
* @param delete 是否删除
*/
@GetMapping("/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.checkAllowDownload(fileName))
{
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = RuoYiConfig.getDownloadPath() + fileName;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
/**
* 通用上传请求(单个)
*/
@PostMapping("/upload")
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
* 通用上传请求(多个)
*/
@PostMapping("/uploads")
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files)
{
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
* 本地资源通用下载
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
try
{
if (!FileUtils.checkAllowDownload(resource))
{
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
String localPath = RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
}

View File

@@ -0,0 +1,111 @@
package com.pxdj.web.controller.monitor;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.domain.SysCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 缓存监控
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/cache")
public class CacheController
{
@Autowired
private RedisTemplate<String, String> redisTemplate;
private final static List<SysCache> caches = new ArrayList<SysCache>();
{
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
Map<String, Object> result = new HashMap<>(3);
result.put("info", info);
result.put("dbSize", dbSize);
List<Map<String, String>> pieList = new ArrayList<>();
commandStats.stringPropertyNames().forEach(key -> {
Map<String, String> data = new HashMap<>(2);
String property = commandStats.getProperty(key);
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
pieList.add(data);
});
result.put("commandStats", pieList);
return AjaxResult.success(result);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getNames")
public AjaxResult cache()
{
return AjaxResult.success(caches);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getKeys/{cacheName}")
public AjaxResult getCacheKeys(@PathVariable String cacheName)
{
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
return AjaxResult.success(cacheKeys);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getValue/{cacheName}/{cacheKey}")
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
{
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
return AjaxResult.success(sysCache);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheName/{cacheName}")
public AjaxResult clearCacheName(@PathVariable String cacheName)
{
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheKey/{cacheKey}")
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
{
redisTemplate.delete(cacheKey);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheAll")
public AjaxResult clearCacheAll()
{
Collection<String> cacheKeys = redisTemplate.keys("*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
}

View File

@@ -0,0 +1,104 @@
package com.pxdj.web.controller.monitor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.Demo;
import com.pxdj.system.service.IDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 用户测试Controller
*
* @author ruoyi
* @date 2024-11-27
*/
@RestController
@RequestMapping("/user/demo")
@Api(value = "用户测试控制器", tags = {"用户测试管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class DemoController extends BaseController {
@Autowired
private final IDemoService demoService;
/**
* 查询用户测试列表
*/
@ApiOperation("查询用户测试列表")
@PreAuthorize("@ss.hasPermi('system:demo:list')")
@GetMapping("/list")
public TableDataInfo list(Demo demo) {
startPage();
List<Demo> list = demoService.list(new QueryWrapper<Demo>(demo));
return getDataTable(list);
}
/**
* 导出用户测试列表
*/
@ApiOperation("导出用户测试列表")
@PreAuthorize("@ss.hasPermi('system:demo:export')")
@Log(title = "用户测试", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(Demo demo) {
List<Demo> list = demoService.list(new QueryWrapper<Demo>(demo));
ExcelUtil<Demo> util = new ExcelUtil<Demo>(Demo.class);
return util.exportExcel(list, "用户测试数据");
}
/**
* 获取用户测试详细信息
*/
@ApiOperation("获取用户测试详细信息")
@PreAuthorize("@ss.hasPermi('system:demo:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(demoService.getById(id));
}
/**
* 新增用户测试
*/
@ApiOperation("新增用户测试")
@PreAuthorize("@ss.hasPermi('system:demo:add')")
@Log(title = "用户测试", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Demo demo) {
return toAjax(demoService.save(demo));
}
/**
* 修改用户测试
*/
@ApiOperation("修改用户测试")
@PreAuthorize("@ss.hasPermi('system:demo:edit')")
@Log(title = "用户测试", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Demo demo) {
return toAjax(demoService.updateById(demo));
}
/**
* 删除用户测试
*/
@ApiOperation("删除用户测试")
@PreAuthorize("@ss.hasPermi('system:demo:remove')")
@Log(title = "用户测试", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(demoService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,29 @@
package com.pxdj.web.controller.monitor;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.web.domain.Server;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 服务器监控
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/server")
public class ServerController
{
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Server server = new Server();
server.copyTo();
return AjaxResult.success(server);
}
}

View File

@@ -0,0 +1,79 @@
package com.pxdj.web.controller.monitor;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.SysLogininfor;
import com.pxdj.system.service.ISysLogininforService;
import com.pxdj.web.service.SysPasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 系统访问记录
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
@Autowired
private ISysLogininforService logininforService;
@Autowired
private SysPasswordService passwordService;
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
}
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志");
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}")
public AjaxResult remove(@PathVariable Long[] infoIds)
{
return toAjax(logininforService.deleteLogininforByIds(infoIds));
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{
logininforService.cleanLogininfor();
return success();
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public AjaxResult unlock(@PathVariable("userName") String userName)
{
passwordService.clearLoginRecordCache(userName);
return success();
}
}

View File

@@ -0,0 +1,65 @@
package com.pxdj.web.controller.monitor;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.SysOperLog;
import com.pxdj.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 操作日志记录
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
@Autowired
private ISysOperLogService operLogService;
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
}
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志");
}
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}")
public AjaxResult remove(@PathVariable Long[] operIds)
{
return toAjax(operLogService.deleteOperLogByIds(operIds));
}
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/clean")
public AjaxResult clean()
{
operLogService.cleanOperLog();
return success();
}
}

View File

@@ -0,0 +1,80 @@
package com.pxdj.web.controller.monitor;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.domain.SysUserOnline;
import com.pxdj.system.service.ISysUserOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* 在线用户监控
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
@Autowired
private ISysUserOnlineService userOnlineService;
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list")
public TableDataInfo list(String ipaddr, String userName)
{
Collection<String> keys = RedisUtil.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
LoginUser user = RedisUtil.getCacheObject(key);
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
{
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
}
else if (StringUtils.isNotEmpty(ipaddr))
{
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
}
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
{
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
}
else
{
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
}
}
Collections.reverse(userOnlineList);
userOnlineList.removeAll(Collections.singleton(null));
return getDataTable(userOnlineList);
}
/**
* 强退用户
*/
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@DeleteMapping("/{tokenId}")
public AjaxResult forceLogout(@PathVariable String tokenId)
{
RedisUtil.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
return success();
}
}

View File

@@ -0,0 +1,194 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package com.pxdj.web.controller.pxdj;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.Merchant;
import com.pxdj.api.domain.MerchantComm;
import com.pxdj.api.domain.User;
import com.pxdj.api.enums.BaseEnum;
import com.pxdj.api.service.MerchantService;
import com.pxdj.api.service.UserService;
import com.pxdj.api.vo.UserVO;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.api.service.MerchantCommService;
import com.pxdj.common.utils.StringUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author lanhai
*/
@RestController
@RequestMapping("/comm")
@Tag(name = "评论接口")
@AllArgsConstructor
public class CommController extends BaseController {
private final MerchantCommService prodCommService;
private final MerchantService merchantService;
private final UserService userService;
/**
* 查询评论列表
*/
@ApiOperation("查询评论列表")
@PreAuthorize("@ss.hasPermi('system:order:list')")
@GetMapping("/list")
public TableDataInfo list(MerchantComm merchantComm) {
startPage();
QueryWrapper<MerchantComm> wrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(merchantComm.getContent())) {
wrapper.like("content", merchantComm.getContent());
}
if (StringUtils.isNotEmpty(merchantComm.getName())) {
QueryWrapper<User> userWrapper = new QueryWrapper<>();
userWrapper.like("nick_name", merchantComm.getName());
List<User> users = userService.list(userWrapper);
List<String> userIds = users.stream()
.map(User::getUserId)
.collect(Collectors.toList());
if (!userIds.isEmpty()) {
wrapper.in("user_id", userIds);
}
}
if (merchantComm.getReplySts() != null) {
wrapper.eq("reply_sts", merchantComm.getReplySts());
}
if (merchantComm.getScore() != null) {
wrapper.eq("score", merchantComm.getScore());
}
if (merchantComm.getEvaluate() != null) {
wrapper.eq("evaluate", merchantComm.getEvaluate());
}
List<MerchantComm> list = prodCommService.list(wrapper);
// 关联用户信息和服务信息
if (!list.isEmpty()) {
// 获取所有用户ID和服务ID
List<String> userIds = list.stream()
.map(MerchantComm::getUserId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
List<String> merchantIds = list.stream()
.map(MerchantComm::getMerchantId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
// 查询所有相关用户
List<User> users = userService.listByIds(userIds);
Map<String, User> userMap = users.stream()
.collect(Collectors.toMap(User::getUserId, user -> user));
// 查询所有相关服务
List<Merchant> merchants = merchantService.listByIds(merchantIds);
Map<String, Merchant> merchantMap = merchants.stream()
.collect(Collectors.toMap(Merchant::getId, merchant -> merchant));
// 设置用户信息和服务信息
for (MerchantComm comm : list) {
// 设置用户信息
User user = userMap.get(comm.getUserId());
if (user != null) {
UserVO userVO = new UserVO();
userVO.setUserId(user.getUserId());
userVO.setNickName(user.getNickName());
userVO.setPic(user.getPic());
comm.setUser(userVO);
}
// 设置服务名称
Merchant merchant = merchantMap.get(comm.getMerchantId());
if (merchant != null) {
comm.setName(merchant.getName());
}
}
}
return getDataTable(list);
}
/**
* 获取评论详情
*/
@ApiOperation("获取评论详情")
@PreAuthorize("@ss.hasPermi('system:order:query')")
@GetMapping("/update/{id}")
public AjaxResult getInfo(@PathVariable Long id) {
MerchantComm merchantComm = prodCommService.getById(id);
if (merchantComm != null) {
// 关联用户信息
if (StringUtils.isNotEmpty(merchantComm.getUserId())) {
User user = userService.getById(merchantComm.getUserId());
if (user != null) {
UserVO userVO = new UserVO();
userVO.setUserId(user.getUserId());
userVO.setNickName(user.getNickName());
userVO.setPic(user.getPic());
merchantComm.setUser(userVO);
}
}
// 关联服务信息
if (StringUtils.isNotEmpty(merchantComm.getMerchantId())) {
Merchant merchant = merchantService.getById(merchantComm.getMerchantId());
if (merchant != null) {
merchantComm.setName(merchant.getName());
}
}
}
return success(merchantComm);
}
/**
* 修改
*/
@PostMapping("/update")
public AjaxResult edit(@RequestBody MerchantComm merchantComm)
{
prodCommService.updateById(merchantComm);
if (Objects.equals(merchantComm.getStatus(), BaseEnum.YES_ONE.getKey())){
merchantService.updateEvaluateNum(merchantComm.getMerchantId());
}
return success();
}
/**
* 删除评论
*/
@ApiOperation("删除评论")
@PreAuthorize("@ss.hasPermi('system:order:remove')")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
prodCommService.removeByIds(Arrays.asList(ids));
return success();
}
}

View File

@@ -0,0 +1,55 @@
package com.pxdj.web.controller.pxdj;
import com.pxdj.api.dto.FileDto;
import com.pxdj.api.service.AttachFileService;
import com.pxdj.common.bean.Qiniu;
import com.pxdj.common.response.ServerResponseEntity;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
/**
* @Author liwq
* @Date 2025年03月14日 14:38
* @Desc
*/
@RestController
@RequestMapping("file")
@AllArgsConstructor
public class FileController {
private Qiniu qiniu;
private AttachFileService attachFileService;
/**
* 通用上传请求(多个)
*/
@PostMapping("/uploads")
@SneakyThrows
public ServerResponseEntity<List<FileDto>> uploadFiles(List<MultipartFile> files) {
List<FileDto> fileDtoS = new ArrayList<>();
for (MultipartFile file : files) {
String fileName = attachFileService.uploadFile(file);
fileDtoS.add(new FileDto(qiniu.getResourcesUrl() + fileName, fileName));
}
return ServerResponseEntity.success(fileDtoS);
}
/**
* 上传文件
*/
@PostMapping("/upload")
@SneakyThrows
public ServerResponseEntity<FileDto> uploadFile(MultipartFile file) {
// 上传并返回新文件名称
String fileName = attachFileService.uploadFile(file);
return ServerResponseEntity.success(new FileDto(qiniu.getResourcesUrl() + fileName, fileName));
}
}

View File

@@ -0,0 +1,114 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.List;
import com.pxdj.api.domain.IndexImg;
import com.pxdj.api.domain.Merchant;
import com.pxdj.api.service.IndexImgService;
import com.pxdj.api.service.MerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
/**
* 主页轮播图Controller
*
* @author ZiJieNb
* @date 2025-03-31
*/
@RestController
@RequestMapping("/index/img")
@Api(value = "主页轮播图控制器", tags = {"主页轮播图管理"})
public class IndexImgController extends BaseController {
@Autowired
private IndexImgService indexImgService;
@Autowired
MerchantService merchantService;
/**
* 查询主页轮播图列表
*/
@ApiOperation("查询主页轮播图列表")
@PreAuthorize("@ss.hasPermi('index:img:list')")
@GetMapping("/list")
public TableDataInfo list(IndexImg indexImg) {
startPage();
QueryWrapper<IndexImg> wrapper = new QueryWrapper<>(indexImg);
List<IndexImg> list = indexImgService.list(wrapper);
// 关联商户信息
for (IndexImg img : list) {
Merchant merchant = merchantService.getById(img.getMerchantId());
if (merchant != null) {
img.setName(merchant.getName());
}
}
return getDataTable(list);
}
/**
* 导出主页轮播图列表
*/
@ApiOperation("导出主页轮播图列表")
@PreAuthorize("@ss.hasPermi('index:img:export')")
@Log(title = "主页轮播图", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(IndexImg indexImg) {
List<IndexImg> list = indexImgService.list(new QueryWrapper<IndexImg>(indexImg));
ExcelUtil<IndexImg> util = new ExcelUtil<IndexImg>(IndexImg.class);
return util.exportExcel(list, "主页轮播图数据");
}
/**
* 获取主页轮播图详细信息
*/
@ApiOperation("获取主页轮播图详细信息")
@PreAuthorize("@ss.hasPermi('index:img:query')")
@GetMapping(value = "/{imgId}")
public AjaxResult getInfo(@PathVariable("imgId") Long imgId) {
return AjaxResult.success(indexImgService.getById(imgId));
}
/**
* 新增主页轮播图
*/
@ApiOperation("新增主页轮播图")
@PreAuthorize("@ss.hasPermi('index:img:add')")
@Log(title = "主页轮播图", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IndexImg indexImg) {
return toAjax(indexImgService.save(indexImg));
}
/**
* 修改主页轮播图
*/
@ApiOperation("修改主页轮播图")
@PreAuthorize("@ss.hasPermi('index:img:edit')")
@Log(title = "主页轮播图", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IndexImg indexImg) {
return toAjax(indexImgService.updateById(indexImg));
}
/**
* 删除主页轮播图
*/
@ApiOperation("删除主页轮播图")
@PreAuthorize("@ss.hasPermi('index:img:remove')")
@Log(title = "主页轮播图", businessType = BusinessType.DELETE)
@DeleteMapping("/{imgIds}")
public AjaxResult remove(@PathVariable Long[] imgIds) {
return toAjax(indexImgService.removeByIds(Arrays.asList(imgIds)));
}
}

View File

@@ -0,0 +1,66 @@
package com.pxdj.web.controller.pxdj;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.Label;
import com.pxdj.api.domain.Project;
import com.pxdj.api.service.LabelService;
import com.pxdj.api.service.ProjectService;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 标签管理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/Label")
public class LabelController extends BaseController
{
@Autowired
private LabelService labelService;
/**
* 获取列表
*/
@GetMapping("/list")
public AjaxResult list(Label dept)
{
List<Label> projectList = labelService.list(new QueryWrapper<>());
return success(projectList);
}
/**
* 新增
*/
@PostMapping("/add")
public AjaxResult add(@RequestBody Label dept)
{
labelService.save(dept);
return success();
}
/**
* 修改
*/
@PostMapping("/update")
public AjaxResult edit(@RequestBody Label dept)
{
labelService.updateById(dept);
return success();
}
/**
* 删除
*/
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
labelService.removeById(id);
return success();
}
}

View File

@@ -0,0 +1,159 @@
package com.pxdj.web.controller.pxdj;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.Merchant;
import com.pxdj.api.domain.MerchantApply;
import com.pxdj.api.domain.MerchantLabel;
import com.pxdj.api.domain.User;
import com.pxdj.api.enums.BaseEnum;
import com.pxdj.api.service.MerchantApplyService;
import com.pxdj.api.service.MerchantLabelService;
import com.pxdj.api.service.MerchantService;
import com.pxdj.api.service.UserService;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDept;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.response.ServerResponseEntity;
import com.pxdj.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 商户入驻申请Controller
*/
@RestController
@RequestMapping("/merchant/apply")
@Api(value = "商户入驻申请控制器", tags = {"商户入驻申请管理"})
public class MerchantApplyController extends BaseController {
@Autowired
private MerchantApplyService merchantApplyService;
@Autowired
private MerchantService merchantService;
@Autowired
private UserService userService;
@Autowired
private MerchantLabelService merchantLabelService;
/**
* 查询商户入驻申请列表
*/
@ApiOperation("查询商户入驻申请列表")
@GetMapping("/list")
public TableDataInfo list(MerchantApply merchantApply) {
startPage();
List<Map<String, Object>> list = merchantApplyService.listApplyWithDeptName(merchantApply);
return getDataTable(list);
}
/**
* 获取商户入驻申请详细信息
*/
@ApiOperation("获取商户入驻申请详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
Map<String, Object> applyInfo = merchantApplyService.getApplyWithDeptName(id);
return AjaxResult.success(applyInfo);
}
/**
* 审核商户入驻申请
*/
@ApiOperation("审核商户入驻申请")
@Log(title = "商户入驻申请", businessType = BusinessType.UPDATE)
@PutMapping("/audit/{id}")
@Transactional(rollbackFor = Exception.class)
public AjaxResult audit(@PathVariable("id") Long id, @RequestParam("status") Integer status) {
MerchantApply merchantApply = merchantApplyService.getById(id);
if (merchantApply == null) {
return AjaxResult.error("申请记录不存在");
}
// 更新审核状态
merchantApply.setStatus(status);
boolean result = merchantApplyService.updateById(merchantApply);
if (result) {
if (status == 2) { // 通过
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserMobile, merchantApply.getMobile());
queryWrapper.eq(User::getUserType, 2);
User mUser = userService.getOne(queryWrapper);
if (mUser == null){
User user = new User();
String userId = IdUtil.simpleUUID();
Date now = new Date();
user.setModifyTime(now);
user.setUserRegtime(now);
user.setPic(merchantApply.getPhoto());
user.setNickName(merchantApply.getName());
user.setUserMobile(merchantApply.getMobile());
user.setUserId(userId);
user.setStatus(1);
user.setUserType(2);
userService.save(user);
Merchant merchant = new Merchant();
merchant.setId(user.getUserId());
merchant.setName(merchantApply.getName());
merchant.setCity(merchantApply.getTargetCity());
merchant.setPic(merchantApply.getPhoto());
merchant.setUpdateTime(new Date());
merchant.setStatus(BaseEnum.NO_ZERO.getKey());
merchant.setTeamId(merchantApply.getTeamId());
result = merchantService.save(merchant);
//新人标签
MerchantLabel merchantLabel = new MerchantLabel();
merchantLabel.setMerchantId(user.getUserId());
merchantLabel.setLabelId(5);
merchantLabel.setCreateTime(new Date());
merchantLabelService.save(merchantLabel);
}else {
Merchant existMerchant = merchantService.getById(mUser.getUserId());
// 如果商户已存在,更新状态为正常
existMerchant.setStatus(1);
existMerchant.setUpdateTime(new Date());
result = merchantService.updateById(existMerchant);
}
} else if (status == 3 || status == 1) { // 拒绝或回退
// 下架
QueryWrapper<Merchant> merchantQuery = new QueryWrapper<>();
merchantQuery.eq("id", merchantApply.getUserId());
Merchant merchant = merchantService.getOne(merchantQuery);
if (merchant != null) {
merchant.setStatus(0); // 下架
merchant.setUpdateTime(new Date());
result = merchantService.updateById(merchant);
}
}
}
return toAjax(result);
}
/**
* 删除商户入驻申请
*/
@ApiOperation("删除商户入驻申请")
@Log(title = "商户入驻申请", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(merchantApplyService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,650 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pxdj.api.domain.*;
import com.pxdj.api.service.*;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.security.access.prepost.PreAuthorize;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.Objects;
/**
* 商户信息Controller
*
* @author ZiJieNbPlus
* @date 2025-03-12
*/
@RestController
@RequestMapping("/system/merchant")
@Api(value = "商户信息控制器", tags = {"商户信息管理"})
public class MerchantController extends BaseController {
@Autowired
private MerchantService merchantService;
@Autowired
private MerchantAddrService merchantAddrService;
@Autowired
private MerchantProjectService merchantProjectService;
@Autowired
private ProjectService projectService;
@Autowired
private LabelService labelService;
@Autowired
private MerchantLabelService merchantLabelService;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private UserService userService;
/**
* 查询商户信息列表
*/
@ApiOperation("查询商户信息列表")
//@PreAuthorize("@ss.hasPermi('system:merchant:list')")
@GetMapping("/list")
public TableDataInfo list(Merchant merchant) {
// 构建模糊查询条件
QueryWrapper<Merchant> queryWrapper = new QueryWrapper<>();
if (merchant.getName() != null && !merchant.getName().isEmpty()) {
queryWrapper.like("name", merchant.getName());
}
if (merchant.getStatus() != null) {
queryWrapper.eq("status", merchant.getStatus());
}
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
if(departmentId!=100 && departmentId!=113){
String deptName = sysUser.getDept().getDeptName();
queryWrapper.like("city", deptName);
}else {
if (merchant.getCity() != null && !merchant.getCity().isEmpty()) {
queryWrapper.like("city", merchant.getCity());
}
}
Long parentId =sysUser.getDept().getParentId();
if(parentId == 101){
queryWrapper.eq("team_id", departmentId);
}
startPage();
List<Merchant> list = merchantService.list(queryWrapper);
if (list != null && !list.isEmpty()) {
// 获取所有商户ID
List<String> merchantIds = list.stream()
.map(Merchant::getId)
.map(Object::toString)
.collect(Collectors.toList());
// 批量查询所有商户地址
LambdaQueryWrapper<MerchantAddr> addrBatchQuery = new LambdaQueryWrapper<>();
addrBatchQuery.in(MerchantAddr::getMerchantId, merchantIds);
List<MerchantAddr> allAddresses = merchantAddrService.list(addrBatchQuery);
Map<String, MerchantAddr> addrMap = allAddresses.stream()
.collect(Collectors.toMap(MerchantAddr::getMerchantId, addr -> addr));
// 批量查询所有用户信息
List<String> userIds = list.stream()
.map(Merchant::getId)
.collect(Collectors.toList());
List<User> allUsers = userService.listByIds(userIds);
Map<String, User> userMap = allUsers.stream()
.collect(Collectors.toMap(User::getUserId, user -> user, (v1, v2) -> v1));
// 批量查询商户项目关联
LambdaQueryWrapper<MerchantProject> projectBatchQuery = new LambdaQueryWrapper<>();
projectBatchQuery.in(MerchantProject::getMerchantId, userIds);
List<MerchantProject> allMerchantProjects = merchantProjectService.list(projectBatchQuery);
// 按商户ID分组
Map<String, List<MerchantProject>> merchantProjectMap = allMerchantProjects.stream()
.collect(Collectors.groupingBy(mp -> mp.getMerchantId().toString()));
// 批量查询所有相关项目
List<Long> projectIds = allMerchantProjects.stream()
.map(MerchantProject::getProjectId)
.distinct()
.collect(Collectors.toList());
Map<Long, Project> projectMap = new HashMap<>();
if (!projectIds.isEmpty()) {
List<Project> allProjects = projectService.listByIds(projectIds);
projectMap = allProjects.stream()
.collect(Collectors.toMap(p -> p.getId().longValue(), p -> p, (v1, v2) -> v1));
}
// 批量查询商户标签关联
LambdaQueryWrapper<MerchantLabel> labelBatchQuery = new LambdaQueryWrapper<>();
labelBatchQuery.in(MerchantLabel::getMerchantId, userIds);
List<MerchantLabel> allMerchantLabels = merchantLabelService.list(labelBatchQuery);
// 按商户ID分组
Map<String, List<MerchantLabel>> merchantLabelMap = allMerchantLabels.stream()
.collect(Collectors.groupingBy(ml -> ml.getMerchantId().toString()));
// 批量查询所有相关标签
List<Integer> labelIds = allMerchantLabels.stream()
.map(MerchantLabel::getLabelId)
.distinct()
.collect(Collectors.toList());
Map<Integer, Label> labelMap = new HashMap<>();
if (!labelIds.isEmpty()) {
List<Label> allLabels = labelService.listByIds(labelIds);
labelMap = allLabels.stream()
.collect(Collectors.toMap(Label::getId, l -> l, (v1, v2) -> v1));
}
// 填充关联数据
for (Merchant mer : list) {
String merId = mer.getId().toString();
// 设置商户地址
mer.setMerchantAddr(addrMap.get(merId));
// 设置用户信息
mer.setUser(userMap.get(merId));
// 设置关联项目
List<MerchantProject> merchantProjects = merchantProjectMap.get(merId);
if (merchantProjects != null && !merchantProjects.isEmpty()) {
List<Project> projects = merchantProjects.stream()
.map(MerchantProject::getProjectId)
.map(projectMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
mer.setProjects(projects);
}
// 设置关联标签
List<MerchantLabel> merchantLabels = merchantLabelMap.get(merId);
if (merchantLabels != null && !merchantLabels.isEmpty()) {
List<Label> labels = merchantLabels.stream()
.map(MerchantLabel::getLabelId)
.map(labelMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
mer.setLabels(labels);
}
// 处理多图片
if (mer.getPic() != null && !mer.getPic().isEmpty()) {
String[] picArray = mer.getPic().split(",");
List<String> picList = new ArrayList<>(Arrays.asList(picArray));
mer.setPicList(picList);
} else {
mer.setPicList(new ArrayList<>());
}
}
}
return getDataTable(list);
}
/**
* 导出商户信息列表
*/
@ApiOperation("导出商户信息列表")
// @PreAuthorize("@ss.hasPermi('system:merchant:export')")
@Log(title = "商户信息", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(Merchant merchant) {
// 构建模糊查询条件
QueryWrapper<Merchant> queryWrapper = new QueryWrapper<>();
if (merchant.getName() != null && !merchant.getName().isEmpty()) {
queryWrapper.like("name", merchant.getName());
}
if (merchant.getStatus() != null) {
queryWrapper.eq("status", merchant.getStatus());
}
// 获取当前用户部门信息
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
if(departmentId!=100 && departmentId!=113){
String deptName = sysUser.getDept().getDeptName();
queryWrapper.like("city", deptName);
}else {
if (merchant.getCity() != null && !merchant.getCity().isEmpty()) {
queryWrapper.like("city", merchant.getCity());
}
}
Long parentId =sysUser.getDept().getParentId();
if(parentId == 101){
queryWrapper.eq("teamId", departmentId);
}
List<Merchant> list = merchantService.list(queryWrapper);
if (list != null && !list.isEmpty()) {
// 获取所有商户ID
List<String> merchantIds = list.stream()
.map(Merchant::getId)
.map(Object::toString)
.collect(Collectors.toList());
// 批量查询所有商户地址
LambdaQueryWrapper<MerchantAddr> addrBatchQuery = new LambdaQueryWrapper<>();
addrBatchQuery.in(MerchantAddr::getMerchantId, merchantIds);
List<MerchantAddr> allAddresses = merchantAddrService.list(addrBatchQuery);
// 转为Map方便查找
Map<String, MerchantAddr> addrMap = allAddresses.stream()
.collect(Collectors.toMap(MerchantAddr::getMerchantId, addr -> addr));
// 批量查询所有用户信息
List<User> allUsers = userService.listByIds(merchantIds);
Map<String, User> userMap = allUsers.stream()
.collect(Collectors.toMap(User::getUserId, user -> user, (v1, v2) -> v1));
// 批量查询商户项目关联
LambdaQueryWrapper<MerchantProject> projectBatchQuery = new LambdaQueryWrapper<>();
projectBatchQuery.in(MerchantProject::getMerchantId, merchantIds);
List<MerchantProject> allMerchantProjects = merchantProjectService.list(projectBatchQuery);
// 按商户ID分组
Map<String, List<MerchantProject>> merchantProjectMap = allMerchantProjects.stream()
.collect(Collectors.groupingBy(MerchantProject::getMerchantId));
// 批量查询所有相关项目
List<Long> projectIds = allMerchantProjects.stream()
.map(MerchantProject::getProjectId)
.distinct()
.collect(Collectors.toList());
Map<Long, Project> projectMap = new HashMap<>();
if (!projectIds.isEmpty()) {
List<Project> allProjects = projectService.listByIds(projectIds);
projectMap = allProjects.stream()
.collect(Collectors.toMap(p -> p.getId().longValue(), p -> p, (v1, v2) -> v1));
}
// 批量查询商户标签关联
LambdaQueryWrapper<MerchantLabel> labelBatchQuery = new LambdaQueryWrapper<>();
labelBatchQuery.in(MerchantLabel::getMerchantId, merchantIds);
List<MerchantLabel> allMerchantLabels = merchantLabelService.list(labelBatchQuery);
// 按商户ID分组
Map<String, List<MerchantLabel>> merchantLabelMap = allMerchantLabels.stream()
.collect(Collectors.groupingBy(MerchantLabel::getMerchantId));
// 批量查询所有相关标签
List<Integer> labelIds = allMerchantLabels.stream()
.map(MerchantLabel::getLabelId)
.distinct()
.collect(Collectors.toList());
Map<Integer, Label> labelMap = new HashMap<>();
if (!labelIds.isEmpty()) {
List<Label> allLabels = labelService.listByIds(labelIds);
labelMap = allLabels.stream()
.collect(Collectors.toMap(Label::getId, l -> l, (v1, v2) -> v1));
}
// 填充关联数据
for (Merchant mer : list) {
String merId = mer.getId().toString();
// 设置商户地址
mer.setMerchantAddr(addrMap.get(merId));
// 设置用户信息
mer.setUser(userMap.get(merId));
// 设置关联项目
List<MerchantProject> merchantProjects = merchantProjectMap.get(merId);
if (merchantProjects != null && !merchantProjects.isEmpty()) {
List<Project> projects = merchantProjects.stream()
.map(MerchantProject::getProjectId)
.map(projectMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
mer.setProjects(projects);
}
// 设置关联标签
List<MerchantLabel> merchantLabels = merchantLabelMap.get(merId);
if (merchantLabels != null && !merchantLabels.isEmpty()) {
List<Label> labels = merchantLabels.stream()
.map(MerchantLabel::getLabelId)
.map(labelMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
mer.setLabels(labels);
}
// 处理多图片
if (mer.getPic() != null && !mer.getPic().isEmpty()) {
String[] picArray = mer.getPic().split(",");
List<String> picList = new ArrayList<>(Arrays.asList(picArray));
mer.setPicList(picList);
} else {
mer.setPicList(new ArrayList<>());
}
}
}
ExcelUtil<Merchant> util = new ExcelUtil<Merchant>(Merchant.class);
return util.exportExcel(list, "商户信息数据");
}
/**
* 获取商户信息详细信息
*/
@ApiOperation("获取商户信息详细信息")
// @PreAuthorize("@ss.hasPermi('system:merchant:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
Merchant merchant = merchantService.getById(id);
if (merchant != null) {
// 查询商户地址
LambdaQueryWrapper<MerchantAddr> addrQuery = new LambdaQueryWrapper<>();
addrQuery.eq(MerchantAddr::getMerchantId, id);
MerchantAddr merchantAddr = merchantAddrService.getOne(addrQuery);
merchant.setMerchantAddr(merchantAddr);
// 查询商户用户信息(手机号等)
User user = userService.getUserByUserId(merchant.getId());
merchant.setUser(user);
// 查询商户关联的项目
LambdaQueryWrapper<MerchantProject> projectQuery = new LambdaQueryWrapper<>();
projectQuery.eq(MerchantProject::getMerchantId, id);
List<MerchantProject> merchantProjects = merchantProjectService.list(projectQuery);
if (merchantProjects != null && !merchantProjects.isEmpty()) {
List<Long> projectIds = merchantProjects.stream()
.map(MerchantProject::getProjectId)
.collect(Collectors.toList());
List<Project> projects = projectService.listByIds(projectIds);
merchant.setProjects(projects);
}
// 查询商户关联的标签
LambdaQueryWrapper<MerchantLabel> labelQuery = new LambdaQueryWrapper<>();
labelQuery.eq(MerchantLabel::getMerchantId, id);
List<MerchantLabel> merchantLabels = merchantLabelService.list(labelQuery);
if (merchantLabels != null && !merchantLabels.isEmpty()) {
List<Integer> labelIds = merchantLabels.stream()
.map(MerchantLabel::getLabelId)
.collect(Collectors.toList());
List<Label> labels = labelService.listByIds(labelIds);
merchant.setLabels(labels);
}
// 处理多图片
if (merchant.getPic() != null && !merchant.getPic().isEmpty()) {
String[] picArray = merchant.getPic().split(",");
List<String> picList = new ArrayList<>(Arrays.asList(picArray));
merchant.setPicList(picList);
} else {
merchant.setPicList(new ArrayList<>());
}
}
return AjaxResult.success(merchant);
}
/**
* 修改商户信息
*/
@ApiOperation("修改商户信息")
//@PreAuthorize("@ss.hasPermi('system:merchant:edit')")
@Log(title = "商户信息", businessType = BusinessType.UPDATE)
@PutMapping
@Transactional(rollbackFor = Exception.class)
public AjaxResult edit(@RequestBody Merchant merchant) {
// 处理多图片
List<String> picList = merchant.getPicList();
if (picList != null && !picList.isEmpty()) {
merchant.setPic(String.join(",", picList));
}
// 处理商户地址信息
MerchantAddr merchantAddr = merchant.getMerchantAddr();
if (merchantAddr != null) {
// 如果有地址信息同步更新city字段
if (merchantAddr.getCity() != null && !merchantAddr.getCity().isEmpty()) {
merchant.setCity(merchantAddr.getCity());
}
// 查询是否已存在地址
LambdaQueryWrapper<MerchantAddr> addrQuery = new LambdaQueryWrapper<>();
addrQuery.eq(MerchantAddr::getMerchantId, merchant.getId().toString());
MerchantAddr existAddr = merchantAddrService.getOne(addrQuery);
if (existAddr != null) {
// 更新已有地址
merchantAddr.setAddrId(existAddr.getAddrId());
merchantAddr.setAddrOrderId(existAddr.getAddrOrderId());
merchantAddrService.updateById(merchantAddr);
} else {
// 新增地址
merchantAddr.setMerchantId(merchant.getId().toString());
merchantAddr.setMerchantName(merchant.getName());
merchantAddrService.save(merchantAddr);
}
}
// 更新用户信息(手机号等)
User user = merchant.getUser();
if (user != null) {
User existUser = userService.getUserByUserId(merchant.getId());
if (existUser != null) {
existUser.setUserMobile(user.getUserMobile());
existUser.setIsPerson(user.getIsPerson());
userService.updateById(existUser);
}
}
// 更新商户信息
boolean result = merchantService.updateById(merchant);
// 处理商户项目关联
List<Project> projects = merchant.getProjects();
if (result) {
// 先删除原有项目关联
LambdaQueryWrapper<MerchantProject> projectQuery = new LambdaQueryWrapper<>();
projectQuery.eq(MerchantProject::getMerchantId, merchant.getId());
merchantProjectService.remove(projectQuery);
// 再添加新的项目关联
if (projects != null && !projects.isEmpty()) {
List<MerchantProject> merchantProjects = new ArrayList<>();
for (Project project : projects) {
MerchantProject merchantProject = new MerchantProject();
merchantProject.setMerchantId(merchant.getId());
merchantProject.setProjectId(project.getId().longValue());
merchantProjects.add(merchantProject);
}
merchantProjectService.saveBatch(merchantProjects);
}
}
// 处理商户标签关联
List<Label> labels = merchant.getLabels();
if (result) {
// 先删除原有标签关联
LambdaQueryWrapper<MerchantLabel> labelQuery = new LambdaQueryWrapper<>();
labelQuery.eq(MerchantLabel::getMerchantId, merchant.getId());
merchantLabelService.remove(labelQuery);
// 再添加新的标签关联
if (labels != null && !labels.isEmpty()) {
List<MerchantLabel> merchantLabels = new ArrayList<>();
Date now = new Date();
for (Label label : labels) {
MerchantLabel merchantLabel = new MerchantLabel();
merchantLabel.setMerchantId(merchant.getId());
merchantLabel.setLabelId(label.getId());
merchantLabel.setCreateTime(now);
merchantLabel.setUpdateTime(now);
merchantLabels.add(merchantLabel);
}
merchantLabelService.saveBatch(merchantLabels);
}
}
return toAjax(result);
}
/**
* 删除商户信息
*/
@ApiOperation("删除商户信息")
// @PreAuthorize("@ss.hasPermi('system:merchant:remove')")
@Log(title = "商户信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@Transactional(rollbackFor = Exception.class)
public AjaxResult remove(@PathVariable String[] ids) {
// 删除商户关联的地址信息
List<String> merchantIds = Arrays.stream(ids)
.map(String::valueOf)
.collect(Collectors.toList());
LambdaQueryWrapper<MerchantAddr> addrQuery = new LambdaQueryWrapper<>();
addrQuery.in(MerchantAddr::getMerchantId, merchantIds);
merchantAddrService.remove(addrQuery);
// 删除商户关联的项目信息
for (String id : ids) {
LambdaQueryWrapper<MerchantProject> projectQuery = new LambdaQueryWrapper<>();
projectQuery.eq(MerchantProject::getMerchantId, id);
merchantProjectService.remove(projectQuery);
// 删除商户关联的标签信息
LambdaQueryWrapper<MerchantLabel> labelQuery = new LambdaQueryWrapper<>();
labelQuery.eq(MerchantLabel::getMerchantId, id);
merchantLabelService.remove(labelQuery);
}
// 删除商户信息
return toAjax(merchantService.removeByIds(Arrays.asList(ids)));
}
/**
* 获取所有标签
*/
@ApiOperation("获取所有标签")
@GetMapping("/labels")
public AjaxResult getAllLabels() {
List<Label> labels = labelService.list();
return AjaxResult.success(labels);
}
/* *//**
* 新增商户信息
*//*
@ApiOperation("新增商户信息")
// @PreAuthorize("@ss.hasPermi('system:merchant:add')")
@Log(title = "商户信息", businessType = BusinessType.INSERT)
@PostMapping
@Transactional(rollbackFor = Exception.class)
public AjaxResult add(@RequestBody Merchant merchant) {
String lastId = merchantService.getLastMerchantId();
String newId;
if (lastId == null) {
newId = "54312321410";
} else {
long lastIdNum = Long.parseLong(lastId);
newId = String.valueOf(lastIdNum + 1);
}
merchant.setId(newId);
// 保存商户信息
boolean result = merchantService.save(merchant);
// 处理商户地址信息
MerchantAddr merchantAddr = merchant.getMerchantAddr();
if (merchantAddr != null && result) {
merchantAddr.setMerchantId(merchant.getId());
merchantAddr.setMerchantName(merchant.getName());
merchantAddrService.save(merchantAddr);
}
// 处理商户项目关联
List<Project> projects = merchant.getProjects();
if (projects != null && !projects.isEmpty() && result) {
List<MerchantProject> merchantProjects = new ArrayList<>();
for (Project project : projects) {
MerchantProject merchantProject = new MerchantProject();
merchantProject.setMerchantId(merchant.getId());
merchantProject.setProjectId(project.getId().longValue());
merchantProjects.add(merchantProject);
}
merchantProjectService.saveBatch(merchantProjects);
}
return toAjax(result);
}*/
/**
* 新增标签
*/
@ApiOperation("新增标签")
@Log(title = "标签", businessType = BusinessType.INSERT)
@PostMapping("/label")
public AjaxResult addLabel(@RequestBody Label label) {
return toAjax(labelService.save(label));
}
/**
* 修改标签
*/
@ApiOperation("修改标签")
@Log(title = "标签", businessType = BusinessType.UPDATE)
@PutMapping("/label")
public AjaxResult updateLabel(@RequestBody Label label) {
return toAjax(labelService.updateById(label));
}
/**
* 删除标签
*/
@ApiOperation("删除标签")
@Log(title = "标签", businessType = BusinessType.DELETE)
@DeleteMapping("/label/{ids}")
@Transactional(rollbackFor = Exception.class)
public AjaxResult removeLabel(@PathVariable Integer[] ids) {
// 删除标签关联
for (Integer id : ids) {
LambdaQueryWrapper<MerchantLabel> labelQuery = new LambdaQueryWrapper<>();
labelQuery.eq(MerchantLabel::getLabelId, id);
merchantLabelService.remove(labelQuery);
}
// 删除标签
return toAjax(labelService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,148 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pxdj.api.domain.*;
import com.pxdj.api.enums.BaseEnum;
import com.pxdj.api.service.MerchantExamineService;
import com.pxdj.api.service.MerchantService;
import com.pxdj.api.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
/**
* 商户激活审核Controller
*
* @author ruoyi
* @date 2025-04-15
*/
@RestController
@RequestMapping("/system/examine")
@Api(value = "商户激活审核控制器", tags = {"商户激活审核管理"})
public class MerchantExamineController extends BaseController {
@Autowired
private MerchantExamineService merchantExamineService;
@Autowired
private UserService userService;
@Autowired
private MerchantService merchantService;
/**
* 查询商户激活审核列表
*/
@ApiOperation("查询商户激活审核列表")
@GetMapping("/list")
public TableDataInfo list(MerchantExamine merchantExamine) {
startPage();
List<MerchantExamine> list = merchantExamineService.list(new QueryWrapper<MerchantExamine>(merchantExamine));
return getDataTable(list);
}
/**
* 导出商户激活审核列表
*/
@ApiOperation("导出商户激活审核列表")
@Log(title = "商户激活审核", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(MerchantExamine merchantExamine) {
List<MerchantExamine> list = merchantExamineService.list(new QueryWrapper<MerchantExamine>(merchantExamine));
ExcelUtil<MerchantExamine> util = new ExcelUtil<MerchantExamine>(MerchantExamine.class);
return util.exportExcel(list, "商户激活审核数据");
}
/**
* 获取商户激活审核详细信息
*/
@ApiOperation("获取商户激活审核详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(merchantExamineService.getById(id));
}
/**
* 新增商户激活审核
*/
@ApiOperation("新增商户激活审核")
@Log(title = "商户激活审核", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MerchantExamine merchantExamine) {
return toAjax(merchantExamineService.save(merchantExamine));
}
/**
* 审核商户入驻申请
*/
@ApiOperation("审核商户入驻申请")
@Log(title = "商户入驻申请", businessType = BusinessType.UPDATE)
@PutMapping("/audit/{id}")
@Transactional(rollbackFor = Exception.class)
public AjaxResult audit(@PathVariable("id") Long id, @RequestParam("status") Integer status) {
MerchantExamine merchantExamine = merchantExamineService.getById(id);
if (merchantExamine == null) {
return AjaxResult.error("申请记录不存在");
}
// 更新审核状态
merchantExamine.setStatus(status);
boolean result = merchantExamineService.updateById(merchantExamine);
if (result) {
if (status == 2) { // 通过
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserMobile, merchantExamine.getMobile());
queryWrapper.eq(User::getUserType, 2);
User mUser = userService.getOne(queryWrapper);
Merchant existMerchant = merchantService.getById(mUser.getUserId());
existMerchant.setBrief(merchantExamine.getBrief());
existMerchant.setImages(merchantExamine.getImages());
existMerchant.setPic(merchantExamine.getPic());
existMerchant.setName(merchantExamine.getName());
// 如果商户已存在,更新状态为正常
existMerchant.setStatus(1);
existMerchant.setUpdateTime(new Date());
result = merchantService.updateById(existMerchant);
userService.update(Wrappers.<User>lambdaUpdate()
.set(User::getIsActivation, BaseEnum.NO_ZERO.getKey())
.eq(User::getUserId,mUser.getUserId()));
}
}
return toAjax(result);
}
/**
* 修改商户激活审核
*/
@ApiOperation("修改商户激活审核")
@Log(title = "商户激活审核", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MerchantExamine merchantExamine) {
return toAjax(merchantExamineService.updateById(merchantExamine));
}
/**
* 删除商户激活审核
*/
@ApiOperation("删除商户激活审核")
@Log(title = "商户激活审核", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(merchantExamineService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,103 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.List;
import com.pxdj.api.domain.MerchantProject;
import com.pxdj.api.service.MerchantProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
/**
* 商户项目管理Controller
*
* @author ZiJieNbPlus
* @date 2025-03-12
*/
@RestController
@RequestMapping("/system/project")
@Api(value = "商户项目管理控制器", tags = {"商户项目管理管理"})
public class MerchantProjectController extends BaseController {
@Autowired
private MerchantProjectService merchantProjectService;
/**
* 查询商户项目管理列表
*/
@ApiOperation("查询商户项目管理列表")
@PreAuthorize("@ss.hasPermi('system:project:list')")
@GetMapping("/list")
public TableDataInfo list(MerchantProject merchantProject) {
startPage();
List<MerchantProject> list = merchantProjectService.list(new QueryWrapper<MerchantProject>(merchantProject));
return getDataTable(list);
}
/**
* 导出商户项目管理列表
*/
@ApiOperation("导出商户项目管理列表")
@PreAuthorize("@ss.hasPermi('system:project:export')")
@Log(title = "商户项目管理", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(MerchantProject merchantProject) {
List<MerchantProject> list = merchantProjectService.list(new QueryWrapper<MerchantProject>(merchantProject));
ExcelUtil<MerchantProject> util = new ExcelUtil<MerchantProject>(MerchantProject.class);
return util.exportExcel(list, "商户项目管理数据");
}
/**
* 获取商户项目管理详细信息
*/
@ApiOperation("获取商户项目管理详细信息")
@PreAuthorize("@ss.hasPermi('system:project:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(merchantProjectService.getById(id));
}
/**
* 新增商户项目管理
*/
@ApiOperation("新增商户项目管理")
@PreAuthorize("@ss.hasPermi('system:project:add')")
@Log(title = "商户项目管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MerchantProject merchantProject) {
return toAjax(merchantProjectService.save(merchantProject));
}
/**
* 修改商户项目管理
*/
@ApiOperation("修改商户项目管理")
@PreAuthorize("@ss.hasPermi('system:project:edit')")
@Log(title = "商户项目管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MerchantProject merchantProject) {
return toAjax(merchantProjectService.updateById(merchantProject));
}
/**
* 删除商户项目管理
*/
@ApiOperation("删除商户项目管理")
@PreAuthorize("@ss.hasPermi('system:project:remove')")
@Log(title = "商户项目管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(merchantProjectService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,617 @@
package com.pxdj.web.controller.pxdj;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.*;
import com.pxdj.api.dto.MerchantInfoDto;
import com.pxdj.api.enums.BaseEnum;
import com.pxdj.api.enums.OrderStatusEnum;
import com.pxdj.api.mapper.OrderMapper;
import com.pxdj.api.param.CancelOrderParam;
import com.pxdj.api.service.*;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.utils.PageParam;
import com.pxdj.common.utils.PayUtil;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.utils.RedisUtil;
import io.swagger.v3.oas.annotations.Operation;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.stream.Collectors;
/**
* 订单Controller
*
* @author ruoyi
* @date 2025-03-12
*/
@Slf4j
@RestController
@RequestMapping("/order/order")
@Api(value = "订单控制器", tags = {"订单管理"})
public class OrderController extends BaseController {
@Autowired
private OrderService orderService;
@Autowired
private OrderRefundService orderRefundService;
@Autowired
private OrderMapper orderMapper;
@Autowired
private MerchantCommService prodCommService;
@Autowired
private UserService userService;
@Autowired
private MerchantService merchantService;
@Autowired
private OrderSettlementService orderSettlementService;
@Autowired
private PayUtil payUtil;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private ProjectService projectService;
/**
* 查询订单列表
*/
@ApiOperation("查询订单列表")
@PreAuthorize("@ss.hasPermi('system:order:list')")
@GetMapping("/page")
public TableDataInfo list(Order order, @RequestParam(value = "beginTime", required = false) String beginTimeStr,
@RequestParam(value = "endTime", required = false) String endTimeStr,
@RequestParam(value = "city", required = false) String queryCity) {
List<Integer> statusList = new ArrayList<>();
if (order.getStatus() != null) {
statusList.add(order.getStatus());
}
Date beginTime = null;
Date endTime = null;
if (StringUtils.hasText(beginTimeStr)) {
beginTime = DateUtil.parseDate(beginTimeStr);
}
if (StringUtils.hasText(endTimeStr)) {
endTime = DateUtil.parseDate(endTimeStr);
}
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
Long parentId =sysUser.getDept().getParentId();
String city ="";
if (departmentId == 100&& departmentId!=113) {
if (StringUtils.hasText(queryCity)) {
city = queryCity;
}
} else {
city = sysUser.getDept().getDeptName();
}
Long teamId =null;
if(parentId == 101){
teamId = departmentId;
}
startPage();
List<Order> list = orderService.getOrders(order.getOrderNumber(), statusList, beginTime, endTime, city,teamId);
for (Order orderItem : list) {
if (orderItem.getUserAddrOrder() != null) {
UserAddrOrder addr = orderItem.getUserAddrOrder();
String fullAddress = String.format("%s %s %s %s",
addr.getProvince() != null ? addr.getProvince() : "",
addr.getCity() != null ? addr.getCity() : "",
addr.getArea() != null ? addr.getArea() : "",
addr.getAddr() != null ? addr.getAddr() : "");
orderItem.setFullAddress(fullAddress.trim());
}
}
return getDataTable(list);
}
/**
* 导出订单列表
*/
@ApiOperation("导出订单列表")
@PreAuthorize("@ss.hasPermi('system:order:export')")
@Log(title = "订单", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(Order Order) {
List<Order> list = orderService.list(new QueryWrapper<Order>(Order));
ExcelUtil<Order> util = new ExcelUtil<Order>(Order.class);
return util.exportExcel(list, "订单数据");
}
/**
* 获取订单详细信息
*/
@ApiOperation("获取订单详细信息")
@PreAuthorize("@ss.hasPermi('system:order:query')")
@GetMapping(value = "/{orderId}")
public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
return AjaxResult.success(orderService.getById(orderId));
}
/**
* 获取待接单数
*/
@ApiOperation("获取待接单数")
//@PreAuthorize("@ss.hasPermi('system:order:query')")
@GetMapping(value = "/getOrderNum")
public AjaxResult getInfo() {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
Long parentId =sysUser.getDept().getParentId();
Long teamId =null;
if(parentId == 101){
teamId = departmentId;
}
if(departmentId!=100&& departmentId!=113){
return AjaxResult.success(orderMapper.getOrderNum(sysUser.getDept().getDeptName(),teamId));
}
return AjaxResult.success(0);
}
/**
* 新增订单
*/
@ApiOperation("新增订单")
@PreAuthorize("@ss.hasPermi('system:order:add')")
@Log(title = "订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Order Order) {
return toAjax(orderService.save(Order));
}
/**
* 修改订单
*/
@ApiOperation("修改订单")
@PreAuthorize("@ss.hasPermi('system:order:edit')")
@Log(title = "订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Order Order) {
return toAjax(orderService.updateById(Order));
}
/**
* 删除订单
*/
@ApiOperation("删除订单")
@PreAuthorize("@ss.hasPermi('system:order:remove')")
@Log(title = "订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{orderIds}")
public AjaxResult remove(@PathVariable Long[] orderIds) {
return toAjax(orderService.removeByIds(Arrays.asList(orderIds)));
}
@PostMapping("/refund")
@Operation(summary = "订单退款", description = "订单退款")
public AjaxResult refund(@Valid @RequestBody CancelOrderParam cancelOrderParam) {
OrderRefund order = orderRefundService.getOne(new LambdaQueryWrapper<OrderRefund>().eq(OrderRefund::getOrderNumber, cancelOrderParam.getOrderNumber()));
if(Objects.equals(order.getReturnMoneySts(), BaseEnum.YES_ONE.getKey())){
return AjaxResult.success("已经退款成功,请勿重新提交");
}
if (!RedisUtil.reUsed(RedisUtil.REFUNDORDER + order.getOrderNumber(), 5)) {
return AjaxResult.success("已经退款成功,请勿重新提交");
}
orderService.refund(order,cancelOrderParam.getAmount(), cancelOrderParam.getRefundSts());
return AjaxResult.success("退款成功");
}
@GetMapping("/userRefundInfo")
@Operation(summary = "申请退款信息", description = "申请退款信息")
public AjaxResult userRefundInfo(String orderNumber) {
OrderRefund orderRefund =orderService.userRefundInfo(orderNumber);
return success(orderRefund);
}
@PostMapping("/transferOrder")
@Operation(summary = "订单转移", description = "订单转移")
public AjaxResult transferOrder(@Valid @RequestBody CancelOrderParam cancelOrderParam) {
if (!RedisUtil.reUsed(RedisUtil.TRANSFERORDER + cancelOrderParam.getOrderNumber(), 5)) {
return AjaxResult.success("已经转移成功,请勿重新提交");
}
Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, cancelOrderParam.getOrderNumber()));
Project project = projectService.getById(order.getProjectId());
return AjaxResult.success( orderService.transferOrder(order,project.getDuration(),cancelOrderParam.getToMerchantId()));
}
@Scheduled(cron = "0 * * * * ?")
public void autoCancelUnpaidOrdersTask() {
log.info("开始执行自动取消未支付订单任务");
Date fifteenMinutesAgo = DateUtil.offsetMinute(new Date(), -15);
List<Order> orders = orderMapper.selectList(new QueryWrapper<Order>().eq("status", OrderStatusEnum.UNPAY.value())
.lt("create_time", fifteenMinutesAgo));
orders.forEach(order -> {
order.setStatus(OrderStatusEnum.CLOSE.value());
orderMapper.updateById(order);
log.info("订单[{}]因超时未支付已自动取消", order.getOrderNumber());
});
log.info("完结订单30分钟后自动好评");
Date minutesAgo = DateUtil.offsetMinute(new Date(), -30);
List<Order> successOrders = orderMapper.selectList(new QueryWrapper<Order>()
.eq("status", OrderStatusEnum.SUCCESS.value())
.eq("is_evaluate", BaseEnum.NO_ZERO.getKey())
.lt("finally_time", minutesAgo));
successOrders.forEach(successOrder -> {
successOrder.setIsEvaluate(BaseEnum.YES_ONE.getKey());
orderMapper.updateById(successOrder);
//添加评论
Random random = new Random();
int index = random.nextInt(Constants.COMMON_WHITELIST.size()); // 生成 0 到 size-1 的随机索引
String common = Constants.COMMON_WHITELIST.get(index);
MerchantComm prodComm = new MerchantComm();
prodComm.setMerchantId(successOrder.getMerchantId());
prodComm.setUserId(successOrder.getUserId());
prodComm.setScore(5);
prodComm.setContent(common);
prodComm.setIsAnonymous(BaseEnum.YES_ONE.getKey());
prodComm.setRecTime(new Date());
prodComm.setStatus(1);
prodComm.setEvaluate(BaseEnum.YES.getKey());
prodCommService.save(prodComm);
merchantService.updateEvaluateNum(successOrder.getMerchantId());
log.info("订单[{}]自动评论", successOrder.getOrderNumber());
});
}
//完结订单
@Scheduled(cron = "0 * * * * ?")
public void completedOrder() {
log.info("开始服务中的订单两小时后不点完结订单后自动完结");
/*Date serviceMinutesAgo = DateUtil.offsetHour(new Date(), -2);
List<Order> serviceOrders = orderMapper.selectList(new QueryWrapper<Order>().in("status", OrderStatusEnum.INSERVICE.value())
.lt("create_time", serviceMinutesAgo));
serviceOrders.forEach(service -> {
service.setStatus(OrderStatusEnum.SUCCESS.value());
orderMapper.updateById(service);
//添加商户余额
userService.updateBalance(service.getMerchantId(), service.getTotal());
log.info("订单[{}]2小时后自动完接订单", service.getOrderNumber());
});*/
log.info("服务完成的订单两小时后不点完结订单后自动完结");
Date completeMinutesAgo = DateUtil.offsetHour(new Date(), -2);
List<Order> completeOrders = orderMapper.selectList(new QueryWrapper<Order>().in("status", OrderStatusEnum.COMPLETE.value())
.lt("create_time", completeMinutesAgo));
completeOrders.forEach(complete -> {
complete.setStatus(OrderStatusEnum.SUCCESS .value());
orderMapper.updateById(complete);
//添加商户余额
userService.updateBalance(complete.getMerchantId(), complete.getTotal());
log.info("订单[{}]2小时后自动完接订单", complete.getOrderNumber());
});
}
/**
* 每分钟检查vip付款发货
*/
@Scheduled(cron = "0 * * * * ?")
public void sendOutGoods() {
log.info("虚拟付款发货");
List<Order> orders = orderMapper.selectList(new QueryWrapper<Order>().eq("status",OrderStatusEnum.SUCCESS.value())
.eq("refund_sts", BaseEnum.NO_ZERO.getKey()));
orders.forEach(order -> {
// 获取用户信息
User user = userService.getById(order.getUserId());
Boolean flag = payUtil.insertVipLogistics(order.getThirdTradeNo(),user.getOpenid());
if(flag){
order.setRefundSts(BaseEnum.YES_ONE.getKey());
orderMapper.updateById(order);
log.info("虚拟付款发货成功");
}
});
}
/**
* 获取统计数据
*/
@ApiOperation("获取统计数据")
@GetMapping("/statistics")
public AjaxResult getStatistics() {
Map<String, Object> result = new HashMap<>();
Date now = new Date();
Date sevenDaysAgo = DateUtil.offsetDay(now, -7);
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
String city = "";
boolean isAdmin = false;
if(departmentId==100 || departmentId==113){
isAdmin=true;
}
if (!isAdmin) {
city = sysUser.getDept().getDeptName();
}
Long teamId = null;
Long parentId =sysUser.getDept().getParentId();
if(parentId == 101){
teamId=departmentId;
}
// 统计总用户数
long totalUsers = userService.count(new LambdaQueryWrapper<User>().eq(User::getUserType, 1));
result.put("totalUsers", totalUsers);
// 统计今日新增用户数
Date today = DateUtil.beginOfDay(now);
long newUsersToday;
if (isAdmin) {
newUsersToday = userService.count(new LambdaQueryWrapper<User>()
.ge(User::getUserRegtime, today));
} else {
// 非管理员只查看自己城市的新增
newUsersToday = userService.count(new LambdaQueryWrapper<User>()
.ge(User::getUserRegtime, today)
.exists("SELECT 1 FROM tz_user_addr ua WHERE ua.user_id = tz_user.user_id AND ua.city LIKE {0}", "%" + city + "%"));
}
result.put("newUsersToday", newUsersToday);
// 统计总商户数
long totalMerchants;
if (isAdmin) {
// 管理员查看所有商户
totalMerchants = merchantService.count();
} else {
if(teamId!=null){
// 非管理员只查看自己城市的商户
totalMerchants = merchantService.count(new LambdaQueryWrapper<Merchant>()
.like(Merchant::getCity, city)
.eq(Merchant::getTeamId, teamId));
}else {
// 非管理员只查看自己城市的商户
totalMerchants = merchantService.count(new LambdaQueryWrapper<Merchant>()
.like(Merchant::getCity, city));
}
}
result.put("totalMerchants", totalMerchants);
// 统计总现金流水
Double totalCashFlow;
if (isAdmin) {
// 管理员只统计已支付流水
totalCashFlow = orderSettlementService.list(
new LambdaQueryWrapper<OrderSettlement>().eq(OrderSettlement::getPayStatus, 1)
).stream()
.mapToDouble(item -> {
try {
return Double.parseDouble(item.getPayAmount().toString());
} catch (NullPointerException e) {
return 0.0;
}
})
.sum();
} else {
// 非管理员只查看自己城市的流水
List<Map<String, Object>> cityFlows = orderSettlementService.getCashFlowList(null, null, null, city,teamId);
totalCashFlow = cityFlows.stream()
.mapToDouble(item -> {
try {
return Double.parseDouble(item.get("payAmount").toString());
} catch (NullPointerException e) {
return 0.0;
}
})
.sum();
}
result.put("cashFlow", totalCashFlow);
// 获取最近7天的数据
List<Map<String, Object>> chartData = new ArrayList<>();
for (int i = 6; i >= 0; i--) {
Date date = DateUtil.offsetDay(now, -i);
Date startOfDay = DateUtil.beginOfDay(date);
Date endOfDay = DateUtil.endOfDay(date);
String dateLabel = DateUtil.format(date, "M-d");
Double dailyCashFlow;
if (isAdmin) {
// 管理员查看所有流水
dailyCashFlow = orderSettlementService.list(new LambdaQueryWrapper<OrderSettlement>()
.between(OrderSettlement::getCreateTime, startOfDay, endOfDay))
.stream()
.mapToDouble(item -> {
try {
return Double.parseDouble(item.getPayAmount().toString());
} catch (NullPointerException e) {
return 0.0;
}
})
.sum();
} else {
// 非管理员只查看自己城市的流水
List<Map<String, Object>> cityDailyFlows = orderSettlementService.getCashFlowList(null, startOfDay, endOfDay, city,teamId);
dailyCashFlow = cityDailyFlows.stream()
.mapToDouble(item -> {
try {
return Double.parseDouble(item.get("payAmount").toString());
} catch (NullPointerException e) {
return 0.0;
}
})
.sum();
}
Map<String, Object> dayData = new HashMap<>();
dayData.put("dateLabel", dateLabel);
dayData.put("cashFlow", dailyCashFlow);
chartData.add(dayData);
}
result.put("chartData", chartData);
Map<String, Object> statistics = new HashMap<>();
statistics.put("totalUsers", totalUsers);
statistics.put("newUsersToday", newUsersToday);
statistics.put("totalMerchants", totalMerchants);
statistics.put("cashFlow", totalCashFlow);
result.put("statistics", statistics);
return AjaxResult.success(result);
}
/**
* 获取现金流水列表
*/
@ApiOperation("获取现金流水列表")
@GetMapping("/getCashFlowList")
public TableDataInfo getCashFlowList(
@RequestParam(value = "merchantName", required = false) String merchantName,
@RequestParam(value = "startTime", required = false) String startTimeStr,
@RequestParam(value = "endTime", required = false) String endTimeStr,
@RequestParam(value = "timeRangeType", required = false) String timeRangeType,
@RequestParam(value = "city", required = false) String searchCity,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize
) {
startPage();
Date startTime = null;
Date endTime = null;
if (StringUtils.hasText(startTimeStr)) {
startTime = DateUtil.parseDate(startTimeStr);
}
if (StringUtils.hasText(endTimeStr)) {
endTime = DateUtil.parseDate(endTimeStr);
}
if (StringUtils.hasText(timeRangeType) && startTime == null && endTime == null) {
Date now = new Date();
switch (timeRangeType) {
case "day":
startTime = DateUtil.beginOfDay(now);
endTime = DateUtil.endOfDay(now);
break;
case "week":
startTime = DateUtil.beginOfWeek(now);
endTime = DateUtil.endOfWeek(now);
break;
case "month":
startTime = DateUtil.beginOfMonth(now);
endTime = DateUtil.endOfMonth(now);
break;
default:
break;
}
}
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
String city = "";
if (StringUtils.hasText(searchCity)) {
city = searchCity;
}
else if (departmentId != 100 && departmentId!=113) {
city = sysUser.getDept().getDeptName();
}
Long teamId = null;
Long parentId =sysUser.getDept().getParentId();
if(parentId == 101){
teamId=departmentId;
}
List<Map<String, Object>> cashFlowList = orderSettlementService.getCashFlowList(merchantName, startTime, endTime, city,teamId);
final double totalAmount;
totalAmount = cashFlowList.stream()
.mapToDouble(item -> {
try {
return Double.parseDouble(item.get("payAmount").toString());
} catch (NullPointerException e) {
return Double.parseDouble(item.get("pointsTotal").toString());
}
})
.sum();
final double finalTotalAmount = totalAmount;
cashFlowList.forEach(item -> item.put("totalAmount", finalTotalAmount));
return getDataTable(cashFlowList);
}
@GetMapping("/soldExcel")
@Operation(summary = "导出销售记录", description = "导出销售记录")
public void getSoldExcel(
@RequestParam(value = "orderNumber", required = false) String orderNumber,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "beginTime", required = false) String beginTimeStr,
@RequestParam(value = "endTime", required = false) String endTimeStr,
@RequestParam(value = "city", required = false) String queryCity,
HttpServletResponse response) {
List<Integer> statusList = new ArrayList<>();
if (status != null) {
statusList.add(status);
}
Date beginTime = null;
Date endTime = null;
if (StringUtils.hasText(beginTimeStr)) {
beginTime = DateUtil.parseDateTime(beginTimeStr);
}
if (StringUtils.hasText(endTimeStr)) {
endTime = DateUtil.parseDateTime(endTimeStr);
}
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
Long parentId =sysUser.getDept().getParentId();
String city = "";
// 管理员或pxdj用户可以筛选城市
if (departmentId == 100&& departmentId==113) {
if (StringUtils.hasText(queryCity)) {
city = queryCity;
}
} else {
// 非管理员只能导出自己城市的订单
city = sysUser.getDept().getDeptName();
}
Long teamId =null;
if(parentId == 101){
teamId = departmentId;
}
List<Order> list = orderService.getOrders(orderNumber, statusList, beginTime, endTime, city,teamId);
}
}

View File

@@ -0,0 +1,34 @@
package com.pxdj.web.controller.pxdj;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.IndexImg;
import com.pxdj.api.service.IndexImgService;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
*
* @author ruoyi
* @date 2025-03-12
*/
@RestController
@RequestMapping("/other")
@Api(value = "通用控制层", tags = {"通用控制层"})
public class OtherController extends BaseController {
}

View File

@@ -0,0 +1,84 @@
package com.pxdj.web.controller.pxdj;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.Project;
import com.pxdj.api.service.ProjectService;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 项目管理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/project")
public class ProjectController extends BaseController
{
@Autowired
private ProjectService projectService;
/**
* 获取列表
*/
@GetMapping("/list")
public AjaxResult list(Project project)
{
// 构建查询条件
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
// 根据名称模糊查询
if (StringUtils.isNotEmpty(project.getName())) {
queryWrapper.like("name", project.getName());
}
// 根据价格查询
if (project.getPrice() != null) {
queryWrapper.eq("price", project.getPrice());
}
// 根据时长查询
if (project.getDuration() != null) {
queryWrapper.eq("duration", project.getDuration());
}
// 按id排序
queryWrapper.orderByDesc("id");
List<Project> projectList = projectService.list(queryWrapper);
return success(projectList);
}
/**
* 新增
*/
@PostMapping("/add")
public AjaxResult add(@RequestBody Project dept)
{
projectService.save(dept);
return success();
}
/**
* 修改
*/
@PostMapping("/update")
public AjaxResult edit(@RequestBody Project dept)
{
projectService.updateById(dept);
return success();
}
/**
* 删除
*/
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
projectService.removeById(id);
return success();
}
}

View File

@@ -0,0 +1,122 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.List;
import com.pxdj.api.domain.User;
import com.pxdj.api.service.UserService;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
/**
* app用户Controller
*
* @author ZiJieNbPlus
* @date 2025-04-08
*/
@RestController
@RequestMapping("/user/app")
@Api(value = "app用户控制器", tags = {"app用户管理"})
public class UserController extends BaseController {
@Autowired
private UserService userService;
@Autowired
private ISysUserService iSysUserService;
/**
* 查询app用户列表
*/
@ApiOperation("查询app用户列表")
@PreAuthorize("@ss.hasPermi('user:app:list')")
@GetMapping("/list")
public TableDataInfo list(User user) {
startPage();
user.setUserType(1);
List<User> list = userService.list(new QueryWrapper<User>(user));
return getDataTable(list);
}
/**
* 查询app用户列表
*/
@ApiOperation("查询商户列表")
@PreAuthorize("@ss.hasPermi('user:app:list')")
@GetMapping("/merchantList")
public TableDataInfo merchantList(User user) {
startPage();
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
List<User> list = userService.list(new QueryWrapper<User>(user));
return getDataTable(list);
}
/**
* 导出app用户列表
*/
@ApiOperation("导出app用户列表")
@PreAuthorize("@ss.hasPermi('user:app:export')")
@Log(title = "app用户", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(User user) {
List<User> list = userService.list(new QueryWrapper<User>(user));
ExcelUtil<User> util = new ExcelUtil<User>(User.class);
return util.exportExcel(list, "app用户数据");
}
/**
* 获取app用户详细信息
*/
@ApiOperation("获取app用户详细信息")
@PreAuthorize("@ss.hasPermi('user:app:query')")
@GetMapping(value = "/{userId}")
public AjaxResult getInfo(@PathVariable("userId") String userId) {
return AjaxResult.success(userService.getById(userId));
}
/**
* 新增app用户
*/
@ApiOperation("新增app用户")
@PreAuthorize("@ss.hasPermi('user:app:add')")
@Log(title = "app用户", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody User user) {
return toAjax(userService.save(user));
}
/**
* 修改app用户
*/
@ApiOperation("修改app用户")
@PreAuthorize("@ss.hasPermi('user:app:edit')")
@Log(title = "app用户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody User user) {
return toAjax(userService.updateById(user));
}
/**
* 删除app用户
*/
@ApiOperation("删除app用户")
@PreAuthorize("@ss.hasPermi('user:app:remove')")
@Log(title = "app用户", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable String[] userIds) {
return toAjax(userService.removeByIds(Arrays.asList(userIds)));
}
}

View File

@@ -0,0 +1,148 @@
package com.pxdj.web.controller.pxdj;
import java.util.Arrays;
import java.util.List;
import com.pxdj.api.domain.VipPackage;
import com.pxdj.api.service.VipPackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.common.core.page.TableDataInfo;
import org.apache.commons.lang3.StringUtils;
/**
* 会员套餐Controller
*
* @author ZIJieNbPlus
* @date 2025-03-28
*/
@RestController
@RequestMapping("/vip/package")
@Api(value = "会员套餐控制器", tags = {"会员套餐管理"})
public class VipPackageController extends BaseController {
@Autowired
private VipPackageService vipPackageService;
/**
* 查询会员套餐列表
*/
@ApiOperation("查询会员套餐列表")
@PreAuthorize("@ss.hasPermi('vip:package:list')")
@GetMapping("/list")
public TableDataInfo list(VipPackage vipPackage) {
startPage();
LambdaQueryWrapper<VipPackage> queryWrapper = new LambdaQueryWrapper<>();
// 名称模糊查询
if (StringUtils.isNotBlank(vipPackage.getName())) {
queryWrapper.like(VipPackage::getName, vipPackage.getName());
}
// 精确匹配
if (vipPackage.getGrade() != null) {
queryWrapper.eq(VipPackage::getGrade, vipPackage.getGrade());
}
if (vipPackage.getStatus() != null) {
queryWrapper.eq(VipPackage::getStatus, vipPackage.getStatus());
}
// 按创建时间降序排序
queryWrapper.orderByDesc(VipPackage::getCreateTime);
List<VipPackage> list = vipPackageService.list(queryWrapper);
return getDataTable(list);
}
/**
* 导出会员套餐列表
*/
@ApiOperation("导出会员套餐列表")
@PreAuthorize("@ss.hasPermi('vip:package:export')")
@Log(title = "会员套餐", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(VipPackage vipPackage) {
LambdaQueryWrapper<VipPackage> queryWrapper = new LambdaQueryWrapper<>();
// 名称模糊查询
if (StringUtils.isNotBlank(vipPackage.getName())) {
queryWrapper.like(VipPackage::getName, vipPackage.getName());
}
// 别名模糊查询
if (StringUtils.isNotBlank(vipPackage.getNameExtra())) {
queryWrapper.like(VipPackage::getNameExtra, vipPackage.getNameExtra());
}
// 精确匹配
if (vipPackage.getGrade() != null) {
queryWrapper.eq(VipPackage::getGrade, vipPackage.getGrade());
}
if (vipPackage.getStatus() != null) {
queryWrapper.eq(VipPackage::getStatus, vipPackage.getStatus());
}
// 按创建时间降序排序
queryWrapper.orderByDesc(VipPackage::getCreateTime);
List<VipPackage> list = vipPackageService.list(queryWrapper);
ExcelUtil<VipPackage> util = new ExcelUtil<VipPackage>(VipPackage.class);
return util.exportExcel(list, "会员套餐数据");
}
/**
* 获取会员套餐详细信息
*/
@ApiOperation("获取会员套餐详细信息")
@PreAuthorize("@ss.hasPermi('vip:package:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(vipPackageService.getById(id));
}
/**
* 新增会员套餐
*/
@ApiOperation("新增会员套餐")
@PreAuthorize("@ss.hasPermi('vip:package:add')")
@Log(title = "会员套餐", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody VipPackage vipPackage) {
return toAjax(vipPackageService.save(vipPackage));
}
/**
* 修改会员套餐
*/
@ApiOperation("修改会员套餐")
@PreAuthorize("@ss.hasPermi('vip:package:edit')")
@Log(title = "会员套餐", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody VipPackage vipPackage) {
return toAjax(vipPackageService.updateById(vipPackage));
}
/**
* 删除会员套餐
*/
@ApiOperation("删除会员套餐")
@PreAuthorize("@ss.hasPermi('vip:package:remove')")
@Log(title = "会员套餐", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(vipPackageService.removeByIds(Arrays.asList(ids)));
}
}

View File

@@ -0,0 +1,127 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.SysConfig;
import com.pxdj.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 参数配置 信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/config")
public class SysConfigController extends BaseController
{
@Autowired
private ISysConfigService configService;
/**
* 获取参数配置列表
*/
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据");
}
/**
* 根据参数编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId)
{
return success(configService.selectConfigById(configId));
}
/**
* 根据参数键名查询参数值
*/
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
{
return success(configService.selectConfigByKey(configKey));
}
/**
* 新增参数配置
*/
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysConfig config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(getUsername());
return toAjax(configService.insertConfig(config));
}
/**
* 修改参数配置
*/
@PreAuthorize("@ss.hasPermi('system:config:edit')")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysConfig config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(getUsername());
return toAjax(configService.updateConfig(config));
}
/**
* 删除参数配置
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
{
configService.deleteConfigByIds(configIds);
return success();
}
/**
* 刷新参数缓存
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
configService.resetConfigCache();
return success();
}
}

View File

@@ -0,0 +1,126 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.constant.UserConstants;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDept;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.service.ISysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 部门信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
/**
* 获取部门列表
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}
/**
* 查询部门列表(排除节点)
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
}
/**
* 根据部门编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId));
}
/**
* 新增部门
*/
@PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (!deptService.checkDeptNameUnique(dept))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept));
}
/**
* 修改部门
*/
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(deptId))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{
return error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(getUsername());
return toAjax(deptService.updateDept(dept));
}
/**
* 删除部门
*/
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
return warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
}

View File

@@ -0,0 +1,115 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDictData;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.service.ISysDictDataService;
import com.pxdj.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* 数据字典信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
* 查询字典数据详细
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable Long dictCode)
{
return success(dictDataService.selectDictDataById(dictCode));
}
/**
* 根据字典类型查询字典数据信息
*/
@GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return success(data);
}
/**
* 新增字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
dict.setCreateBy(getUsername());
return toAjax(dictDataService.insertDictData(dict));
}
/**
* 修改保存字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
dict.setUpdateBy(getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
/**
* 删除字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
}

View File

@@ -0,0 +1,120 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDictType;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 数据字典信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/type")
@Api(value = "数据字典信息", tags = {"数据字典信息"})
public class SysDictTypeController extends BaseController {
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
@ApiOperation("查询字典信息")
public TableDataInfo list(SysDictType dictType) {
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType) {
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型");
}
/**
* 查询字典类型详细
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}")
public AjaxResult getInfo(@PathVariable Long dictId) {
return success(dictTypeService.selectDictTypeById(dictId));
}
/**
* 新增字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增字典信息")
public AjaxResult add(@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(getUsername());
return toAjax(dictTypeService.insertDictType(dict));
}
/**
* 修改字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@ApiOperation("修改字典信息")
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
// dict.setUpdateBy(getUsername());
return toAjax(dictTypeService.updateDictType(dict));
}
/**
* 删除字典类型
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds) {
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}
/**
* 刷新字典缓存
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache() {
dictTypeService.resetDictCache();
return success();
}
/**
* 获取字典选择框列表
*/
@GetMapping("/optionselect")
public AjaxResult optionselect() {
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes);
}
}

View File

@@ -0,0 +1,29 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.config.RuoYiConfig;
import com.pxdj.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 首页
*
* @author ruoyi
*/
@RestController
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/**
* 访问首页,提示语
*/
@RequestMapping("/")
public String index()
{
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
}
}

View File

@@ -0,0 +1,91 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysMenu;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.LoginBody;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.system.service.ISysMenuService;
import com.pxdj.web.service.SysLoginService;
import com.pxdj.web.service.SysPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Set;
/**
* 登录验证
*
* @author ruoyi
*/
@RestController
@Api(value = "登录", tags = {"登录"})
public class SysLoginController {
@Autowired
private SysLoginService loginService;
@Autowired
private ISysMenuService menuService;
@Autowired
private SysPermissionService permissionService;
/**
* 登录方法
*
* @param loginBody 登录信息
* @return 结果
*/
@ApiOperation("用户登录")
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
* 获取用户信息
*
* @return 用户信息
*/
@GetMapping("getInfo")
public AjaxResult getInfo() {
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return ajax;
}
/**
* 获取路由信息
*
* @return 路由信息
*/
@GetMapping("getRouters")
public AjaxResult getRouters() {
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
}
}

View File

@@ -0,0 +1,136 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.constant.UserConstants;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysMenu;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 菜单信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
@Autowired
private ISysMenuService menuService;
/**
* 获取菜单列表
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menus);
}
/**
* 根据菜单编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}")
public AjaxResult getInfo(@PathVariable Long menuId)
{
return success(menuService.selectMenuById(menuId));
}
/**
* 获取菜单下拉树列表
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menuService.buildMenuTreeSelect(menus));
}
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
List<SysMenu> menus = menuService.selectMenuList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
/**
* 新增菜单
*/
@PreAuthorize("@ss.hasPermi('system:menu:add')")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysMenu menu)
{
if (!menuService.checkMenuNameUnique(menu))
{
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
menu.setCreateBy(getUsername());
return toAjax(menuService.insertMenu(menu));
}
/**
* 修改菜单
*/
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
{
if (!menuService.checkMenuNameUnique(menu))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
else if (menu.getMenuId().equals(menu.getParentId()))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
menu.setUpdateBy(getUsername());
return toAjax(menuService.updateMenu(menu));
}
/**
* 删除菜单
*/
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.hasChildByMenuId(menuId))
{
return warn("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId))
{
return warn("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
}
}

View File

@@ -0,0 +1,85 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.system.domain.SysNotice;
import com.pxdj.system.service.ISysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 公告 信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController
{
@Autowired
private ISysNoticeService noticeService;
/**
* 获取通知公告列表
*/
@PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list")
public TableDataInfo list(SysNotice notice)
{
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
}
/**
* 根据通知公告编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:notice:query')")
@GetMapping(value = "/{noticeId}")
public AjaxResult getInfo(@PathVariable Long noticeId)
{
return success(noticeService.selectNoticeById(noticeId));
}
/**
* 新增通知公告
*/
@PreAuthorize("@ss.hasPermi('system:notice:add')")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysNotice notice)
{
notice.setCreateBy(getUsername());
return toAjax(noticeService.insertNotice(notice));
}
/**
* 修改通知公告
*/
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
{
notice.setUpdateBy(getUsername());
return toAjax(noticeService.updateNotice(notice));
}
/**
* 删除通知公告
*/
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public AjaxResult remove(@PathVariable Long[] noticeIds)
{
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
}
}

View File

@@ -0,0 +1,123 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.SysPost;
import com.pxdj.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 岗位信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
@Autowired
private ISysPostService postService;
/**
* 获取岗位列表
*/
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据");
}
/**
* 根据岗位编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}")
public AjaxResult getInfo(@PathVariable Long postId)
{
return success(postService.selectPostById(postId));
}
/**
* 新增岗位
*/
@PreAuthorize("@ss.hasPermi('system:post:add')")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysPost post)
{
if (!postService.checkPostNameUnique(post))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (!postService.checkPostCodeUnique(post))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(getUsername());
return toAjax(postService.insertPost(post));
}
/**
* 修改岗位
*/
@PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysPost post)
{
if (!postService.checkPostNameUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (!postService.checkPostCodeUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(getUsername());
return toAjax(postService.updatePost(post));
}
/**
* 删除岗位
*/
@PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult remove(@PathVariable Long[] postIds)
{
return toAjax(postService.deletePostByIds(postIds));
}
/**
* 获取岗位选择框列表
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysPost> posts = postService.selectPostAll();
return success(posts);
}
}

View File

@@ -0,0 +1,127 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.config.RuoYiConfig;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.file.FileUploadUtils;
import com.pxdj.common.utils.file.MimeTypeUtils;
import com.pxdj.system.service.ISysUserService;
import com.pxdj.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* 个人信息 业务处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController {
@Autowired
private ISysUserService userService;
@Autowired
private TokenService tokenService;
/**
* 个人信息
*/
@GetMapping
public AjaxResult profile() {
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
return ajax;
}
/**
* 修改用户
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user) {
LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) {
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) {
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
if (userService.updateUserProfile(currentUser) > 0) {
// 更新缓存用户信息
tokenService.setLoginUser(loginUser);
return success();
}
return error("修改个人信息异常,请联系管理员");
}
/**
* 重置密码
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password)) {
return error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return success();
}
return error("修改密码异常,请联系管理员");
}
/**
* 头像上传
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar);
// 更新缓存用户头像
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return error("上传图片异常,请联系管理员");
}
}

View File

@@ -0,0 +1,39 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.model.RegisterBody;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.service.ISysConfigService;
import com.pxdj.web.service.SysRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* 注册验证
*
* @author ruoyi
*/
@RestController
public class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return error("当前系统没有开启注册功能!");
}
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
}
}

View File

@@ -0,0 +1,245 @@
package com.pxdj.web.controller.system;
/**
* 角色信息
*
* @author ruoyi
*/
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDept;
import com.pxdj.common.core.domain.entity.SysRole;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.domain.SysUserRole;
import com.pxdj.system.service.ISysDeptService;
import com.pxdj.system.service.ISysRoleService;
import com.pxdj.system.service.ISysUserService;
import com.pxdj.web.service.SysPermissionService;
import com.pxdj.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping("/system/role")
public class SysRoleController extends BaseController {
@Autowired
private ISysRoleService roleService;
@Autowired
private TokenService tokenService;
@Autowired
private SysPermissionService permissionService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysDeptService deptService;
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo list(SysRole role) {
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysRole role) {
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据");
}
/**
* 根据角色编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId);
return success(roleService.selectRoleById(roleId));
}
/**
* 新增角色
*/
@PreAuthorize("@ss.hasPermi('system:role:add')")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysRole role) {
if (!roleService.checkRoleNameUnique(role)) {
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(getUsername());
return toAjax(roleService.insertRole(role));
}
/**
* 修改保存角色
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysRole role) {
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) {
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(getUsername());
if (roleService.updateRole(role) > 0) {
// 更新缓存用户权限
LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
tokenService.setLoginUser(loginUser);
}
return success();
}
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
/**
* 修改保存数据权限
*//*
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public AjaxResult dataScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role));
}
/**
* 状态修改
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysRole role) {
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUsername());
return toAjax(roleService.updateRoleStatus(role));
}
/**
* 删除角色
*/
@PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public AjaxResult remove(@PathVariable Long[] roleIds) {
return toAjax(roleService.deleteRoleByIds(roleIds));
}
/**
* 获取角色选择框列表
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping("/optionselect")
public AjaxResult optionselect() {
return success(roleService.selectRoleAll());
}
/**
* 查询已分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
* 查询未分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
* 取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) {
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
* 批量取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) {
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
* 批量选择用户授权
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) {
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
/**
* 获取对应角色部门树列表
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}")
public AjaxResult deptTree(@PathVariable("roleId") Long roleId) {
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
return ajax;
}
}

View File

@@ -0,0 +1,246 @@
package com.pxdj.web.controller.system;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysDept;
import com.pxdj.common.core.domain.entity.SysRole;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.poi.ExcelUtil;
import com.pxdj.system.service.ISysDeptService;
import com.pxdj.system.service.ISysPostService;
import com.pxdj.system.service.ISysRoleService;
import com.pxdj.system.service.ISysUserService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysPostService postService;
/**
* 获取用户列表
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据");
}
/**
* 根据用户编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId))
{
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
}
/**
* 新增用户
*/
@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user)
{
if (!userService.checkUserNameUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(getUsername());
user.setShopId(1L);
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
/**
* 修改用户
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (!userService.checkUserNameUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(getUsername());
return toAjax(userService.updateUser(user));
}
/**
* 删除用户
*/
@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds)
{
if (ArrayUtils.contains(userIds, getUserId()))
{
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
}
/**
* 重置密码
*/
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(getUsername());
return toAjax(userService.resetPwd(user));
}
/**
* 状态修改
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
* 根据用户编号获取授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
* 用户授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
}
/**
* 获取部门树列表
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept)
{
return success(deptService.selectDeptTreeList(dept));
}
}

View File

@@ -0,0 +1,172 @@
package com.pxdj.web.controller.tool;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.R;
import com.pxdj.common.utils.StringUtils;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* swagger 用户测试方法
*
* @author ruoyi
*/
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
}
@ApiOperation("获取用户列表")
@GetMapping("/list")
public R<List<UserEntity>> userList()
{
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return R.ok(userList);
}
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@GetMapping("/{userId}")
public R<UserEntity> getUser(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
return R.ok(users.get(userId));
}
else
{
return R.fail("用户不存在");
}
}
@ApiOperation("新增用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("/save")
public R<String> save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("更新用户")
@PutMapping("/update")
public R<String> update(@RequestBody UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
return R.fail("用户不存在");
}
users.remove(user.getUserId());
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@DeleteMapping("/{userId}")
public R<String> delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
users.remove(userId);
return R.ok();
}
else
{
return R.fail("用户不存在");
}
}
}
@ApiModel(value = "UserEntity", description = "用户实体")
class UserEntity
{
@ApiModelProperty("用户ID")
private Integer userId;
@ApiModelProperty("用户名称")
private String username;
@ApiModelProperty("用户密码")
private String password;
@ApiModelProperty("用户手机")
private String mobile;
public UserEntity()
{
}
public UserEntity(Integer userId, String username, String password, String mobile)
{
this.userId = userId;
this.username = username;
this.password = password;
this.mobile = mobile;
}
public Integer getUserId()
{
return userId;
}
public void setUserId(Integer userId)
{
this.userId = userId;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getMobile()
{
return mobile;
}
public void setMobile(String mobile)
{
this.mobile = mobile;
}
}

View File

@@ -0,0 +1,94 @@
package com.pxdj.web.controller.tool;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
public class demo {
public static void main(String[] args) {
// socket();
ByteBuf();
// ByteBufCopy();
}
public static void socket() {
try {
Socket socket = new Socket("localhost", 8848);
OutputStream outputStream = socket.getOutputStream();
PrintWriter printWriter = new PrintWriter(outputStream);
printWriter.write("$tmb00035ET3318/08/22 11:5804029.94,027.25,20.00,20.00$");
printWriter.flush();
socket.shutdownOutput();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void ByteBuf() {
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
buf.writeBytes(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
log(buf);
//从buf这个总的数据中分别拆分5个字节保存到两个ByteBuf中
//零拷贝机制 (浅克隆)
// ByteBuf bb1 = buf.slice(0, 5);
// ByteBuf bb2 = buf.slice(5, 5);
// log(bb1);
// log(bb2);
byte b = buf.readByte();
byte i1 = buf.readByte();
//废弃字节,释放已经读过的字节空间
ByteBuf byteBuf = buf.discardReadBytes();
int i2 = byteBuf.readByte();
System.out.println(b + "----" + i1 + "---" + i2);
System.out.println("修改原始数据");
buf.setByte(2, 8);
log(buf);
}
public static void ByteBufCopy() {
ByteBuf header = ByteBufAllocator.DEFAULT.buffer();
header.writeBytes(new byte[]{1, 2, 3, 4, 5});
ByteBuf body = ByteBufAllocator.DEFAULT.buffer();
body.writeBytes(new byte[]{6, 7, 8, 9, 10});
/* ByteBuf total= Unpooled.buffer(header.readableBytes()+body.readableBytes());
total.writeBytes(header);
total.writeBytes(body);*/
//从逻辑成面构建了一个总的buf数据。
//第二个零拷贝实现
//通过CompositeByteBuf构建了一个逻辑整体里面仍然是两个真实对象也就是有一个指针指向了同一个对象所以这里类似于浅拷贝的实现
/* CompositeByteBuf compositeByteBuf=Unpooled.compositeBuffer();
compositeByteBuf.addComponents(true,header,body);
log(compositeByteBuf);*/
//Unpooled
ByteBuf total = Unpooled.wrappedBuffer(header, body);
log(total);
header.setByte(2, 9);
log(total);
}
private static void log(ByteBuf buf) {
StringBuilder sb = new StringBuilder();
sb.append(" read index:").append(buf.readerIndex()); //读索引
sb.append(" write index:").append(buf.writerIndex()); //写索引
sb.append(" capacity :").append(buf.capacity()); //容量
ByteBufUtil.appendPrettyHexDump(sb, buf);
System.out.println(sb);
}
}

View File

@@ -0,0 +1,232 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package com.pxdj.web.controller.user;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pxdj.api.domain.User;
import com.pxdj.api.domain.UserWithdrawal;
import com.pxdj.api.domain.Merchant;
import com.pxdj.api.param.UserWithdrawalParam;
import com.pxdj.api.service.UserService;
import com.pxdj.api.service.UserWithdrawalService;
import com.pxdj.api.service.MerchantService;
import com.pxdj.common.annotation.Log;
import com.pxdj.common.core.controller.BaseController;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.page.TableDataInfo;
import com.pxdj.common.enums.BusinessType;
import com.pxdj.common.response.ServerResponseEntity;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.service.ISysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Objects;
import java.util.HashMap;
/**
* 用户提现管理
*/
@RestController
@RequestMapping("/api/withdrawal")
@Tag(name = "用户提现管理")
public class UserWithdrawalController extends BaseController {
@Autowired
private UserWithdrawalService userWithdrawalService;
@Autowired
private UserService userService;
@Autowired
private ISysUserService iSysUserService;
/**
* 提现申请列表
*/
//@PreAuthorize("@ss.hasPermi('api:withdrawal:list')")
@GetMapping("/list")
@Operation(summary = "提现申请列表", description = "获取提现申请列表")
public TableDataInfo list(
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "city", required = false) String city) {
startPage();
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId = sysUser.getDeptId();
Long parentId =sysUser.getDept().getParentId();
if (departmentId != 100 && departmentId!=113&& parentId!=101) {
city = sysUser.getDept().getDeptName();
}
Long teamId = null;
if(parentId == 101){
teamId=departmentId;
departmentId = null;
}
if(departmentId == null || departmentId==100||departmentId==113){
departmentId = null;
}
List<UserWithdrawal> list = userWithdrawalService.getWithdrawalList(status, userName, city, userId, departmentId,teamId);
return getDataTable(list);
}
/**
* 代理提现的详情
*/
@PreAuthorize("@ss.hasPermi('api:withdrawal:query')")
@GetMapping(value = "/getAgentInfo")
@Operation(summary = "提现申请详情", description = "获取提现申请详情")
public AjaxResult getAgentInfo() {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
String city = sysUser.getDept().getDeptName();
if(departmentId!=100 && departmentId!=113){
Long teamId = null;
Long parentId =sysUser.getDept().getParentId();
if(parentId == 101){
teamId=departmentId;
city=null;
}
return success(userWithdrawalService.getAgentInfo(city,userId,teamId));
}
return success();
}
/**
* 获取提现申请详情
*/
@PreAuthorize("@ss.hasPermi('api:withdrawal:query')")
@GetMapping(value = "/{id}")
@Operation(summary = "提现申请详情", description = "获取提现申请详情")
public AjaxResult getInfo(@PathVariable("id") Long id) {
UserWithdrawal withdrawal = userWithdrawalService.getById(id);
if (withdrawal != null) {
// 关联用户信息
User user = userService.getById(withdrawal.getUserId());
withdrawal.setUser(user);
}
return success(withdrawal);
}
/**
* 审批提现申请
*/
@PreAuthorize("@ss.hasPermi('api:withdrawal:approve')")
@Log(title = "提现审批", businessType = BusinessType.UPDATE)
@PutMapping("/approve")
@Operation(summary = "审批提现申请", description = "审批提现申请")
public AjaxResult approve(@RequestBody @Validated ApproveParam param) {
SysUser user = SecurityUtils.getLoginUser().getUser();
boolean result = userWithdrawalService.approveWithdrawal(
param.getId(),
user,
user.getNickName(),
param.getStatus(),
param.getRejectReason());
return toAjax(result);
}
@PreAuthorize("@ss.hasPermi('api:withdrawal:query')")
@GetMapping(value = "/getPxdjInfo")
@Operation(summary = "提现申请详情", description = "获取提现申请详情")
public AjaxResult getPxdjInfo() {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
if(departmentId==113){
return success(userWithdrawalService.getPxdjInfo(sysUser.getDept().getDeptName(),userId));
}
return success();
}
/**
* admin提现的详情
*/
@PreAuthorize("@ss.hasPermi('api:withdrawal:query')")
@GetMapping(value = "/getAdminInfo")
@Operation(summary = "提现申请详情", description = "获取提现申请详情")
public AjaxResult getAdminInfo() {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
if(departmentId==100){
return success(userWithdrawalService.getAdminInfo());
}
return success();
}
/**
* 代理申请提现
*/
@PostMapping("/apply")
@Operation(summary = "申请提现", description = "用户申请提现")
public AjaxResult applyWithdrawal(@RequestBody @Validated UserWithdrawalParam param) {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
if(departmentId!=100 && departmentId!=113){
userWithdrawalService.applyWithdrawalByRoot(sysUser, param);
return AjaxResult.success();
}else {
return AjaxResult.error("该角色不支持提现");
}
}
/**
* pxdj申请提现
*/
@PostMapping("/pxdjApply")
@Operation(summary = "pxdj申请提现", description = "pxdj")
public AjaxResult pxdjApply(@RequestBody @Validated UserWithdrawalParam param) {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = iSysUserService.selectUserById(userId);
Long departmentId =sysUser.getDeptId();
if(departmentId==113){
userWithdrawalService.pxdjApply(sysUser, param);
return AjaxResult.success();
}else {
return AjaxResult.error("角色错误");
}
}
/**
* 审批参数
*/
@Data
public static class ApproveParam {
/**
* 提现记录ID
*/
@NotNull(message = "提现记录ID不能为空")
private Long id;
/**
* 状态: 1-通过, 2-拒绝
*/
@NotNull(message = "审批状态不能为空")
private Integer status;
/**
* 拒绝原因
*/
private String rejectReason;
}
}

View File

@@ -0,0 +1,237 @@
package com.pxdj.web.domain;
import com.pxdj.common.utils.Arith;
import com.pxdj.common.utils.ip.IpUtils;
import com.pxdj.web.domain.server.*;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.CentralProcessor.TickType;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.FileSystem;
import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem;
import oshi.util.Util;
import java.net.UnknownHostException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
/**
* 服务器相关信息
*
* @author ruoyi
*/
public class Server
{
private static final int OSHI_WAIT_SECOND = 1000;
/**
* CPU相关信息
*/
private Cpu cpu = new Cpu();
/**
* 內存相关信息
*/
private Mem mem = new Mem();
/**
* JVM相关信息
*/
private Jvm jvm = new Jvm();
/**
* 服务器相关信息
*/
private Sys sys = new Sys();
/**
* 磁盘相关信息
*/
private List<SysFile> sysFiles = new LinkedList<SysFile>();
public Cpu getCpu()
{
return cpu;
}
public void setCpu(Cpu cpu)
{
this.cpu = cpu;
}
public Mem getMem()
{
return mem;
}
public void setMem(Mem mem)
{
this.mem = mem;
}
public Jvm getJvm()
{
return jvm;
}
public void setJvm(Jvm jvm)
{
this.jvm = jvm;
}
public Sys getSys()
{
return sys;
}
public void setSys(Sys sys)
{
this.sys = sys;
}
public List<SysFile> getSysFiles()
{
return sysFiles;
}
public void setSysFiles(List<SysFile> sysFiles)
{
this.sysFiles = sysFiles;
}
public void copyTo() throws Exception
{
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
setCpuInfo(hal.getProcessor());
setMemInfo(hal.getMemory());
setSysInfo();
setJvmInfo();
setSysFiles(si.getOperatingSystem());
}
/**
* 设置CPU信息
*/
private void setCpuInfo(CentralProcessor processor)
{
// CPU信息
long[] prevTicks = processor.getSystemCpuLoadTicks();
Util.sleep(OSHI_WAIT_SECOND);
long[] ticks = processor.getSystemCpuLoadTicks();
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()];
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];
long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()];
long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()];
long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()];
long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()];
long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()];
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
cpu.setCpuNum(processor.getLogicalProcessorCount());
cpu.setTotal(totalCpu);
cpu.setSys(cSys);
cpu.setUsed(user);
cpu.setWait(iowait);
cpu.setFree(idle);
}
/**
* 设置内存信息
*/
private void setMemInfo(GlobalMemory memory)
{
mem.setTotal(memory.getTotal());
mem.setUsed(memory.getTotal() - memory.getAvailable());
mem.setFree(memory.getAvailable());
}
/**
* 设置服务器信息
*/
private void setSysInfo()
{
Properties props = System.getProperties();
sys.setComputerName(IpUtils.getHostName());
sys.setComputerIp(IpUtils.getHostIp());
sys.setOsName(props.getProperty("os.name"));
sys.setOsArch(props.getProperty("os.arch"));
sys.setUserDir(props.getProperty("user.dir"));
}
/**
* 设置Java虚拟机
*/
private void setJvmInfo() throws UnknownHostException
{
Properties props = System.getProperties();
jvm.setTotal(Runtime.getRuntime().totalMemory());
jvm.setMax(Runtime.getRuntime().maxMemory());
jvm.setFree(Runtime.getRuntime().freeMemory());
jvm.setVersion(props.getProperty("java.version"));
jvm.setHome(props.getProperty("java.home"));
}
/**
* 设置磁盘信息
*/
private void setSysFiles(OperatingSystem os)
{
FileSystem fileSystem = os.getFileSystem();
List<OSFileStore> fsArray = fileSystem.getFileStores();
for (OSFileStore fs : fsArray)
{
long free = fs.getUsableSpace();
long total = fs.getTotalSpace();
long used = total - free;
SysFile sysFile = new SysFile();
sysFile.setDirName(fs.getMount());
sysFile.setSysTypeName(fs.getType());
sysFile.setTypeName(fs.getName());
sysFile.setTotal(convertFileSize(total));
sysFile.setFree(convertFileSize(free));
sysFile.setUsed(convertFileSize(used));
sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
sysFiles.add(sysFile);
}
}
/**
* 字节转换
*
* @param size 字节大小
* @return 转换后值
*/
public String convertFileSize(long size)
{
long kb = 1024;
long mb = kb * 1024;
long gb = mb * 1024;
if (size >= gb)
{
return String.format("%.1f GB", (float) size / gb);
}
else if (size >= mb)
{
float f = (float) size / mb;
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
}
else if (size >= kb)
{
float f = (float) size / kb;
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
}
else
{
return String.format("%d B", size);
}
}
}

View File

@@ -0,0 +1,102 @@
package com.pxdj.web.domain.server;
import com.pxdj.common.utils.Arith;
/**
* CPU相关信息
*
* @author ruoyi
*/
public class Cpu
{
/**
* 核心数
*/
private int cpuNum;
/**
* CPU总的使用率
*/
private double total;
/**
* CPU系统使用率
*/
private double sys;
/**
* CPU用户使用率
*/
private double used;
/**
* CPU当前等待率
*/
private double wait;
/**
* CPU当前空闲率
*/
private double free;
public int getCpuNum()
{
return cpuNum;
}
public void setCpuNum(int cpuNum)
{
this.cpuNum = cpuNum;
}
public double getTotal()
{
return Arith.round(Arith.mul(total, 100), 2);
}
public void setTotal(double total)
{
this.total = total;
}
public double getSys()
{
return Arith.round(Arith.mul(sys / total, 100), 2);
}
public void setSys(double sys)
{
this.sys = sys;
}
public double getUsed()
{
return Arith.round(Arith.mul(used / total, 100), 2);
}
public void setUsed(double used)
{
this.used = used;
}
public double getWait()
{
return Arith.round(Arith.mul(wait / total, 100), 2);
}
public void setWait(double wait)
{
this.wait = wait;
}
public double getFree()
{
return Arith.round(Arith.mul(free / total, 100), 2);
}
public void setFree(double free)
{
this.free = free;
}
}

View File

@@ -0,0 +1,132 @@
package com.pxdj.web.domain.server;
import com.pxdj.common.utils.Arith;
import com.pxdj.common.utils.DateUtils;
import java.lang.management.ManagementFactory;
/**
* JVM相关信息
*
* @author ruoyi
*/
public class Jvm
{
/**
* 当前JVM占用的内存总数(M)
*/
private double total;
/**
* JVM最大可用内存总数(M)
*/
private double max;
/**
* JVM空闲内存(M)
*/
private double free;
/**
* JDK版本
*/
private String version;
/**
* JDK路径
*/
private String home;
public double getTotal()
{
return Arith.div(total, (1024 * 1024), 2);
}
public void setTotal(double total)
{
this.total = total;
}
public double getMax()
{
return Arith.div(max, (1024 * 1024), 2);
}
public void setMax(double max)
{
this.max = max;
}
public double getFree()
{
return Arith.div(free, (1024 * 1024), 2);
}
public void setFree(double free)
{
this.free = free;
}
public double getUsed()
{
return Arith.div(total - free, (1024 * 1024), 2);
}
public double getUsage()
{
return Arith.mul(Arith.div(total - free, total, 4), 100);
}
/**
* 获取JDK名称
*/
public String getName()
{
return ManagementFactory.getRuntimeMXBean().getVmName();
}
public String getVersion()
{
return version;
}
public void setVersion(String version)
{
this.version = version;
}
public String getHome()
{
return home;
}
public void setHome(String home)
{
this.home = home;
}
/**
* JDK启动时间
*/
public String getStartTime()
{
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate());
}
/**
* JDK运行时间
*/
public String getRunTime()
{
return DateUtils.timeDistance(DateUtils.getNowDate(), DateUtils.getServerStartDate());
}
/**
* 运行参数
*/
public String getInputArgs()
{
return ManagementFactory.getRuntimeMXBean().getInputArguments().toString();
}
}

View File

@@ -0,0 +1,62 @@
package com.pxdj.web.domain.server;
import com.pxdj.common.utils.Arith;
/**
* 內存相关信息
*
* @author ruoyi
*/
public class Mem
{
/**
* 内存总量
*/
private double total;
/**
* 已用内存
*/
private double used;
/**
* 剩余内存
*/
private double free;
public double getTotal()
{
return Arith.div(total, (1024 * 1024 * 1024), 2);
}
public void setTotal(long total)
{
this.total = total;
}
public double getUsed()
{
return Arith.div(used, (1024 * 1024 * 1024), 2);
}
public void setUsed(long used)
{
this.used = used;
}
public double getFree()
{
return Arith.div(free, (1024 * 1024 * 1024), 2);
}
public void setFree(long free)
{
this.free = free;
}
public double getUsage()
{
return Arith.mul(Arith.div(used, total, 4), 100);
}
}

View File

@@ -0,0 +1,84 @@
package com.pxdj.web.domain.server;
/**
* 系统相关信息
*
* @author ruoyi
*/
public class Sys
{
/**
* 服务器名称
*/
private String computerName;
/**
* 服务器Ip
*/
private String computerIp;
/**
* 项目路径
*/
private String userDir;
/**
* 操作系统
*/
private String osName;
/**
* 系统架构
*/
private String osArch;
public String getComputerName()
{
return computerName;
}
public void setComputerName(String computerName)
{
this.computerName = computerName;
}
public String getComputerIp()
{
return computerIp;
}
public void setComputerIp(String computerIp)
{
this.computerIp = computerIp;
}
public String getUserDir()
{
return userDir;
}
public void setUserDir(String userDir)
{
this.userDir = userDir;
}
public String getOsName()
{
return osName;
}
public void setOsName(String osName)
{
this.osName = osName;
}
public String getOsArch()
{
return osArch;
}
public void setOsArch(String osArch)
{
this.osArch = osArch;
}
}

View File

@@ -0,0 +1,114 @@
package com.pxdj.web.domain.server;
/**
* 系统文件相关信息
*
* @author ruoyi
*/
public class SysFile
{
/**
* 盘符路径
*/
private String dirName;
/**
* 盘符类型
*/
private String sysTypeName;
/**
* 文件类型
*/
private String typeName;
/**
* 总大小
*/
private String total;
/**
* 剩余大小
*/
private String free;
/**
* 已经使用量
*/
private String used;
/**
* 资源的使用率
*/
private double usage;
public String getDirName()
{
return dirName;
}
public void setDirName(String dirName)
{
this.dirName = dirName;
}
public String getSysTypeName()
{
return sysTypeName;
}
public void setSysTypeName(String sysTypeName)
{
this.sysTypeName = sysTypeName;
}
public String getTypeName()
{
return typeName;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public String getTotal()
{
return total;
}
public void setTotal(String total)
{
this.total = total;
}
public String getFree()
{
return free;
}
public void setFree(String free)
{
this.free = free;
}
public String getUsed()
{
return used;
}
public void setUsed(String used)
{
this.used = used;
}
public double getUsage()
{
return usage;
}
public void setUsage(double usage)
{
this.usage = usage;
}
}

View File

@@ -0,0 +1,139 @@
package com.pxdj.web.exception;
import com.pxdj.common.constant.HttpStatus;
import com.pxdj.common.core.domain.AjaxResult;
import com.pxdj.common.exception.DemoModeException;
import com.pxdj.common.exception.ServiceException;
import com.pxdj.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingPathVariableException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.servlet.http.HttpServletRequest;
/**
* 全局异常处理器
*
* @author ruoyi
*/
@RestControllerAdvice
public class GlobalExceptionHandler
{
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 权限校验异常
*/
@ExceptionHandler(AccessDeniedException.class)
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
}
/**
* 请求方式不支持
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
return AjaxResult.error(e.getMessage());
}
/**
* 业务异常
*/
@ExceptionHandler(ServiceException.class)
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
{
log.error(e.getMessage(), e);
Integer code = e.getCode();
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
}
/**
* 请求路径中缺少必需的路径变量
*/
@ExceptionHandler(MissingPathVariableException.class)
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
}
/**
* 请求参数类型不匹配
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
}
/**
* 拦截未知的运行时异常
*/
@ExceptionHandler(RuntimeException.class)
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
/**
* 系统异常
*/
@ExceptionHandler(Exception.class)
public AjaxResult handleException(Exception e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
/**
* 自定义验证异常
*/
@ExceptionHandler(BindException.class)
public AjaxResult handleBindException(BindException e)
{
log.error(e.getMessage(), e);
String message = e.getAllErrors().get(0).getDefaultMessage();
return AjaxResult.error(message);
}
/**
* 自定义验证异常
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
{
log.error(e.getMessage(), e);
String message = e.getBindingResult().getFieldError().getDefaultMessage();
return AjaxResult.error(message);
}
/**
* 演示模式异常
*/
@ExceptionHandler(DemoModeException.class)
public AjaxResult handleDemoModeException(DemoModeException e)
{
return AjaxResult.error("演示模式,不允许操作");
}
}

View File

@@ -0,0 +1,169 @@
package com.pxdj.web.service;
import com.pxdj.common.core.domain.entity.SysRole;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.web.config.security.context.PermissionContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Set;
/**
* RuoYi首创 自定义权限实现ss取自SpringSecurity首字母
*
* @author ruoyi
*/
@Service("ss")
public class PermissionService
{
/** 所有权限标识 */
private static final String ALL_PERMISSION = "*:*:*";
/** 管理员角色权限标识 */
private static final String SUPER_ADMIN = "admin";
private static final String ROLE_DELIMETER = ",";
private static final String PERMISSION_DELIMETER = ",";
/**
* 验证用户是否具备某权限
*
* @param permission 权限字符串
* @return 用户是否具备某权限
*/
public boolean hasPermi(String permission)
{
if (StringUtils.isEmpty(permission))
{
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
{
return false;
}
PermissionContextHolder.setContext(permission);
return hasPermissions(loginUser.getPermissions(), permission);
}
/**
* 验证用户是否不具备某权限,与 hasPermi逻辑相反
*
* @param permission 权限字符串
* @return 用户是否不具备某权限
*/
public boolean lacksPermi(String permission)
{
return hasPermi(permission) != true;
}
/**
* 验证用户是否具有以下任意一个权限
*
* @param permissions 以 PERMISSION_DELIMETER 为分隔符的权限列表
* @return 用户是否具有以下任意一个权限
*/
public boolean hasAnyPermi(String permissions)
{
if (StringUtils.isEmpty(permissions))
{
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
{
return false;
}
PermissionContextHolder.setContext(permissions);
Set<String> authorities = loginUser.getPermissions();
for (String permission : permissions.split(PERMISSION_DELIMETER))
{
if (permission != null && hasPermissions(authorities, permission))
{
return true;
}
}
return false;
}
/**
* 判断用户是否拥有某个角色
*
* @param role 角色字符串
* @return 用户是否具备某角色
*/
public boolean hasRole(String role)
{
if (StringUtils.isEmpty(role))
{
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
{
return false;
}
for (SysRole sysRole : loginUser.getUser().getRoles())
{
String roleKey = sysRole.getRoleKey();
if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role)))
{
return true;
}
}
return false;
}
/**
* 验证用户是否不具备某角色,与 isRole逻辑相反。
*
* @param role 角色名称
* @return 用户是否不具备某角色
*/
public boolean lacksRole(String role)
{
return hasRole(role) != true;
}
/**
* 验证用户是否具有以下任意一个角色
*
* @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表
* @return 用户是否具有以下任意一个角色
*/
public boolean hasAnyRoles(String roles)
{
if (StringUtils.isEmpty(roles))
{
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
{
return false;
}
for (String role : roles.split(ROLE_DELIMETER))
{
if (hasRole(role))
{
return true;
}
}
return false;
}
/**
* 判断是否包含权限
*
* @param permissions 权限列表
* @param permission 权限字符串
* @return 用户是否具备某权限
*/
private boolean hasPermissions(Set<String> permissions, String permission)
{
return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission));
}
}

View File

@@ -0,0 +1,178 @@
package com.pxdj.web.service;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.constant.UserConstants;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.exception.ServiceException;
import com.pxdj.common.exception.user.*;
import com.pxdj.common.utils.DateUtils;
import com.pxdj.common.utils.MessageUtils;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.ip.IpUtils;
import com.pxdj.framework.manager.AsyncManager;
import com.pxdj.framework.manager.factory.AsyncFactory;
import com.pxdj.system.service.ISysConfigService;
import com.pxdj.system.service.ISysUserService;
import com.pxdj.web.config.security.context.AuthenticationContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 登录校验方法
*
* @author ruoyi
*/
@Component
public class SysLoginService
{
@Autowired
private TokenService tokenService;
@Resource
private AuthenticationManager authenticationManager;
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
/**
* 登录验证
*
* @param username 用户名
* @param password 密码
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public String login(String username, String password, String code, String uuid)
{
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证
Authentication authentication = null;
try
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
}
finally
{
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public void validateCaptcha(String username, String code, String uuid)
{
boolean captchaEnabled = configService.selectCaptchaEnabled();
if (captchaEnabled)
{
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = RedisUtil.getCacheObject(verifyKey);
RedisUtil.deleteObject(verifyKey);
if (captcha == null)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
}
}
/**
* 登录前置校验
* @param username 用户名
* @param password 用户密码
*/
public void loginPreCheck(String username, String password)
{
// 用户名或密码为空 错误
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
throw new UserNotExistsException();
}
// 密码如果不在指定范围内 错误
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
// 用户名不在指定范围内 错误
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
// IP黑名单校验
String blackStr = configService.selectConfigByKey("sys.login.blackIPList");
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("login.blocked")));
throw new BlackListException();
}
}
/**
* 记录登录信息
*
* @param userId 用户ID
*/
public void recordLoginInfo(Long userId)
{
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr());
sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser);
}
}

View File

@@ -0,0 +1,95 @@
package com.pxdj.web.service;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.exception.user.UserPasswordNotMatchException;
import com.pxdj.common.exception.user.UserPasswordRetryLimitExceedException;
import com.pxdj.common.utils.MessageUtils;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.framework.manager.AsyncManager;
import com.pxdj.framework.manager.factory.AsyncFactory;
import com.pxdj.web.config.security.context.AuthenticationContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* 登录密码方法
*
* @author ruoyi
*/
@Component
public class SysPasswordService
{
@Value(value = "${user.password.maxRetryCount}")
private int maxRetryCount;
@Value(value = "${user.password.lockTime}")
private int lockTime;
/**
* 登录账户密码错误次数缓存键名
*
* @param username 用户名
* @return 缓存键key
*/
private String getCacheKey(String username)
{
return CacheConstants.PWD_ERR_CNT_KEY + username;
}
public void validate(SysUser user)
{
Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
String username = usernamePasswordAuthenticationToken.getName();
String password = usernamePasswordAuthenticationToken.getCredentials().toString();
Integer retryCount = RedisUtil.getCacheObject(getCacheKey(username));
if (retryCount == null)
{
retryCount = 0;
}
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount, lockTime)));
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
}
if (!matches(user, password))
{
retryCount = retryCount + 1;
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
MessageUtils.message("user.password.retry.limit.count", retryCount)));
RedisUtil.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
throw new UserPasswordNotMatchException();
}
else
{
clearLoginRecordCache(username);
}
}
public boolean matches(SysUser user, String rawPassword)
{
return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
}
public void clearLoginRecordCache(String loginName)
{
if (RedisUtil.hasKey(getCacheKey(loginName)))
{
RedisUtil.deleteObject(getCacheKey(loginName));
}
}
}

View File

@@ -0,0 +1,84 @@
package com.pxdj.web.service;
import com.pxdj.common.core.domain.entity.SysRole;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.system.service.ISysMenuService;
import com.pxdj.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 用户权限处理
*
* @author ruoyi
*/
@Component
public class SysPermissionService
{
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysMenuService menuService;
/**
* 获取角色数据权限
*
* @param user 用户信息
* @return 角色权限信息
*/
public Set<String> getRolePermission(SysUser user)
{
Set<String> roles = new HashSet<String>();
// 管理员拥有所有权限
if (user.isAdmin())
{
roles.add("admin");
}
else
{
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
}
return roles;
}
/**
* 获取菜单数据权限
*
* @param user 用户信息
* @return 菜单权限信息
*/
public Set<String> getMenuPermission(SysUser user)
{
Set<String> perms = new HashSet<String>();
// 管理员拥有所有权限
if (user.isAdmin())
{
perms.add("*:*:*");
}
else
{
List<SysRole> roles = user.getRoles();
if (!CollectionUtils.isEmpty(roles))
{
// 多角色设置permissions属性以便数据权限匹配权限
for (SysRole role : roles)
{
Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
role.setPermissions(rolePerms);
perms.addAll(rolePerms);
}
}
else
{
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
}
}
return perms;
}
}

View File

@@ -0,0 +1,115 @@
package com.pxdj.web.service;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.constant.UserConstants;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.RegisterBody;
import com.pxdj.common.exception.user.CaptchaException;
import com.pxdj.common.exception.user.CaptchaExpireException;
import com.pxdj.common.utils.MessageUtils;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.SecurityUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.framework.manager.AsyncManager;
import com.pxdj.framework.manager.factory.AsyncFactory;
import com.pxdj.system.service.ISysConfigService;
import com.pxdj.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 注册校验方法
*
* @author ruoyi
*/
@Component
public class SysRegisterService
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
/**
* 注册
*/
public String register(RegisterBody registerBody)
{
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
// 验证码开关
boolean captchaEnabled = configService.selectCaptchaEnabled();
if (captchaEnabled)
{
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
}
if (StringUtils.isEmpty(username))
{
msg = "用户名不能为空";
}
else if (StringUtils.isEmpty(password))
{
msg = "用户密码不能为空";
}
else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
{
msg = "账户长度必须在2到20个字符之间";
}
else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
{
msg = "密码长度必须在5到20个字符之间";
}
else if (!userService.checkUserNameUnique(sysUser))
{
msg = "保存用户'" + username + "'失败,注册账号已存在";
}
else
{
sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(password));
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag)
{
msg = "注册失败,请联系系统管理人员";
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success")));
}
}
return msg;
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public void validateCaptcha(String username, String code, String uuid)
{
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = RedisUtil.getCacheObject(verifyKey);
RedisUtil.deleteObject(verifyKey);
if (captcha == null)
{
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
throw new CaptchaException();
}
}
}

View File

@@ -0,0 +1,232 @@
package com.pxdj.web.service;
import com.pxdj.common.constant.CacheConstants;
import com.pxdj.common.constant.Constants;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.utils.RedisUtil;
import com.pxdj.common.utils.ServletUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.common.utils.ip.AddressUtils;
import com.pxdj.common.utils.ip.IpUtils;
import com.pxdj.common.utils.uuid.IdUtils;
import eu.bitwalker.useragentutils.UserAgent;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* token验证处理
*
* @author ruoyi
*/
@Component
public class TokenService
{
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
// 令牌自定义标识
@Value("${token.header}")
private String header;
// 令牌秘钥
@Value("${token.secret}")
private String secret;
// 令牌有效期默认30分钟
@Value("${token.expireTime}")
private int expireTime;
protected static final long MILLIS_SECOND = 1000;
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
/**
* 获取用户身份信息
*
* @return 用户信息
*/
public LoginUser getLoginUser(HttpServletRequest request)
{
// 获取请求携带的令牌
String token = getToken(request);
if (StringUtils.isNotEmpty(token))
{
try
{
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
LoginUser user = RedisUtil.getCacheObject(userKey);
return user;
}
catch (Exception e)
{
log.error("获取用户信息异常'{}'", e.getMessage());
}
}
return null;
}
/**
* 设置用户身份信息
*/
public void setLoginUser(LoginUser loginUser)
{
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken()))
{
refreshToken(loginUser);
}
}
/**
* 删除用户身份信息
*/
public void delLoginUser(String token)
{
if (StringUtils.isNotEmpty(token))
{
String userKey = getTokenKey(token);
RedisUtil.deleteObject(userKey);
}
}
/**
* 创建令牌
*
* @param loginUser 用户信息
* @return 令牌
*/
public String createToken(LoginUser loginUser)
{
String token = IdUtils.fastUUID();
loginUser.setToken(token);
setUserAgent(loginUser);
refreshToken(loginUser);
Map<String, Object> claims = new HashMap<>();
claims.put(Constants.LOGIN_USER_KEY, token);
return createToken(claims);
}
/**
* 验证令牌有效期相差不足20分钟自动刷新缓存
*
* @param loginUser
* @return 令牌
*/
public void verifyToken(LoginUser loginUser)
{
long expireTime = loginUser.getExpireTime();
long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
{
refreshToken(loginUser);
}
}
/**
* 刷新令牌有效期
*
* @param loginUser 登录信息
*/
public void refreshToken(LoginUser loginUser)
{
loginUser.setLoginTime(System.currentTimeMillis());
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
// 根据uuid将loginUser缓存
String userKey = getTokenKey(loginUser.getToken());
RedisUtil.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
}
/**
* 设置用户代理信息
*
* @param loginUser 登录信息
*/
public void setUserAgent(LoginUser loginUser)
{
UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
String ip = IpUtils.getIpAddr();
loginUser.setIpaddr(ip);
loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
loginUser.setBrowser(userAgent.getBrowser().getName());
loginUser.setOs(userAgent.getOperatingSystem().getName());
}
/**
* 从数据声明生成令牌
*
* @param claims 数据声明
* @return 令牌
*/
private String createToken(Map<String, Object> claims)
{
String token = Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS512, secret).compact();
return token;
}
/**
* 从令牌中获取数据声明
*
* @param token 令牌
* @return 数据声明
*/
private Claims parseToken(String token)
{
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
}
/**
* 从令牌中获取用户名
*
* @param token 令牌
* @return 用户名
*/
public String getUsernameFromToken(String token)
{
Claims claims = parseToken(token);
return claims.getSubject();
}
/**
* 获取请求token
*
* @param request
* @return token
*/
private String getToken(HttpServletRequest request)
{
String token = request.getHeader(header);
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
{
token = token.replace(Constants.TOKEN_PREFIX, "");
}
return token;
}
private String getTokenKey(String uuid)
{
return CacheConstants.LOGIN_TOKEN_KEY + uuid;
}
}

View File

@@ -0,0 +1,66 @@
package com.pxdj.web.service;
import com.pxdj.common.core.domain.entity.SysUser;
import com.pxdj.common.core.domain.model.LoginUser;
import com.pxdj.common.enums.UserStatus;
import com.pxdj.common.exception.ServiceException;
import com.pxdj.common.utils.MessageUtils;
import com.pxdj.common.utils.StringUtils;
import com.pxdj.system.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
/**
* 用户验证处理
*
* @author ruoyi
*/
@Service
public class UserDetailsServiceImpl implements UserDetailsService
{
private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
@Autowired
private ISysUserService userService;
@Autowired
private SysPasswordService passwordService;
@Autowired
private SysPermissionService permissionService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
{
SysUser user = userService.selectUserByUserName(username);
if (StringUtils.isNull(user))
{
log.info("登录用户:{} 不存在.", username);
throw new ServiceException(MessageUtils.message("user.not.exists"));
}
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
{
log.info("登录用户:{} 已被删除.", username);
throw new ServiceException(MessageUtils.message("user.password.delete"));
}
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
{
log.info("登录用户:{} 已被停用.", username);
throw new ServiceException(MessageUtils.message("user.blocked"));
}
passwordService.validate(user);
return createLoginUser(user);
}
public UserDetails createLoginUser(SysUser user)
{
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
}
}

View File

@@ -0,0 +1 @@
restart.include.json=/com.alibaba.fastjson.*.jar

View File

@@ -0,0 +1,41 @@
# 数据源配置
spring:
datasource:
dynamic:
strict: false
primary: master
datasource:
master:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://43.136.31.205:3306/mcdj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: mcdj
# password: XyTJr4WHpztHMLyR
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://114.132.54.150:3306/pxdj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: pxdj
# password: LK6R56DsXNFBj3Ds
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://114.132.54.150:3306/pxdj_prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&tinyInt1isBit=false
username: pxdj_prod
password: YDAGK6BrPdNwfXMm
# redis 配置
redis:
# 地址
host: 114.132.54.150
# 端口默认为6379
port: 6379
# 数据库索引
database: 1
password: pxdj8888Redis
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@@ -0,0 +1,33 @@
# 数据源配置
spring:
datasource:
dynamic:
strict: false
primary: master
datasource:
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://114.132.54.150:3306/pxdj_prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: pxdj_prod
password: YDAGK6BrPdNwfXMm
# redis 配置
redis:
# 地址
host: 114.132.54.150
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
password: pxdj8888Redis
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@@ -0,0 +1,135 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8085
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
config: classpath:logback.xml
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 10
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: druid
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: false
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
# mybaits-plus配置
mybatis-plus:
# 指定实体类所在包的路径MyBatis-Plus 会自动扫描该路径下的实体类
typeAliasesPackage: com.pxdj.**.domain
# 指定 Mapper 接口所在包的路径MyBatis-Plus 会自动扫描该路径下的 Mapper 接口
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 指定 MyBatis 全局配置文件的位置
# configLocation: classpath:mybatis/mybatis-config.xml
configuration:
#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: AUTO
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: NOT_NULL
# 默认数据库表下划线命名
table-underline: true
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
weixin:
appid: wx6c611942c5fbf47e
secret: 579b3cd3b14c1ae3831ea24f747d1b84
mch-id: 1708886761
mch-serial-no: 49D19119FC1DF4BC78A949380DACCDF8CF5B49F5
api-v3key: PUdiazcXXOXtGTXcBmulsRiFliWxbmUf
package-name: Sign=WXPay
notify-url: http://u5t3kp.natappfree.cc/p/pay/callback
refund-notify-url:
public-key-id: PUB_KEY_ID_0117088867612025030500298900002052
key-path: classpath:cert/apiclient_key.pem
cert-path: classpath:cert/apiclient_cert.pem
public-key: classpath:cert/pub_key.pem
refund_notify-url: http://u5t3kp.natappfree.cc/p/pay/refundCallback

View File

@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIEKDCCAxCgAwIBAgIUIb6GSToxflxGTGee7APx3xc7C5AwDQYJKoZIhvcNAQEL
BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
Q0EwHhcNMjUwNDMwMTIwNjE1WhcNMzAwNDI5MTIwNjE1WjCBgTETMBEGA1UEAwwK
MTY0MTk2NDQ3NDEbMBkGA1UECgwS5b6u5L+h5ZWG5oi357O757ufMS0wKwYDVQQL
DCTnpo/lu7rmjqXop6bnp5HmioDmnI3liqHmnInpmZDlhazlj7gxCzAJBgNVBAYT
AkNOMREwDwYDVQQHDAhTaGVuWmhlbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAMlVd5v9XqJjNC9YtBIRGL42lo8vwNUU7OZ1d5loL8zTAOfVLQddyEaz
hwN/1fMdIpYFCLHezpzu3vCT2LvoStJdOBHt8x7D02/pwqvUpgUZGtKigBVUziI4
dTirahnTnR5mrFgUccW7vYQVmITOhMvlab/UP/uXSwo+04m+mTb/ydl9C3dT5DzW
wy9IiuNvW62DQ467wfdZwYdhfNsmYISRos8L73/ISiVWyDCUxB42V+h6sM5xkIvk
E53ckFmTuAJHZYE9tJVFwDik/1WwQOIebido7QugrlgQ0RuKDjRLAtTEBehNTuiT
Teqa52nRbz3v/PLHBts2GWrb77+fAMsCAwEAAaOBuTCBtjAJBgNVHRMEAjAAMAsG
A1UdDwQEAwID+DCBmwYDVR0fBIGTMIGQMIGNoIGKoIGHhoGEaHR0cDovL2V2Y2Eu
aXRydXMuY29tLmNuL3B1YmxpYy9pdHJ1c2NybD9DQT0xQkQ0MjIwRTUwREJDMDRC
MDZBRDM5NzU0OTg0NkMwMUMzRThFQkQyJnNnPUhBQ0M0NzFCNjU0MjJFMTJCMjdB
OUQzM0E4N0FEMUNERjU5MjZFMTQwMzcxMA0GCSqGSIb3DQEBCwUAA4IBAQBheQf2
lpnTaaZEmZUHecDhWAw5jHOERUazJO/9h17SpjzBXQO/AnO9x4sLZz1Ml7zldNnL
CDM64P5H1MFSLrWyLCUV++2I1/q24B11BybH+/73al5e2KcNQd8D0NATxwsZLhso
yNx/Fu9b3lpyrIjMmQmv5itpkuwh0O11sfkxKrHoM/qKErKsRJ8C+skvrvDRTXoR
CcEwQFhSjIzXUlqnnpVn7jC1REI8Ik9p/cus2tITQmCcAJweJuN3BezTwO4u6UaF
PwLkN41qfGVY4SuSFrs7o4qyGDANAqb5RoWi9o1pV/tJ7TOAIH1MaWN6Kyovfxtg
AzZ97iE0EtFWmt4e
-----END CERTIFICATE-----

View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDJVXeb/V6iYzQv
WLQSERi+NpaPL8DVFOzmdXeZaC/M0wDn1S0HXchGs4cDf9XzHSKWBQix3s6c7t7w
k9i76ErSXTgR7fMew9Nv6cKr1KYFGRrSooAVVM4iOHU4q2oZ050eZqxYFHHFu72E
FZiEzoTL5Wm/1D/7l0sKPtOJvpk2/8nZfQt3U+Q81sMvSIrjb1utg0OOu8H3WcGH
YXzbJmCEkaLPC+9/yEolVsgwlMQeNlfoerDOcZCL5BOd3JBZk7gCR2WBPbSVRcA4
pP9VsEDiHm4naO0LoK5YENEbig40SwLUxAXoTU7ok03qmudp0W897/zyxwbbNhlq
2++/nwDLAgMBAAECggEAVgIx96yUqfCRUYymWHV/SXsOdJrk2OJ4lbcm4Z01ll2p
rGBQPS5eKX32NpN89b/Dj60U2s+hGj+dc87lLtj8ZcO2+Unaq5DimZOWO0u7pL/l
yofrCbHR4aKWyR/JUsEpBNy90V7if6NFQdDr+Ag1iNk3hOCKeNNYFkdinRyUXX7E
LOuf+sInxcB9yHco10CqmTaZglBr7XpLlCjtvYRiukB+4XmzHNdRKegWGhl4/zIS
N+uoCo6CJdzs/pbVwqNoa4rTscsbpSaKFYwhYaDmjgGw3L+d/nnmkv6PjZD2ijJS
PM54QhtP93O2dsTqh3scRsTnlM1TmH/9XmpQmpy+wQKBgQDuMySoRBV9DblVe2bz
GE3p7wAyYnih0KLLLefq5TjGqf+tqayl6buGS3lgfWvSiDSrg2J/4g5kz1blVE1B
UOEfTDCPXbvtxyqDLEkm6CKtDOFBv3Ag1On6akv3oRIWyq62t6BF30MtxgYTdI/7
XG55axAaZDBYc1VsGZLKgny7YQKBgQDYYRBx2Ff5OJqVoAMe3yH53EX6yiGVcwSa
I47k/eQpjXCZhA972p/tCGea3fdUDxkF4r246vAIy2aA8WMoueKn76zBtKhzdOgV
8HV+meE5Pu4pqwmbP2RjuqmtnT8/Czz/DGQMi7DNeJRvOcyyDvZs1PUrK76b2Gol
i88l8Yw3qwKBgChPqW18kDJopyvLRYHwZAcp9luQhJ/F4jcGXtBG2JPuYyGtrFUr
uBujHDhzIVMwz9ES3BGOXSc8W5VV7fkWyfJ0/2bT0yELaqtmTD70XCHzIw/waPZ1
cd96K78NmDUZOfYcH1iTzxepApA6Ur+URfHwZ3o/6Fqfsh4oOcphyOAhAoGAIVVS
ozcg1lPR/JrZ4DeflE5KuYfKBKvjWZuAt+Yk8AHKBtxBRmM3n9xbmY/4OgrZX/6+
G26V68Tp1ZNaIzv/nr9dbbnW+XJZDogskYRDHf6D0gd3Q2NQo8xtt0EyLRQeIWxX
PVeHtR+OPlQ5JHUJoVptKmliw79jGsWe88lyQGECgYBfQdeVWHVg7VSJ39SYhJl6
CzFZzvPafDBFxobkJuq5AKfIdEACB1wH1ZpiVl9tuQnYt+cqKncCoYp5C4rj4dkt
I15Q9iLkrTgA6ZNinv9u3Fb8/hiABsNCuSLlUfzqXl8TIhDPfXbYLot12R4/2fdV
jSrx4xqgKfxCCN3unQW/4A==
-----END PRIVATE KEY-----

View File

@@ -0,0 +1,38 @@
#错误消息
not.null=* 必须填写
user.jcaptcha.error=验证码错误
user.jcaptcha.expire=验证码已失效
user.not.exists=用户不存在/密码错误
user.password.not.match=用户不存在/密码错误
user.password.retry.limit.count=密码输入错误{0}次
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
user.password.delete=对不起,您的账号已被删除
user.blocked=用户已封禁,请联系管理员
role.blocked=角色已封禁,请联系管理员
login.blocked=很遗憾访问IP已被列入系统黑名单
user.logout.success=退出成功
length.not.valid=长度必须在{min}到{max}个字符之间
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成且必须以非数字开头
user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误
user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功
user.register.success=注册成功
user.notfound=请重新登录
user.forcelogout=管理员强制退出,请重新登录
user.unknown.error=未知错误,请重新登录
##文件上传消息
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB
upload.filename.exceed.length=上传的文件名最长{0}个字符
##权限
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.pxdj" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>