增加了海报功能(未完善),redis选库,小程序后台去掉对frame中的jwt依赖
parent
bda9c6054e
commit
d972b2b661
70
pom.xml
70
pom.xml
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>3.6.0</version>
|
||||
|
||||
<name>ruoyi</name>
|
||||
|
|
@ -33,11 +34,78 @@
|
|||
<poi.version>4.1.2</poi.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<alipay.version>4.8.10.ALL</alipay.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 生成二维码的jar -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>${alipay.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
<!--dom4j -->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--腾讯云短信-->
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.0.6</version> <!-- 注:如提示报错,先升级基础包版,无法解决可联系技术支持 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<!--腾讯云OSS-->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>5.6.8</version>
|
||||
</dependency>
|
||||
<!-- 阿里云OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.projectlombok</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- <version>1.18.12</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- SpringBoot的依赖配置-->
|
||||
<dependency>
|
||||
|
|
@ -231,7 +299,7 @@
|
|||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,320 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
||||
<name>ruoyi</name>
|
||||
<url>http://www.ruoyi.vip</url>
|
||||
<description>魔金商城平台管理</description>
|
||||
|
||||
<properties>
|
||||
<ruoyi.version>3.0.0</ruoyi.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatis.boot.version>1.3.2</mybatis.boot.version>
|
||||
<druid.version>1.1.14</druid.version>
|
||||
<bitwalker.version>1.19</bitwalker.version>
|
||||
<swagger.version>2.9.2</swagger.version>
|
||||
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
||||
<fastjson.version>1.2.70</fastjson.version>
|
||||
<oshi.version>3.9.1</oshi.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||
<poi.version>3.17</poi.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<jwt.version>0.9.0</jwt.version>
|
||||
<alipay.version>4.8.10.ALL</alipay.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 生成二维码的jar -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>${alipay.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
<!--dom4j -->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
<!--腾讯云短信-->
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.0.6</version> <!-- 注:如提示报错,先升级基础包版,无法解决可联系技术支持 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<!--腾讯云OSS-->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>5.6.8</version>
|
||||
</dependency>
|
||||
<!-- 阿里云OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
</dependency>
|
||||
<!--swagger2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<!-- SpringBoot的依赖配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!--阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 解析客户端操作系统、浏览器等 -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>${bitwalker.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pagehelper 分页插件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper.boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2-UI-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里JSON解析器 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--Token生成与解析-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-quartz</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-mall</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>ruoyi-store</module>
|
||||
<!-- <module>ruoyi-web</module>-->
|
||||
<module>ruoyi-web</module>
|
||||
<module>ruoyi-admin</module>
|
||||
<module>ruoyi-framework</module>
|
||||
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-mall</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
|
|
|||
|
|
@ -1,148 +1,131 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
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.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;
|
||||
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
|
||||
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
|
||||
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 解决 无法直接注入 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
|
||||
{
|
||||
httpSecurity
|
||||
// CSRF禁用,因为不使用session
|
||||
.csrf().disable()
|
||||
// 认证失败处理类
|
||||
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
||||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
.antMatchers("/login", "/register", "/captchaImage").anonymous()
|
||||
.antMatchers(
|
||||
HttpMethod.GET,
|
||||
"/",
|
||||
"/*.html",
|
||||
"/**/*.html",
|
||||
"/**/*.css",
|
||||
"/**/*.js",
|
||||
"/profile/**"
|
||||
).permitAll()
|
||||
.antMatchers("/common/download**").anonymous()
|
||||
.antMatchers("/common/download/resource**").anonymous()
|
||||
.antMatchers("/swagger-ui.html").anonymous()
|
||||
.antMatchers("/swagger-resources/**").anonymous()
|
||||
.antMatchers("/webjars/**").anonymous()
|
||||
.antMatchers("/*/api-docs").anonymous()
|
||||
.antMatchers("/druid/**").anonymous()
|
||||
// 临时放开对商城的前端访问
|
||||
.antMatchers("/default/**").anonymous()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.headers().frameOptions().disable();
|
||||
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());
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security;
|
||||
|
||||
import com.ruoyi.security.filter.JwtAuthenticationTokenFilter;
|
||||
import com.ruoyi.security.handle.AuthenticationEntryPointImpl;
|
||||
import com.ruoyi.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.http.SessionCreationPolicy;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 解决 无法直接注入 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 | 如果有参数,参数表示角色,则其中任何一个角色可以访问
|
||||
*
|
||||
* @ss.hasPermi | 如果有参数,参数表示权限,则其权限可以访问
|
||||
* hasIpAddress | 如果有参数,参数表示IP地址,如果用户IP和参数匹配,则可以访问
|
||||
* hasRole | 如果有参数,参数表示角色,则其角色可以访问
|
||||
* permitAll | 用户可以任意访问
|
||||
* rememberMe | 允许通过remember-me登录的用户访问
|
||||
* authenticated | 用户登录后可访问
|
||||
*/
|
||||
@Override
|
||||
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
||||
httpSecurity
|
||||
// CRSF禁用,因为不使用session
|
||||
.csrf().disable()
|
||||
// 认证失败处理类
|
||||
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
||||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
// 对于登录login 验证码captchaImage 允许匿名访问
|
||||
.antMatchers("/login", "/captchaImage").anonymous()
|
||||
.antMatchers(
|
||||
HttpMethod.GET,
|
||||
"/*.html",
|
||||
"/**/*.html",
|
||||
"/**/*.css",
|
||||
"/**/*.js"
|
||||
).permitAll()
|
||||
.antMatchers("/profile/**").anonymous()
|
||||
.antMatchers("/common/download**").anonymous()
|
||||
.antMatchers("/common/download/resource**").anonymous()
|
||||
.antMatchers("/swagger-ui.html").anonymous()
|
||||
.antMatchers("/swagger-resources/**").anonymous()
|
||||
.antMatchers("/webjars/**").anonymous()
|
||||
.antMatchers("/*/api-docs").anonymous()
|
||||
.antMatchers("/druid/**").anonymous()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.headers().frameOptions().disable();
|
||||
httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
|
||||
// 添加JWT filter
|
||||
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 强散列哈希加密实现
|
||||
*/
|
||||
@Bean
|
||||
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份认证接口
|
||||
*/
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +1,43 @@
|
|||
package com.ruoyi.framework.security.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
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 com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.filter;
|
||||
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.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 {
|
||||
logger.debug(request.getRequestURI());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,33 @@
|
|||
package com.ruoyi.framework.security.handle;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 认证失败处理类 返回未授权
|
||||
*
|
||||
* @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)));
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.handle;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.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)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +1,51 @@
|
|||
package com.ruoyi.framework.security.handle;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
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 com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
|
||||
/**
|
||||
* 自定义退出处理类 返回成功
|
||||
*
|
||||
* @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.error(HttpStatus.SUCCESS, "退出成功")));
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.handle;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.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.error(HttpStatus.SUCCESS, "退出成功")));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,240 +1,211 @@
|
|||
package com.ruoyi.framework.web.domain;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import com.ruoyi.common.utils.Arith;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.framework.web.domain.server.Cpu;
|
||||
import com.ruoyi.framework.web.domain.server.Jvm;
|
||||
import com.ruoyi.framework.web.domain.server.Mem;
|
||||
import com.ruoyi.framework.web.domain.server.Sys;
|
||||
import com.ruoyi.framework.web.domain.server.SysFile;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.domain;
|
||||
|
||||
import com.ruoyi.common.utils.Arith;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.security.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置磁盘信息
|
||||
*/
|
||||
private void setSysFiles(OperatingSystem os) {
|
||||
FileSystem fileSystem = os.getFileSystem();
|
||||
OSFileStore[] fsArray = fileSystem.getFileStores().toArray(new OSFileStore[0]);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节转换
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,101 +1,88 @@
|
|||
package com.ruoyi.framework.web.domain.server;
|
||||
|
||||
import com.ruoyi.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;
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.domain.server;
|
||||
|
||||
import com.ruoyi.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,122 +1,107 @@
|
|||
package com.ruoyi.framework.web.domain.server;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import com.ruoyi.common.utils.Arith;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
|
||||
/**
|
||||
* 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.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.domain.server;
|
||||
|
||||
import com.ruoyi.common.utils.Arith;
|
||||
import com.ruoyi.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.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +1,53 @@
|
|||
package com.ruoyi.framework.web.domain.server;
|
||||
|
||||
import com.ruoyi.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);
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.domain.server;
|
||||
|
||||
import com.ruoyi.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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,84 +1,73 @@
|
|||
package com.ruoyi.framework.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;
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,114 +1,99 @@
|
|||
package com.ruoyi.framework.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;
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.ruoyi.security.web.exception;
|
||||
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.exception.DemoModeException;
|
||||
import com.ruoyi.common.exception.base.BaseException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.AccountExpiredException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
/**
|
||||
* 基础异常
|
||||
*/
|
||||
@ExceptionHandler(BaseException.class)
|
||||
public AjaxResult baseException(BaseException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(CustomException.class)
|
||||
public AjaxResult businessException(CustomException e) {
|
||||
if (StringUtils.isNull(e.getCode())) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public AjaxResult handlerNoFoundException(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error(HttpStatus.NOT_FOUND, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public AjaxResult handleAuthorizationException(AccessDeniedException e) {
|
||||
log.error(e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccountExpiredException.class)
|
||||
public AjaxResult handleAccountExpiredException(AccountExpiredException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UsernameNotFoundException.class)
|
||||
public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public AjaxResult handleException(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public AjaxResult validatedBindException(BindException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Object validExceptionHandler(MethodArgumentNotValidException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 演示模式异常
|
||||
*/
|
||||
@ExceptionHandler(DemoModeException.class)
|
||||
public AjaxResult demoModeException(DemoModeException e) {
|
||||
return AjaxResult.error("演示模式,不允许操作");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,165 +1,153 @@
|
|||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import java.util.Set;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
return hasPermissions(loginUser.getPermissions(), permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户是否不具备某权限,与 hasPermi逻辑相反
|
||||
*
|
||||
* @param permission 权限字符串
|
||||
* @return 用户是否不具备某权限
|
||||
*/
|
||||
public boolean lacksPermi(String permission)
|
||||
{
|
||||
return hasPermi(permission) != true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户是否具有以下任意一个权限
|
||||
*
|
||||
* @param permissions 以 PERMISSION_NAMES_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;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 = ",";
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 验证用户是否具备某权限
|
||||
*
|
||||
* @param permission 权限字符串
|
||||
* @return 用户是否具备某权限
|
||||
*/
|
||||
public boolean hasPermi(String permission) {
|
||||
if (StringUtils.isEmpty(permission)) {
|
||||
return false;
|
||||
}
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
|
||||
return false;
|
||||
}
|
||||
return hasPermissions(loginUser.getPermissions(), permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户是否不具备某权限,与 hasPermi逻辑相反
|
||||
*
|
||||
* @param permission 权限字符串
|
||||
* @return 用户是否不具备某权限
|
||||
*/
|
||||
public boolean lacksPermi(String permission) {
|
||||
return hasPermi(permission) != true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户是否具有以下任意一个权限
|
||||
*
|
||||
* @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表
|
||||
* @return 用户是否具有以下任意一个权限
|
||||
*/
|
||||
public boolean hasAnyPermi(String permissions) {
|
||||
if (StringUtils.isEmpty(permissions)) {
|
||||
return false;
|
||||
}
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
|
||||
return false;
|
||||
}
|
||||
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 = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
|
||||
return false;
|
||||
}
|
||||
for (SysRole sysRole : loginUser.getUser().getRoles()) {
|
||||
String roleKey = sysRole.getRoleKey();
|
||||
if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(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 = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,129 +1,80 @@
|
|||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
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 com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class SysLoginService
|
||||
{
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Resource
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@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)
|
||||
{
|
||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||
// 验证码开关
|
||||
if (captchaOnOff)
|
||||
{
|
||||
validateCaptcha(username, code, uuid);
|
||||
}
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try
|
||||
{
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
recordLoginInfo(loginUser.getUser());
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public void validateCaptcha(String username, String code, String uuid)
|
||||
{
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
redisCache.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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*/
|
||||
public void recordLoginInfo(SysUser user)
|
||||
{
|
||||
user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||
user.setLoginDate(DateUtils.getNowDate());
|
||||
userService.updateUserProfile(user);
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.service;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
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 RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public String login(String username, String password, String code, String uuid) {
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
redisCache.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();
|
||||
}
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try {
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
} 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 CustomException(e.getMessage());
|
||||
}
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +1,58 @@
|
|||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*
|
||||
* @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
|
||||
{
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
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 {
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +1,52 @@
|
|||
package com.ruoyi.framework.web.service;
|
||||
|
||||
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;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 用户验证处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@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("登录用户:" + username + " 不存在");
|
||||
}
|
||||
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||
{
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
}
|
||||
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||
{
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
|
||||
return createLoginUser(user);
|
||||
}
|
||||
|
||||
public UserDetails createLoginUser(SysUser user)
|
||||
{
|
||||
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
|
||||
}
|
||||
}
|
||||
package com.ruoyi.security.web.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.exception.base.BaseException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.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 SysPermissionService permissionService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
|
||||
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new BaseException("对不起,您的账号:" + username + " 已被删除");
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new BaseException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
|
||||
return createLoginUser(user);
|
||||
}
|
||||
|
||||
public UserDetails createLoginUser(SysUser user) {
|
||||
return new LoginUser(user, permissionService.getMenuPermission(user));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import com.ruoyi.security.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;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.domain.Server;
|
||||
|
||||
/**
|
||||
* 服务器监控
|
||||
|
|
|
|||
|
|
@ -1,113 +0,0 @@
|
|||
package com.ruoyi.web.controller.segchk;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
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.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.common.core.domain.AjaxResult.*;
|
||||
|
||||
/**
|
||||
* seg首页推荐商户Controller
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/default/provider")
|
||||
@Api("运营商小程序接口")
|
||||
public class SegchkDefaultProviderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
|
||||
/**
|
||||
* 查询seg用户中心信息 尹志颖
|
||||
* {
|
||||
* "userId": 240,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2//* 0运营商,1商户,2用户
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_info:query')")
|
||||
@PostMapping("/storeUserInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg运营商中心信息", notes = "需要鉴权")
|
||||
public AjaxResult storeUserInfo(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
// startPage();
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
|
||||
SegchkUserWebResp segchkUserWebResp = segchkUserWebReq.getUserLevel() == 2 ?
|
||||
segchkUserIndexService.selectSegchkUserWebInfo(segchkUserWebReq)
|
||||
: (segchkUserWebReq.getUserLevel() == 1 ?
|
||||
segchkStoreIndexService.selectSegchkStoreWebInfo(segchkUserWebReq) : segchkProviderIndexService.selectSegchkProviderWebInfo(segchkUserWebReq));
|
||||
ajax.put("value", segchkUserWebResp);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据运营商id,角色等级,返回运营商下所有核消统计或售卡统计 尹志颖
|
||||
* {
|
||||
* "providerId": 4,//*
|
||||
* "staticMonth": "10",,//测试
|
||||
* "srcFlag": 0//*0核消汇总1售卡汇总
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_service_sale:list')")
|
||||
@PostMapping("/providerServiceAndSaleList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id,角色等级,返回运营商下所有核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo providerServiceAndSaleList(SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleWebResp> segchkServiceAndSaleWebRespList = segchkProviderIndexService.selectProviderServiceAndSaleList(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleWebRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运营商id,角色等级,返回运营商下核消统计或售卡统计 尹志颖
|
||||
* {
|
||||
* "providerId": 4,//*
|
||||
* "staticMonth": "2021-06-01",//*
|
||||
* "srcFlag": 0//*0核消详情1售卡详情
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_service_sale:query')")
|
||||
@PostMapping("/providerServiceAndSaleDetails")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id,角色等级,返回运营商下核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo providerServiceAndSaleDetails(SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleDetailWebResp> segchkServiceAndSaleDetailWebRespList = segchkProviderIndexService.selectProviderServiceAndSaleDetails(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleDetailWebRespList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,498 +0,0 @@
|
|||
package com.ruoyi.web.controller.segchk;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
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.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.common.core.domain.AjaxResult.*;
|
||||
|
||||
/**
|
||||
* seg首页推荐商户Controller
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/default/user")
|
||||
@Api("用户小程序接口")
|
||||
public class SegchkDefaultUserController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
@Autowired
|
||||
private ISegchkUserCollectService segchkUserCollectService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserLikegoService segchkUserLikegoService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserChargeService segchkUserChargeService;
|
||||
/**
|
||||
* 新增保存seg用户收藏记录
|
||||
* {
|
||||
* "collectType": "1",//*
|
||||
* "providerId": 0,//*
|
||||
* "userId": 0,//*
|
||||
* "storeId": 0,//*
|
||||
* "modTime": "2021-08-16 13:43:43",
|
||||
* "mgtState": 0//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:add')")
|
||||
@Log(title = "seg用户收藏记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addUserCollect")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "添加seg用户收藏记录", notes = "需要鉴权")
|
||||
public AjaxResult add_user_collect(SegchkUserCollect segchkUserCollect)
|
||||
{
|
||||
return toAjax(segchkUserCollectService.insertSegchkUserCollect(segchkUserCollect));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除seg用户收藏记录
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:remove')")
|
||||
@Log(title = "seg用户收藏记录", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/removeUserCollect")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "删除seg用户收藏记录", notes = "需要鉴权")
|
||||
public AjaxResult removeUserCollect(String ids)
|
||||
{
|
||||
return toAjax(segchkUserCollectService.deleteSegchkUserCollectByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存seg用户想去记录
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:add')")
|
||||
@Log(title = "seg用户想去记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addOrderUserLikego")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "添加seg用户想去记录", notes = "需要鉴权")
|
||||
public AjaxResult add_order_user_likego(SegchkUserLikego segchkUserLikego)
|
||||
{
|
||||
return toAjax(segchkUserLikegoService.insertSegchkUserLikego(segchkUserLikego));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询seg用户中心信息 尹志颖
|
||||
* {
|
||||
* "userId": 240,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2//* 0运营商,1商户,2用户
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_info:query')")
|
||||
@PostMapping("/storeUserInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户中心信息", notes = "需要鉴权")
|
||||
public AjaxResult store_user_info(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
// startPage();
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
|
||||
SegchkUserWebResp segchkUserWebResp = segchkUserWebReq.getUserLevel() == 2 ?
|
||||
segchkUserIndexService.selectSegchkUserWebInfo(segchkUserWebReq)
|
||||
: (segchkUserWebReq.getUserLevel() == 1 ?
|
||||
segchkStoreIndexService.selectSegchkStoreWebInfo(segchkUserWebReq) : segchkProviderIndexService.selectSegchkProviderWebInfo(segchkUserWebReq));
|
||||
ajax.put("value", segchkUserWebResp);
|
||||
return ajax;
|
||||
// return getDataTable(segchkServiceCommentWebRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户核消列表 尹志颖
|
||||
* {
|
||||
* "userId": 245,//*
|
||||
* "providerId": 4//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_check:list')")
|
||||
@PostMapping("/storeServiceCheckList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户核消列表", notes = "需要鉴权")
|
||||
public TableDataInfo store_service_check_list(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserWebSCResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserServiceCHKList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户可用会员卡列表或者优惠券列表 尹志颖
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_card:list')")
|
||||
@PostMapping("/userCardList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户可用会员卡列表或者优惠券列表", notes = "需要鉴权")
|
||||
public TableDataInfo user_card_list(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserWebCardResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCardList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户收藏列表 尹志颖
|
||||
* {
|
||||
* "userId": 439,//*
|
||||
* "providerId": 4//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:list')")
|
||||
@PostMapping("/userCollectList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户收藏列表", notes = "需要鉴权")
|
||||
public TableDataInfo user_collect_list(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserCollectWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCollectList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户预约单列表 尹志颖
|
||||
* {
|
||||
* "userId": 234,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 0//测试用
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:list')")
|
||||
@PostMapping("/userLikeGOList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户预约单列表", notes = "需要鉴权")
|
||||
public TableDataInfo userLikeGOList(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserLikeGoWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserLikGoList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除seg用户想去记录
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:remove')")
|
||||
@Log(title = "seg用户想去记录", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/removeOrderUserLikego")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "删除seg用户想去记录", notes = "需要鉴权")
|
||||
public AjaxResult removeOrderUserLikego(String ids)
|
||||
{
|
||||
return toAjax(segchkUserLikegoService.deleteSegchkUserLikegoByLikegoIds(Convert.toLongArray(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* seg服务评价查询
|
||||
* {
|
||||
* "commentId": 3//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_comment:query')")
|
||||
@Log(title = "seg服务评价查看", businessType = BusinessType.OTHER)
|
||||
@PostMapping( "/getComment")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg服务评价查询", notes = "需要鉴权")
|
||||
public AjaxResult get_comment(SegchkServiceCommentUserReq segchkServiceCommentUserReq)
|
||||
{
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
SegchkServiceComment segchkServiceComment = segchkUserIndexService.selectSegchkServiceComment(segchkServiceCommentUserReq);
|
||||
if(segchkServiceComment == null){
|
||||
ajax.put(CODE_TAG, "300");
|
||||
ajax.put(MSG_TAG, "未查到相关评价");
|
||||
}
|
||||
else{
|
||||
ajax.put(CODE_TAG, "200");
|
||||
ajax.put(DATA_TAG, segchkServiceComment);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seg服务评价提交
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_comment:add')")
|
||||
@Log(title = "seg服务评价提交", businessType = BusinessType.INSERT)
|
||||
@PostMapping( "/addComment")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg服务评价提交", notes = "需要鉴权")
|
||||
public AjaxResult addComment(SegchkServiceCommentUserReq segchkServiceCommentUserReq)
|
||||
{
|
||||
return toAjax(segchkUserIndexService.insertSegchkServiceComment(segchkServiceCommentUserReq));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户充值列表 尹志颖
|
||||
* {
|
||||
* "userId": 34,//*
|
||||
* "providerId": 2//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:list')")
|
||||
@PostMapping("/userChargeList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户充值列表", notes = "需要鉴权")
|
||||
public TableDataInfo userChargeList(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserChargeWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserChargeList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户提现列表 尹志颖
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_cash:list')")
|
||||
@PostMapping("/userCashList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户提现列表", notes = "需要鉴权")
|
||||
public TableDataInfo userCashList(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkUserCashWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCashList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,角色等级查询seg用户消息列表 尹志颖
|
||||
* {
|
||||
* "userId": 392,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2,//*
|
||||
* "phoneNo": 1//测试
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_msg:list')")
|
||||
@PostMapping("/userMsgList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户消息列表", notes = "需要鉴权")
|
||||
public TableDataInfo userMsgList(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkMsgWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserMsgList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户进入余额充值页面时,根据用户id,运营商id查询可充值 的卡
|
||||
* {
|
||||
* "userId": 465,
|
||||
* "providerId": 4
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:add')")
|
||||
@PostMapping( "/userChargePre")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户可充值列表", notes = "需要鉴权")
|
||||
public AjaxResult userChargePre(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
List<SegchkUserChargeCard> segchkUserChargeCards = segchkUserIndexService.SegchkUserChargePre(segchkUserWebReq);
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
if(segchkUserChargeCards == null){
|
||||
ajax.put(CODE_TAG, "300");
|
||||
}
|
||||
else{
|
||||
ajax.put(CODE_TAG, "200");
|
||||
ajax.put(DATA_TAG, segchkUserChargeCards);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户进入余额充值页面时,根据用户id,运营商id查询可充值的卡,生成充值记录
|
||||
* {
|
||||
* "userId": 465,
|
||||
* "charge": 299.0,
|
||||
* "accountUsed": 10.0,
|
||||
* "cardTypeId": 1,
|
||||
* "providerId": 4
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:pre')")
|
||||
@PostMapping( "/userChargeReq")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户可充值", notes = "需要鉴权")
|
||||
public AjaxResult userChargeReq(SegchkUserCharge segchkUserCharge)
|
||||
{
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
System.out.println(segchkUserCharge.getAccountUsed());
|
||||
if(segchkUserCharge.getAccountUsed() != null && segchkUserCharge.getAccountUsed().compareTo(new BigDecimal(0.0)) == 1) {
|
||||
BigDecimal user_account = segchkUserIndexService.getAccount(segchkUserCharge);
|
||||
if(user_account == null || user_account.compareTo(segchkUserCharge.getAccountUsed()) == -1){
|
||||
ajax.put(CODE_TAG, "500");
|
||||
ajax.put(MSG_TAG, "余额不足!");
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
int ret = segchkUserChargeService.insertSegchkUserCharge(segchkUserCharge);
|
||||
if(ret < 1){
|
||||
ajax.put(CODE_TAG, "500");
|
||||
ajax.put(MSG_TAG, "充值失败!");
|
||||
}
|
||||
else{
|
||||
ajax.put(CODE_TAG, "200");
|
||||
ajax.put(MSG_TAG, "充值成功!");
|
||||
ajax.put(DATA_TAG, segchkUserCharge.getChargeId());
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* {
|
||||
* "chargeId": "demoData",//*
|
||||
* "ret": 0//*0成功,其他失败
|
||||
* }
|
||||
*/
|
||||
@Log(title = "seg用户充值结果回调", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userChargeResult")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户充值结果回调", notes = "需要鉴权")
|
||||
public void userChargeResult(String chargeId, int ret)
|
||||
{
|
||||
segchkUserIndexService.chargeRet(chargeId, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户点击提现时的反应
|
||||
* {
|
||||
* "userId": 459,
|
||||
* "cash": 5.6,
|
||||
* "providerId": 4,
|
||||
* "userLevel": 2
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_cash:add')")
|
||||
@PostMapping( "/userCashReq")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户提现请求", notes = "需要鉴权")
|
||||
public AjaxResult userCashReq(SegchkUserCashOpsReq segchkUserCashOpsReq)
|
||||
{
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
if(segchkUserCashOpsReq.getUserLevel() == 0){
|
||||
ajax.put(CODE_TAG, "300");
|
||||
ajax.put(MSG_TAG, "运营商无法线上提现");
|
||||
return ajax;
|
||||
}
|
||||
// segchkUserCashOpsReq.setUserLevel(2);
|
||||
int ret = segchkUserIndexService.getAccountForCash(segchkUserCashOpsReq);
|
||||
switch (ret){
|
||||
case -1: ajax.put(CODE_TAG, "400");ajax.put(MSG_TAG, "无余额信息");break;
|
||||
case -2: ajax.put(CODE_TAG, "400");ajax.put(MSG_TAG, "无余额信息");break;
|
||||
case -3: ajax.put(CODE_TAG, "400");ajax.put(MSG_TAG, "提现受限");break;
|
||||
case -4: ajax.put(CODE_TAG, "400");ajax.put(MSG_TAG, "余额不足");break;
|
||||
case 2: ajax.put(CODE_TAG, "200");ajax.put(MSG_TAG, "提现请求成功,请耐心等候");break;
|
||||
default: ajax.put(CODE_TAG, "500");ajax.put(MSG_TAG, "未知错误");break;
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* {
|
||||
* "userId": 43,//*
|
||||
* "passwd": "sfsdfds",//*
|
||||
* "providerId": 2,//*
|
||||
* "userLevel": 2//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_set:add')")
|
||||
@Log(title = "seg设置用户信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/SetInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg设置用户信息", notes = "需要鉴权")
|
||||
public AjaxResult SetInfo(SegchkUserSetInfoReq segchkUserSetInfoReq)
|
||||
{
|
||||
int ret = 0;
|
||||
if(segchkUserSetInfoReq.getUserLevel() == 2) {
|
||||
ret = segchkUserIndexService.updateUserInfo(segchkUserSetInfoReq);
|
||||
}
|
||||
else if(segchkUserSetInfoReq.getUserLevel() == 1){
|
||||
ret = segchkStoreIndexService.updateUserInfo(segchkUserSetInfoReq);
|
||||
}
|
||||
return toAjax(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seg设置用户实名信息
|
||||
* {
|
||||
* "userName": "demoData",
|
||||
* "userId": 0,
|
||||
* "providerId": 0,
|
||||
* "IDcard": "demoData",
|
||||
* "card1": "demoData",
|
||||
* "card2": "demoData"
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_certicify:add')")
|
||||
@Log(title = "seg设置用户实名信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userCerticify")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg设置用户实名信息", notes = "需要鉴权")
|
||||
public AjaxResult user_certicify(SegchkUserCertificationInfo segchkUserCertificationInfo)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = segchkUserIndexService.userCerticify(segchkUserCertificationInfo);
|
||||
return toAjax(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* {
|
||||
* "chargeId": "45435",
|
||||
* "userLevel": "1/2/0",
|
||||
* "ret": 1
|
||||
* }
|
||||
*/
|
||||
@Log(title = "seg提现结果回调", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userCashResult")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg提现结果回调", notes = "需要鉴权")
|
||||
public void userCashResult(String chargeId, int userLevel, int ret)
|
||||
{
|
||||
if(userLevel == 1) {
|
||||
segchkStoreIndexService.cashRet(chargeId, ret);
|
||||
}
|
||||
else if(userLevel == 2){
|
||||
segchkUserIndexService.cashRet(chargeId, ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,9 @@ package com.ruoyi.web.controller.system;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ruoyi.security.web.service.SysLoginService;
|
||||
import com.ruoyi.security.web.service.SysPermissionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -13,8 +16,6 @@ import com.ruoyi.common.core.domain.entity.SysMenu;
|
|||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.security.web.service.SysPermissionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -23,7 +25,6 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.common.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 不需要拦截注解
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UnAuth {
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.common.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class CustomException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
public CustomException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CustomException(String message, Integer code) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public CustomException(String message, Throwable e) {
|
||||
super(message, e);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ package com.ruoyi.common.exception;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public final class ServiceException extends RuntimeException
|
||||
public class ServiceException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
@ -70,4 +70,8 @@ public final class ServiceException extends RuntimeException
|
|||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -46,20 +46,20 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
/**
|
||||
* 跨域配置
|
||||
*/
|
||||
@Bean
|
||||
public CorsFilter corsFilter()
|
||||
{
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
// 设置访问源地址
|
||||
config.addAllowedOrigin("*");
|
||||
// 设置访问源请求头
|
||||
config.addAllowedHeader("*");
|
||||
// 设置访问源请求方法
|
||||
config.addAllowedMethod("*");
|
||||
// 对接口配置跨域设置
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
// @Bean
|
||||
// public CorsFilter corsFilter()
|
||||
// {
|
||||
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
// CorsConfiguration config = new CorsConfiguration();
|
||||
// config.setAllowCredentials(true);
|
||||
// // 设置访问源地址
|
||||
// config.addAllowedOrigin("*");
|
||||
// // 设置访问源请求头
|
||||
// config.addAllowedHeader("*");
|
||||
// // 设置访问源请求方法
|
||||
// config.addAllowedMethod("*");
|
||||
// // 对接口配置跨域设置
|
||||
// source.registerCorsConfiguration("/**", config);
|
||||
// return new CorsFilter(source);
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
package com.ruoyi.framework.web.exception;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.DemoModeException;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
* @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(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("演示模式,不允许操作");
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,139 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>ruoyi-segchk-web</artifactId>
|
||||
|
||||
<description>
|
||||
web服务入口
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2-->
|
||||
<!--<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
|
||||
<!--<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>-->
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>-->
|
||||
|
||||
<!-- swagger2-UI-->
|
||||
<!--<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- swagger3-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</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.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-segchk</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- <resources>-->
|
||||
<!-- <resource>-->
|
||||
<!-- <directory>src/main/java</directory>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>**/*.properties</include>-->
|
||||
<!-- <include>**/*.xml</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- <!–是否替换资源中的属性–>-->
|
||||
<!-- <filtering>false</filtering>-->
|
||||
<!-- </resource>-->
|
||||
<!-- <resource>-->
|
||||
<!-- <directory>src/main/resources</directory>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>**/*.properties</include>-->
|
||||
<!-- <include>**/*.xml</include>-->
|
||||
<!-- <include>**/*.yml</include>-->
|
||||
<!-- <include>**/Dockerfile</include>-->
|
||||
<!-- <include>**/*.xlsx</include>-->
|
||||
<!-- <include>**/*.jpg</include>-->
|
||||
<!-- <include>**/*.png</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- <!–是否替换资源中的属性–>-->
|
||||
<!-- <filtering>false</filtering>-->
|
||||
<!-- </resource>-->
|
||||
<!-- </resources>-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
FROM openjdk:8-jre
|
||||
VOLUME /tmp
|
||||
ADD lecshop_web_applets-3.0.0-SNAPSHOT.jar app.jar
|
||||
ENTRYPOINT ["java","-Duser.timezone=GMT+08","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=prod"]
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.ruoyi;
|
||||
|
||||
|
||||
import com.ruoyi.util.QrCodeController;
|
||||
import com.ruoyi.common.utils.SnowflakeIdWorker;
|
||||
import com.ruoyi.util.RedisCacheErrorHandler;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 2019/5/1.
|
||||
* 小程序app后端启动类
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@EnableTransactionManagement
|
||||
public class AppletsAppApplication {
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
System.out.println("start-------------");
|
||||
// SpringApplication.run(MallPortalApplication.class, args);
|
||||
ConfigurableApplicationContext application = SpringApplication.run(AppletsAppApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
|
||||
System.out.println("\n----------------------------------------------------------\n\t" +
|
||||
"Application mallplus-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + "/\n\t" +
|
||||
"swagger-ui: \thttp://" + ip + ":" + port + "/swagger-ui.html\n\t" +
|
||||
"https://gitee.com/zscat/mallplus/wikis/pages/preview?sort_id=2168368&doc_id=326093"+
|
||||
"-----------------页面请部署 mallplus-admin-web-----------------------------------------");
|
||||
}
|
||||
/**
|
||||
* redis 异常处理
|
||||
*/
|
||||
@Bean
|
||||
public CacheErrorHandler errorHandler() {
|
||||
return new RedisCacheErrorHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列号生成器
|
||||
*/
|
||||
@Bean
|
||||
public SnowflakeIdWorker snowflakeIdWorker() {
|
||||
SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker(0, 1);
|
||||
return snowflakeIdWorker;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
final CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true); // 允许cookies跨域
|
||||
config.addAllowedOrigin("*");// #允许向该服务器提交请求的URI,*表示全部允许,在SpringMVC中,如果设成*,会自动转成当前请求头中的Origin
|
||||
config.addAllowedHeader("*");// #允许访问的头信息,*表示全部
|
||||
config.setMaxAge(18000L);// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
|
||||
config.addAllowedMethod("OPTIONS");// 允许提交请求的方法,*表示全部允许
|
||||
config.addAllowedMethod("HEAD");
|
||||
config.addAllowedMethod("GET");// 允许Get的请求方法
|
||||
config.addAllowedMethod("PUT");
|
||||
config.addAllowedMethod("POST");
|
||||
config.addAllowedMethod("DELETE");
|
||||
config.addAllowedMethod("PATCH");
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.interceptor.AuthorityInterceptor;
|
||||
import com.ruoyi.util.Claims;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 小程序登录工具类
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
public class AppletsLoginUtils {
|
||||
private static AppletsLoginUtils ourInstance = new AppletsLoginUtils();
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AppletsLoginUtils.class);
|
||||
|
||||
private AppletsLoginUtils() {
|
||||
}
|
||||
|
||||
public static AppletsLoginUtils getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户id
|
||||
*
|
||||
* @return 返回用户id
|
||||
*/
|
||||
public long getCustomerId(HttpServletRequest request) {
|
||||
long customerId = 0;
|
||||
if (!ObjectUtils.isEmpty(getClaims(getToken(request)))) {
|
||||
customerId = getClaims(getToken(request)).getUserId();
|
||||
}
|
||||
return customerId;
|
||||
}
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param request request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
log.debug("request.header--->{}", request.getHeaderNames().toString());
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer")) {
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
return authHeader.length() >= 7 ? authHeader.substring(7) : authHeader.substring(6);
|
||||
}
|
||||
/**
|
||||
* 获取openId
|
||||
*
|
||||
* @return 返回openId
|
||||
*/
|
||||
public String getOpenId(HttpServletRequest request) {
|
||||
return ((Claims) request.getAttribute("claims")).getOpenId();
|
||||
}
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
private Claims getClaims(String token) {
|
||||
String claims = SpringUtils.getBean(RedisCache.class).getCacheObject(token);
|
||||
return StringUtils.isEmpty(claims) ? null : JSONObject.parseObject(claims, Claims.class);
|
||||
}
|
||||
/**
|
||||
* 获取unionId
|
||||
*
|
||||
* @return 返回unionId
|
||||
*/
|
||||
public String getUnionId(HttpServletRequest request) {
|
||||
return ((Claims) request.getAttribute("claims")).getUnionId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
public Claims getClaims(HttpServletRequest request) {
|
||||
return ((Claims) request.getAttribute("claims"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
|
||||
import com.ruoyi.util.md5.MessageSourceUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 基础返回
|
||||
* Created by 魔金商城 on 17/7/10.
|
||||
*/
|
||||
public class BaseResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 结果码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String message;
|
||||
|
||||
public BaseResponse(String code) {
|
||||
this.code = code;
|
||||
this.message = MessageSourceUtil.getMessage(code);
|
||||
}
|
||||
|
||||
public BaseResponse(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static BaseResponse SUCCESSFUL() {
|
||||
return new BaseResponse(ResultCode.SUCCESSFUL);
|
||||
}
|
||||
|
||||
public static BaseResponse FAILED() {
|
||||
return new BaseResponse(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
|
||||
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 2019/5/25.
|
||||
* 错误控制器
|
||||
*/
|
||||
@RestController
|
||||
public class ErrorController extends AbstractErrorController {
|
||||
|
||||
/**
|
||||
* 错误地址
|
||||
*/
|
||||
private static final String ERROR_PATH = "/error";
|
||||
|
||||
public ErrorController(ErrorAttributes errorAttributes) {
|
||||
super(errorAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
return ERROR_PATH;
|
||||
}
|
||||
|
||||
@RequestMapping(ERROR_PATH)
|
||||
@UnAuth
|
||||
public Map<String, Object> handleError(HttpServletRequest request) {
|
||||
return getErrorAttributes(request, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/7/10.
|
||||
* 全局异常
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class GlobalWebExceptionHandler {
|
||||
|
||||
/**
|
||||
* 调试日志
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(GlobalWebExceptionHandler.class);
|
||||
|
||||
/**
|
||||
* 未认证异常(有可能是未关联用户 也有可能是微信未授权根据返回码判断)
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
@ExceptionHandler(UnAuthorizedException.class)
|
||||
@ResponseBody
|
||||
public BaseResponse signatureExceptionHandler(HttpServletRequest request, UnAuthorizedException ex) {
|
||||
logger.error("do [{}] on [{}] failed. exMsg:{}", request.getMethod(), request.getRequestURL(),
|
||||
ex.getLocalizedMessage());
|
||||
logger.error("queryString:{}, parameterMap: {}", request.getQueryString(), request.getParameterMap(), ex);
|
||||
|
||||
return new BaseResponse(ex.getErrorCode(), ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(value = ServiceException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
public BaseResponse serviceExceptionHandler(HttpServletRequest request, ServiceException ex) throws Exception {
|
||||
if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null)
|
||||
throw ex;
|
||||
|
||||
logger.error("do [{}] on [{}] failed. exMsg:{}", request.getMethod(), request.getRequestURL(),
|
||||
ex.getLocalizedMessage());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.error("queryString:{}, parameterMap: {}", request.getQueryString(), request.getParameterMap(), ex);
|
||||
}
|
||||
|
||||
return new BaseResponse(ex.getMessage(), ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/7/10.
|
||||
* 结果返回吗
|
||||
*/
|
||||
public interface ResultCode {
|
||||
|
||||
/**
|
||||
* 操作成功;
|
||||
*/
|
||||
String SUCCESSFUL = "R-00000";
|
||||
|
||||
/**
|
||||
* 操作失败;
|
||||
*/
|
||||
String FAILED = "R-00001";
|
||||
|
||||
/**
|
||||
* 微信未授权
|
||||
*/
|
||||
String WX_NOT_AUTHORIZED = "R-00002";
|
||||
|
||||
/**
|
||||
* 微信未关联用户
|
||||
*/
|
||||
String WX_NOT_LINKD = "R-00003";
|
||||
|
||||
/**
|
||||
* 小程序账号已绑定错误
|
||||
*/
|
||||
String WX_ALREADY_BIND_ERROR = "R-00004";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.ruoyi.appletsutil;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.util.md5.MessageSourceUtil;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 2018/6/13.
|
||||
* 微信小程序未授权异常
|
||||
*/
|
||||
public class UnAuthorizedException extends ServiceException {
|
||||
|
||||
/**
|
||||
* 错误code
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
public UnAuthorizedException(String errorCode) {
|
||||
this(errorCode, MessageSourceUtil.getMessage(errorCode));
|
||||
}
|
||||
|
||||
public UnAuthorizedException(String errorCode, String message) {
|
||||
super(message == null ? errorCode : message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.config;
|
||||
|
||||
import com.ruoyi.interceptor.AuthorityInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 2019/5/13.
|
||||
* 拦截器配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfigurer implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 注入登录拦截器
|
||||
*/
|
||||
@Autowired
|
||||
private AuthorityInterceptor authorityInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authorityInterceptor).excludePathPatterns("/**/**", "/v2/**", "/swagger-ui.html", "/webjars/**", "/swagger-resources/**");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
package com.ruoyi.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.appletsutil.AppletsLoginUtils;
|
||||
import com.ruoyi.util.Claims;
|
||||
import com.ruoyi.appletsutil.ResultCode;
|
||||
import com.ruoyi.appletsutil.UnAuthorizedException;
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.segchk.domain.WeChatCustomerLink;
|
||||
import com.ruoyi.member.service.WeChatCustomerLinkService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 2018/6/13.
|
||||
* 访问拦截器
|
||||
*/
|
||||
@Component
|
||||
public class AuthorityInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthorityInterceptor.class);
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
|
||||
/**
|
||||
* 注入微信用户关联服务
|
||||
*/
|
||||
@Autowired
|
||||
@Lazy
|
||||
private WeChatCustomerLinkService weChatCustomerLinkService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String requestType = ((HttpServletRequest) request).getMethod();
|
||||
String fullUrl = ((HttpServletRequest) request).getRequestURL().toString();
|
||||
log.debug("fullUrl--->{}", fullUrl);
|
||||
int startIntercept = fullUrl.replace("//", "a").indexOf("/") + 1;
|
||||
String interfaceName = fullUrl.substring(startIntercept, fullUrl.length());
|
||||
if (!"OPTIONS".equals(requestType) && !interfaceName.contains("webjars")
|
||||
&& !interfaceName.contains("api-docs")) {
|
||||
log.info(formMapKey(AppletsLoginUtils.getInstance().getCustomerId(request), fullUrl, requestType,
|
||||
IpUtils.getIpAddr((HttpServletRequest) request), null, null)
|
||||
+ ",\"cost\":\"");
|
||||
}
|
||||
|
||||
// 如果不需要拦截 则直接返回
|
||||
if (!isNeedFilter(handler)) {
|
||||
log.debug("Donot need authority.....");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
|
||||
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer ")) {
|
||||
log.info("AuthorityInterceptor preHandle fail....");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
|
||||
// 获得凭证
|
||||
Claims claims = getAppletsClaimsFromRedis(authHeader.substring(7));
|
||||
|
||||
// 没有凭证 直接返回
|
||||
if (Objects.isNull(claims)) {
|
||||
log.info("AuthorityInterceptor preHandle fail....");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
|
||||
// 校验有没有uid 如果没有uid 则直接返回
|
||||
if (!claims.hasCustomerId()) {
|
||||
log.error("applets has not authorized");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
|
||||
// 如果没有会员id 则从数据库查询 是否有会员id
|
||||
/*if (!claims.hasCustomerId()) {
|
||||
// 小程序没有关联用户则提示用户去关联用户
|
||||
WeChatCustomerLink weChatCustomerLink = queryWeChatCustomerLinkByUnionId(claims.getUnionId());
|
||||
if (Objects.isNull(weChatCustomerLink)) {
|
||||
log.error("applets has not linked member....");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_LINKD);
|
||||
} else {
|
||||
log.info("applets has unionId and has member....");
|
||||
// 将凭证信息返回redis
|
||||
putClaimsToRedis(weChatCustomerLink, claims, authHeader.substring(7));
|
||||
//如果没有小程序的openId,则更新关联信息
|
||||
if (!weChatCustomerLink.hasAppletOpenId()) {
|
||||
weChatCustomerLink.setAppletOpenId(claims.getOpenId());
|
||||
weChatCustomerLinkService.updateWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
request.setAttribute("claims", claims);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formMapKey(Object userId, String mothedName, String requestType,
|
||||
String ip, String params, String token) {
|
||||
return "\"time\"" + ":\"" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS").format(new Date())
|
||||
+ "\",\"name\"" + ":\"" + mothedName + "\",\"uid\":\"" + userId
|
||||
+ "\",\"type\":\"" + requestType + "\",\"ip\":\"" + ip
|
||||
+ "\",\"token\":\"" + token + "\",\"params\":\"" + params + "\"";
|
||||
}
|
||||
/**
|
||||
* 将凭证放入redis
|
||||
*
|
||||
* @param weChatCustomerLink 会员和小程序的绑定关系
|
||||
* @param claims 凭证
|
||||
* @param token token
|
||||
*/
|
||||
/*private void putClaimsToRedis(WeChatCustomerLink weChatCustomerLink, Claims claims, String token) {
|
||||
claims.setUserId(weChatCustomerLink.);
|
||||
redisService.putToRedis(token, JSON.toJSONString(claims));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 根据unionId查询会员和小程序的绑定关系
|
||||
*
|
||||
* @param unionId 小程序唯一id
|
||||
* @return 返回会员和小程序的绑定关系
|
||||
*/
|
||||
private WeChatCustomerLink queryWeChatCustomerLinkByUnionId(String unionId) {
|
||||
return weChatCustomerLinkService.queryWeChatCustomerLinkByUnionId(unionId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据token从redis 获取uid和customerId
|
||||
*
|
||||
* @param token token
|
||||
* @return 返回uid和customerId
|
||||
*/
|
||||
private Claims getAppletsClaimsFromRedis(String token) {
|
||||
String claims = redisService.getCacheObject(token);
|
||||
return StringUtils.isEmpty(claims) ? null : JSONObject.parseObject(redisService.getCacheObject(token), Claims.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否需要拦截
|
||||
*/
|
||||
private boolean isNeedFilter(Object handler) {
|
||||
if (handler instanceof HandlerMethod) {
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
return handlerMethod.getMethod().getAnnotation(UnAuth.class) == null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.ruoyi.login;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.setting.bean.OssSetting;
|
||||
import com.ruoyi.setting.bean.UploadData;
|
||||
import com.ruoyi.setting.service.OssService;
|
||||
import com.ruoyi.util.CommonConstant;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Oss相关操作接口
|
||||
* https://github.com/shenzhuan/mallplus on 2018/4/26.
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "OssController", description = "Oss管理")
|
||||
@RequestMapping("/aliyun/oss")
|
||||
public class OssController {
|
||||
@Resource
|
||||
private OssService ossService;
|
||||
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param name 上传文件的name 默认为image
|
||||
* @param type 上传文件的类型 默认为图片 0 图片 1 视频
|
||||
* @return 返回图片在腾讯云的地址
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("uploadToQqOSSYun")
|
||||
@ApiOperation(value = "上传图片", notes = "上传图片(不需要认证)")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "String", name = "name", value = "上传文件的name 默认为image"),
|
||||
@ApiImplicitParam(paramType = "form", dataType = "String", name = "type", value = "上传文件的类型 默认为图片 0 图片 1 视频"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "返回图片在腾讯云的地址", response = String.class)
|
||||
})
|
||||
public AjaxResult uploadToQqOSSYun(@RequestParam("file") MultipartFile multipartFile,MultipartHttpServletRequest request, String name, String type) throws Exception {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = "image";
|
||||
}
|
||||
|
||||
// 默认上传图片
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
type = CommonConstant.UPLOAD_PIC;
|
||||
}
|
||||
if (Objects.isNull(multipartFile)) {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
return AjaxResult.success(ossService.uploadToQqOss(Arrays.asList(UploadData.build(multipartFile.getInputStream(), multipartFile.getBytes(), multipartFile.getOriginalFilename(), type, multipartFile))).stream().findFirst().orElse(""));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param name 上传文件的name 默认为image
|
||||
* @param type 上传文件的类型 默认为图片 0 图片 1 视频
|
||||
* @return 返回图片在阿里云的地址
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("uploadToAliOss")
|
||||
@ApiOperation(value = "上传图片", notes = "上传图片(不需要认证)")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "String", name = "name", value = "上传文件的name 默认为image"),
|
||||
@ApiImplicitParam(paramType = "form", dataType = "String", name = "type", value = "上传文件的类型 默认为图片 0 图片 1 视频"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "返回图片在阿里云的地址", response = String.class)
|
||||
})
|
||||
public AjaxResult uploadToOSSYun(@RequestParam("file") MultipartFile multipartFile, String name, String type) throws Exception {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = "image";
|
||||
}
|
||||
|
||||
// 默认上传图片
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
type = CommonConstant.UPLOAD_PIC;
|
||||
}
|
||||
|
||||
if (Objects.isNull(multipartFile)) {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
return AjaxResult.success(ossService.uploadToOss(Arrays.asList(UploadData.build(multipartFile.getInputStream(), multipartFile.getBytes(), multipartFile.getOriginalFilename(), type, multipartFile))).stream().findFirst().orElse(""));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询云存储设置
|
||||
*
|
||||
* @return 云存储设置信息
|
||||
*/
|
||||
@GetMapping("/oss")
|
||||
@PreAuthorize("@ss.hasPermi('setting:ossSetting:list')")
|
||||
@ApiOperation(value = "查询阿里云存储设置", notes = "查询阿里云存储设置(需要认证)")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "又拍云设置信息", response = OssSetting.class)
|
||||
})
|
||||
public OssSetting queryUpYunSet() {
|
||||
return ossService.queryOssSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改又拍云设置
|
||||
*
|
||||
* @param ossSetting 又拍云设置信息
|
||||
* @return 成功1 否则失败
|
||||
*/
|
||||
@PutMapping("/oss")
|
||||
@ApiOperation(value = "修改阿里云存储设置", notes = "修改阿里云存储设置(需要认证)")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "成功1 否则失败", response = Integer.class)
|
||||
})
|
||||
public int updateOss(@RequestBody OssSetting ossSetting) {
|
||||
return ossService.updateOss(ossSetting);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,680 @@
|
|||
package com.ruoyi.login;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.segchk.domain.SegchkUserWebReq;
|
||||
import com.ruoyi.util.Claims;
|
||||
import com.ruoyi.appletsutil.ResultCode;
|
||||
import com.ruoyi.appletsutil.UnAuthorizedException;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.SnowflakeIdWorker;
|
||||
import com.ruoyi.segchk.domain.SegchkUserWechat;
|
||||
import com.ruoyi.util.WeChatAppletLoginResponse;
|
||||
import com.ruoyi.util.WechatSetting;
|
||||
import com.ruoyi.member.service.*;
|
||||
import com.ruoyi.member.vo.BindParams;
|
||||
import com.ruoyi.setting.bean.WechatPaySet;
|
||||
import com.ruoyi.setting.service.ILsPaySettingService;
|
||||
import com.ruoyi.util.CommonConstant;
|
||||
import com.ruoyi.util.WeChatAppletUtils;
|
||||
import io.swagger.annotations.*;
|
||||
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.Controller;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 登录控制器
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
@Controller
|
||||
@Api(description = "登录接口")
|
||||
//@RequestMapping("/default/login")
|
||||
public class SegChkLoginController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SegChkLoginController.class);
|
||||
/**
|
||||
* 注入微信小程序登录服务
|
||||
*/
|
||||
// @Autowired
|
||||
// private WeChatAppletLoginService weChatAppletLoginService;
|
||||
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
|
||||
/**
|
||||
* jwt密钥
|
||||
*/
|
||||
@Value("${token.secret}")
|
||||
private String jwtSecretKey;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 注入登录处理service
|
||||
*/
|
||||
@Resource(name = "loginService")
|
||||
private LoginService loginService;
|
||||
|
||||
/**
|
||||
* 注入注册服务
|
||||
*/
|
||||
@Autowired
|
||||
private RegisterService registerService;
|
||||
|
||||
/**
|
||||
* 注入注册聚合服务
|
||||
*/
|
||||
@Autowired
|
||||
private RegisterServiceApi registerServiceApi;
|
||||
|
||||
/**
|
||||
* 注入微信用户关联服务
|
||||
*/
|
||||
@Autowired
|
||||
private WeChatCustomerLinkService weChatCustomerLinkService;
|
||||
/**
|
||||
* 注入随机数生成器
|
||||
*/
|
||||
@Autowired
|
||||
private SnowflakeIdWorker snowflakeIdWorker;
|
||||
/**
|
||||
* 注入支付设置服务
|
||||
*/
|
||||
@Autowired
|
||||
private ILsPaySettingService paySetService;
|
||||
/**
|
||||
* 会员登录
|
||||
*
|
||||
*
|
||||
* @return -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
@UnAuth
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "会员登录", notes = "会员登录(不需要认证)")
|
||||
public AjaxResult login(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request) {
|
||||
Long userId = 0L;
|
||||
if(!ObjectUtils.isEmpty(segchkUserWebReq) && "999999".equals(segchkUserWebReq.getRemark())){
|
||||
return loginService.login(segchkUserWebReq);
|
||||
}
|
||||
// Object cacheObject = redisService.getCacheObject(String.format("%s", "eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNqqViouTVKyUipPTc5ILMnJT8"));
|
||||
// logger.warn(ObjectUtils.nullSafeToString(cacheObject));
|
||||
try {
|
||||
if (ObjectUtils.isEmpty(getClaims(getToken(request)))) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
|
||||
Claims claims = getClaims(getToken(request));
|
||||
SegchkUserWebReq segchkUserWebReq1 = new SegchkUserWebReq();
|
||||
segchkUserWebReq1.setUserId(claims.getUserId());
|
||||
segchkUserWebReq1.setProviderId(claims.getProviderId());
|
||||
segchkUserWebReq1.setUserLevel(claims.getUserLevel());
|
||||
|
||||
return loginService.login(segchkUserWebReq1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* r
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @return 0 成功 1 失败 -1 手机号码已经存在
|
||||
*/
|
||||
@UnAuth
|
||||
@RequestMapping(value = "/sendmobilecode")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "mobile", value = "手机号码"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "0 成功 1 失败 -1 手机号码已经存在", response = Integer.class)
|
||||
})
|
||||
public AjaxResult sendSmsCode(String mobile) {
|
||||
// 发送短信验证码
|
||||
logger.debug("sendmobilecode ---> phone:{}", mobile);
|
||||
int ret = registerService.sendRegisterSmsCode(mobile, code -> redisService.setCacheObject(String.format("%s_%s", CommonConstant.APPLET_REGISTER_CODE_KEY, mobile), code, 5, TimeUnit.MINUTES));
|
||||
|
||||
if(ret != 0 ){
|
||||
return AjaxResult.error("500", "验证码发送失败,请稍后重试");
|
||||
}
|
||||
return AjaxResult.success("验证码发送成功");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
@UnAuth
|
||||
@RequestMapping("/register")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "用户注册", notes = "用户注册(不需要认证)", httpMethod = "POST")
|
||||
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "-1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在", response = Integer.class)
|
||||
})
|
||||
public AjaxResult register(@RequestBody SegChkLoginController.RegisterData registerData) {
|
||||
AjaxResult res = null;
|
||||
try {
|
||||
res = registerServiceApi.registerCustomer(registerData.getMobile(), registerData.getCode()
|
||||
, redisService.getCacheObject(String.format("%s_%s", CommonConstant.APPLET_REGISTER_CODE_KEY, registerData.getMobile())), registerData.getRecommendId(), registerData.getRecommendLevel(), registerData.getProviderId(), registerData.getRemark());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return res;
|
||||
}
|
||||
// 如果返回结果中不存在token,说明没有进行微信绑定
|
||||
return res;
|
||||
}
|
||||
|
||||
@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/bindaccount")
|
||||
@ApiOperation(value = "小程序获取登录信息", notes = "小程序获取登录信息(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "code", value = "用户登录凭证"),
|
||||
})
|
||||
public AjaxResult bindaccount(@RequestBody BindParams bindParams , HttpServletRequest request) {
|
||||
WechatPaySet wechatAppletPaySet = paySetService.queryPaySet().getWechatAppletPaySet();
|
||||
WechatSetting wechatSetting = new WechatSetting();
|
||||
if(!StringUtils.isEmpty(bindParams.getRemark())){
|
||||
wechatSetting.setType(999999);
|
||||
}
|
||||
wechatSetting.setAppId(wechatAppletPaySet.getAppId());
|
||||
// wechatSetting.setAppId(appId);
|
||||
wechatSetting.setAppSecret(wechatAppletPaySet.getAppSecret());
|
||||
// wechatSetting.setAppSecret(appSecrt);
|
||||
if (!wechatSetting.checkAppletOAuthParams()) {
|
||||
// log.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
return AjaxResult.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
}
|
||||
|
||||
WeChatAppletLoginResponse weChatAppletLoginResponse = WeChatAppletUtils.getLoginInfo(bindParams.getCode(), wechatSetting);
|
||||
if (Objects.isNull(weChatAppletLoginResponse)) {
|
||||
// log.error("getLoginInfo fail: getLoginInfo fail");
|
||||
return AjaxResult.error("getLoginInfo fail: getLoginInfo fail");
|
||||
}
|
||||
|
||||
SegchkUserWechat segchkUserWechat = new SegchkUserWechat();
|
||||
segchkUserWechat.setUserId(Long.valueOf(bindParams.getUserId()));
|
||||
segchkUserWechat.setOpenid(weChatAppletLoginResponse.getOpenid());
|
||||
segchkUserWechat.setUnionId(weChatAppletLoginResponse.getUnionid());
|
||||
segchkUserWechat.setProviderId(Long.valueOf(bindParams.getProviderId()));
|
||||
segchkUserWechat.setNickName("");
|
||||
// 将用户与微信openid绑定
|
||||
int ret = weChatCustomerLinkService.addSegchkUserWechat(segchkUserWechat, bindParams.getUserLevel());
|
||||
if(ret < 1){
|
||||
return AjaxResult.error(500, "微信绑定失败!");
|
||||
}
|
||||
// 产生token
|
||||
String token = registerServiceApi.createToke(CommonConstant.APPLET_LOGIN_KEY, Long.valueOf(bindParams.getUserId()), Long.valueOf(bindParams.getProviderId()), Integer.valueOf(bindParams.getUserLevel()));
|
||||
// String token = snowflakeIdWorker.nextId()+"";
|
||||
Claims claims = new Claims();
|
||||
claims.setUserId(Long.valueOf(bindParams.getUserId()));
|
||||
claims.setOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
claims.setProviderId(Long.valueOf(bindParams.getProviderId()));
|
||||
claims.setUserLevel(Integer.valueOf(bindParams.getUserLevel()));
|
||||
// 将用户的token进行缓存
|
||||
redisService.setCacheObject(token, claims);
|
||||
return AjaxResult.success("绑定成功", token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册实体
|
||||
*/
|
||||
@ApiModel(description = "用户注册实体")
|
||||
private static class RegisterData extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
|
||||
/**
|
||||
* 手机验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 推荐码
|
||||
*/
|
||||
@ApiModelProperty(value = "推荐码")
|
||||
private String recommendId;
|
||||
|
||||
/**
|
||||
* 推荐码
|
||||
*/
|
||||
@ApiModelProperty(value = "推荐人角色")
|
||||
private String recommendLevel;
|
||||
|
||||
/** 运营商id,全局唯一 */
|
||||
@Excel(name = "运营商id,全局唯一")
|
||||
private String providerId;
|
||||
|
||||
/**
|
||||
* 授权code
|
||||
*/
|
||||
@ApiModelProperty(value = "授权code")
|
||||
private String wechatCode;
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getRecommendId() {
|
||||
return recommendId;
|
||||
}
|
||||
|
||||
public void setRecommendId(String recommendId) {
|
||||
this.recommendId = recommendId;
|
||||
}
|
||||
|
||||
public String getRecommendLevel() {
|
||||
return recommendLevel;
|
||||
}
|
||||
|
||||
public void setRecommendLevel(String recommendLevel) {
|
||||
this.recommendLevel = recommendLevel;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getWechatCode() {
|
||||
return wechatCode;
|
||||
}
|
||||
|
||||
public void setWechatCode(String wechatCode) {
|
||||
this.wechatCode = wechatCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RegisterData{" +
|
||||
"mobile='" + mobile + '\'' +
|
||||
", code='" + code + '\'' +
|
||||
", recommendId='" + recommendId + '\'' +
|
||||
", recommendLevel='" + recommendLevel + '\'' +
|
||||
", providerId='" + providerId + '\'' +
|
||||
", wechatCode='" + wechatCode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册登录
|
||||
*
|
||||
* @param loginParams 登录参数
|
||||
* @return -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
*/
|
||||
/*@PostMapping("/logout")
|
||||
@UnAuth
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "会员登录", notes = "会员登录(不需要认证)")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "result: -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误 token:放登录成功后的token", response = Map.class)
|
||||
})
|
||||
public AjaxResult logout(@RequestBody LoginParams loginParams, HttpServletRequest request)*/
|
||||
|
||||
/**
|
||||
* 会员登录
|
||||
*
|
||||
* @param loginParams 登录参数
|
||||
* @return -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
*/
|
||||
/*@PostMapping("/logout")
|
||||
@UnAuth
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "会员登录", notes = "会员登录(不需要认证)")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "result: -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误 token:放登录成功后的token", response = Map.class)
|
||||
})
|
||||
public AjaxResult logout(@RequestBody LoginParams loginParams, HttpServletRequest request) {
|
||||
AppletLoginRedisParamResponse appletLoginRedisParamResponse = JSON.parseObject(redisService.getValue(getToken(request)),AppletLoginRedisParamResponse.class) ;
|
||||
redisService.deleteObject(getToken(request));
|
||||
// redisService.deleteObject(appletLoginRedisParamResponse.);
|
||||
return AjaxResult.success();
|
||||
}*/
|
||||
/**
|
||||
* 小程序获取登录信息
|
||||
*
|
||||
* @param 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 api,使用 code 换取 openid 和 session_key 等信息
|
||||
* @return 登录信息
|
||||
*/
|
||||
/*@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/getOpenId")
|
||||
@ApiOperation(value = "小程序获取登录信息", notes = "小程序获取登录信息(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "code", value = "用户登录凭证"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "登录信息", response = AppletLoginInfo.class)
|
||||
})
|
||||
public AjaxResult getOpenId(@RequestBody AppletLoginRedisParamResponse appletLoginRedisParamResponse , HttpServletRequest request) {
|
||||
|
||||
WechatPaySet wechatAppletPaySet = paySetService.queryPaySet().getWechatAppletPaySet();
|
||||
WechatSetting wechatSetting = new WechatSetting();
|
||||
wechatSetting.setAppId(wechatAppletPaySet.getAppId());
|
||||
wechatSetting.setAppSecret(wechatAppletPaySet.getAppSecret());
|
||||
if (!wechatSetting.checkAppletOAuthParams()) {
|
||||
log.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
return AjaxResult.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
}
|
||||
WeChatAppletLoginResponse weChatAppletLoginResponse = WeChatAppletUtils.getLoginInfo(appletLoginRedisParamResponse.getCode(), wechatSetting);
|
||||
if (Objects.isNull(weChatAppletLoginResponse)) {
|
||||
log.error("getLoginInfo fail: getLoginInfo fail");
|
||||
return AjaxResult.error("getLoginInfo fail: getLoginInfo fail");
|
||||
}
|
||||
UmsMember member = new UmsMember();
|
||||
member.setAppletOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
long customerId = 0;
|
||||
if (!ObjectUtils.isEmpty(getClaims(getToken(request)))) {
|
||||
customerId = getClaims(getToken(request)).getCustomerId();
|
||||
}
|
||||
member.setId(customerId);
|
||||
return AjaxResult.success(memberService.updateUmsMember(member));
|
||||
}*/
|
||||
/**
|
||||
* 小程序获取登录信息
|
||||
*
|
||||
* @param 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 api,使用 code 换取 openid 和 session_key 等信息
|
||||
* @return 登录信息
|
||||
*/
|
||||
/*@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/mpWechatLogin")
|
||||
@ApiOperation(value = "小程序获取登录信息", notes = "小程序获取登录信息(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "code", value = "用户登录凭证"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "登录信息", response = AppletLoginInfo.class)
|
||||
})
|
||||
public AjaxResult mpWechatLogin(@RequestBody AppletLoginRedisParamResponse appletLoginRedisParamResponse , HttpServletRequest request) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
String token = snowflakeIdWorker.nextId() + "";
|
||||
appletLoginRedisParamResponse.setToken(token);
|
||||
WechatPaySet wechatAppletPaySet = paySetService.queryPaySet().getWechatAppletPaySet();
|
||||
WechatSetting wechatSetting = new WechatSetting();
|
||||
wechatSetting.setAppId(wechatAppletPaySet.getAppId());
|
||||
wechatSetting.setAppSecret(wechatAppletPaySet.getAppSecret());
|
||||
if (!wechatSetting.checkAppletOAuthParams()) {
|
||||
log.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
return AjaxResult.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
}
|
||||
WeChatAppletLoginResponse weChatAppletLoginResponse = WeChatAppletUtils.getLoginInfo(appletLoginRedisParamResponse.getCode(), wechatSetting);
|
||||
if (Objects.isNull(weChatAppletLoginResponse)) {
|
||||
log.error("getLoginInfo fail: getLoginInfo fail");
|
||||
return AjaxResult.error("getLoginInfo fail: getLoginInfo fail");
|
||||
}
|
||||
appletLoginRedisParamResponse.setSessionKey(weChatAppletLoginResponse.getSession_key());
|
||||
appletLoginRedisParamResponse.setOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
UmsMember member =memberService.queryCustomerByappletOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
if (member!=null){
|
||||
appletLoginRedisParamResponse.setCustomerId(member.getId());
|
||||
appletLoginRedisParamResponse.setToken(sb.toString());
|
||||
redisService.putToRedis(sb.toString(), JSON.toJSONString(appletLoginRedisParamResponse));
|
||||
// redisService.putToRedis(loginParams.getMobile(), sb.toString());
|
||||
res.put("access_token", sb.toString());
|
||||
res.put("refresh_token", sb.toString());
|
||||
res.put("member", member);
|
||||
}else {
|
||||
member = new UmsMember();
|
||||
member.setSource("5");
|
||||
member.setMobile("123456789");
|
||||
member.setAppletOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
member.setPassword("123456");
|
||||
memberService.addCustomer(member);
|
||||
redisService.putToRedis(sb.toString(), JSON.toJSONString(appletLoginRedisParamResponse));
|
||||
// redisService.putToRedis(loginParams.getMobile(), sb.toString());
|
||||
res.put("access_token", sb.toString());
|
||||
res.put("refresh_token", sb.toString());
|
||||
res.put("member", member);
|
||||
}
|
||||
return AjaxResult.success(res);
|
||||
|
||||
}*/
|
||||
/**
|
||||
* 小程序获取登录信息
|
||||
*
|
||||
* @param code 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 api,使用 code 换取 openid 和 session_key 等信息
|
||||
* @return 登录信息
|
||||
*/
|
||||
/*@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/getlogininfo")
|
||||
@ApiOperation(value = "小程序获取登录信息", notes = "小程序获取登录信息(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "code", value = "用户登录凭证"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "登录信息", response = AppletLoginInfo.class)
|
||||
})
|
||||
public AppletLoginInfo getLoginInfo(String code, HttpServletRequest request) {
|
||||
String unionId = null;
|
||||
if (!StringUtils.isEmpty(getToken(request))) {
|
||||
unionId = Objects.isNull(getClaims(getToken(request))) ? null : getClaims(getToken(request)).getUnionId();
|
||||
redisService.delValue(getToken(request));
|
||||
}
|
||||
return weChatAppletLoginService.getLoginInfo(code, unionId, appletLoginRedisParamResponse -> {
|
||||
redisService.putToRedis(appletLoginRedisParamResponse.getToken(), JSON.toJSONString(appletLoginRedisParamResponse));
|
||||
if (appletLoginRedisParamResponse.hasUnionId()) {
|
||||
redisService.putToRedis(appletLoginRedisParamResponse.getUnionId(), appletLoginRedisParamResponse.getToken());
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 处理用户信息
|
||||
*
|
||||
* @param weChatAppletUserInfo 小程序用户信息实体
|
||||
* @return 登录信息
|
||||
*/
|
||||
/*@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/dealuserinfo")
|
||||
@ApiOperation(value = "处理用户信息", notes = "处理用户信息(不需要认证)", httpMethod = "POST")
|
||||
public AppletLoginInfo dealUserInfo(WeChatAppletUserInfo weChatAppletUserInfo, HttpServletRequest request) {
|
||||
String token = getToken(request);
|
||||
Claims claims = getClaims(token);
|
||||
return weChatAppletLoginService.dealUserInfo(weChatAppletUserInfo, claims.getOpenId(), claims.getSessionKey(), appletLoginRedisParamResponse -> afterDealUserInfo(claims, appletLoginRedisParamResponse, token));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 绑定账号
|
||||
*
|
||||
* @param loginParams 登录参数
|
||||
*/
|
||||
/*@RequestMapping("/bindaccount")
|
||||
@ResponseBody
|
||||
@UnAuth
|
||||
@ApiOperation(value = "绑定账号", notes = "绑定账号(不需要认证)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "username", value = "用户名"),
|
||||
@ApiImplicitParam(paramType = "form", dataType = "string", name = "password", value = "密码"),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "返回码 -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误", response = Integer.class)
|
||||
})
|
||||
public AjaxResult bindAccount(@ApiIgnore LoginParams loginParams, HttpServletRequest request) {
|
||||
//回调
|
||||
loginParams.setConsumer(customer ->
|
||||
alterLoginSuccess(customer.getId(), request)
|
||||
);
|
||||
return AjaxResult.success(loginService.login(loginParams));
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 解绑账号
|
||||
*
|
||||
* @return 1成功
|
||||
*/
|
||||
/*@RequestMapping("/unbindaccount")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "解绑账号", notes = "解绑账号(需要认证)", httpMethod = "POST")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "1成功", response = Integer.class)
|
||||
})
|
||||
public int unbindAccount(HttpServletRequest request) {
|
||||
weChatAppletLoginService.unbindAccount(AppletsLoginUtils.getInstance().getCustomerId(request), AppletsLoginUtils.getInstance().getUnionId(request));
|
||||
Claims claims = AppletsLoginUtils.getInstance().getClaims(request);
|
||||
claims.setCustomerId(CommonConstant.NO_CUSTOMER_ID);
|
||||
redisService.putToRedis(getToken(request), JSONObject.toJSONString(claims));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param request request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer")) {
|
||||
logger.info("getClaims fail :Authorization fail ");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
String token = authHeader.length() >= 7 ? authHeader.substring(7) : authHeader.substring(6);
|
||||
// logger.warn("get toke info from {}---{}({})", authHeader, token, token.length());
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
private Claims getClaims(String token) {
|
||||
|
||||
Object claims = redisService.getCacheObject(token);
|
||||
logger.debug("getClaims---token:{} Claims:{}", token, claims);
|
||||
return ObjectUtils.isEmpty(claims) ? null : (Claims) claims;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理小程序凭证信息
|
||||
*
|
||||
* @param claims 小程序凭证实体
|
||||
* @param appletLoginRedisParamResponse 小程序redis参数返回实体
|
||||
* @param token token
|
||||
*/
|
||||
/*private void afterDealUserInfo(Claims claims, AppletLoginRedisParamResponse appletLoginRedisParamResponse, String token) {
|
||||
if (Objects.nonNull(appletLoginRedisParamResponse)) {
|
||||
claims.setCustomerId(appletLoginRedisParamResponse.getCustomerId());
|
||||
claims.setUnionId(appletLoginRedisParamResponse.getUnionId());
|
||||
redisService.putToRedis(token, JSON.toJSONString(claims));
|
||||
if (appletLoginRedisParamResponse.hasUnionId()) {
|
||||
redisService.putToRedis(appletLoginRedisParamResponse.getUnionId(), token);
|
||||
}
|
||||
} else {
|
||||
log.error("afterDealUserInfo fail:appletLoginRedisParamResponse is null");
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 登录成功后处理的事
|
||||
*
|
||||
* @param customerId 用户id
|
||||
*/
|
||||
/*private void alterLoginSuccess(long customerId, HttpServletRequest request) {
|
||||
if (!ObjectUtils.isEmpty(customerId)) {
|
||||
Claims claims = getClaims(getToken(request));
|
||||
// 校验有没有uid 如果没有uid 则直接返回
|
||||
if (!claims.hasUnionId()) {
|
||||
log.error("applets has not authorized");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
//绑定账号
|
||||
try {
|
||||
weChatAppletLoginService.bindAccount(claims.getOpenId(), claims.getUnionId(), customerId);
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
//捕获异常,可能已经绑定过账号
|
||||
WeChatCustomerLink weChatCustomerLink = weChatCustomerLinkService.queryWeChatCustomerLinkByUnionId(claims.getUnionId());
|
||||
if (Objects.nonNull(weChatCustomerLink)) {
|
||||
customerId = weChatCustomerLink.getCustomerId();
|
||||
} else {
|
||||
customerId = CommonConstant.NO_CUSTOMER_ID;
|
||||
}
|
||||
}
|
||||
if (customerId == CommonConstant.NO_CUSTOMER_ID) {
|
||||
claims.setCustomerId(customerId);
|
||||
redisService.putToRedis(getToken(request), JSONObject.toJSONString(claims));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* token测试方法
|
||||
*
|
||||
* @param token token
|
||||
*/
|
||||
@UnAuth
|
||||
@ResponseBody
|
||||
@RequestMapping("/tokentest")
|
||||
@ApiOperation(value = "处理用户信息", notes = "处理用户信息(不需要认证)", httpMethod = "GET")
|
||||
public AjaxResult token_test(@RequestBody String token, HttpServletRequest request) {
|
||||
Object cacheObject = redisService.getCacheObject(token);
|
||||
logger.warn("get token: {} for value: {}", token, cacheObject);
|
||||
logger.warn("tokentest get claim: {}", getClaims(token).toString());
|
||||
return AjaxResult.success(cacheObject);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
package com.ruoyi.web.controller.segchk;
|
||||
package com.ruoyi.segchk;
|
||||
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.ISegchkRecommenderIndexService;
|
||||
import com.ruoyi.segchk.service.ISegchkStoreIndexService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -29,14 +30,13 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkRecommenderIndexService segchkRecommenderIndexService;
|
||||
/**
|
||||
* 根据用户当前所在地市行政id,返回运营商id 尹志颖
|
||||
* {
|
||||
* "adcode": 110000
|
||||
* }
|
||||
*/
|
||||
@UnAuth
|
||||
@GetMapping("/getProviderByadcode")
|
||||
@ApiOperation(value = "查询运营商id", notes = "根据用户当前位置所在行政区代码或用户选择的行政区代码")
|
||||
@ApiImplicitParams({
|
||||
|
|
@ -70,9 +70,11 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* }
|
||||
* }
|
||||
*/
|
||||
@GetMapping("/StoreSearch")
|
||||
@UnAuth
|
||||
@RequestMapping(value = "/StoreSearch",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public TableDataInfo store_search(SegchkStoreWebReq segchkStoreWebReq)
|
||||
@ApiOperation(value = "搜索商户", notes = "搜索商户(不需要认证)", httpMethod = "POST")
|
||||
public TableDataInfo store_search(@RequestBody SegchkStoreWebReq segchkStoreWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkStoreIndexWebResp> list = segchkStoreIndexService.selectSegchkStoreSearch(segchkStoreWebReq);
|
||||
|
|
@ -85,6 +87,7 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* "providerId": 4
|
||||
* }
|
||||
*/
|
||||
@UnAuth
|
||||
@GetMapping("/lableListByProvider")
|
||||
@ResponseBody
|
||||
public TableDataInfo lable_list_by_provider(Long providerId)
|
||||
|
|
@ -103,10 +106,11 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* "userLat": 43.123456
|
||||
* }
|
||||
*/
|
||||
@GetMapping("/listByProvider")
|
||||
@UnAuth
|
||||
@RequestMapping(value = "/listByProvider",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id查询seg首页推荐商户列表", notes = "不需要鉴权")
|
||||
public TableDataInfo list_by_provider(SegchkRecommenderStoreWebReq segchkRecommenderStoreWebReq)
|
||||
public TableDataInfo list_by_provider(@RequestBody SegchkRecommenderStoreWebReq segchkRecommenderStoreWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkRecommenderStoreWebResp> list = segchkStoreIndexService.selectSegchkRecommenderStoreListByProvider(segchkRecommenderStoreWebReq);
|
||||
|
|
@ -126,10 +130,11 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* "userLat": 39.684333
|
||||
* }
|
||||
*/
|
||||
@GetMapping("/listByProviderwithLable")
|
||||
@UnAuth
|
||||
@PostMapping("/listByProviderwithLable")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据标签id,搜索商户列表", notes = "不需要鉴权")
|
||||
public TableDataInfo list_by_providerwith_lable(SegchkStoreWebReq segchkStoreWebReq)
|
||||
public TableDataInfo list_by_providerwith_lable(@RequestBody SegchkStoreWebReq segchkStoreWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkStoreIndexWebResp> list = segchkStoreIndexService.selectSegchkStoreList(segchkStoreWebReq);
|
||||
|
|
@ -142,7 +147,8 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* "providerId": 3
|
||||
* }
|
||||
*/
|
||||
@GetMapping("/getBannersByProvider")
|
||||
@UnAuth
|
||||
@PostMapping("/getBannersByProvider")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id,返回轮播图列表", notes = "不需要鉴权")
|
||||
public TableDataInfo get_banners_by_provider(Long providerId)
|
||||
|
|
@ -164,28 +170,34 @@ public class SegchkDefaultIndexController extends BaseController
|
|||
* "storeId": 124
|
||||
* }
|
||||
*/
|
||||
@GetMapping("/storeDetails")
|
||||
@UnAuth
|
||||
@PostMapping("/storeDetails")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商,商户id,查询商户详情", notes = "不需要鉴权")
|
||||
public AjaxResult store_details(SegchkStoreWebReq segchkStoreWebReq)
|
||||
public AjaxResult store_details(@RequestBody SegchkStoreWebReq segchkStoreWebReq, String recommenderId, String recommenderLevel)
|
||||
{
|
||||
// startPage();
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
|
||||
SegchkStoreBasicInfoWebResp segchkStoreBasicInfoWebResp = segchkStoreIndexService.selectSegchkStoreDetails(segchkStoreWebReq);
|
||||
ajax.put("value", segchkStoreBasicInfoWebResp);
|
||||
AjaxResult ajax = AjaxResult.success("获取成功", segchkStoreBasicInfoWebResp);
|
||||
if(!StringUtils.isEmpty(recommenderId) && !StringUtils.isEmpty(recommenderLevel)){
|
||||
int ret = segchkStoreIndexService.recommenderIsExit(recommenderId, recommenderLevel, segchkStoreWebReq.getProviderId().toString());
|
||||
if(ret == 1){
|
||||
ajax.put("recommenderId", recommenderId);
|
||||
ajax.put("recommenderLevel", recommenderLevel);
|
||||
}
|
||||
logger.warn("the recommender: {}{} is {}", recommenderId, recommenderLevel, ret < 1 ? "not exit" : "exit");
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询seg商户评价列表 尹志颖
|
||||
*/
|
||||
@GetMapping("/storeCommentList")
|
||||
@UnAuth
|
||||
@PostMapping("/storeCommentList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg商户评价列表", notes = "不需要鉴权")
|
||||
public TableDataInfo store_comment_list(SegchkStoreWebReq segchkStoreWebReq)
|
||||
public TableDataInfo store_comment_list(@RequestBody SegchkStoreWebReq segchkStoreWebReq)
|
||||
{
|
||||
startPage();
|
||||
List<SegchkServiceCommentWebResp> segchkServiceCommentWebRespList = segchkStoreIndexService.selectSegchkStoreComments(segchkStoreWebReq);
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
package com.ruoyi.segchk;
|
||||
|
||||
import com.ruoyi.appletsutil.ResultCode;
|
||||
import com.ruoyi.appletsutil.UnAuthorizedException;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.login.SegChkLoginController;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
import com.ruoyi.util.Claims;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* seg首页推荐商户Controller
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/default/provider")
|
||||
@Api("运营商小程序接口")
|
||||
public class SegchkDefaultProviderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
|
||||
/**
|
||||
* 查询seg用户中心信息 尹志颖
|
||||
* {
|
||||
* "userId": 240,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2//* 0运营商,1商户,2用户
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_info:query')")
|
||||
@PostMapping("/storeUserInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg运营商中心信息", notes = "需要鉴权")
|
||||
public AjaxResult storeUserInfo(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
// startPage();
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
|
||||
SegchkUserWebResp segchkUserWebResp = segchkUserWebReq.getUserLevel() == 2 ?
|
||||
segchkUserIndexService.selectSegchkUserWebInfo(segchkUserWebReq)
|
||||
: (segchkUserWebReq.getUserLevel() == 1 ?
|
||||
segchkStoreIndexService.selectSegchkStoreWebInfo(segchkUserWebReq) : segchkProviderIndexService.selectSegchkProviderWebInfo(segchkUserWebReq));
|
||||
ajax.put("value", segchkUserWebResp);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据运营商id,角色等级,返回运营商下所有核消统计或售卡统计 尹志颖
|
||||
* {
|
||||
* "providerId": 4,//*
|
||||
* "staticMonth": "10",,//测试
|
||||
* "srcFlag": 0//*0核消汇总1售卡汇总
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_service_sale:list')")
|
||||
@PostMapping("/providerServiceAndSaleList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id,角色等级,返回运营商下所有核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo providerServiceAndSaleList(@RequestBody SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = -1L;
|
||||
Claims claims = null;
|
||||
try {
|
||||
claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = claims.getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(!StringUtils.isEmpty(segchkServiceAndSaleWebReq.getRemark())){
|
||||
segchkServiceAndSaleWebReq.setStaticMonth(segchkServiceAndSaleWebReq.getRemark());
|
||||
}
|
||||
else if(!segchkServiceAndSaleWebReq.getProviderId().equals(claims.getUserId())){
|
||||
// segchkServiceAndSaleWebReq.setProviderId(claims.getUserId());
|
||||
logger.warn("providerServiceAndSaleList --- from provider: {} with toke: {}", segchkServiceAndSaleWebReq.getProviderId(), claims);
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(301);
|
||||
tableDataInfo.setMsg("用户信息异常");
|
||||
return tableDataInfo;
|
||||
}
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleWebResp> segchkServiceAndSaleWebRespList = segchkProviderIndexService.selectProviderServiceAndSaleList(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleWebRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运营商id,角色等级,返回运营商下核消统计或售卡统计 尹志颖
|
||||
* {
|
||||
* "providerId": 4,//*
|
||||
* "staticMonth": "2021-06-01",//*
|
||||
* "srcFlag": 0//*0核消详情1售卡详情
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:provider_service_sale:query')")
|
||||
@PostMapping("/providerServiceAndSaleDetails")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据运营商id,角色等级,返回运营商下核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo providerServiceAndSaleDetails(@RequestBody SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = -1L;
|
||||
Claims claims = null;
|
||||
try {
|
||||
claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(!StringUtils.isEmpty(segchkServiceAndSaleWebReq.getRemark())){
|
||||
segchkServiceAndSaleWebReq.setStaticMonth(segchkServiceAndSaleWebReq.getRemark());
|
||||
}
|
||||
else if(!segchkServiceAndSaleWebReq.getProviderId().equals(claims.getUserId())){
|
||||
// segchkServiceAndSaleWebReq.setProviderId(claims.getUserId());
|
||||
logger.warn("providerServiceAndSaleList --- from provider: {} with toke: {}", segchkServiceAndSaleWebReq.getProviderId(), claims);
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(301);
|
||||
tableDataInfo.setMsg("用户信息异常");
|
||||
return tableDataInfo;
|
||||
}
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleDetailWebResp> segchkServiceAndSaleDetailWebRespList = segchkProviderIndexService.selectProviderServiceAndSaleDetails(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleDetailWebRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param request request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer")) {
|
||||
logger.info("getClaims fail :Authorization fail ");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
String token = authHeader.length() >= 7 ? authHeader.substring(7) : authHeader.substring(6);
|
||||
// logger.warn("get toke info from {}---{}({})", authHeader, token, token.length());
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
private Claims getClaims(String token) {
|
||||
|
||||
Object claims = redisService.getCacheObject(token);
|
||||
logger.debug("getClaims---token:{} Claims:{}", token, claims);
|
||||
return ObjectUtils.isEmpty(claims) ? null : (Claims) claims;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,28 @@
|
|||
package com.ruoyi.web.controller.segchk;
|
||||
package com.ruoyi.segchk;
|
||||
|
||||
import com.ruoyi.appletsutil.ResultCode;
|
||||
import com.ruoyi.appletsutil.UnAuthorizedException;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
import com.ruoyi.util.Claims;
|
||||
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.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ruoyi.common.core.domain.AjaxResult.*;
|
||||
|
||||
|
|
@ -45,6 +46,12 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
|
||||
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
/**
|
||||
* 查询seg用户中心信息 尹志颖
|
||||
* {
|
||||
|
|
@ -90,8 +97,20 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@PostMapping("/storeServiceAndSaleList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据商家id,运营商id,角色等级,返回核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo store_service_and_sale_list(SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq)
|
||||
public TableDataInfo store_service_and_sale_list(@RequestBody SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkServiceAndSaleWebReq.getRemark())){
|
||||
segchkServiceAndSaleWebReq.setStoreId(claims.getUserId());
|
||||
segchkServiceAndSaleWebReq.setProviderId(claims.getProviderId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleWebResp> segchkServiceAndSaleWebRespList = segchkStoreIndexService.selectStoreServiceAndSaleList(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleWebRespList);
|
||||
|
|
@ -110,8 +129,20 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@PostMapping("/storeServiceAndSaleDetails")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据商家id,运营商id,角色等级,返回核消统计或售卡统计", notes = "需要鉴权")
|
||||
public TableDataInfo store_service_and_sale_details(SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq)
|
||||
public TableDataInfo store_service_and_sale_details(@RequestBody SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkServiceAndSaleWebReq.getRemark())){
|
||||
segchkServiceAndSaleWebReq.setStoreId(claims.getUserId());
|
||||
segchkServiceAndSaleWebReq.setProviderId(claims.getProviderId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkServiceAndSaleDetailWebResp> segchkServiceAndSaleDetailWebRespList = segchkStoreIndexService.selectStoreServiceAndSaleDetails(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkServiceAndSaleDetailWebRespList);
|
||||
|
|
@ -130,8 +161,20 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@PostMapping("/storeUserLikeGoList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据商家id,运营商id,返回针对该商家的预约列表", notes = "需要鉴权")
|
||||
public TableDataInfo store_user_like_go_list(SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq)
|
||||
public TableDataInfo store_user_like_go_list(@RequestBody SegchkServiceAndSaleWebReq segchkServiceAndSaleWebReq, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkServiceAndSaleWebReq.getRemark())){
|
||||
segchkServiceAndSaleWebReq.setStoreId(claims.getUserId());
|
||||
segchkServiceAndSaleWebReq.setProviderId(claims.getProviderId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkUserLikeGoWebResp> segchkUserLikeGoWebRespList = segchkStoreIndexService.selectStoreUserLikeGoList(segchkServiceAndSaleWebReq);
|
||||
return getDataTable(segchkUserLikeGoWebRespList);
|
||||
|
|
@ -150,8 +193,20 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@PostMapping("/storeCashList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "根据用户id,运营商id,查询seg商户提现列表", notes = "需要鉴权")
|
||||
public TableDataInfo store_cash_list(SegchkUserWebReq segchkUserWebReq)
|
||||
public TableDataInfo store_cash_list(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
segchkUserWebReq.setProviderId(claims.getProviderId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkUserCashWebResp> segchkUserWebSCRespList = segchkStoreIndexService.selectStoreCashList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
|
|
@ -170,8 +225,19 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
@PostMapping( "/ServiceCheckTest")
|
||||
@ResponseBody
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public AjaxResult service_check_test(Long likegoId, String storeId)
|
||||
public AjaxResult service_check_test(Long likegoId, String storeId, String remark, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(remark)){
|
||||
if(!storeId.equals(claims.getUserId())){
|
||||
logger.warn("ServiceCheckTest---storeid: {} is not then token: {}", storeId, claims);
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
}
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
SegchkServiceOrderChkTestResp segchkServiceOrderChkTestResp = segchkUserIndexService.selectUserOrderPredInfo(likegoId);
|
||||
|
|
@ -223,7 +289,7 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
|
||||
|
||||
/**
|
||||
* 提现结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* 提现结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败 未测试
|
||||
* {
|
||||
* "chargeId": "45435",
|
||||
* "userLevel": "1/2/0",
|
||||
|
|
@ -243,4 +309,35 @@ public class SegchkDefaultStoreController extends BaseController
|
|||
segchkUserIndexService.cashRet(chargeId, ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
private Claims getClaims(String token) {
|
||||
|
||||
Object claims = redisService.getCacheObject(token);
|
||||
logger.debug("getClaims---token:{} Claims:{}", token, claims);
|
||||
return ObjectUtils.isEmpty(claims) ? null : (Claims) claims;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param request request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer")) {
|
||||
logger.info("getClaims fail :Authorization fail ");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
return authHeader.length() >= 7 ? authHeader.substring(7) : authHeader.substring(6);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,889 @@
|
|||
package com.ruoyi.segchk;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.appletsutil.ResultCode;
|
||||
import com.ruoyi.appletsutil.UnAuthorizedException;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.segchk.domain.*;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
import com.ruoyi.util.Claims;
|
||||
import com.ruoyi.util.CommonResponse;
|
||||
import com.ruoyi.util.WechatUtils;
|
||||
import com.ruoyi.util.bean.PrepayResult;
|
||||
import com.ruoyi.util.bean.WechatApletPrepayResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ruoyi.common.core.domain.AjaxResult.*;
|
||||
import static com.ruoyi.common.utils.ip.IpUtils.getIpAddr;
|
||||
|
||||
/**
|
||||
* seg首页推荐商户Controller
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/default/user")
|
||||
@Api("用户小程序接口")
|
||||
public class SegchkDefaultUserController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
@Autowired
|
||||
private ISegchkUserCollectService segchkUserCollectService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserLikegoService segchkUserLikegoService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserChargeService segchkUserChargeService;
|
||||
|
||||
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
/**
|
||||
* 新增保存seg用户收藏记录
|
||||
* {
|
||||
* "collectType": "1",//*
|
||||
* "providerId": 0,//*
|
||||
* "userId": 0,//*
|
||||
* "storeId": 0,//*
|
||||
* "modTime": "2021-08-16 13:43:43",
|
||||
* "mgtState": 0//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:add')")
|
||||
@UnAuth
|
||||
@Log(title = "seg用户收藏记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addUserCollect")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "添加seg用户收藏记录", notes = "需要鉴权")
|
||||
public AjaxResult add_user_collect(@RequestBody SegchkUserCollect segchkUserCollect, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserCollect.getRemark())){
|
||||
/*if(!segchkUserCollect.getUserId().equals(claims.getUserId())){
|
||||
return AjaxResult.error(301, "用户异常");
|
||||
}*/
|
||||
segchkUserCollect.setUserId(claims.getUserId());
|
||||
segchkUserCollect.setProviderId(claims.getProviderId());
|
||||
}
|
||||
return toAjax(segchkUserCollectService.insertSegchkUserCollect(segchkUserCollect));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除seg用户收藏记录
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:remove')")
|
||||
@UnAuth
|
||||
@Log(title = "删除seg用户收藏记录", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/removeUserCollect")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "删除seg用户收藏记录", notes = "需要鉴权")
|
||||
public AjaxResult removeUserCollect(@RequestBody RemoveIds removeIds, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
return toAjax(segchkUserCollectService.deleteSegchkUserCollectByIds(removeIds.getIds()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运营商id,用户id,商户id,查询该用户在该商户可使用的会员卡或优惠券 尹志颖
|
||||
* {
|
||||
* "providerId": 4,
|
||||
* "storeId": 128,
|
||||
* "userId": 245
|
||||
* }
|
||||
*/
|
||||
@UnAuth
|
||||
@Log(title = "查询该用户在该商户可使用的会员卡或优惠券", businessType = BusinessType.GENCODE)
|
||||
@PostMapping("/userOrderPredList")
|
||||
@ResponseBody
|
||||
public TableDataInfo UserOrderPredList(@RequestBody SegchkServiceOrderWebReq segchkServiceOrderWebReq, HttpServletRequest request)
|
||||
{
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkServiceOrderWebReq.getRemark())){
|
||||
segchkServiceOrderWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkServiceOrderWebReq> segchkServiceOrderWebReqList = segchkUserIndexService.selectUserOrderPredCardListWebInfo(segchkServiceOrderWebReq);
|
||||
return getDataTable(segchkServiceOrderWebReqList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存seg用户想去记录
|
||||
* {
|
||||
* "providerId": 4,//*
|
||||
* "userId": 231,//*
|
||||
* "storeId": 128,//*
|
||||
* "cardId": 230,//*
|
||||
* "cardType": 0 //* 0充值卡2优惠券1赠卡
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:add')")
|
||||
@UnAuth
|
||||
@Log(title = "seg用户想去记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addOrderUserLikego")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "添加seg用户想去记录", notes = "需要鉴权")
|
||||
public AjaxResult add_order_user_likego(@RequestBody SegchkUserLikego segchkUserLikego, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserLikego.getRemark())){
|
||||
segchkUserLikego.setUserId(claims.getUserId());
|
||||
segchkUserLikego.setProviderId(claims.getProviderId());
|
||||
}
|
||||
return toAjax(segchkUserLikegoService.insertSegchkUserLikego(segchkUserLikego));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询seg用户中心信息 尹志颖
|
||||
* {
|
||||
* "userId": 240,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2//* 0运营商,1商户,2用户
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_info:query')")
|
||||
@UnAuth
|
||||
@PostMapping("/storeUserInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户中心信息", notes = "需要鉴权")
|
||||
public AjaxResult store_user_info(SegchkUserWebReq segchkUserWebReq)
|
||||
{
|
||||
// startPage();
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
|
||||
SegchkUserWebResp segchkUserWebResp = segchkUserWebReq.getUserLevel() == 2 ?
|
||||
segchkUserIndexService.selectSegchkUserWebInfo(segchkUserWebReq)
|
||||
: (segchkUserWebReq.getUserLevel() == 1 ?
|
||||
segchkStoreIndexService.selectSegchkStoreWebInfo(segchkUserWebReq) : segchkProviderIndexService.selectSegchkProviderWebInfo(segchkUserWebReq));
|
||||
ajax.put("value", segchkUserWebResp);
|
||||
return ajax;
|
||||
// return getDataTable(segchkServiceCommentWebRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户核消列表 尹志颖
|
||||
* {
|
||||
* "userId": 245,//*
|
||||
* "providerId": 4//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_check:list')")
|
||||
@UnAuth
|
||||
@PostMapping("/storeServiceCheckList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户核消列表", notes = "需要鉴权")
|
||||
public TableDataInfo store_service_check_list(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
|
||||
List<SegchkUserWebSCResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserServiceCHKList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户可用会员卡列表或者优惠券列表 尹志颖
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_card:list')")
|
||||
@UnAuth
|
||||
@PostMapping("/userCardList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户可用会员卡列表或者优惠券列表", notes = "需要鉴权")
|
||||
public TableDataInfo user_card_list(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
|
||||
List<SegchkUserWebCardResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCardList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户收藏列表 尹志颖
|
||||
* {
|
||||
* "userId": 439,//*
|
||||
* "providerId": 4//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_collect:list')")
|
||||
@UnAuth
|
||||
@PostMapping("/userCollectList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户收藏列表", notes = "需要鉴权")
|
||||
public TableDataInfo user_collect_list(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
|
||||
List<SegchkUserCollectWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCollectList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户预约单列表 尹志颖
|
||||
* {
|
||||
* "userId": 234,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 0//测试用
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:list')")
|
||||
@UnAuth
|
||||
@PostMapping("/userLikeGOList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户预约单列表", notes = "需要鉴权")
|
||||
public TableDataInfo userLikeGOList(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkUserLikeGoWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserLikGoList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除seg用户想去记录
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_likego:remove')")
|
||||
@Log(title = "seg用户想去记录", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/removeOrderUserLikego")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "删除seg用户想去记录", notes = "需要鉴权")
|
||||
public AjaxResult removeOrderUserLikego(@RequestBody RemoveIds removeIds, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(removeIds.getRemark())){
|
||||
removeIds.setUserId(claims.getUserId());
|
||||
}
|
||||
return toAjax(segchkUserLikegoService.deleteSegchkUserLikegoByLikegoIds(Convert.toLongArray(removeIds.getIds())));
|
||||
}
|
||||
|
||||
/**
|
||||
* seg服务评价查询
|
||||
* {
|
||||
* "commentId": 3//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_comment:query')")
|
||||
@Log(title = "seg服务评价查看", businessType = BusinessType.OTHER)
|
||||
@PostMapping( "/getComment")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg服务评价查询", notes = "需要鉴权")
|
||||
public AjaxResult get_comment(@RequestBody SegchkServiceCommentUserReq segchkServiceCommentUserReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
SegchkServiceComment segchkServiceComment = segchkUserIndexService.selectSegchkServiceComment(segchkServiceCommentUserReq);
|
||||
if(segchkServiceComment == null){
|
||||
ajax.put(CODE_TAG, "300");
|
||||
ajax.put(MSG_TAG, "未查到相关评价");
|
||||
}
|
||||
else{
|
||||
ajax.put(CODE_TAG, "200");
|
||||
ajax.put(DATA_TAG, segchkServiceComment);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seg服务评价提交
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_comment:add')")
|
||||
@Log(title = "seg服务评价提交", businessType = BusinessType.INSERT)
|
||||
@PostMapping( "/addComment")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg服务评价提交", notes = "需要鉴权")
|
||||
public AjaxResult addComment(@RequestBody SegchkServiceCommentUserReq segchkServiceCommentUserReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
return toAjax(segchkUserIndexService.insertSegchkServiceComment(segchkServiceCommentUserReq));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户充值列表 尹志颖
|
||||
* {
|
||||
* "userId": 34,//*
|
||||
* "providerId": 2//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:list')")
|
||||
@PostMapping("/userChargeList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户充值列表", notes = "需要鉴权")
|
||||
public TableDataInfo userChargeList(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkUserChargeWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserChargeList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,查询seg用户提现列表 尹志颖
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_cash:list')")
|
||||
@PostMapping("/userCashList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户提现列表", notes = "需要鉴权")
|
||||
public TableDataInfo userCashList(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkUserCashWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserCashList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id,运营商id,角色等级查询seg用户消息列表 尹志颖
|
||||
* {
|
||||
* "userId": 392,//*
|
||||
* "providerId": 4,//*
|
||||
* "userLevel": 2,//*
|
||||
* "phoneNo": 1//测试
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_msg:list')")
|
||||
@PostMapping("/userMsgList")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户消息列表", notes = "需要鉴权")
|
||||
public TableDataInfo userMsgList(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setCode(300);
|
||||
tableDataInfo.setMsg("请先登录注册");
|
||||
return tableDataInfo;
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
}
|
||||
startPage();
|
||||
List<SegchkMsgWebResp> segchkUserWebSCRespList = segchkUserIndexService.selectUserMsgList(segchkUserWebReq);
|
||||
return getDataTable(segchkUserWebSCRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户进入余额充值页面时,根据用户id,运营商id查询可充值 的卡
|
||||
* {
|
||||
* "userId": 465,
|
||||
* "providerId": 4
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:add')")
|
||||
@PostMapping( "/userChargePre")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询seg用户可充值列表", notes = "需要鉴权")
|
||||
public AjaxResult userChargePre(@RequestBody SegchkUserWebReq segchkUserWebReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
// userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserWebReq.getRemark())){
|
||||
segchkUserWebReq.setUserLevel(claims.getUserLevel());
|
||||
segchkUserWebReq.setUserId(claims.getUserId());
|
||||
segchkUserWebReq.setProviderId(claims.getProviderId());
|
||||
}
|
||||
|
||||
|
||||
List<SegchkUserChargeCard> segchkUserChargeCards = segchkUserIndexService.SegchkUserChargePre(segchkUserWebReq);
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
if(segchkUserChargeCards == null){
|
||||
ajax.put(CODE_TAG, "300");
|
||||
}
|
||||
else{
|
||||
ajax.put(CODE_TAG, "200");
|
||||
ajax.put(DATA_TAG, segchkUserChargeCards);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户进入余额充值页面时,根据用户id,运营商id查询可充值的卡,生成充值记录 未测试
|
||||
* {
|
||||
* "userId": 465,
|
||||
* "charge": 299.0,
|
||||
* "accountUsed": 10.0,
|
||||
* "cardTypeId": 1,
|
||||
* "providerId": 4
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_charge:pre')")
|
||||
@PostMapping( "/userChargeReq")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户可充值", notes = "需要鉴权")
|
||||
public AjaxResult userChargeReq(@RequestBody SegchkUserCharge segchkUserCharge, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserCharge.getRemark())){
|
||||
segchkUserCharge.setUserId(claims.getUserId());
|
||||
segchkUserCharge.setProviderId(claims.getProviderId());
|
||||
}
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
// logger.debug(segchkUserCharge.getAccountUsed());
|
||||
if(segchkUserCharge.getAccountUsed() != null && segchkUserCharge.getAccountUsed().compareTo(new BigDecimal(0.0)) == 1) {
|
||||
BigDecimal user_account = segchkUserIndexService.getAccount(segchkUserCharge);
|
||||
if(user_account == null || user_account.compareTo(segchkUserCharge.getAccountUsed()) == -1){
|
||||
ajax.put(CODE_TAG, "500");
|
||||
ajax.put(MSG_TAG, "余额不足!");
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
int ret = segchkUserChargeService.insertSegchkUserCharge(segchkUserCharge);
|
||||
if(ret < 1){
|
||||
ajax.put(CODE_TAG, "500");
|
||||
ajax.put(MSG_TAG, "充值失败!");
|
||||
}
|
||||
else{
|
||||
CommonResponse<PrepayResult> prepayResultCommonResponse = segchkUserIndexService.wechatAppletPay(
|
||||
segchkUserCharge.getChargeId().toString()
|
||||
, segchkUserCharge.getUserId()
|
||||
, segchkUserCharge.getProviderId()
|
||||
, getIpAddr(request), 2);
|
||||
switch (prepayResultCommonResponse.getFlag()){
|
||||
case -1: return AjaxResult.error(500, "用户不存在");
|
||||
case -5: return AjaxResult.error(500, "微信生成订单出错");
|
||||
case -7: return AjaxResult.error(500, "没有设置网站地址");
|
||||
case -8: return AjaxResult.error(500, "缺少配置");
|
||||
case -10: return AjaxResult.error(500, "没有绑定微信");
|
||||
case 1: {
|
||||
/*WechatApletPrepayResult wechatApletPrepayResult = new WechatApletPrepayResult();
|
||||
wechatApletPrepayResult.setAppId(prepayResultCommonResponse.getData().getAppid());
|
||||
wechatApletPrepayResult.setPaySign(prepayResultCommonResponse.getData().getPay_sign());
|
||||
wechatApletPrepayResult.setPackage_(prepayResultCommonResponse.getData().getPackage_());
|
||||
wechatApletPrepayResult.setNonceStr(prepayResultCommonResponse.getData().getNonce_str());
|
||||
wechatApletPrepayResult.setTimeStamp(prepayResultCommonResponse.getData().getTime_stamp());*/
|
||||
|
||||
return AjaxResult.success("充值成功", prepayResultCommonResponse);
|
||||
}
|
||||
default: return AjaxResult.error(600, "未知错误");
|
||||
}
|
||||
// ajax.put(CODE_TAG, "200");
|
||||
// ajax.put(MSG_TAG, "充值成功!");
|
||||
// ajax.put(DATA_TAG, prepayResultCommonResponse);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* {
|
||||
* "chargeId": "demoData",//*
|
||||
* "ret": 0//*0成功,其他失败
|
||||
* }
|
||||
*/
|
||||
@Log(title = "seg用户充值结果回调", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userChargeResult")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户充值结果回调", notes = "需要鉴权")
|
||||
public void userChargeResult(String chargeId, int ret, HttpServletRequest request)
|
||||
{
|
||||
|
||||
segchkUserIndexService.chargeRet(chargeId, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
*/
|
||||
@RequestMapping("/wechatnotify")
|
||||
@UnAuth
|
||||
@ApiIgnore
|
||||
public void weChatNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
if (segchkUserIndexService.weChatAppletNotify(request.getInputStream()) > 0) {
|
||||
sendMessage(response, WechatUtils.SUCCESS_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户点击提现时的反应 未测试
|
||||
* {
|
||||
* "userId": 459,
|
||||
* "cash": 5.6,
|
||||
* "providerId": 4,
|
||||
* "userLevel": 2
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_cash:add')")
|
||||
@PostMapping( "/userCashReq")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg用户提现请求", notes = "需要鉴权")
|
||||
public AjaxResult userCashReq(@RequestBody SegchkUserCashOpsReq segchkUserCashOpsReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserCashOpsReq.getRemark())){
|
||||
segchkUserCashOpsReq.setUserId(claims.getUserId());
|
||||
segchkUserCashOpsReq.setProviderId(claims.getProviderId());
|
||||
segchkUserCashOpsReq.setUserLevel(claims.getUserLevel());
|
||||
}
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
if(segchkUserCashOpsReq.getUserLevel() == 0){
|
||||
return AjaxResult.error(301, "运营商无法线上提现");
|
||||
}
|
||||
// segchkUserCashOpsReq.setUserLevel(2);
|
||||
int ret = segchkUserIndexService.getAccountForCash(segchkUserCashOpsReq, getIpAddr(request));
|
||||
switch (ret){
|
||||
case -1: return AjaxResult.error(401, "无余额信息");
|
||||
case -2: return AjaxResult.error(402, "无余额信息");
|
||||
case -3: return AjaxResult.error(403, "提现受限");
|
||||
case -4: return AjaxResult.error(404, "余额不足");
|
||||
case -5:
|
||||
case -8:
|
||||
case -11:
|
||||
case -12:
|
||||
case -9: return AjaxResult.error(405, "提现异常,请联系平台客服");
|
||||
case -10: return AjaxResult.error(410, "微信未绑定");
|
||||
case 1: {
|
||||
return AjaxResult.error(200, "提现成功");
|
||||
}
|
||||
default: ajax.put(CODE_TAG, "500");ajax.put(MSG_TAG, "未知错误");break;
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户信息 未测试
|
||||
* {
|
||||
* "userId": 43,//*
|
||||
* "passwd": "sfsdfds",//*
|
||||
* "providerId": 2,//*
|
||||
* "userLevel": 2//*
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_set:add')")
|
||||
@Log(title = "seg设置用户信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/SetInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg设置用户信息", notes = "需要鉴权")
|
||||
public AjaxResult SetInfo(@RequestBody SegchkUserSetInfoReq segchkUserSetInfoReq, HttpServletRequest request)
|
||||
{
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserSetInfoReq.getRemark())){
|
||||
segchkUserSetInfoReq.setUserId(claims.getUserId());
|
||||
segchkUserSetInfoReq.setProviderId(claims.getProviderId());
|
||||
segchkUserSetInfoReq.setUserLevel(claims.getUserLevel());
|
||||
}
|
||||
int ret = 0;
|
||||
if(segchkUserSetInfoReq.getUserLevel() == 2) {
|
||||
ret = segchkUserIndexService.updateUserInfo(segchkUserSetInfoReq);
|
||||
}
|
||||
else if(segchkUserSetInfoReq.getUserLevel() == 1){
|
||||
ret = segchkStoreIndexService.updateUserInfo(segchkUserSetInfoReq);
|
||||
}
|
||||
return toAjax(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seg设置用户实名信息 未测试
|
||||
* {
|
||||
* "userName": "demoData",
|
||||
* "userId": 0,
|
||||
* "providerId": 0,
|
||||
* "IDcard": "demoData",
|
||||
* "card1": "demoData",
|
||||
* "card2": "demoData"
|
||||
* }
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('segchk:user_certicify:add')")
|
||||
@Log(title = "seg设置用户实名信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userCerticify")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg设置用户实名信息", notes = "需要鉴权")
|
||||
public AjaxResult user_certicify(@RequestBody SegchkUserCertificationInfo segchkUserCertificationInfo, HttpServletRequest request)
|
||||
{
|
||||
int ret = 0;
|
||||
Long userId = 0L;
|
||||
Claims claims = getClaims(getToken(request));
|
||||
if (ObjectUtils.isEmpty(claims)) {
|
||||
// 如果用户未登录,则要求用户使用手机号登录注册
|
||||
userId = getClaims(getToken(request)).getUserId();
|
||||
return AjaxResult.error(300, "请先登录注册");
|
||||
}
|
||||
if(StringUtils.isEmpty(segchkUserCertificationInfo.getRemark())){
|
||||
segchkUserCertificationInfo.setUserId(claims.getUserId());
|
||||
segchkUserCertificationInfo.setProviderId(claims.getProviderId());
|
||||
// segchkUserCertificationInfo.setUserLevel(claims.getUserLevel());
|
||||
}
|
||||
ret = segchkUserIndexService.userCerticify(segchkUserCertificationInfo);
|
||||
return toAjax(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现结果回调接口,接口微信的支付结果,更新充值结果, ret 0成功,其他失败
|
||||
* {
|
||||
* "chargeId": "45435",
|
||||
* "userLevel": "1/2/0",
|
||||
* "ret": 1
|
||||
* }
|
||||
*/
|
||||
@Log(title = "seg提现结果回调", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/userCashResult")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "seg提现结果回调", notes = "需要鉴权")
|
||||
public void userCashResult(String chargeId, int userLevel, int ret, HttpServletRequest request)
|
||||
{
|
||||
if(userLevel == 1) {
|
||||
segchkStoreIndexService.cashRet(chargeId, ret);
|
||||
}
|
||||
else if(userLevel == 2){
|
||||
segchkUserIndexService.cashRet(chargeId, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序凭证实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序凭证实体
|
||||
*/
|
||||
private Claims getClaims(String token) {
|
||||
|
||||
Object claims = redisService.getCacheObject(token);
|
||||
logger.debug("getClaims---token:{} Claims:{}", token, claims);
|
||||
return ObjectUtils.isEmpty(claims) ? null : (Claims) claims;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param request request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 认证信息在header 中的key
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
|
||||
if (Objects.isNull(authHeader) || !authHeader.startsWith("Bearer")) {
|
||||
logger.info("getClaims fail :Authorization fail ");
|
||||
throw new UnAuthorizedException(ResultCode.WX_NOT_AUTHORIZED);
|
||||
}
|
||||
return authHeader.length() >= 7 ? authHeader.substring(7) : authHeader.substring(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回传信息
|
||||
*
|
||||
* @param message 信息
|
||||
*/
|
||||
private void sendMessage(HttpServletResponse response, String message) {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
out.println(message);
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class RemoveIds extends BaseEntity {
|
||||
private Long userId;
|
||||
private String ids;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(String ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.util;
|
||||
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.setting.bean.BaseInfoSet;
|
||||
import com.ruoyi.setting.service.BaseInfoSetService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
|
||||
/**
|
||||
* 系统设置控制器
|
||||
*/
|
||||
@Controller
|
||||
@Api(description = "系统设置接口")
|
||||
public class BaseInfoSetController {
|
||||
|
||||
/**
|
||||
* 注入系统设置服务
|
||||
*/
|
||||
@Autowired
|
||||
private BaseInfoSetService baseInfoSetService;
|
||||
|
||||
/**
|
||||
* 查询基本信息和高级信息设置
|
||||
*
|
||||
* @return 基本信息和高级信息设置实体类
|
||||
*/
|
||||
@RequestMapping("/querybaseinfoset")
|
||||
@ResponseBody
|
||||
@UnAuth
|
||||
@ApiOperation(value = "查询基本信息和高级信息设置", notes = "查询基本信息和高级信息设置(不需要认证)", httpMethod = "POST")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "基本信息和高级信息设置实体类", response = BaseInfoSet.class)
|
||||
})
|
||||
public AjaxResult queryBaseInfoSet() {
|
||||
return AjaxResult.success(baseInfoSetService.queryBaseInfoSet());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.ruoyi.util;
|
||||
|
||||
import com.ruoyi.common.annotation.UnAuth;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* 二维码控制器
|
||||
*
|
||||
* @author 魔金商城 created on 2020/6/23
|
||||
*/
|
||||
@Controller
|
||||
@Api(description = "二维码接口")
|
||||
public class QrCodeController {
|
||||
|
||||
|
||||
@Value("${segchk.qr_path}")
|
||||
private String qrPath;
|
||||
|
||||
@Value("${segchk.poster_path}")
|
||||
private String posterPath;
|
||||
|
||||
/**
|
||||
* 创建二维码图片
|
||||
*
|
||||
* @param url 地址
|
||||
* @param w 宽
|
||||
* @param h 高
|
||||
*/
|
||||
@RequestMapping("/createqrcode")
|
||||
@ResponseBody
|
||||
@UnAuth
|
||||
@ApiIgnore
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "form", dataType = "String", name = "url", value = "地址"),
|
||||
@ApiImplicitParam(paramType = "form", dataType = "Integer", name = "w", value = "宽"),
|
||||
@ApiImplicitParam(paramType = "form", dataType = "Integer", name = "h", value = "高"),
|
||||
})
|
||||
public void createQrCode(HttpServletResponse response, String url, Integer w, Integer h) {
|
||||
createQRImg(response, url, w, h);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("qRCode")
|
||||
public void qRCode(HttpServletResponse response, String storeId, Integer w, Integer h) {
|
||||
|
||||
//获取生成海报的图片路径
|
||||
// qRCodeNew(storeId, response);
|
||||
}
|
||||
|
||||
/*private void qRCodeNew(String storeId, HttpServletResponse response) {
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = response.getOutputStream();
|
||||
QRCodeUtils.qRCode(storeId, "jpg", qrPath, posterPath, outputStream);
|
||||
outputStream.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 创建二维码图片
|
||||
*
|
||||
* @param url 链接地址
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
*/
|
||||
private void createQRImg(HttpServletResponse response, String url, Integer width, Integer height) {
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = response.getOutputStream();
|
||||
QRCodeUtils.createQrCode(url, width, height, "jpg", outputStream);
|
||||
|
||||
outputStream.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:8306/segchksaas?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: segchksaas
|
||||
password: 2wsx@WSX
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username:
|
||||
login-password:
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
|
||||
yzytest:
|
||||
login:
|
||||
smstest: true
|
||||
|
||||
segchk:
|
||||
qr_path: uploadPath
|
||||
poster_path: uploadPath
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
master:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.16.11.13:3306/yzy_ruoyi_vue?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: yzyuser
|
||||
password: yzy123456
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
slave:
|
||||
enabled: false
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.16.11.13:3306/yzy_payshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: yzyuser
|
||||
password: yzy123456
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
redis:
|
||||
cluster:
|
||||
nodes: 172.16.11.10:63795
|
||||
timeout: 1000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 2
|
||||
max-wait: 300
|
||||
password: retinabd@2020
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-name: elasticsearch
|
||||
cluster-nodes: 10.1.192.113:29208,10.1.192.113:29209,10.1.192.113:29210
|
||||
messages:
|
||||
basename: messages/messages
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 15MB
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
master:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.22.4.2:3306/yzy_ruoyi_vue?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: oywkpjEi9MW4NL9mR88YTydj9wHE5E
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
slave1:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.22.4.2:3306/wsfmall_test?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: oywkpjEi9MW4NL9mR88YTydj9wHE5E
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
redis:
|
||||
host: 172.22.0.3
|
||||
port: 6379
|
||||
timeout: 100
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 2
|
||||
max-wait: 300
|
||||
password: sfakjfiju99jjf87LJSDDU8
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-nodes: 172.22.0.3:9300
|
||||
messages:
|
||||
basename: messages/messages
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 15MB
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
master:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.22.4.2:3306/wsfmall_uat?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: oywkpjEi9MW4NL9mR88YTydj9wHE5E
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
slave1:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.22.4.2:3306/wsfmall_uat?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: oywkpjEi9MW4NL9mR88YTydj9wHE5E
|
||||
# 初始化连接大小
|
||||
initial-size: 5
|
||||
# 最小空闲连接数
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 30000
|
||||
# 可关闭的空闲连接间隔时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置连接在池中的最小生存时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select '1' from dual
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
redis:
|
||||
host: 172.22.0.4
|
||||
port: 6379
|
||||
timeout: 100
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 2
|
||||
max-wait: 300
|
||||
password: sfakjfiju99jjf87LJSDDU8
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-nodes: 172.22.0.4:9300
|
||||
messages:
|
||||
basename: messages/messages
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 15MB
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
# 项目相关配置 商城端
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.0.0
|
||||
# 版权年份
|
||||
copyrightYear: 2019
|
||||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置F:\ideaproj\RuoYi-Vue\uploadPath
|
||||
#,Linux配置 /root/yzychk_vue/uploadPath)
|
||||
profile: /root/yzychk_vue/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为 8091 测试 9092
|
||||
port: 9092
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
# tomcat最大线程数,默认为200
|
||||
max-threads: 800
|
||||
# Tomcat启动初始化的线程数,默认值25
|
||||
min-spare-threads: 30
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: debug
|
||||
org.springframework: warn
|
||||
|
||||
# Spring配置
|
||||
spring:
|
||||
# 资源信息
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: dev
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
# 服务模块
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: 127.0.0.1
|
||||
# 端口,默认为6379
|
||||
port: 63795
|
||||
# 数据库索引
|
||||
database: 3
|
||||
# 密码
|
||||
password: retinabd@2020
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最小空闲连接
|
||||
min-idle: 0
|
||||
# 连接池中的最大空闲连接
|
||||
max-idle: 8
|
||||
# 连接池的最大数据库连接数
|
||||
max-active: 8
|
||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-wait: -1ms
|
||||
|
||||
# token配置
|
||||
token:
|
||||
# 令牌自定义标识
|
||||
header: Authorization
|
||||
# 令牌密钥
|
||||
secret: abcdefghijklmnopqrstuvwxyz
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 3000
|
||||
|
||||
# MyBatis配置
|
||||
mybatis:
|
||||
# 搜索指定包别名
|
||||
typeAliasesPackage: com.ruoyi.**.domain
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 加载全局的配置文件
|
||||
configLocation: classpath:mybatis/mybatis-config.xml
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
reasonable: true
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
# 是否开启swagger
|
||||
enabled: true
|
||||
# 请求前缀
|
||||
pathMapping: /dev-api
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
# 过滤开关
|
||||
enabled: true
|
||||
# 排除链接(多个用逗号分隔)
|
||||
excludes: /system/notice/*
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"dev": {
|
||||
"name": "value",
|
||||
"bindtoken": "eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNqqViouTVKyUnIMCPBxDYn38Xf39Iv3do1U0lHKTCxRsjI0MzY0tDCwtLDQUSotTi3yTFGyMjUw1lEqKMovy0yBCBhB5HxSy1JzwLzUigKYVhNTC4taAAAAAP__.diChD7JjY3y8SBNTBE8ACoNWWIuz-r-mHESPfL73eZI",
|
||||
"bindtoken1": "eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNqqViouTVKyUnIMCPBxDYn38Xf39Iv3do1U0lHKTCxRsjI0MzYyNDQwNDLVUSotTi3yTFGyMjUw1lEqKMovy0yBCBhB5HxSy1JzwLzUigKYVmNzI9NaAAAAAP__.Y5uJzL55q9baNor4ScWmVg9UZyfHkTxZ0Oz79guiXXg",
|
||||
// "token2": "APPLET_LOGIN_KEY_885553054366171136abcdefghijklmnopqrstuvwxyz",
|
||||
"token3": "eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNqqViouTVKyUipPTc5ILMnJT8_MU9JRykwsUbIyNDM2NDQ3sDAx0VEqLU4t8kxRsjLWUSooyi_LTIFwjSAyPqllqTlgXmpFAUyjCRDUAgAAAP__.5qRMCYs8YUoFJdSo_XSZiGlqJ13LGa20qJAT8GoiMHg",
|
||||
"providertoken": "eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNqqViouTVKyUnIMCPBxDYn38Xf39Iv3do1U0lHKTCxRsjI0MzY0MjC1MDTWUSotTi3yTFGyMtJRKijKL8tMgXNBMj6pZak5SlYGOkqpFQUwjZYmhsa1AAAAAP__.DkyBrM5f7G0eLi7DnYpgAqGTYnLaWRrpD3xemTa1s3k",
|
||||
"store_search":
|
||||
{
|
||||
"providerId": 2,
|
||||
"sortType": 0,
|
||||
"storeName": "99",
|
||||
"lableName": "99",
|
||||
"typeId": 1,
|
||||
"userLon": 114.123456,
|
||||
"userLat": 43.123456
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<!-- 应用名称-->
|
||||
<property name="appName" value="web"/>
|
||||
<!-- 日志的存放目录-->
|
||||
<property name="log.path" value="/root/yzychk_vue/logs" />
|
||||
<!-- debug-->
|
||||
<property name="DEBUG_LOG_FILE_NAME_PATTERN" value="logs/${appName}/debug.%d{yyyy-MM-dd}.%i.log"/>
|
||||
<property name="INFO_LOG_FILE_NAME_PATTERN" value="logs/${appName}/all.%d{yyyy-MM-dd}.%i.log"/>
|
||||
<property name="WARN_LOG_FILE_NAME_PATTERN" value="logs/${appName}/warn.%d{yyyy-MM-dd}.%i.log"/>
|
||||
<property name="ERROR_LOG_FILE_NAME_PATTERN" value="logs/${appName}/error.%d{yyyy-MM-dd}.%i.log"/>
|
||||
<!-- 日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%c){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
<property name="FILE_LOG_PATTERN"
|
||||
value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %c : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
<!--输出到控制台-->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
<!--输出到INFO文件-->
|
||||
<appender name="info_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${INFO_LOG_FILE_NAME_PATTERN}</fileNamePattern>
|
||||
<!-- 日志保留天数 -->
|
||||
<maxHistory>14</maxHistory>
|
||||
<!-- 日志文件上限大小,达到指定大小后删除旧的日志文件 -->
|
||||
<totalSizeCap>30GB</totalSizeCap>
|
||||
<!-- 每个日志文件的最大值 -->
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!--输出到ERROR文件-->
|
||||
<appender name="error_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${ERROR_LOG_FILE_NAME_PATTERN}</fileNamePattern>
|
||||
<!-- 日志保留天数 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<!-- 日志文件上限大小,达到指定大小后删除旧的日志文件 -->
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
<!-- 每个日志文件的最大值 -->
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
<!-- 此日志文件只记录error级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>error</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
<!-- region 根据不同的环境设置不同的日志输出级别 -->
|
||||
<springProfile name="default,local,dev">
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
<logger name="com.lecshop" level="debug"/>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="prod,dev,test,uat">
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="info_file"/>
|
||||
<appender-ref ref="error_file"/>
|
||||
</root>
|
||||
<logger name="com.lecshop" level="debug"/>
|
||||
</springProfile>
|
||||
<!-- endregion -->
|
||||
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
####################################
|
||||
## \u7ED3\u679C\u7801\u4FE1\u606F\u5B9A\u4E49 ##
|
||||
#####################################
|
||||
R-00002=\u5C0F\u7A0B\u5E8F\u672A\u6388\u6743
|
||||
R-00003=\u5C0F\u7A0B\u5E8F\u672A\u548C\u7528\u6237\u7ED1\u5B9A
|
||||
R-00004=\u7528\u6237\u7ED1\u5B9A\u5931\u8D25\uFF0C\u5DF2\u7ED1\u5B9A\u5176\u4ED6\u8D26\u6237
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
####################################
|
||||
## \u7ED3\u679C\u7801\u4FE1\u606F\u5B9A\u4E49 ##
|
||||
#####################################
|
||||
R-00002=\u5C0F\u7A0B\u5E8F\u672A\u6388\u6743
|
||||
R-00003=\u5C0F\u7A0B\u5E8F\u672A\u548C\u7528\u6237\u7ED1\u5B9A
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
####################################
|
||||
## \u7ED3\u679C\u7801\u4FE1\u606F\u5B9A\u4E49 ##
|
||||
#####################################
|
||||
R-00002=\u5C0F\u7A0B\u5E8F\u672A\u6388\u6743
|
||||
R-00003=\u5C0F\u7A0B\u5E8F\u672A\u548C\u7528\u6237\u7ED1\u5B9A
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
|
||||
<settings>
|
||||
<setting name="cacheEnabled" value="true"/> <!-- 全局映射器启用缓存 -->
|
||||
<setting name="useGeneratedKeys" value="true"/> <!-- 允许 JDBC 支持自动生成主键 -->
|
||||
<setting name="defaultExecutorType" value="REUSE"/> <!-- 配置默认的执行器 -->
|
||||
<setting name="logImpl" value="SLF4J"/> <!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
|
||||
</settings>
|
||||
|
||||
</configuration>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 188 KiB |
|
|
@ -0,0 +1,876 @@
|
|||
|
||||
|
||||
###
|
||||
GET https://api.weixin.qq.com/sns/jscode2session?appid=wx2ce4e2083b3a871a&secret=adc865e9ab24ab23b534f9ca5c0960b3&js_code=053okall2BHyK74GMcol2S8Exc0okaln&grant_type=authorization_code
|
||||
Accept: */*
|
||||
|
||||
###
|
||||
GET http://localhost:8091//createqrcode?url="http://yxr8cu.natappfree.cc//tokentest?dfasdf=1+werwer=1231"&w=300&h=300
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
|
||||
###
|
||||
############### 商家接口测试 ####################
|
||||
|
||||
### 商家核消操作
|
||||
POST http://localhost:8091//default/store/ServiceCheckTest?likegoId=16877&storeId=128&remark=999999
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
|
||||
### 根据用户id,运营商id,查询seg商户提现列表
|
||||
POST http://localhost:8091//default/store/storeCashList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 84,
|
||||
"phoneNo": "demoData",
|
||||
"providerId": 3,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:8091//default/store/storeUserLikeGoList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 123,
|
||||
"staticMonth": "60",
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:8091//default/store/storeServiceAndSaleDetails
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 123,
|
||||
"staticMonth": "2021-06-01",
|
||||
"srcFlag": 0,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
### 根据商家id,运营商id,角色等级,返回核消统计或售卡统计
|
||||
POST http://localhost:8091//default/store/storeServiceAndSaleList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 123,
|
||||
"staticMonth": "6",
|
||||
"srcFlag": 0,
|
||||
"remark": "999999"
|
||||
}
|
||||
############### END ####################
|
||||
|
||||
|
||||
|
||||
############### 用户接口测试 ####################
|
||||
###
|
||||
POST http://localhost:8091//default/user/userCashReq
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken1}}
|
||||
|
||||
{
|
||||
"userId": 503,
|
||||
"cash": 5,
|
||||
"providerId": 2,
|
||||
"userLevel": 2
|
||||
}
|
||||
|
||||
### 用户充值操作
|
||||
#返回结果
|
||||
#{
|
||||
# "msg": "充值成功",
|
||||
# "code": 200,
|
||||
# "data": {
|
||||
# "flag": 1,
|
||||
# "data": {
|
||||
# "return_code": "SUCCESS",
|
||||
# "return_msg": "OK",
|
||||
# "appid": "wx2ce4e2083b3a871a",
|
||||
# "mch_id": "1614166120",
|
||||
# "nonce_str": "wknhqpLNvr4F6CLI",
|
||||
# "sign": "2519A7C975E5F38B95D0EE453C1A11D2",
|
||||
# "result_code": "SUCCESS",
|
||||
# "err_code": null,
|
||||
# "err_code_des": null,
|
||||
# "trade_type": "JSAPI",
|
||||
# "prepay_id": "wx201612191353691146536bf76294620000",
|
||||
# "code_url": null,
|
||||
# "mweb_url": null,
|
||||
# "time_stamp": "1632125538",
|
||||
# "package_": "prepay_id=wx201612191353691146536bf76294620000",
|
||||
# "sign_type": "MD5",
|
||||
# "pay_sign": "087F0D138F3970B5228A3456E1A5496E"
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
POST http://localhost:8091//default/user/userChargeReq
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken1}}
|
||||
|
||||
{
|
||||
"userId": 503,
|
||||
"charge": 9.9,
|
||||
"accountUsed": 0,
|
||||
"cardTypeId": 0,
|
||||
"providerId": 2
|
||||
}
|
||||
|
||||
|
||||
### 用户充值请求
|
||||
POST http://localhost:8091//default/user/userChargePre
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken1}}
|
||||
|
||||
{
|
||||
"userId": 465,
|
||||
"providerId": 4,
|
||||
"userLevel": 2
|
||||
}
|
||||
|
||||
### 查询seg用户消息列表
|
||||
POST http://localhost:8091//default/user/userMsgList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 392,
|
||||
"providerId": 4,
|
||||
"userLevel": 2,
|
||||
"remark": "999999",
|
||||
"phoneNo": 1
|
||||
}
|
||||
|
||||
### 查询seg用户提现列表
|
||||
POST http://localhost:8091//default/user/userCashList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 34,
|
||||
"providerId": 2,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
### 查询seg用户充值列表
|
||||
POST http://localhost:8091//default/user/userChargeList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 34,
|
||||
"providerId": 2,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
### seg服务评价提交
|
||||
POST http://localhost:8091//default/user/addComment
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"starLevel": 4.5,
|
||||
"contentText": "测试评价9343",
|
||||
"chkServiceId": 9343
|
||||
}
|
||||
|
||||
### seg服务评价查询
|
||||
POST http://localhost:8091//default/user/getComment
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"commentId": 3
|
||||
}
|
||||
|
||||
### 删除seg用户想去记录
|
||||
POST http://localhost:8091//default/user/removeOrderUserLikego
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 245,
|
||||
"ids": "16733"
|
||||
}
|
||||
|
||||
### 查询seg用户收藏列表
|
||||
POST http://localhost:8091//default/user/userLikeGOList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 245,
|
||||
"providerId": 4,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
### 查询seg用户收藏列表 "remark": "999999"测试标识
|
||||
#{
|
||||
# "total": 48,//用户收藏列表数量
|
||||
# "rows": [
|
||||
# {
|
||||
# "collectId": 2002,//收藏id
|
||||
# "providerId": 4,//运营商id
|
||||
# "storeId": 134,//商家id,跳转商家详情使用
|
||||
# "storeName": "4商家名称018",//商家名称,展示使用
|
||||
# "storeIcon": "http://10.1.192.113:60902/profile/upload/2021/07/02/706f0a58-6031-4523-abbd-dc5dd823278c.jpg",//图标,展示使用
|
||||
# "serviceState": 0,//在线送达
|
||||
# "storeLon": 116.4980500000,//商家位置,导航时使用
|
||||
# "storeLat": 39.8831020000,//商家位置,导航时使用
|
||||
# "chkCount": 280,//核消数量
|
||||
# "starAvg": 2.71,//综合评价,展示使用
|
||||
# "modTime": "2021-07-16",//收藏时间,展示使用
|
||||
# "segchkRecommenderStoreLableWebList": [//商家标签列表
|
||||
# {
|
||||
# "lableId": 0,//标签id
|
||||
# "lableTypeId": 0,//一级标签id
|
||||
# "lableName": "99",//标签名称,展示使用
|
||||
# },
|
||||
# {
|
||||
# "lableId": 0,
|
||||
# "lableTypeId": 1,
|
||||
# "lableName": "美食",
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/user/userCollectList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 439,
|
||||
"providerId": 4,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
### 查询seg用户可用会员卡列表或者优惠券列表 "userLevel": 0(查会员卡),1(查优惠券),"remark": "999999"测试标识
|
||||
#结果说明
|
||||
#{
|
||||
# "total": 3,//优惠券数量
|
||||
# "rows": [
|
||||
# {
|
||||
# "cardName": "赠卡",//优惠券名称,展示使用
|
||||
# "storeName": "4商家名称028",//归属商家名称,展示使用
|
||||
# "leftCount": 49,//剩余次数,展示使用
|
||||
# "effectiveTime": "2021-07-13",//有效期,展示使用
|
||||
# "typeFlag": 1,//
|
||||
# "cardStatus": "过期"//状态
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
#
|
||||
#{
|
||||
# "total": 1,//卡包数量
|
||||
# "rows": [
|
||||
# {
|
||||
# "cardName": "299",//会员卡名称,展示使用
|
||||
# "storeName": null,//商家名称,展示使用,查询优惠券时有效
|
||||
# "useCount": 31,//已使用权益次数,展示使用
|
||||
# "leftCount": 69,//剩余权益次数,展示使用
|
||||
# "effectiveTime": "2021-09-15",//有效期,展示使用
|
||||
# "typeFlag": 0,//卡券标识,0会员卡,1券(或赠卡)
|
||||
# "cardStatus": "可用"//会员卡状态。是否可用,展示使用
|
||||
# }
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/user/userCardList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 241,
|
||||
"providerId": 4,
|
||||
"userLevel": 0,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
### 查询seg用户核消列表
|
||||
#结果说明
|
||||
#{
|
||||
# "total": 38,//用户核消列表数量
|
||||
# "rows": [//用户核消列表
|
||||
# {
|
||||
# "providerId": 4,//运营商id
|
||||
# "cardId": 244,//卡号或券号
|
||||
# "storeId": 119,//商家id
|
||||
# "cardTypeId": 0,//
|
||||
# "userId": 245,//用户id
|
||||
# "modTime": "2021-07-12",//核消时间,展示使用
|
||||
# "chkServiceId": 11168,//核消id
|
||||
# "commentId": 0,//评价id,0表示未评价,其他表示已评,展示使用
|
||||
# "cardTypeName": "99",//卡券名称,展示使用
|
||||
# "storeName": "4商家名称003",//商家名称,展示使用
|
||||
# "chkSource": 0//
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/user/storeServiceCheckList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 245,
|
||||
"providerId": 4,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
### 添加seg用户想去记录
|
||||
POST http://localhost:8091//default/user/addOrderUserLikego
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"userId": 245,
|
||||
"storeId": 128,
|
||||
"cardId": 244,
|
||||
"cardType": 0,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
### 查询该用户在该商户可使用的会员卡或优惠券,remark为测试标识
|
||||
#返回结果
|
||||
#{
|
||||
# "total": 3,//可用卡券列表数量
|
||||
# "rows": [//可用卡券列表
|
||||
# {
|
||||
# "providerId": 4,//运营商id
|
||||
# "storeId": 128,//商家id
|
||||
# "userId": 245,//用户id
|
||||
# "cardId": 244,//卡号或券号
|
||||
# "lableId": 0,//子标签id
|
||||
# "typeId": 0,//一级标签id
|
||||
# "cardName": "99会员卡"//预约下拉中展示使用
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/user/userOrderPredList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 128,
|
||||
"userId": 245,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
### 根据收藏id,删除收藏列表 ids:要删除的收藏列表id,删除多个时,使用逗号拼接
|
||||
POST http://localhost:8091//default/user/removeUserCollect
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 0,
|
||||
"ids": "23432,456"
|
||||
}
|
||||
|
||||
###
|
||||
### seg用户收藏记录
|
||||
POST http://localhost:8091//default/user/addUserCollect
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"collectType": "1",
|
||||
"providerId": 2,
|
||||
"userId": 8,
|
||||
"storeId": 12,
|
||||
"mgtState": 0,
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
############### END ####################
|
||||
|
||||
|
||||
|
||||
############### 运营商接口测试 ####################
|
||||
|
||||
### 根据运营商id,返回运营商下核消统计或售卡统计详情
|
||||
#无token时返回
|
||||
#{
|
||||
# "total": 0,
|
||||
# "rows": null,
|
||||
# "code": 300,
|
||||
# "msg": "请先登录注册"
|
||||
#}
|
||||
#token用户信息不一致返回
|
||||
#{
|
||||
# "total": 0,
|
||||
# "rows": null,
|
||||
# "code": 301,
|
||||
# "msg": "用户信息异常"
|
||||
#}
|
||||
#{
|
||||
# "total": 106,//该月份的统计
|
||||
# "rows": [
|
||||
# {
|
||||
# "cardName": "99",//卡券名称,展示使用
|
||||
# "storeName": "2商家名称001",//商家名称,展示使用
|
||||
# "staticCount": 24//统计值
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/provider/providerServiceAndSaleDetails
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{providertoken}}
|
||||
|
||||
{
|
||||
"providerId": 2,
|
||||
"staticMonth": "2021-06-01",
|
||||
"srcFlag": 0
|
||||
}
|
||||
|
||||
###
|
||||
### 根据运营商id,返回运营商下所有核消统计或售卡统计
|
||||
#返回结果说明
|
||||
#{//无token时
|
||||
# "total": 0,
|
||||
# "rows": null,
|
||||
# "code": 300,
|
||||
# "msg": "请先登录注册"
|
||||
#}
|
||||
#{//token与用户标识不一致时
|
||||
# "total": 0,
|
||||
# "rows": null,
|
||||
# "code": 301,
|
||||
# "msg": "用户信息异常"
|
||||
#}
|
||||
#查询成功
|
||||
#{
|
||||
# "total": 7,//统计月数
|
||||
# "rows": [
|
||||
# {
|
||||
# "staticMonth": "202107",//具体月份,展示使用
|
||||
# "queryMon": "2021-07-01",//具体月份,详情查询时使用
|
||||
# "staticCount": 1062//统计值,展示使用
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/provider/providerServiceAndSaleList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{providertoken}}
|
||||
|
||||
{
|
||||
"providerId": 3,
|
||||
"staticMonth": "10",
|
||||
"srcFlag": 1
|
||||
}
|
||||
|
||||
###
|
||||
GET http://localhost:8091/register
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"mobile": "13000000001",
|
||||
"code": "1234",
|
||||
"providerId": "2"
|
||||
}
|
||||
|
||||
### 无token登录 Authorization: Bearer {{providertoken}}使用token登录
|
||||
POST http://localhost:8091/login
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{providertoken}}
|
||||
|
||||
{
|
||||
"userId": 3,
|
||||
"providerId": 2,
|
||||
"userLevel": 2,
|
||||
"cardID": "11111"
|
||||
}
|
||||
|
||||
### 商家评价列表
|
||||
#返回结果说明
|
||||
#"{
|
||||
# ""total"": 151,//该商家的评价列表
|
||||
# ""rows"": [
|
||||
# {
|
||||
# ""storeId"": 130,//商家id
|
||||
# ""starLevel"": 4,//星级评价,展示使用
|
||||
# ""contentText"": ""content004542"",//评价内容
|
||||
# ""modTime"": ""2021-07-05"",//评价时间,展示使用
|
||||
# ""cardName"": ""299"",//卡券名称,展示使用
|
||||
# ""userName"": ""nick_name40221""//用户名称,展示使用
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# ""code"": 200,
|
||||
# ""msg"": ""查询成功""
|
||||
#}"
|
||||
POST http://localhost:8091//default/index/storeCommentList
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 130
|
||||
}
|
||||
|
||||
|
||||
|
||||
############### END ####################
|
||||
|
||||
|
||||
############### 小程序展示接口测试 ####################
|
||||
|
||||
|
||||
###
|
||||
### 根据运营商,商户id,查询商户详情 增加后拼接参数意味着是二维码分享?recommenderId=124&recommenderLevel=1
|
||||
#返回结果说明
|
||||
#{
|
||||
# "msg": "获取成功",//
|
||||
# "recommenderId": "124",//推荐人id,只在在url后面带有该参数时才会返回该值
|
||||
# "code": 200,
|
||||
# "data": {
|
||||
# "providerId": 4,//运营商id
|
||||
# "storeId": 124,//商家id
|
||||
# "storeName": "4商家名称008",//商家名称,展示使用
|
||||
# "storePhone": "13000004008",//商家电话,展示联系时使用
|
||||
# "serviceState": "0",//商家在线状态
|
||||
# "salerId": 1,//对应销售id
|
||||
# "storeAddr": "4商家名称008商家地址'",//商家地址,展示导航时使用
|
||||
# "storeLon": 116.6160200000,//商家位置,导航时使用
|
||||
# "storeLat": 39.8341900000,//商家位置,导航时使用
|
||||
# "onService": "2商家名称001商家地址",//商家营业信息,展示使用
|
||||
# "detail": "<p><b>详情1</b></p><p>dsfasdfsadfasdf</p><p><img src=\"http://localhost:9092/profile/upload/2021/07/12/81464a1c-c6c3-4265-bd06-fb8f84339eb3.jpg\" style=\"width: 50%;\"></p><p>fsadfsadfdsafsd</p><p>adsfsadfsaf</p><p><b>详情2</b></p><p>sdafasdfsd</p><p><img src=\"http://localhost:9092/profile/upload/2021/07/12/3b86450f-2038-43a8-accc-49ca76a6d87b.jpg\" style=\"width: 50%;\"><br><br></p>",//商家详情内容,展示使用
|
||||
# "storeCarousel1": "http://10.1.192.113:60902/profile/upload/2021/07/02/fefc46d3-dc55-4c45-af07-f21377386ba9.jpg",//商家轮播图,展示使用
|
||||
# "storeCarousel2": "http://10.1.192.113:60902/profile/upload/2021/07/02/ccc51e2e-036b-4d13-9028-adbe7bbfe176.jpg",//商家轮播图,展示使用
|
||||
# "storeCarousel3": "http://10.1.192.113:60902/profile/upload/2021/07/02/648f3997-bebf-4e27-8264-b6a2795c6b89.jpg",//商家轮播图,展示使用
|
||||
# "storeCarousel4": "http://10.1.192.113:60902/profile/upload/2021/07/02/61127f59-dd36-43ff-827b-baae7a0ea883.jpg",//商家轮播图,展示使用
|
||||
# "storeCarousel5": "http://10.1.192.113:60902/profile/upload/2021/07/02/cea01831-ab52-46ec-b8ce-dc9d64bdec6c.jpg",//商家轮播图,展示使用
|
||||
# "storeCarousel6": "http://10.1.192.113:60902/profile/upload/2021/07/02/09216bac-25fa-4112-a122-ccf140158b2d.jpg",//商家轮播图,展示使用
|
||||
# "chkCount": 262,//商家核消记录数
|
||||
# "starAvg": 2.90,//商家综合评价,展示使用
|
||||
# "segchkRecommenderStoreLableWebList": [//商家标签
|
||||
# {
|
||||
# "lableSortId": 2,//标签id
|
||||
# "lableTypeId": 2,//一级标签id
|
||||
# "lableName": "团购",//标签名称,展示使用
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
# },
|
||||
# "recommenderLevel": "1"//推荐人角色,只在在url后面带有该参数时才会返回该值
|
||||
#}
|
||||
POST http://localhost:8091//default/index/storeDetails?recommenderId=124&recommenderLevel=1
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 4,
|
||||
"storeId": 124
|
||||
}
|
||||
|
||||
###
|
||||
### 根据运营商id,返回轮播图列表
|
||||
#返回结果
|
||||
#{
|
||||
# "total": 6,//该运营商轮播图数量
|
||||
# "rows": [
|
||||
# {
|
||||
# "providerId": 2,//运营商id,跳转商家详情使用
|
||||
# "storeId": 3,//商家id,跳转商家详情使用
|
||||
# "storeCarousel": "http://10.1.192.113:60902/profile/upload/2021/07/05/606861e9-02d2-4c66-8e44-31a20ba4112d.jpg",//商家首页轮播图,展示使用
|
||||
# "sortId": 0,//轮播图顺序
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/index/getBannersByProvider
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 3
|
||||
}
|
||||
|
||||
###
|
||||
### 根据标签id,会员卡类型id,搜索商户列表
|
||||
POST http://localhost:8091//default/index/listByProviderwithLable
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 2,
|
||||
"sortType": 1,
|
||||
"lableId": 2,
|
||||
"typeId": 2,
|
||||
"userLon": 116.25849,
|
||||
"userLat": 39.684333
|
||||
}
|
||||
|
||||
###
|
||||
### 根据运营商id查询seg首页推荐商户列表
|
||||
POST http://localhost:8091//default/index/listByProvider
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 2,
|
||||
"sortType": 3,
|
||||
"userLon": 116.25849,
|
||||
"userLat": 39.684333
|
||||
}
|
||||
|
||||
###
|
||||
### 搜索商户名称,根据名称,标签,充值卡等
|
||||
#请求参数
|
||||
#{
|
||||
# "providerId": 2, //*运营商id
|
||||
# "sortType": 0, // 排序方式 0,默认排序,1热度,2评价,3距离
|
||||
# "storeName": "99", //*商家名称(即搜索内容)
|
||||
# "lableName": "99", //*标签名称(即搜索内容)
|
||||
# "userLon": 114.123456, //用户位置
|
||||
# "userLat": 43.123456 //用户位置
|
||||
#}
|
||||
#返回结果
|
||||
#{
|
||||
# "total": 51,搜索的商家数量
|
||||
# "rows": [
|
||||
# {
|
||||
# "providerId": 2,运营商id
|
||||
# "storeId": 3,商家id,用于进行商家详情查询使用
|
||||
# "storeName": "2商家名称001", 商家名称,展示使用
|
||||
# "serviceState": "0",服务状态,在线
|
||||
# "storeSort": 3,商家展示顺序
|
||||
# "storeIcon": "http://10.1.192.113:60902/profile/upload/2021/07/02/706f0a58-6031-4523-abbd-dc5dd823278c.jpg", 商家小图片,列表模式时使用
|
||||
# "storeGificon": "http://10.1.192.113:60902/profile/upload/2021/07/02/e4c00b15-84f7-491d-bb34-bf5253f7f6b7.jpg", 商家大图片,大图模式时使用
|
||||
# "storeLon": 116.2667540000, 商家位置
|
||||
# "storeLat": 39.6789740000,
|
||||
# "userDist": 0, 用户距离,展示使用
|
||||
# "chkCount": 89, 热度,展示使用
|
||||
# "starAvg": 3.16, 综合评价,展示使用
|
||||
# "salerId": 3, 销售id
|
||||
# "lables": [ 商家支持的标签列表
|
||||
# {
|
||||
# "lableId": 0, 标签id
|
||||
# "lableTypeId": 2, 一级标签id
|
||||
# "lableName": "团购", 标签名称,展示使用
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "code": 200,
|
||||
# "msg": "查询成功"
|
||||
#}
|
||||
POST http://localhost:8091//default/index/StoreSearch
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"providerId": 2,
|
||||
"sortType": 0,
|
||||
"storeName": "99",
|
||||
"lableName": "99",
|
||||
"userLon": 114.123456,
|
||||
"userLat": 43.123456
|
||||
}
|
||||
|
||||
###查询seg标签列表
|
||||
###返回值说明
|
||||
#"{
|
||||
# ""total"": 7,首页标签区域运营商的标签列表,超过8个时最后一个标签为更多
|
||||
# ""rows"": [
|
||||
# {
|
||||
# ""lableId"": 0, 子标签id,查询使用
|
||||
# ""lableSortId"": 0, 标签显示顺序,一级标签下的显示顺序
|
||||
# ""lableTypeId"": 0, 一级标签id,查询使用
|
||||
# ""lableName"": ""9块9"", 标签名称,展示使用
|
||||
# ""lablePic"": ""http://10.1.192.113:60902/profile/upload/2021/07/05/4f8fb474-97d9-4547-afca-47a2ca1d5180.jpg"" 标签图标,展示使用
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# ""code"": 200,
|
||||
# ""msg"": ""查询成功""
|
||||
#}"
|
||||
GET http://localhost:8091//default/index/lableListByProvider?providerId=2
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
|
||||
###
|
||||
### 根据用户当前所在地市行政id,返回运营商id 尹志颖
|
||||
### 返回值说明 {
|
||||
# "code": 200,
|
||||
# "data": 2//该值用于在小程序内部留存,在后续接口请求时都会用到
|
||||
#}
|
||||
GET http://localhost:8091//default/index/getProviderByadcode
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
130502
|
||||
|
||||
###
|
||||
### 测试微信账号绑定
|
||||
GET http://localhost:8091//bindaccount
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token1}}
|
||||
|
||||
{
|
||||
"userId": "503",
|
||||
"providerId": "2",
|
||||
"userLevel": "2",
|
||||
"code": "001kiv000uUEsM11G5000vLWKN2kiv0m"
|
||||
}
|
||||
|
||||
### 测试token取值
|
||||
GET http://localhost:8091/tokentest
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{{bindtoken1}}
|
||||
|
||||
### 用户利用token进行登录
|
||||
POST http://yxr8cu.natappfree.cc/login
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{bindtoken}}
|
||||
|
||||
{
|
||||
"userId": 3,
|
||||
"providerId": 2,
|
||||
"userLevel": 2,
|
||||
"cardID": "11111"
|
||||
}
|
||||
|
||||
### 已有用户的登录注册标识
|
||||
GET http://localhost:8091/register
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"mobile": "13000020002",
|
||||
"code": "1234",
|
||||
"providerId": "2",
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
> {% client.global.set("token2", response.body.data.token); %}
|
||||
|
||||
### 进行新用户注册 remark测试标识
|
||||
GET http://localhost:8091/register
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"mobile": "99999999999",
|
||||
"code": "1234",
|
||||
"recommendId": "5",
|
||||
"recommendLevel": "1",
|
||||
"providerId": "2",
|
||||
"remark": "999999"
|
||||
}
|
||||
|
||||
> {% client.global.set("token1", response.body.data.token); %}
|
||||
|
||||
### 发送短信验证码
|
||||
POST http://localhost:8091/sendmobilecode?mobile=99999999999
|
||||
Accept: */*
|
||||
Cache-Control: no-cache
|
||||
Content-Type: application/json
|
||||
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-segchk</artifactId>
|
||||
|
||||
<properties>
|
||||
<alipay.version>4.8.10.ALL</alipay.version>
|
||||
</properties>
|
||||
<description>
|
||||
system系统模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 生成二维码的jar -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>${alipay.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
<!--dom4j -->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--腾讯云短信-->
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.0.6</version> <!-- 注:如提示报错,先升级基础包版,无法解决可联系技术支持 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<!--腾讯云OSS-->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>5.6.8</version>
|
||||
</dependency>
|
||||
<!-- 阿里云OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.ruoyi</groupId>-->
|
||||
<!-- <artifactId>ruoyi-common</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.5.6</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,891 @@
|
|||
package com.ruoyi.member.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.util.ShareCodeUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 会员对象 ums_member
|
||||
*
|
||||
* @author 魔金商城
|
||||
* @date 2020-07-25
|
||||
*/
|
||||
public class UmsMember extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Excel(name = "用户名")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@Excel(name = "用户密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@Excel(name = "昵称")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
@Excel(name = "头像地址")
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@Excel(name = "真实姓名")
|
||||
private String relename;
|
||||
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
@Excel(name = "身份证")
|
||||
private String cardid;
|
||||
|
||||
/**
|
||||
* 性别 0 保密 1男 2女 默认0
|
||||
*/
|
||||
@Excel(name = "性别 0 保密 1男 2女 默认0")
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 月收入 0 无收入 1 2000以下 2 2000-3999 3 4000-59994 6000-7999 5 8000以上
|
||||
*/
|
||||
@Excel(name = "月收入 0 无收入 1 2000以下 2 2000-3999 3 4000-5999 4 6000-7999 5 8000以上")
|
||||
private String monthlyIncome;
|
||||
|
||||
/**
|
||||
* 婚姻状况 0 保密 1未婚 2 已婚 默认0 保姆
|
||||
*/
|
||||
@Excel(name = "婚姻状况 0 保密 1未婚 2 已婚 默认0 保姆")
|
||||
private String marriageStatus;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Excel(name = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 邮箱地址
|
||||
*/
|
||||
@Excel(name = "邮箱地址")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 更改中的邮箱(绑定新邮箱使用)
|
||||
*/
|
||||
@Excel(name = "更改中的邮箱", readConverterExp = "绑=定新邮箱使用")
|
||||
private String modifiedEmail;
|
||||
|
||||
/**
|
||||
* 校验码(绑定新邮箱时使用)
|
||||
*/
|
||||
@Excel(name = "校验码", readConverterExp = "绑=定新邮箱时使用")
|
||||
private String checkCode;
|
||||
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
@Excel(name = "省")
|
||||
private Long province;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
@Excel(name = "市")
|
||||
private Long city;
|
||||
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
@Excel(name = "区")
|
||||
private Long county;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
@Excel(name = "详细地址")
|
||||
private String detailaddress;
|
||||
|
||||
/**
|
||||
* 兴趣爱好
|
||||
*/
|
||||
@Excel(name = "兴趣爱好")
|
||||
private String interest;
|
||||
|
||||
/**
|
||||
* 店铺id 平台的为0 默认为平台
|
||||
*/
|
||||
@Excel(name = "店铺id 平台的为0 默认为平台")
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* 1 普通用户 2 商家店铺用户 3 店铺员工
|
||||
*/
|
||||
@Excel(name = "1 普通用户 2 商家店铺用户 3 店铺员工")
|
||||
private String type;
|
||||
|
||||
private String appletOpenId;
|
||||
|
||||
private String appOpenId;
|
||||
|
||||
private String h5OpenId;
|
||||
/**
|
||||
* 总的消费金额
|
||||
*/
|
||||
@Excel(name = "总的消费金额")
|
||||
private BigDecimal consumptionAmount;
|
||||
|
||||
/**
|
||||
* 预存款支付密码
|
||||
*/
|
||||
@Excel(name = "预存款支付密码")
|
||||
private String paypassword;
|
||||
|
||||
/**
|
||||
* 用户注册来源 1 pc 2app 3 手机h5 4 管理员后台新增 5applet
|
||||
*/
|
||||
@Excel(name = "用户注册来源 1 pc 2app 3 手机h5 4 管理员后台新增 ")
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 用户状态 1 正常 2 冻结 3 未启用 默认1
|
||||
*/
|
||||
@Excel(name = "用户状态 1 正常 2 冻结 3 未启用 默认1 ")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 会员签到次数
|
||||
*/
|
||||
@Excel(name = "会员签到次数")
|
||||
private int signNum;
|
||||
|
||||
/**
|
||||
* 手机是否验证 0 否 1 验证 默认0
|
||||
*/
|
||||
@Excel(name = "手机是否验证 0 否 1 验证 默认0 ")
|
||||
private String isMobileVerification;
|
||||
|
||||
/**
|
||||
* 邮箱是否验证 0 否 1 验证 默认0
|
||||
*/
|
||||
@Excel(name = "邮箱是否验证 0 否 1 验证 默认0 ")
|
||||
private String isEmailVerification;
|
||||
|
||||
/**
|
||||
* 错误登录的次数
|
||||
*/
|
||||
@Excel(name = "错误登录的次数")
|
||||
private int loginErrorCount;
|
||||
|
||||
/**
|
||||
* 删除标记 0 未删除 1删除 默认0
|
||||
*/
|
||||
private int delFlag;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date delTime;
|
||||
|
||||
/**
|
||||
* 锁定时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "锁定时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private LocalDateTime lockTime;
|
||||
|
||||
/**
|
||||
* 最近登陆时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "最近登陆时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* 推荐人的会员id 如果没有 则为-1 默认为-1
|
||||
*/
|
||||
@Excel(name = "推荐人的会员id 如果没有 则为-1 默认为-1")
|
||||
private Long recommended = -1L;
|
||||
|
||||
/**
|
||||
* 二级推荐人的会员id (上级的上级) 如果没有 则为-1 默认为-1
|
||||
*/
|
||||
@Excel(name = "二级推荐人的会员id ", readConverterExp = "上=级的上级")
|
||||
private Long sRecommended = -1L;
|
||||
|
||||
/**
|
||||
* 会员自己的推荐码
|
||||
*/
|
||||
@Excel(name = "会员自己的推荐码")
|
||||
private String selfRecommendCode;
|
||||
|
||||
/**
|
||||
* 会员的佣金
|
||||
*/
|
||||
@Excel(name = "会员的佣金")
|
||||
private BigDecimal commission;
|
||||
|
||||
/**
|
||||
* 会员所属的店铺id
|
||||
*/
|
||||
@Excel(name = "会员所属的店铺id")
|
||||
private Long beloneStoreId;
|
||||
/**
|
||||
* 用户积分
|
||||
*/
|
||||
@ApiModelProperty(value = "用户积分")
|
||||
private int customerPoint;
|
||||
private int subSpreadCustomerCount;
|
||||
/**
|
||||
* 推荐人code 如果为空 则说明没有推荐人
|
||||
*/
|
||||
private String recommondCode;
|
||||
/**
|
||||
* 自动注册渠道类型
|
||||
*/
|
||||
@ApiModelProperty(value = "自动注册渠道类型")
|
||||
private String channelType;
|
||||
private UmsMemberLevel customerLevel;
|
||||
|
||||
private BigDecimal allPredeposit;
|
||||
|
||||
/**
|
||||
* 构造app用户注册对象
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param password 密码
|
||||
* @param recommondCode 推荐吗
|
||||
* @return 返回app用户注册对象
|
||||
*/
|
||||
public static UmsMember buildAppRegisterCustomer(String mobile, String password, String recommondCode) {
|
||||
UmsMember customer = new UmsMember();
|
||||
customer.username = mobile;
|
||||
customer.password = password;
|
||||
customer.mobile = mobile;
|
||||
customer.type = "1";
|
||||
customer.source = "2";
|
||||
customer.isMobileVerification = "1";
|
||||
|
||||
customer.recommondCode = recommondCode;
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造h5用户注册对象
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param recommondCode 推荐吗
|
||||
* @return 返回app用户注册对象
|
||||
*/
|
||||
public static UmsMember buildH5RegisterCustomer(String mobile, String recommondCode) {
|
||||
UmsMember customer = new UmsMember();
|
||||
customer.username = mobile;
|
||||
customer.password = "123456";
|
||||
customer.mobile = mobile;
|
||||
customer.type = "1";
|
||||
customer.source = "3";
|
||||
customer.isMobileVerification = "1";
|
||||
|
||||
customer.recommondCode = recommondCode;
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造代客下单自动注册对象
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @return 返回代客下单自动注册对象
|
||||
*/
|
||||
public static UmsMember buildStoreShoppingRegisterCustomer(String mobile, long beloneStoreId) {
|
||||
UmsMember customer = new UmsMember();
|
||||
customer.username = mobile;
|
||||
customer.password = "123456";
|
||||
customer.mobile = mobile;
|
||||
customer.type = "1";
|
||||
customer.source = "4";
|
||||
customer.status = "1";
|
||||
customer.storeId = 0L;
|
||||
customer.isMobileVerification = "1";
|
||||
customer.beloneStoreId = beloneStoreId;
|
||||
return customer;
|
||||
|
||||
}
|
||||
|
||||
public int getSubSpreadCustomerCount() {
|
||||
return subSpreadCustomerCount;
|
||||
}
|
||||
|
||||
public void setSubSpreadCustomerCount(int subSpreadCustomerCount) {
|
||||
this.subSpreadCustomerCount = subSpreadCustomerCount;
|
||||
}
|
||||
|
||||
public String getRecommondCode() {
|
||||
return recommondCode;
|
||||
}
|
||||
|
||||
public void setRecommondCode(String recommondCode) {
|
||||
this.recommondCode = recommondCode;
|
||||
}
|
||||
|
||||
public UmsMemberLevel getCustomerLevel() {
|
||||
return customerLevel;
|
||||
}
|
||||
|
||||
public void setCustomerLevel(UmsMemberLevel customerLevel) {
|
||||
this.customerLevel = customerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下级分销会员数量
|
||||
*
|
||||
* @param subSpreadCustomerCount 下级分销会员数量
|
||||
* @return 返回当前对象
|
||||
*/
|
||||
public UmsMember addSubSpreadCustomerCount(int subSpreadCustomerCount) {
|
||||
this.subSpreadCustomerCount = subSpreadCustomerCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自己的推荐吗
|
||||
*
|
||||
* @return 返回当前对象
|
||||
*/
|
||||
public UmsMember addSelfRecommondCode() {
|
||||
this.selfRecommendCode = ShareCodeUtils.toSerialCode(Long.parseLong(this.mobile));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有推荐人 有返回true 没有返回false
|
||||
*
|
||||
* @return 有返回true 没有返回false
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean hasRecommonded() {
|
||||
return !StringUtils.isEmpty(this.recommondCode) || this.recommended != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端添加用户设置默认值
|
||||
*
|
||||
* @return 返回用户信息
|
||||
*/
|
||||
public UmsMember setDefaultValuesForAdminAdd() {
|
||||
this.storeId = 0L;
|
||||
this.type = "1";
|
||||
this.source = "4";
|
||||
this.status = "1";
|
||||
this.isMobileVerification = "1";
|
||||
if (!StringUtils.isEmpty(this.email)) {
|
||||
this.isEmailVerification = "1";
|
||||
}
|
||||
|
||||
this.beloneStoreId = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置归属门店id
|
||||
*
|
||||
* @param beloneStoreId 归属门店id
|
||||
* @return 返回用户信息
|
||||
*/
|
||||
public UmsMember setBelongStoreIdForStore(long beloneStoreId) {
|
||||
this.beloneStoreId = beloneStoreId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除用户密码
|
||||
*/
|
||||
public UmsMember clearPassword() {
|
||||
this.password = "**********";
|
||||
if (!StringUtils.isEmpty(this.paypassword)) {
|
||||
this.paypassword = "**********";
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员对象
|
||||
*
|
||||
* @param customerId 会员id
|
||||
* @return 会员对象
|
||||
*/
|
||||
public UmsMember setCustomerId(long customerId) {
|
||||
this.id = customerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得会员的会员等级id
|
||||
*
|
||||
* @return 返回会员的会员等级id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public long getCustomerLevelId() {
|
||||
return Objects.isNull(this.customerLevel) ? -1 : this.customerLevel.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得会员等级名称
|
||||
*
|
||||
* @return 返回会员等级名称
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getCustomerLevelName() {
|
||||
return Objects.isNull(this.customerLevel) ? "" : this.customerLevel.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更改金额
|
||||
*
|
||||
* @param money 更改金额
|
||||
* @return true 可以更改 false 更改后总金额小于0,不可以更改
|
||||
*/
|
||||
public boolean checkConsumptionAmount(BigDecimal money) {
|
||||
if (money.intValue() >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (money.abs().compareTo(this.consumptionAmount) > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更改佣金金额
|
||||
*
|
||||
* @param money 更改佣金金额
|
||||
* @return true 可以更改 false 更改后总金额小于0,不可以更改
|
||||
*/
|
||||
public boolean checkCommission(BigDecimal money) {
|
||||
if (money.intValue() >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (money.abs().compareTo(this.commission) > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 为用户添加用户名
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public UmsMember addUsername(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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 getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getRelename() {
|
||||
return relename;
|
||||
}
|
||||
|
||||
public void setRelename(String relename) {
|
||||
this.relename = relename;
|
||||
}
|
||||
|
||||
public String getCardid() {
|
||||
return cardid;
|
||||
}
|
||||
|
||||
public void setCardid(String cardid) {
|
||||
this.cardid = cardid;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getMonthlyIncome() {
|
||||
return monthlyIncome;
|
||||
}
|
||||
|
||||
public void setMonthlyIncome(String monthlyIncome) {
|
||||
this.monthlyIncome = monthlyIncome;
|
||||
}
|
||||
|
||||
public String getMarriageStatus() {
|
||||
return marriageStatus;
|
||||
}
|
||||
|
||||
public void setMarriageStatus(String marriageStatus) {
|
||||
this.marriageStatus = marriageStatus;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getModifiedEmail() {
|
||||
return modifiedEmail;
|
||||
}
|
||||
|
||||
public void setModifiedEmail(String modifiedEmail) {
|
||||
this.modifiedEmail = modifiedEmail;
|
||||
}
|
||||
|
||||
public String getCheckCode() {
|
||||
return checkCode;
|
||||
}
|
||||
|
||||
public void setCheckCode(String checkCode) {
|
||||
this.checkCode = checkCode;
|
||||
}
|
||||
|
||||
public Long getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(Long province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public Long getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(Long city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public Long getCounty() {
|
||||
return county;
|
||||
}
|
||||
|
||||
public void setCounty(Long county) {
|
||||
this.county = county;
|
||||
}
|
||||
|
||||
public String getDetailaddress() {
|
||||
return detailaddress;
|
||||
}
|
||||
|
||||
public void setDetailaddress(String detailaddress) {
|
||||
this.detailaddress = detailaddress;
|
||||
}
|
||||
|
||||
public String getInterest() {
|
||||
return interest;
|
||||
}
|
||||
|
||||
public void setInterest(String interest) {
|
||||
this.interest = interest;
|
||||
}
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Long storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAppletOpenId() {
|
||||
return appletOpenId;
|
||||
}
|
||||
|
||||
public void setAppletOpenId(String appletOpenId) {
|
||||
this.appletOpenId = appletOpenId;
|
||||
}
|
||||
|
||||
public String getAppOpenId() {
|
||||
return appOpenId;
|
||||
}
|
||||
|
||||
public void setAppOpenId(String appOpenId) {
|
||||
this.appOpenId = appOpenId;
|
||||
}
|
||||
|
||||
public String getH5OpenId() {
|
||||
return h5OpenId;
|
||||
}
|
||||
|
||||
public void setH5OpenId(String h5OpenId) {
|
||||
this.h5OpenId = h5OpenId;
|
||||
}
|
||||
|
||||
public BigDecimal getConsumptionAmount() {
|
||||
return consumptionAmount;
|
||||
}
|
||||
|
||||
public void setConsumptionAmount(BigDecimal consumptionAmount) {
|
||||
this.consumptionAmount = consumptionAmount;
|
||||
}
|
||||
|
||||
public String getPaypassword() {
|
||||
return paypassword;
|
||||
}
|
||||
|
||||
public void setPaypassword(String paypassword) {
|
||||
this.paypassword = paypassword;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getSignNum() {
|
||||
return signNum;
|
||||
}
|
||||
|
||||
public void setSignNum(int signNum) {
|
||||
this.signNum = signNum;
|
||||
}
|
||||
|
||||
public String getIsMobileVerification() {
|
||||
return isMobileVerification;
|
||||
}
|
||||
|
||||
public void setIsMobileVerification(String isMobileVerification) {
|
||||
this.isMobileVerification = isMobileVerification;
|
||||
}
|
||||
|
||||
public String getIsEmailVerification() {
|
||||
return isEmailVerification;
|
||||
}
|
||||
|
||||
public void setIsEmailVerification(String isEmailVerification) {
|
||||
this.isEmailVerification = isEmailVerification;
|
||||
}
|
||||
|
||||
public int getLoginErrorCount() {
|
||||
return loginErrorCount;
|
||||
}
|
||||
|
||||
public void setLoginErrorCount(int loginErrorCount) {
|
||||
this.loginErrorCount = loginErrorCount;
|
||||
}
|
||||
|
||||
public int getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(int delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Date getDelTime() {
|
||||
return delTime;
|
||||
}
|
||||
|
||||
public void setDelTime(Date delTime) {
|
||||
this.delTime = delTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getLockTime() {
|
||||
return lockTime;
|
||||
}
|
||||
|
||||
public void setLockTime(LocalDateTime lockTime) {
|
||||
this.lockTime = lockTime;
|
||||
}
|
||||
|
||||
public Date getLastLoginTime() {
|
||||
return lastLoginTime;
|
||||
}
|
||||
|
||||
public void setLastLoginTime(Date lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
public Long getRecommended() {
|
||||
return recommended;
|
||||
}
|
||||
|
||||
public void setRecommended(Long recommended) {
|
||||
this.recommended = recommended;
|
||||
}
|
||||
|
||||
public Long getsRecommended() {
|
||||
return sRecommended;
|
||||
}
|
||||
|
||||
public void setsRecommended(Long sRecommended) {
|
||||
this.sRecommended = sRecommended;
|
||||
}
|
||||
|
||||
public String getSelfRecommendCode() {
|
||||
return selfRecommendCode;
|
||||
}
|
||||
|
||||
public void setSelfRecommendCode(String selfRecommendCode) {
|
||||
this.selfRecommendCode = selfRecommendCode;
|
||||
}
|
||||
|
||||
public BigDecimal getCommission() {
|
||||
return commission;
|
||||
}
|
||||
|
||||
public void setCommission(BigDecimal commission) {
|
||||
this.commission = commission;
|
||||
}
|
||||
|
||||
public Long getBeloneStoreId() {
|
||||
return beloneStoreId;
|
||||
}
|
||||
|
||||
public void setBeloneStoreId(Long beloneStoreId) {
|
||||
this.beloneStoreId = beloneStoreId;
|
||||
}
|
||||
|
||||
public int getCustomerPoint() {
|
||||
return customerPoint;
|
||||
}
|
||||
|
||||
public void setCustomerPoint(int customerPoint) {
|
||||
this.customerPoint = customerPoint;
|
||||
}
|
||||
|
||||
public String getChannelType() {
|
||||
return channelType;
|
||||
}
|
||||
|
||||
public void setChannelType(String channelType) {
|
||||
this.channelType = channelType;
|
||||
}
|
||||
|
||||
public BigDecimal getAllPredeposit() {
|
||||
return allPredeposit;
|
||||
}
|
||||
|
||||
public void setAllPredeposit(BigDecimal allPredeposit) {
|
||||
this.allPredeposit = allPredeposit;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package com.ruoyi.member.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 会员等级对象 ums_member_level
|
||||
*
|
||||
* @author 魔金商城
|
||||
* @date 2020-07-25
|
||||
*/
|
||||
public class UmsMemberLevel extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员等级名称
|
||||
*/
|
||||
@Excel(name = "会员等级名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 消费小值(包含该值)
|
||||
*/
|
||||
@Excel(name = "消费小值", readConverterExp = "包=含该值")
|
||||
private Long minMoney;
|
||||
|
||||
/**
|
||||
* 消费金额最大值 不包含该值
|
||||
*/
|
||||
@Excel(name = "消费金额最大值 不包含该值")
|
||||
private Long maxMoney;
|
||||
|
||||
/**
|
||||
* 会员折扣
|
||||
*/
|
||||
@Excel(name = "会员折扣")
|
||||
private BigDecimal discount;
|
||||
|
||||
/**
|
||||
* 删除标记 0 未删除 1删除 默认0
|
||||
*/
|
||||
private int delFlag;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date delTime;
|
||||
|
||||
/**
|
||||
* 构造未知等级实体
|
||||
*
|
||||
* @return 返回未知等级实体
|
||||
*/
|
||||
public static UmsMemberLevel buildNoLevel() {
|
||||
UmsMemberLevel customerLevel = new UmsMemberLevel();
|
||||
customerLevel.name = "非会员";
|
||||
return customerLevel;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getMinMoney() {
|
||||
return minMoney;
|
||||
}
|
||||
|
||||
public void setMinMoney(Long minMoney) {
|
||||
this.minMoney = minMoney;
|
||||
}
|
||||
|
||||
public Long getMaxMoney() {
|
||||
return maxMoney;
|
||||
}
|
||||
|
||||
public void setMaxMoney(Long maxMoney) {
|
||||
this.maxMoney = maxMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(BigDecimal discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public int getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(int delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Date getDelTime() {
|
||||
return delTime;
|
||||
}
|
||||
|
||||
public void setDelTime(Date delTime) {
|
||||
this.delTime = delTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的金额判断 是否是当前等级
|
||||
*
|
||||
* @param money 传入金金额
|
||||
* @return 判断规则 [0,100) 前闭后开 包含0 不包含100
|
||||
*/
|
||||
public boolean isCurrentLevl(BigDecimal money) {
|
||||
if (Objects.isNull(money)) {
|
||||
return false;
|
||||
}
|
||||
return money.intValue() >= this.minMoney && money.intValue() < this.maxMoney;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断传入的会员等级消费金额和当前的会员等级消费金额是否有交集
|
||||
*
|
||||
* @param customerLevel 会员等级
|
||||
* @return 有返回true 没有返回false 传入的值为空 返回false
|
||||
*/
|
||||
public boolean hasIntersection(UmsMemberLevel customerLevel) {
|
||||
if (Objects.isNull(customerLevel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果传入的最小值比当前的最大值要大于等于 则肯定没有交集
|
||||
if (customerLevel.minMoney >= this.maxMoney) {
|
||||
return false;
|
||||
}
|
||||
if (customerLevel.minMoney >= customerLevel.maxMoney) {
|
||||
return true;
|
||||
}
|
||||
// 如果传入的最小值在当前会员等级最大值和最小值之间(不包含最大值 包含最小值) 则肯定会有交集
|
||||
if (customerLevel.minMoney >= this.minMoney && customerLevel.minMoney < this.maxMoney) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果传入的最小值在比当前的最小值还小 则看传入的最大值
|
||||
if (customerLevel.minMoney < this.minMoney) {
|
||||
if (customerLevel.maxMoney <= this.minMoney) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("minMoney", getMinMoney())
|
||||
.append("maxMoney", getMaxMoney())
|
||||
.append("discount", getDiscount())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("modifyTime", getModifyTime())
|
||||
.append("delTime", getDelTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.ruoyi.member.mapper;
|
||||
|
||||
|
||||
import com.ruoyi.segchk.domain.WeChatCustomerLink;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 微信用户关联数据库接口
|
||||
*/
|
||||
@Repository
|
||||
public interface WeChatCustomerLinkMapper {
|
||||
|
||||
/**
|
||||
* 根据openId查询关联实体
|
||||
*
|
||||
* @param openId 微信用户唯一标识
|
||||
*/
|
||||
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByOpenId(String openId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据customerId查询关联实体
|
||||
*
|
||||
* @param customerId 用户id
|
||||
*/
|
||||
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByCustomerId(long customerId);
|
||||
|
||||
/**
|
||||
* 根据unionId查询关联实体
|
||||
*
|
||||
* @param unionId 微信联合登录id
|
||||
*/
|
||||
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByUnionId(String unionId);
|
||||
|
||||
/**
|
||||
* 增加关联
|
||||
*
|
||||
* @param weChatCustomerLink 关联实体
|
||||
* @return 1:成功
|
||||
*/
|
||||
|
||||
int addWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink);
|
||||
|
||||
/**
|
||||
* 删除关联
|
||||
*
|
||||
* @param customerId 用户id
|
||||
* @return 1:成功
|
||||
*/
|
||||
|
||||
int deleteWeChatCustomerLink(long customerId);
|
||||
|
||||
/**
|
||||
* 更新微信用户关联
|
||||
*
|
||||
* @param weChatCustomerLink 微信用户关联实体
|
||||
* @return 1成功 否则失败
|
||||
*/
|
||||
|
||||
int updateWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.segchk.domain.SegchkUserWebReq;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/7/17.
|
||||
* 登录接口
|
||||
*/
|
||||
public interface LoginService {
|
||||
|
||||
|
||||
/**
|
||||
* segchk前端登录 (app,pc,mobile)
|
||||
*
|
||||
* @param segchkUserWebReq 登入参数
|
||||
* @return 返回码 -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
*/
|
||||
AjaxResult login(SegchkUserWebReq segchkUserWebReq);
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 充值服务
|
||||
*/
|
||||
public interface RechargeService {
|
||||
|
||||
/**
|
||||
* 支付宝pc支付
|
||||
*
|
||||
* @param money 充值金额
|
||||
* @param customerId 用户id
|
||||
* @param type 支付类型 1:订单支付 2:预存款充值
|
||||
* @return 返回码和支付宝支付的html 返回码说明 -1:用户不存在 -2:生成充值记录出错 -5:支付宝生成订单出错 -7 没有设置网站地址 -8 缺少配置 -9 没有启用 1 成功
|
||||
*/
|
||||
AjaxResult aliPagePay(String transCode, BigDecimal money, int payType, long customerId, int type);
|
||||
|
||||
/**
|
||||
* 微信扫码支付
|
||||
*
|
||||
* @param money 充值金额
|
||||
* @param customerId 用户id
|
||||
* @param ip 请求真实ip
|
||||
* @param type 支付类型 1:订单支付 2:预存款充值
|
||||
* @return 返回码和支付宝支付的html 返回码说明 -1:用户不存在 -2:生成充值记录出错 -5:微信生成订单出错 -7 没有设置网站地址 -8 缺少配置 -9 没有启用 1 成功
|
||||
*/
|
||||
AjaxResult wechatQRPay(String transCode, BigDecimal money, int payType, long customerId, String ip, int type);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/18.
|
||||
* 注册服务接口
|
||||
*/
|
||||
public interface RegisterService {
|
||||
|
||||
/**
|
||||
* 发送注册短信验证码
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param consumer 回调接口
|
||||
* @return 0 成功 1 失败 -1 手机号码已经存在
|
||||
*/
|
||||
int sendRegisterSmsCode(String mobile, Consumer<String> consumer);
|
||||
|
||||
/**
|
||||
* 发送注册短信验证码(PC端用,带有图片验证码)
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param kaptcha 用户输入的图片验证码
|
||||
* @param oldKaptcha redis中的图片验证码
|
||||
* @param consumer 回调接口
|
||||
* @return 0 成功 1 失败 -4 手机号码已经存在 -1 图片验证码失效或不存在 -2 图片验证码为空 -3 图片证码不正确
|
||||
*/
|
||||
int sendRegisterSmsCodeForPc(String mobile, String kaptcha, String oldKaptcha, Consumer<String> consumer);
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param password 密码
|
||||
* @param code 用户输入的手机验证码
|
||||
* @param originCode 生成的手机验证码
|
||||
* @param recommondCode 推荐吗
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
int registerCustomer(String mobile, String password, String code, String originCode, String recommondCode);
|
||||
|
||||
/**
|
||||
* 免密用户自动注册
|
||||
*
|
||||
* @param phoneNo 手机号码
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
Long unAuthRegister(String phoneNo, String channelType);
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param kaptcha 验证码
|
||||
* @param kaptchaInSession session中的验证码
|
||||
* @return -1 验证码失效或不存在 -2 验证码为空 -3验证码不正确 1 成功
|
||||
*/
|
||||
int checkKaptcha(String kaptcha, String kaptchaInSession);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
/**
|
||||
* 注册服务聚合接口
|
||||
*/
|
||||
public interface RegisterServiceApi {
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param password 密码
|
||||
* @param code 用户输入的手机验证码
|
||||
* @param originCode 生成的手机验证码
|
||||
* @param recommondCode 推荐吗
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
// int registerCustomer(String mobile, String password, String code, String originCode, String recommondCode);
|
||||
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param code 用户输入的手机验证码
|
||||
* @param originCode 生成的手机验证码
|
||||
* @param recommondId 推荐吗
|
||||
* @param recommondLevel 推荐角色
|
||||
* @param providerId
|
||||
* @param remark
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
AjaxResult registerCustomer(String mobile, String code, String originCode, String recommondId, String recommondLevel, String providerId, String remark);
|
||||
|
||||
String createToke(String subject, Long userId, Long providerId, Integer userLevel);
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/18.
|
||||
* 短信验证码服务接口
|
||||
*/
|
||||
public interface SmsService {
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param content 发送内容
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
int sendSms(String phone, String content);
|
||||
|
||||
/**
|
||||
* 发送核销码短信
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param code 订单号
|
||||
* @param writeOffCode 核销码
|
||||
* @param storeName 店铺名称
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
int sendWiteOffCodeSms(String phone, String code, String writeOffCode, String storeName);
|
||||
|
||||
/**
|
||||
* 发送虚拟商品订单核销码短信
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param code 订单号
|
||||
* @param writeOffCode 核销码
|
||||
* @param storeName 店铺名称
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
int sendVirtualOrderWiteOffCodeSms(String phone, String code, String writeOffCode, String storeName);
|
||||
|
||||
|
||||
/**
|
||||
* 发送社区团购审核结果通知短信
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param submittime 通过时间
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
int sendAuditTemplateOffCodeSms(String phone, String submittime);
|
||||
|
||||
/**
|
||||
* 发送社区团购结算短信
|
||||
*
|
||||
* @param communityName 社区团购名称
|
||||
* @param price 佣金
|
||||
* @param phone 手机号码
|
||||
* @return 成功发挥0 失败返回1
|
||||
*/
|
||||
int sendCommunityBuySettlementSms(String phone, String communityName, BigDecimal price);
|
||||
|
||||
/**
|
||||
* 社区团购提现申请打款通知
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param submittime 打款时间
|
||||
* @param price 金额
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
int sendCommunityBuyWitudrawSms(String phone, String submittime, BigDecimal price);
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
|
||||
import com.ruoyi.member.vo.AppletLoginInfo;
|
||||
import com.ruoyi.member.vo.AppletLoginRedisParamResponse;
|
||||
import com.ruoyi.util.WeChatAppletUserInfo;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 微信小程序登录服务
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
public interface WeChatAppletLoginService {
|
||||
|
||||
/**
|
||||
* 小程序获取登录信息
|
||||
*
|
||||
* @param code 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 api,使用 code 换取 openid 和 session_key 等信息
|
||||
* @param unionId 联合登录id
|
||||
* @param claimsConsumer 回调
|
||||
* @return 登录信息
|
||||
*/
|
||||
AppletLoginInfo getLoginInfo(String code, String unionId, Consumer<AppletLoginRedisParamResponse> claimsConsumer);
|
||||
|
||||
/**
|
||||
* 处理小程序用户信息
|
||||
*
|
||||
* @param weChatAppletUserInfo 小程序用户信息实体
|
||||
* @param openId 微信用户标识
|
||||
* @param sessionKey 小程序sessionKey
|
||||
* @param claimsConsumer 回调
|
||||
* @return 登录信息
|
||||
*/
|
||||
AppletLoginInfo dealUserInfo(WeChatAppletUserInfo weChatAppletUserInfo, String openId, String sessionKey, Consumer<AppletLoginRedisParamResponse> claimsConsumer);
|
||||
|
||||
|
||||
/**
|
||||
* 检验用户是否已绑定
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return -9已经绑定过 1:没有绑定
|
||||
*/
|
||||
int checkCustomerBind(String userName);
|
||||
|
||||
/**
|
||||
* 绑定账号
|
||||
*
|
||||
* @param openId 微信用户唯一标识
|
||||
* @param unionId 微信联合登录id
|
||||
* @param customerId 用户id
|
||||
* @return 1:成功
|
||||
*/
|
||||
int bindAccount(String openId, String unionId, long customerId);
|
||||
|
||||
/**
|
||||
* 解绑账号
|
||||
*
|
||||
* @param customerId 用户id
|
||||
* @param unionId 联合登录id,用于redis缓存
|
||||
* @return 1:成功
|
||||
*/
|
||||
int unbindAccount(long customerId, String unionId);
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.ruoyi.member.service;
|
||||
|
||||
|
||||
import com.ruoyi.segchk.domain.SegchkUserWechat;
|
||||
import com.ruoyi.segchk.domain.WeChatCustomerLink;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 微信用户关联服务接口
|
||||
*/
|
||||
@Repository
|
||||
public interface WeChatCustomerLinkService {
|
||||
|
||||
/**
|
||||
* 增加关联
|
||||
*
|
||||
* @param weChatCustomerLink 关联实体
|
||||
* @return 1:成功
|
||||
*/
|
||||
int addWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink);
|
||||
|
||||
/**
|
||||
* 根据openId查询关联实体
|
||||
*
|
||||
* @param openId 微信用户唯一标识
|
||||
*/
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByOpenId(String openId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id查询关联实体
|
||||
*
|
||||
* @param customerId 用户id
|
||||
*/
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByCustomerId(long customerId);
|
||||
|
||||
/**
|
||||
* 根据用户名查询关联实体
|
||||
*
|
||||
* @param userName 用户名
|
||||
*/
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 根据unionId查询关联实体
|
||||
*
|
||||
* @param unionId 微信联合登录id
|
||||
*/
|
||||
WeChatCustomerLink queryWeChatCustomerLinkByUnionId(String unionId);
|
||||
|
||||
|
||||
/**
|
||||
* 解绑账号
|
||||
*
|
||||
* @param customerId 用户id
|
||||
* @param unionId 联合登录id,redis缓存使用
|
||||
* @return 1:成功
|
||||
*/
|
||||
int unbindWeChatCustomerLink(long customerId, String unionId);
|
||||
|
||||
|
||||
/**
|
||||
* 更新微信用户关联
|
||||
*
|
||||
* @param weChatCustomerLink 微信用户关联实体
|
||||
* @return 1成功 否则失败
|
||||
*/
|
||||
int updateWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink);
|
||||
|
||||
/**
|
||||
* 更新微信用户关联
|
||||
*
|
||||
* @param segchkUserWechat 微信用户关联实体
|
||||
* @param userLevel
|
||||
* @return 1成功 否则失败
|
||||
*/
|
||||
int addSegchkUserWechat(SegchkUserWechat segchkUserWechat, String userLevel);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.member.service.LoginService;
|
||||
import com.ruoyi.member.service.RegisterService;
|
||||
import com.ruoyi.segchk.domain.SegchkUserWebReq;
|
||||
import com.ruoyi.segchk.service.ISegchkProviderIndexService;
|
||||
import com.ruoyi.segchk.service.ISegchkStoreIndexService;
|
||||
import com.ruoyi.segchk.service.ISegchkUserIndexService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/7/17.
|
||||
* 登录服务接口
|
||||
*/
|
||||
@Service("loginService")
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
|
||||
/**
|
||||
* 请求时间戳过期时间5分钟
|
||||
*/
|
||||
private static final int REQUEST_TIME_OUT = 1000 * 60 * 5;
|
||||
/**
|
||||
* 注入会员服务接口
|
||||
*/
|
||||
// @Autowired
|
||||
// private IUmsMemberService customerService;
|
||||
/**
|
||||
* 注册接口
|
||||
*/
|
||||
@Autowired
|
||||
private RegisterService registerService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
|
||||
/**
|
||||
* jwt密钥
|
||||
*/
|
||||
@Value("${token.secret}")
|
||||
private String jwtSecretKey;
|
||||
// @Autowired
|
||||
// private ITStoreInfoService storeInfoService;
|
||||
/**
|
||||
* 密码工具类
|
||||
*/
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Value("${auth.salt:wsfmall}")
|
||||
private String salt;
|
||||
|
||||
// @Override
|
||||
/*public AjaxResult login(LoginParams loginParams) {
|
||||
log.debug("login and loginParams:{}", loginParams);
|
||||
|
||||
if (Objects.isNull(loginParams)) {
|
||||
log.info("login fail due to loginParams is null....");
|
||||
return AjaxResult.error(-6,"loginParams is null");
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
if (!loginParams.validateCode()) {
|
||||
log.info("login fail due to validateCode fail....");
|
||||
return AjaxResult.error(-6,"validateCode fail");
|
||||
}
|
||||
|
||||
|
||||
// 根据用户名查询出用户信息
|
||||
UmsMember customer = customerService.queryCustomerByName(loginParams.getMobile());
|
||||
|
||||
log.debug("login member:{}", customer);
|
||||
|
||||
// 用户不存在直接返回失败
|
||||
if (Objects.isNull(customer)) {
|
||||
log.info("login fail due to member is not exist....");
|
||||
return AjaxResult.error(-4,"member is not exist");
|
||||
}
|
||||
|
||||
// 登录次数
|
||||
int errorCount = customer.getLoginErrorCount();
|
||||
|
||||
// 判断用户账号是否正常
|
||||
if (!"1".equals(customer.getStatus())) {
|
||||
log.info("login fail due to member status is error ....");
|
||||
return AjaxResult.error(-2,"账号冻结");
|
||||
}
|
||||
|
||||
//判断用户的账号是否被锁定
|
||||
if (Objects.nonNull(customer.getLockTime())) {
|
||||
if (LocalDateTime.now().isBefore(customer.getLockTime().plus(30, ChronoUnit.MINUTES))) {
|
||||
// 账户被锁定或禁用
|
||||
log.info("login fail due to member is locked ....");
|
||||
return AjaxResult.error(-3,"账号锁定");
|
||||
} else {
|
||||
// 30分钟后解锁用户
|
||||
customerService.unlockUser(customer.getId());
|
||||
errorCount = 0;
|
||||
}
|
||||
}
|
||||
// -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
|
||||
// 判断用户密码是否正确
|
||||
if (!passwordEncoder.matches(loginParams.getPassword(), customer.getPassword())) {
|
||||
log.info("login fail due to password is wrong....");
|
||||
|
||||
//增加登录失败的次数
|
||||
customerService.updateLoginErrorCount(customer.getId());
|
||||
|
||||
// 如果登录失败次数>= 6次 则锁定帐户 30分钟内不能登录
|
||||
if (errorCount + 1 >= 6) {
|
||||
customerService.lockUser(customer.getId());
|
||||
return null;
|
||||
} else {
|
||||
return AjaxResult.error(-1,"用户名或密码错误");
|
||||
}
|
||||
}
|
||||
// 清除密码
|
||||
customer.clearPassword();
|
||||
|
||||
// 更新登录时间
|
||||
customerService.updateLoginTime(customer.getId());
|
||||
|
||||
//清除登录错误次数
|
||||
customerService.unlockUser(customer.getId());
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(Jwts.builder().setSubject(customer.getUsername())
|
||||
.compressWith(CompressionCodecs.DEFLATE)
|
||||
.signWith(SignatureAlgorithm.HS256, jwtSecretKey)
|
||||
.setIssuedAt(new Date())
|
||||
.claim("userName", customer.getUsername())
|
||||
.claim("nickName", customer.getNickname())
|
||||
.claim("releName", customer.getRelename())
|
||||
.claim("id", customer.getId())
|
||||
.setExpiration(Date.from(Instant.now().plus(1, ChronoUnit.HOURS))) // 有效期1小时
|
||||
.compact());
|
||||
if (customer != null) {
|
||||
AppletLoginRedisParamResponse appletLoginRedisParamResponse = new AppletLoginRedisParamResponse();
|
||||
appletLoginRedisParamResponse.setCustomerId(customer.getId());
|
||||
appletLoginRedisParamResponse.setToken(sb.toString());
|
||||
redisService.putToRedis(sb.toString(), JSON.toJSONString(appletLoginRedisParamResponse),1, TimeUnit.DAYS);
|
||||
redisService.putToRedis(loginParams.getMobile(), sb.toString());
|
||||
res.put("access_token", sb.toString());
|
||||
res.put("refresh_token", sb.toString());
|
||||
res.put("member", customer);
|
||||
}
|
||||
|
||||
log.debug("ok...login success.....");
|
||||
|
||||
return AjaxResult.success(res);
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* segchk前端登录 (app,pc,mobile)
|
||||
*
|
||||
* @param segchkUserWebReq 登入参数
|
||||
* @return 返回码 -1 用户名或密码错误 -2 账号冻结 -3 账号锁定 1 成功 -4 验证码错误
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult login(SegchkUserWebReq segchkUserWebReq) {
|
||||
AjaxResult ajaxResult = null;
|
||||
switch (segchkUserWebReq.getUserLevel()){
|
||||
case 0: ajaxResult = AjaxResult.success(segchkProviderIndexService.selectSegchkProviderWebInfo(segchkUserWebReq));break;
|
||||
case 1: ajaxResult = AjaxResult.success(segchkStoreIndexService.selectSegchkStoreWebInfo(segchkUserWebReq));break;
|
||||
case 2: ajaxResult = AjaxResult.success(segchkUserIndexService.selectSegchkUserWebInfo(segchkUserWebReq));break;
|
||||
default: ajaxResult = AjaxResult.error("301", "用户身份异常");
|
||||
}
|
||||
return ajaxResult;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.SnowflakeIdWorker;
|
||||
import com.ruoyi.member.service.RegisterService;
|
||||
import com.ruoyi.member.service.RegisterServiceApi;
|
||||
import com.ruoyi.segchk.domain.SegchkUserBasicInfo;
|
||||
import com.ruoyi.segchk.domain.SegchkUserExtInfo;
|
||||
import com.ruoyi.segchk.domain.SegchkUserLevelInfo;
|
||||
import com.ruoyi.segchk.service.*;
|
||||
import com.ruoyi.util.Claims;
|
||||
import com.ruoyi.util.CommonConstant;
|
||||
import io.jsonwebtoken.*;
|
||||
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.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 注册服务聚合接口实现
|
||||
*/
|
||||
@Service
|
||||
public class RegisterServiceApiImpl implements RegisterServiceApi {
|
||||
|
||||
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(RegisterServiceApiImpl.class);
|
||||
|
||||
|
||||
/**
|
||||
* jwt密钥
|
||||
*/
|
||||
@Value("${token.secret}")
|
||||
private String jwtSecretKey;
|
||||
|
||||
/**
|
||||
* 注入注册服务
|
||||
*/
|
||||
@Autowired
|
||||
private RegisterService registerService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkStoreIndexService segchkStoreIndexService;
|
||||
|
||||
@Autowired
|
||||
private ISegchkProviderIndexService segchkProviderIndexService;
|
||||
|
||||
/**
|
||||
* 注入redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisCache redisService;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdWorker snowflakeIdWorker;
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
* @param code 用户输入的手机验证码
|
||||
* @param originCode 生成的手机验证码
|
||||
* @param recommondId 推荐吗
|
||||
* @param recommondLevel 推荐角色
|
||||
* @param providerId
|
||||
* @param remark
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult registerCustomer(String mobile, String code, String originCode, String recommondId, String recommondLevel, String providerId, String remark) {
|
||||
if(StringUtils.isEmpty(code)){
|
||||
logger.error("registerCustomer fail due to code is empty...");
|
||||
return AjaxResult.error(500, "验证码为空!");
|
||||
}
|
||||
if(StringUtils.isEmpty(mobile)){
|
||||
logger.error("registerCustomer fail due to mobile is empty...");
|
||||
return AjaxResult.error(500, "手机号码为空!");
|
||||
}
|
||||
|
||||
// 校验验证码是否正确TODO
|
||||
if (!code.equals(originCode)) {
|
||||
logger.error("registerCustomer fail due to code is error with originCode...");
|
||||
return AjaxResult.error(500, "验证码错误!");
|
||||
}
|
||||
|
||||
SegchkUserLevelInfo segchkUserLevelInfo = segchkUserIndexService.selectUserLevelByMobile(mobile);
|
||||
SegchkUserExtInfo segchkUserExtInfo = new SegchkUserExtInfo();
|
||||
|
||||
if(ObjectUtils.isEmpty(segchkUserLevelInfo)){
|
||||
segchkUserLevelInfo = new SegchkUserLevelInfo();
|
||||
// 如果用户信息空,则添加新的用户
|
||||
if(!StringUtils.isEmpty(recommondId) && !StringUtils.isEmpty(recommondLevel)){
|
||||
// 如果推荐人,推荐人角色都非空。要检查推荐人是否存在。否则推荐人设置为运营商
|
||||
Map<String, Object> parmMap = new HashMap<>();
|
||||
parmMap.put("userId", recommondId);
|
||||
parmMap.put("userLevel", recommondLevel);
|
||||
parmMap.put("providerId", providerId);
|
||||
int ret = segchkUserIndexService.recommenderIsExit(parmMap);
|
||||
if(ret == 0){
|
||||
// 推荐人异常
|
||||
logger.error("registerCustomer fail due to recommender is wrong...");
|
||||
|
||||
return AjaxResult.error(500, "推荐人不存在或不在同一地区!");
|
||||
}
|
||||
|
||||
// 添加推荐人绑定
|
||||
segchkUserExtInfo.setProviderId(Long.valueOf(providerId));
|
||||
segchkUserExtInfo.setRecommendersLevel(recommondLevel);
|
||||
segchkUserExtInfo.setUserRecommenders(Long.valueOf(recommondId));
|
||||
}
|
||||
// 添加新用户信息
|
||||
SegchkUserBasicInfo segchkUserBasicInfo = new SegchkUserBasicInfo();
|
||||
segchkUserBasicInfo.setPhoneNo(mobile);
|
||||
segchkUserBasicInfo.setCardTypeId(-1L);
|
||||
segchkUserBasicInfo.setHasWechat("0");
|
||||
segchkUserBasicInfo.setProviderId(Long.valueOf(providerId));
|
||||
segchkUserBasicInfo.setUserIcon("");
|
||||
int ret = segchkUserIndexService.addUserBasicInfo(segchkUserBasicInfo);
|
||||
if(ret != 1){
|
||||
logger.error("registerCustomer fail due to register is wrong...");
|
||||
return AjaxResult.error(500, "注册异常,请联系客服!");
|
||||
}
|
||||
|
||||
segchkUserExtInfo.setProviderId(Long.valueOf(providerId));
|
||||
segchkUserExtInfo.setRecommendersLevel("0");
|
||||
segchkUserExtInfo.setUserRecommenders(0L);
|
||||
segchkUserExtInfo.setUserId(segchkUserBasicInfo.getUserId());
|
||||
ret = segchkUserIndexService.insertUserExtInfo(segchkUserExtInfo);
|
||||
if(ret < 1){
|
||||
logger.error("registerCustomer fail due to recommender binding is wrong...");
|
||||
return AjaxResult.error(500, "推荐人绑定异常,请联系客服!");
|
||||
}
|
||||
segchkUserLevelInfo.setProviderId(Long.valueOf(providerId));
|
||||
segchkUserLevelInfo.setUserId(segchkUserBasicInfo.getUserId());
|
||||
segchkUserLevelInfo.setUserLevel(2L);
|
||||
}
|
||||
// 如果是已经注册的用户。则直接返回用户信息
|
||||
|
||||
String openId = segchkUserIndexService.getWeChatInfoByUserId(segchkUserLevelInfo);
|
||||
if("999999".equals(remark)){
|
||||
openId = code;
|
||||
}
|
||||
if(openId == null){
|
||||
// 说明用户之前没有绑定微信
|
||||
segchkUserLevelInfo.setToken(null);
|
||||
}
|
||||
else {
|
||||
String token = createToken(CommonConstant.APPLET_LOGIN_KEY, segchkUserLevelInfo.getUserId(), segchkUserLevelInfo.getProviderId(), segchkUserLevelInfo.getUserLevel().intValue());
|
||||
segchkUserLevelInfo.setToken(token);
|
||||
Claims claims = new Claims();
|
||||
claims.setUserId(segchkUserLevelInfo.getUserId());
|
||||
claims.setOpenId(openId);
|
||||
claims.setProviderId(segchkUserLevelInfo.getProviderId());
|
||||
claims.setUserLevel(segchkUserLevelInfo.getUserLevel().intValue());
|
||||
// 将用户的token进行缓存
|
||||
redisService.setCacheObject(token, claims);
|
||||
}
|
||||
|
||||
return AjaxResult.success("注册成功", segchkUserLevelInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createToke(String subject, Long userId, Long providerId, Integer userLevel) {
|
||||
String token = createToken(subject, userId, providerId, userLevel);
|
||||
return token;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public int registerCustomer(String mobile, String password, String code, String originCode, String recommondCode) {
|
||||
// logger.debug("registerCustomer and mobile :{} \r\n code:{} \r\n: originCode{} \r\n recommondCode:{}", mobile, code, originCode, recommondCode);
|
||||
// if()
|
||||
//// 根据手机号查询是否存在用户。可能是用户,商家,运营商。
|
||||
// segchkUserIndexService.getUserLoginInfo();
|
||||
// return res;
|
||||
// }
|
||||
|
||||
private String createToken(String subject, Long userId, Long providerId, int userLevel){
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(Jwts.builder().setSubject(subject)
|
||||
.compressWith(CompressionCodecs.DEFLATE)
|
||||
.signWith(SignatureAlgorithm.HS256, jwtSecretKey)
|
||||
.setIssuedAt(new Date())
|
||||
.claim("userId", userId)
|
||||
.claim("providerId", providerId)
|
||||
.claim("userLevel", userLevel)
|
||||
.setExpiration(Date.from(Instant.now().plus(1, ChronoUnit.HOURS))) // 有效期1小时
|
||||
.compact());
|
||||
// sb.append(CommonConstant.APPLET_LOGIN_KEY).append("_").append(snowflakeIdWorker.nextId()).append(jwtSecretKey);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.member.service.RegisterService;
|
||||
import com.ruoyi.member.service.SmsService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/18.
|
||||
* 注册接口
|
||||
*/
|
||||
@Service
|
||||
public class RegisterServiceImpl implements RegisterService {
|
||||
|
||||
/**
|
||||
* 调试日志
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(RegisterServiceImpl.class);
|
||||
|
||||
|
||||
/**
|
||||
* 注入短信接口
|
||||
*/
|
||||
@Autowired
|
||||
private SmsService smsService;
|
||||
|
||||
/**
|
||||
* 注入会员服务接口
|
||||
*/
|
||||
// @Autowired
|
||||
// private IUmsMemberService customerService;
|
||||
|
||||
|
||||
@Override
|
||||
public int sendRegisterSmsCode(String mobile, Consumer<String> consumer) {
|
||||
|
||||
logger.debug("sendRegisterSmsCode and mobile:{}");
|
||||
// 如果要注册的手机号码存在 则直接返回
|
||||
/*if (customerService.isMobileExist(mobile) != 0) {
|
||||
logger.error("sendRegisterSmsCode fail due to mobile :{} is exist...", mobile);
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
// 生成的6位数数字
|
||||
String code = String.format("%06d", (int) (Math.random() * 1000000));
|
||||
|
||||
|
||||
if(true){
|
||||
code = "1234";
|
||||
}
|
||||
else if (smsService.sendSms(mobile, code) == 1) {
|
||||
// 短信验证码发送失败
|
||||
logger.error("send sms fail....");
|
||||
return 1;
|
||||
}
|
||||
// 发送成功后回调
|
||||
if (Objects.nonNull(consumer)) {
|
||||
consumer.accept(code);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendRegisterSmsCodeForPc(String mobile, String kaptcha, String oldKaptcha, Consumer<String> consumer) {
|
||||
|
||||
logger.debug("sendRegisterSmsCode and mobile:{}");
|
||||
|
||||
|
||||
// 如果要注册的手机号码存在 则直接返回
|
||||
/*if (customerService.isMobileExist(mobile) != 0) {
|
||||
logger.error("sendRegisterSmsCode fail due to mobile :{} is exist...", mobile);
|
||||
return -4;
|
||||
}*/
|
||||
|
||||
int checkKaptchaRes = checkKaptcha(kaptcha, oldKaptcha);
|
||||
if (checkKaptchaRes != 1) {
|
||||
logger.error("sendRegisterSmsCode fail due to kaptcha is error...");
|
||||
return checkKaptchaRes;
|
||||
}
|
||||
|
||||
// 生成的6位数数字
|
||||
String code = String.format("%06d", (int) (Math.random() * 1000000));
|
||||
|
||||
// 短信验证码发送失败
|
||||
if (smsService.sendSms(mobile, code) == 1) {
|
||||
logger.error("send sms fail....");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 发送成功后回调
|
||||
if (Objects.nonNull(consumer)) {
|
||||
consumer.accept(code);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int registerCustomer(String mobile, String password, String code, String originCode, String recommondCode) {
|
||||
logger.debug("registerCustomer and mobile :{} \r\n code:{} \r\n: originCode:{} \r\n recommondCode:{}", mobile, code, originCode, recommondCode);
|
||||
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
logger.error("registerCustomer fail due to code is empty...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(mobile) || StringUtils.isEmpty(password)) {
|
||||
logger.error("registerCustomer fail due to mobile or password is empty...");
|
||||
return -2;
|
||||
}
|
||||
|
||||
// 判断手机号码是否存在
|
||||
/*if (customerService.isMobileExist(mobile) != 0) {
|
||||
logger.error("registerCustomer fail due to mobile is exist");
|
||||
return -3;
|
||||
}*/
|
||||
|
||||
// 校验验证码是否正确TODO
|
||||
if (!code.equals(originCode)) {
|
||||
logger.error("registerCustomer fail due to code is error with originCode...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 进行会员注册
|
||||
// return customerService.(UmsMember.buildAppRegisterCustomer(mobile, password, recommondCode));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 免密用户自动注册
|
||||
*
|
||||
* @param phoneNo 手机号码
|
||||
* @param channelType 渠道类型
|
||||
* @return -1 手机验证码错误 -2 参数错误 0 失败 成功>0 -3 手机号码已存在 -10 推荐人不存在
|
||||
*/
|
||||
@Override
|
||||
public Long unAuthRegister(String phoneNo, String channelType) {
|
||||
logger.debug("registerCustomer and mobile :{}", phoneNo);
|
||||
|
||||
// 判断手机号码是否存在
|
||||
/*if (customerService.isMobileExist(phoneNo) != 0) {
|
||||
logger.error("registerCustomer fail due to mobile is exist");
|
||||
return -3L;
|
||||
}*/
|
||||
// UmsMember customer = UmsMember.buildH5RegisterCustomer(phoneNo, null);
|
||||
// customer.setChannelType(channelType);
|
||||
// 进行会员注册
|
||||
// return customerService.autoAddCustomer(customer);
|
||||
return 1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkKaptcha(String kaptcha, String kaptchaInSession) {
|
||||
logger.debug("register checkKaptcha and kaptcha:{}\r\n kaptchaInSession:{}", kaptcha, kaptchaInSession);
|
||||
if (StringUtils.isEmpty(kaptchaInSession)) {
|
||||
logger.error("register checkKaptcha fail:kaptchaInSession is not exist ");
|
||||
return -1;
|
||||
}
|
||||
if (StringUtils.isEmpty(kaptcha)) {
|
||||
logger.error("register checkKaptcha fail:kaptcha is not exist ");
|
||||
return -2;
|
||||
}
|
||||
if (!kaptcha.equals(kaptchaInSession)) {
|
||||
logger.error("register checkKaptcha fail:kaptchaInSession is not equal to kaptcha ");
|
||||
return -3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import com.github.qcloudsms.SmsMultiSender;
|
||||
import com.github.qcloudsms.SmsResultBase;
|
||||
import com.github.qcloudsms.SmsSingleSender;
|
||||
import com.ruoyi.setting.domain.LsSmsSetting;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Tencent Cloud Sms Sendsms
|
||||
* https://cloud.tencent.com/document/product/382/38778
|
||||
*/
|
||||
public class SendTencentSms {
|
||||
private static final Logger log = LoggerFactory.getLogger(SendTencentSms.class);
|
||||
/**
|
||||
* 按模板发送短信 支持单发和群发
|
||||
*
|
||||
* @param smsSet 短信配置
|
||||
*/
|
||||
public static int sendMessage(LsSmsSetting smsSet, String[] params, String phones) {
|
||||
|
||||
String regex = ";";
|
||||
String[] phoneNumbers = phones.split(regex);
|
||||
SmsResultBase result = null;
|
||||
|
||||
try {
|
||||
log.debug("url:{},phones:{},templateId:{},params:{}", smsSet.getUrl(), phones, smsSet.getTemplateId(), params);
|
||||
// 是否单发
|
||||
if (phoneNumbers.length == 1) {
|
||||
//APPID getInterfaceUrl
|
||||
SmsSingleSender ssender = new SmsSingleSender(Integer.parseInt(smsSet.getUrl()), smsSet.getKey());
|
||||
result = ssender.sendWithParam("86", phoneNumbers[0], Integer.parseInt(smsSet.getTemplateId()), params, smsSet.getSign(), "", "");
|
||||
} else {
|
||||
SmsMultiSender msender = new SmsMultiSender(Integer.parseInt(smsSet.getUrl()), smsSet.getKey());
|
||||
result = msender.sendWithParam("86", phoneNumbers, Integer.parseInt(smsSet.getTemplateId()), params, smsSet.getSign(), "", "");
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
log.error("腾讯云短信发送失败,phoneNumbers={},smsSet={}", phoneNumbers, smsSet, e);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.member.service.SmsService;
|
||||
import com.ruoyi.setting.domain.LsSmsSetting;
|
||||
import com.ruoyi.setting.service.ILsSmsSettingService;
|
||||
import com.ruoyi.util.SmsUtil;
|
||||
import com.ruoyi.util.bean.RequestParam;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/18.
|
||||
* 发送短信接口实现
|
||||
*/
|
||||
@Service
|
||||
public class SmsServiceImpl implements SmsService {
|
||||
|
||||
/**
|
||||
* 团长审批状态
|
||||
*/
|
||||
private static final String STATUS = "通过";
|
||||
/**
|
||||
* 调试日志
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(SmsServiceImpl.class);
|
||||
/**
|
||||
* 注入短信设置服务接口
|
||||
*/
|
||||
@Autowired
|
||||
private ILsSmsSettingService smsSetService;
|
||||
|
||||
@Override
|
||||
public int sendSms(String phone, String content) {
|
||||
int result = 1;
|
||||
logger.debug("sendSms and phone:{} \r\n content:{}", phone, content);
|
||||
|
||||
// SmsSet smsSet = smsSetService.querySmsSet().get(0);
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendSms fail due to smsSet is null...");
|
||||
return result;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
// 阿里云短信
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getTemplateId());
|
||||
requestParam.setTemplateParam("{\"code\":\"" + content + "\"}");
|
||||
result = SmsUtil.newSendSms(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[1];
|
||||
params[0] = content;
|
||||
result = SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendWiteOffCodeSms(String phone, String code, String writeOffCode, String storeName) {
|
||||
logger.debug("sendWiteOffCodeSms and phone:{} \r\n code:{} \r\n writeOffCode:{} \r\n storeName:{}", phone, code, writeOffCode, storeName);
|
||||
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendWiteOffCodeSms fail due to smsSet is null...");
|
||||
return 0;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getWriteoffTemplateId());
|
||||
requestParam.setSmsParamString("{\"code\":\"" + code + "\",\"product\":\"\",\"storename\":\"" + storeName + "\",\"writeoffcode\":\"" + writeOffCode + "\"}");
|
||||
SmsUtil.newSendSms(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[3];
|
||||
params[0] = storeName;
|
||||
params[1] = code;
|
||||
params[2] = writeOffCode;
|
||||
SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendVirtualOrderWiteOffCodeSms(String phone, String code, String writeOffCode, String storeName) {
|
||||
logger.debug("sendVirtualOrderWiteOffCodeSms and phone :{} \r\n code:{} \r\n writeOffCode:{} \r\n storeName:{}", phone, code, writeOffCode, storeName);
|
||||
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendVirtualOrderWiteOffCodeSms fail due to smsSet is null...");
|
||||
return 0;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
//阿里云短信
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getVirtualOrderTemplateId());
|
||||
requestParam.setSmsParamString("{\"code\":\"" + code + "\",\"product\":\"\",\"storename\":\"" + storeName + "\",\"writeoffcode\":\"" + writeOffCode + "\"}");
|
||||
SmsUtil.newSendSmsCommon(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[3];
|
||||
params[0] = storeName;
|
||||
params[1] = code;
|
||||
params[2] = writeOffCode;
|
||||
SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送社区团购审核结果通知短信
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param submittime 通过时间
|
||||
* @return 成功返回0 失败返回1
|
||||
*/
|
||||
@Override
|
||||
public int sendAuditTemplateOffCodeSms(String phone, String submittime) {
|
||||
logger.debug("sendAuditTemplateOffCodeSms and phone :{} \r\n submittime:{}", phone, submittime);
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendAuditTemplateOffCodeSms fail due to smsSet is null...");
|
||||
return 0;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
//阿里云短信
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getAuditTemplateId());
|
||||
requestParam.setSmsParamString("{\"submittime\":\"" + submittime + "\",\"product\":\"\",\"status\":\"" + STATUS + "\"}");
|
||||
SmsUtil.newSendSmsCommon(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[1];
|
||||
params[0] = submittime;
|
||||
SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendCommunityBuySettlementSms(String phone, String communityName, BigDecimal price) {
|
||||
|
||||
logger.debug("sendCommunityBuySettlementSms and communityName :{} \r\n price:{} \r\n phone:{}", communityName, price, phone);
|
||||
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendCommunityBuySettlementSms fail due to smsSet is null...");
|
||||
return 0;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
//阿里云短信
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getSettlementTemplateId());
|
||||
requestParam.setSmsParamString("{\"communityname\":\"" + communityName + "\",\"product\":\"\",\"price\":\"" + price + "\"}");
|
||||
SmsUtil.newSendSmsCommon(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[2];
|
||||
params[0] = communityName;
|
||||
params[1] = String.valueOf(price);
|
||||
SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendCommunityBuyWitudrawSms(String phone, String submittime, BigDecimal price) {
|
||||
|
||||
|
||||
logger.debug("sendCommunityBuyWitudrawSms and phone :{} \r\n submittime:{} \r\n price:{}", phone, submittime, price);
|
||||
|
||||
List<LsSmsSetting> smsSetList = smsSetService.selectLsSmsSettingList(null);
|
||||
|
||||
if (Objects.isNull(smsSetList)) {
|
||||
logger.error("sendCommunityBuyWitudrawSms fail due to smsSet is null...");
|
||||
return 0;
|
||||
}
|
||||
for (LsSmsSetting smsSet : smsSetList) {
|
||||
//阿里云短信
|
||||
if (smsSet.getId() == 1 && smsSet.getStatus()) {
|
||||
RequestParam requestParam = convert(phone, smsSet);
|
||||
requestParam.setTemplateCode(smsSet.getWithdrawTemplateId());
|
||||
requestParam.setSmsParamString("{\"submittime\":\"" + submittime + "\",\"product\":\"\",\"price\":\"" + price + "\"}");
|
||||
SmsUtil.newSendSmsCommon(requestParam);
|
||||
} else if (smsSet.getId() == 2 && smsSet.getStatus()) { // 腾讯云短信
|
||||
String[] params = new String[2];
|
||||
params[0] = submittime;
|
||||
params[1] = price.toString();
|
||||
SendTencentSms.sendMessage(smsSet, params, phone);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private RequestParam convert(String phone, LsSmsSetting smsSet) {
|
||||
RequestParam requestParam = new RequestParam();
|
||||
requestParam.setPhoneNumbers(phone);
|
||||
requestParam.setSignName(smsSet.getSign());
|
||||
requestParam.setInterfaceUrl(smsSet.getUrl());
|
||||
requestParam.setAccessKeyId(smsSet.getKey());
|
||||
requestParam.setAccessKeySecret(smsSet.getSecret());
|
||||
return requestParam;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SnowflakeIdWorker;
|
||||
import com.ruoyi.segchk.domain.WeChatCustomerLink;
|
||||
import com.ruoyi.util.*;
|
||||
import com.ruoyi.member.service.WeChatAppletLoginService;
|
||||
import com.ruoyi.member.service.WeChatCustomerLinkService;
|
||||
import com.ruoyi.member.vo.AppletLoginInfo;
|
||||
import com.ruoyi.member.vo.AppletLoginRedisParamResponse;
|
||||
import com.ruoyi.setting.bean.WechatPaySet;
|
||||
import com.ruoyi.setting.service.ILsPaySettingService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 微信小程序登录服务实现类
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
@Service
|
||||
public class WeChatAppletLoginServiceImpl implements WeChatAppletLoginService {
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private Logger log = LoggerFactory.getLogger(WeChatAppletLoginServiceImpl.class);
|
||||
/**
|
||||
* 注入微信用户关联服务
|
||||
*/
|
||||
@Autowired
|
||||
private WeChatCustomerLinkService weChatCustomerLinkService;
|
||||
|
||||
/**
|
||||
* 注入随机数生成器
|
||||
*/
|
||||
@Autowired
|
||||
private SnowflakeIdWorker snowflakeIdWorker;
|
||||
|
||||
/**
|
||||
* 注入支付设置服务
|
||||
*/
|
||||
@Autowired
|
||||
private ILsPaySettingService paySetService;
|
||||
|
||||
|
||||
@Override
|
||||
public AppletLoginInfo getLoginInfo(String code, String unionId, Consumer<AppletLoginRedisParamResponse> claimsConsumer) {
|
||||
log.debug("getLoginInfo and code:{} \r\n unionId:{}", code, unionId);
|
||||
AppletLoginRedisParamResponse appletLoginRedisParamResponse = new AppletLoginRedisParamResponse();
|
||||
String token = snowflakeIdWorker.nextId() + "";
|
||||
appletLoginRedisParamResponse.setToken(token);
|
||||
WechatPaySet wechatAppletPaySet = paySetService.queryPaySet().getWechatAppletPaySet();
|
||||
WechatSetting wechatSetting = new WechatSetting();
|
||||
wechatSetting.setAppId(wechatAppletPaySet.getAppId());
|
||||
wechatSetting.setAppSecret(wechatAppletPaySet.getAppSecret());
|
||||
if (!wechatSetting.checkAppletOAuthParams()) {
|
||||
log.error("getLoginInfo fail:checkAppletOAuthParams fail");
|
||||
return buildNotLinked(claimsConsumer, appletLoginRedisParamResponse, token, null);
|
||||
}
|
||||
WeChatAppletLoginResponse weChatAppletLoginResponse = WeChatAppletUtils.getLoginInfo(code, wechatSetting);
|
||||
if (Objects.isNull(weChatAppletLoginResponse)) {
|
||||
log.error("getLoginInfo fail: getLoginInfo fail");
|
||||
return buildNotLinked(claimsConsumer, appletLoginRedisParamResponse, token, null);
|
||||
}
|
||||
appletLoginRedisParamResponse.setSessionKey(weChatAppletLoginResponse.getSession_key());
|
||||
appletLoginRedisParamResponse.setOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
if (!weChatAppletLoginResponse.hasUnionId()) {
|
||||
weChatAppletLoginResponse.setUnionid(unionId);
|
||||
}
|
||||
if (!weChatAppletLoginResponse.hasUnionId()) {
|
||||
log.info("getLoginInfo: no unionId");
|
||||
return buildNotLinked(claimsConsumer, appletLoginRedisParamResponse, token, null);
|
||||
}
|
||||
appletLoginRedisParamResponse.setUnionId(weChatAppletLoginResponse.getUnionid());
|
||||
WeChatCustomerLink weChatCustomerLink = weChatCustomerLinkService.queryWeChatCustomerLinkByUnionId(weChatAppletLoginResponse.getUnionid());
|
||||
if (Objects.isNull(weChatCustomerLink)) {
|
||||
log.info("getLoginInfo: not linked");
|
||||
return buildNotLinked(claimsConsumer, appletLoginRedisParamResponse, token, weChatAppletLoginResponse.getUnionid());
|
||||
}
|
||||
log.info("getLoginInfo: linked");
|
||||
//如果没有小程序的openId,则更新关联信息
|
||||
if (!weChatCustomerLink.hasAppletOpenId()) {
|
||||
weChatCustomerLink.setAppletOpenId(weChatAppletLoginResponse.getOpenid());
|
||||
weChatCustomerLinkService.updateWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
appletLoginRedisParamResponse.setCustomerId(weChatCustomerLink.getUserId());
|
||||
claimsConsumer.accept(appletLoginRedisParamResponse);
|
||||
return AppletLoginInfo.buildLinked(token);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AppletLoginInfo dealUserInfo(WeChatAppletUserInfo weChatAppletUserInfo, String openId, String sessionKey, Consumer<AppletLoginRedisParamResponse> claimsConsumer) {
|
||||
log.debug("dealUserInfo and weChatAppletUserInfo:{} \r\n sessionKey:{} \r\n openId:{}", weChatAppletUserInfo, sessionKey, openId);
|
||||
String unionId = WeChatAppletUtils.getUnionIdFromUserInfo(sessionKey, weChatAppletUserInfo);
|
||||
if (StringUtils.isEmpty(unionId)) {
|
||||
log.error("dealUserInfo fail : getUnionIdFromUserInfo fail");
|
||||
claimsConsumer.accept(null);
|
||||
return AppletLoginInfo.buildNotLinked();
|
||||
}
|
||||
AppletLoginRedisParamResponse appletLoginRedisParamResponse = new AppletLoginRedisParamResponse();
|
||||
appletLoginRedisParamResponse.setUnionId(unionId);
|
||||
WeChatCustomerLink weChatCustomerLink = weChatCustomerLinkService.queryWeChatCustomerLinkByUnionId(unionId);
|
||||
if (Objects.isNull(weChatCustomerLink)) {
|
||||
log.info("dealUserInfo: not linked");
|
||||
claimsConsumer.accept(appletLoginRedisParamResponse);
|
||||
return AppletLoginInfo.buildNotLinked().addUnionId(unionId);
|
||||
}
|
||||
log.info("dealUserInfo: linked");
|
||||
//如果没有小程序的openId,则更新关联信息
|
||||
if (!weChatCustomerLink.hasAppletOpenId()) {
|
||||
weChatCustomerLink.setAppletOpenId(openId);
|
||||
weChatCustomerLinkService.updateWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
appletLoginRedisParamResponse.setCustomerId(weChatCustomerLink.getUserId());
|
||||
claimsConsumer.accept(appletLoginRedisParamResponse);
|
||||
return AppletLoginInfo.buildLinked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkCustomerBind(String userName) {
|
||||
log.debug("checkCustomerBind and userName:{} ", userName);
|
||||
WeChatCustomerLink weChatCustomerLink = weChatCustomerLinkService.queryWeChatCustomerLinkByUserName(userName);
|
||||
if (!ObjectUtils.isEmpty(weChatCustomerLink) && !StringUtils.isEmpty(weChatCustomerLink.getAppletOpenId())) {
|
||||
log.error("checkCustomerBind fail : bind already");
|
||||
return -9;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindAccount(String openId, String unionId, long customerId) {
|
||||
log.debug("bindAccount and openId:{} \r\n unionId:{} \r\n customerId:{}", openId, unionId, customerId);
|
||||
WeChatCustomerLink weChatCustomerLink = weChatCustomerLinkService.queryWeChatCustomerLinkByCustomerId(customerId);
|
||||
if (!ObjectUtils.isEmpty(weChatCustomerLink) && !weChatCustomerLink.getUnionId().equals(unionId)) {
|
||||
log.error("checkCustomerBind fail : bind already");
|
||||
throw new ServiceException("R-00004");
|
||||
}
|
||||
if (Objects.isNull(weChatCustomerLink)) {
|
||||
weChatCustomerLink = new WeChatCustomerLink();
|
||||
}
|
||||
weChatCustomerLink.setUnionId(unionId);
|
||||
weChatCustomerLink.setAppletOpenId(openId);
|
||||
weChatCustomerLink.setUserId(customerId);
|
||||
//如果数据库中有记录就更新记录
|
||||
if (-1 != weChatCustomerLink.getUserId()) {
|
||||
return weChatCustomerLinkService.updateWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
//否则新增
|
||||
return weChatCustomerLinkService.addWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int unbindAccount(long customerId, String unionId) {
|
||||
log.debug("unbindAccount and customerId:{} \r\n unionId:{}", customerId, unionId);
|
||||
return weChatCustomerLinkService.unbindWeChatCustomerLink(customerId, unionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建未关联返回
|
||||
*
|
||||
* @param claimsConsumer 回调
|
||||
* @param appletLoginRedisParamResponse 小程序redis参数返回实体类
|
||||
* @param token token
|
||||
* @return 小程序登录信息
|
||||
*/
|
||||
private AppletLoginInfo buildNotLinked(Consumer<AppletLoginRedisParamResponse> claimsConsumer, AppletLoginRedisParamResponse appletLoginRedisParamResponse, String token, String unionId) {
|
||||
claimsConsumer.accept(appletLoginRedisParamResponse);
|
||||
return AppletLoginInfo.buildNotLinked(token).addUnionId(unionId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.ruoyi.member.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.segchk.domain.SegchkUserWechat;
|
||||
import com.ruoyi.segchk.service.ISegchkUserIndexService;
|
||||
import com.ruoyi.segchk.domain.WeChatCustomerLink;
|
||||
import com.ruoyi.member.mapper.WeChatCustomerLinkMapper;
|
||||
import com.ruoyi.member.service.WeChatCustomerLinkService;
|
||||
import com.ruoyi.util.RedisCahceKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 微信用户关联服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class WeChatCustomerLinkServiceImpl implements WeChatCustomerLinkService {
|
||||
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(WeChatCustomerLinkServiceImpl.class);
|
||||
/**
|
||||
* 注入微信用户数据库服务
|
||||
*/
|
||||
@Autowired
|
||||
private WeChatCustomerLinkMapper weChatCustomerLinkMapper;
|
||||
/**
|
||||
* 用户数据库服务
|
||||
*/
|
||||
@Autowired
|
||||
private ISegchkUserIndexService segchkUserIndexService;
|
||||
|
||||
|
||||
/**
|
||||
* 注入用户服务
|
||||
*/
|
||||
// @Autowired
|
||||
// private IUmsMemberService customerService;
|
||||
|
||||
|
||||
@CacheEvict(value = RedisCahceKey.WE_CHAT_CUSTOMER_LINK, key = "'WE_CHAT_CUSTOMER_LINK'+#weChatCustomerLink.unionId")
|
||||
@Override
|
||||
public int addWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink) {
|
||||
logger.debug("addWeChatCustomerLink and weChatCustomerLink:{}", weChatCustomerLink);
|
||||
return weChatCustomerLinkMapper.addWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeChatCustomerLink queryWeChatCustomerLinkByOpenId(String openId) {
|
||||
logger.debug("queryWeChatCustomerLinkByOpenId and openId:{}", openId);
|
||||
return weChatCustomerLinkMapper.queryWeChatCustomerLinkByOpenId(openId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeChatCustomerLink queryWeChatCustomerLinkByCustomerId(long customerId) {
|
||||
logger.debug("queryWeChatCustomerLinkByCustomerId and customerId:{}", customerId);
|
||||
return weChatCustomerLinkMapper.queryWeChatCustomerLinkByCustomerId(customerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeChatCustomerLink queryWeChatCustomerLinkByUserName(String userName) {
|
||||
logger.debug("queryWeChatCustomerLinkByUserName and userName:{}", userName);
|
||||
// UmsMember customer = null;
|
||||
// UmsMember customer = customerService.queryCustomerByNameInWriteDataSource(userName);
|
||||
/*if (ObjectUtils.isEmpty(customer)) {
|
||||
logger.error("queryWeChatCustomerLinkByUserName fail: member is null");
|
||||
return null;
|
||||
}*/
|
||||
return null;
|
||||
// return weChatCustomerLinkMapper.queryWeChatCustomerLinkByCustomerId(customer.getCustomerLevelId());
|
||||
}
|
||||
|
||||
@Cacheable(value = RedisCahceKey.WE_CHAT_CUSTOMER_LINK, key = "'WE_CHAT_CUSTOMER_LINK'+#unionId")
|
||||
@Override
|
||||
public WeChatCustomerLink queryWeChatCustomerLinkByUnionId(String unionId) {
|
||||
logger.debug("queryWeChatCustomerLinkByUnionId and unionId:{}", unionId);
|
||||
return weChatCustomerLinkMapper.queryWeChatCustomerLinkByUnionId(unionId);
|
||||
}
|
||||
|
||||
@CacheEvict(value = RedisCahceKey.WE_CHAT_CUSTOMER_LINK, key = "'WE_CHAT_CUSTOMER_LINK'+#unionId")
|
||||
@Override
|
||||
public int unbindWeChatCustomerLink(long customerId, String unionId) {
|
||||
logger.debug("unbindWeChatCustomerLink and customerId:{} \r\n unionId:{}", customerId, unionId);
|
||||
return weChatCustomerLinkMapper.deleteWeChatCustomerLink(customerId);
|
||||
}
|
||||
|
||||
@CacheEvict(value = RedisCahceKey.WE_CHAT_CUSTOMER_LINK, key = "'WE_CHAT_CUSTOMER_LINK'+#weChatCustomerLink.unionId")
|
||||
@Override
|
||||
public int updateWeChatCustomerLink(WeChatCustomerLink weChatCustomerLink) {
|
||||
logger.debug("updateWeChatCustomerLink andweChatCustomerLink:{}", weChatCustomerLink);
|
||||
return weChatCustomerLinkMapper.updateWeChatCustomerLink(weChatCustomerLink);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新微信用户关联
|
||||
*
|
||||
* @param segchkUserWechat 微信用户关联实体
|
||||
* @param userLevel
|
||||
* @return 1成功 否则失败
|
||||
*/
|
||||
@Override
|
||||
public int addSegchkUserWechat(SegchkUserWechat segchkUserWechat, String userLevel) {
|
||||
return segchkUserIndexService.updateWeChatInfoByUserId(segchkUserWechat, userLevel);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 小程序登录信息
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
@ApiModel(description = "小程序登录信息")
|
||||
public class AppletLoginInfo {
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
@ApiModelProperty(value = "token")
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 是否关联用户
|
||||
*/
|
||||
@ApiModelProperty(value = "是否关联用户")
|
||||
private boolean isLink;
|
||||
|
||||
/**
|
||||
* 是否有unionId
|
||||
*/
|
||||
@ApiModelProperty(value = "是否有unionId")
|
||||
private boolean hasUnionId;
|
||||
|
||||
|
||||
/**
|
||||
* 构建已关联用户实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序登录信息实体
|
||||
*/
|
||||
public static AppletLoginInfo buildLinked(String token) {
|
||||
AppletLoginInfo appletLoginInfo = new AppletLoginInfo();
|
||||
appletLoginInfo.isLink = true;
|
||||
appletLoginInfo.token = token;
|
||||
appletLoginInfo.hasUnionId = true;
|
||||
return appletLoginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建为关联用户实体
|
||||
*
|
||||
* @param token token
|
||||
* @return 小程序登录信息实体
|
||||
*/
|
||||
public static AppletLoginInfo buildNotLinked(String token) {
|
||||
AppletLoginInfo appletLoginInfo = new AppletLoginInfo();
|
||||
appletLoginInfo.isLink = false;
|
||||
appletLoginInfo.token = token;
|
||||
return appletLoginInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建已关联用户实体
|
||||
*
|
||||
* @return 小程序登录信息实体
|
||||
*/
|
||||
public static AppletLoginInfo buildLinked() {
|
||||
AppletLoginInfo appletLoginInfo = new AppletLoginInfo();
|
||||
appletLoginInfo.isLink = true;
|
||||
appletLoginInfo.hasUnionId = true;
|
||||
return appletLoginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建为关联用户实体
|
||||
*
|
||||
* @return 小程序登录信息实体
|
||||
*/
|
||||
public static AppletLoginInfo buildNotLinked() {
|
||||
AppletLoginInfo appletLoginInfo = new AppletLoginInfo();
|
||||
appletLoginInfo.isLink = false;
|
||||
return appletLoginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加unionId
|
||||
*
|
||||
* @param unionId 联合登录id
|
||||
* @return 当前实体
|
||||
*/
|
||||
public AppletLoginInfo addUnionId(String unionId) {
|
||||
hasUnionId = !StringUtils.isEmpty(unionId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public boolean isLink() {
|
||||
return isLink;
|
||||
}
|
||||
|
||||
public void setLink(boolean link) {
|
||||
isLink = link;
|
||||
}
|
||||
|
||||
public boolean isHasUnionId() {
|
||||
return hasUnionId;
|
||||
}
|
||||
|
||||
public void setHasUnionId(boolean hasUnionId) {
|
||||
this.hasUnionId = hasUnionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppletLoginInfo{" +
|
||||
"token='" + token + '\'' +
|
||||
", isLink=" + isLink +
|
||||
", hasUnionId=" + hasUnionId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 小程序redis参数返回实体类
|
||||
*
|
||||
* @author SK
|
||||
* @since 2018/6/13
|
||||
*/
|
||||
public class AppletLoginRedisParamResponse {
|
||||
|
||||
/**
|
||||
* 小程序sessionKey
|
||||
*/
|
||||
private String sessionKey;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 联合登录id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private long customerId = -1;
|
||||
|
||||
/**
|
||||
* 微信用户标识
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 判断是否有unionId
|
||||
*
|
||||
* @return 有返回true, 否则返回false
|
||||
*/
|
||||
public boolean hasUnionId() {
|
||||
return !StringUtils.isEmpty(unionId);
|
||||
}
|
||||
|
||||
public String getSessionKey() {
|
||||
return sessionKey;
|
||||
}
|
||||
|
||||
public void setSessionKey(String sessionKey) {
|
||||
this.sessionKey = sessionKey;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUnionId() {
|
||||
return unionId;
|
||||
}
|
||||
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 绑定新邮箱实体
|
||||
*/
|
||||
@ApiModel(description = "绑定新邮箱实体")
|
||||
public class BindNewEmailRequest {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private long customerId;
|
||||
|
||||
/**
|
||||
* 用户手机
|
||||
*/
|
||||
@ApiModelProperty(value = "用户手机")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 新邮箱
|
||||
*/
|
||||
@ApiModelProperty(value = "新邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 是否有凭证
|
||||
*/
|
||||
@ApiModelProperty(value = "是否有凭证")
|
||||
private String hasCert;
|
||||
|
||||
/**
|
||||
* 校验码
|
||||
*/
|
||||
@ApiModelProperty(value = "校验码")
|
||||
private String checkCode;
|
||||
|
||||
/**
|
||||
* 用户输入的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的图片验证码")
|
||||
private String kaptcha;
|
||||
|
||||
/**
|
||||
* 存在redis中的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存在redis中的图片验证码")
|
||||
private String oldKaptcha;
|
||||
|
||||
/**
|
||||
* 随机数
|
||||
*/
|
||||
@ApiModelProperty(value = "随机数")
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 判断是否有凭证
|
||||
*
|
||||
* @return 有返回true
|
||||
*/
|
||||
public boolean hasOwnCert() {
|
||||
return !StringUtils.isEmpty(this.hasCert);
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getHasCert() {
|
||||
return hasCert;
|
||||
}
|
||||
|
||||
public void setHasCert(String hasCert) {
|
||||
this.hasCert = hasCert;
|
||||
}
|
||||
|
||||
public String getCheckCode() {
|
||||
return checkCode;
|
||||
}
|
||||
|
||||
public void setCheckCode(String checkCode) {
|
||||
this.checkCode = checkCode;
|
||||
}
|
||||
|
||||
public String getKaptcha() {
|
||||
return kaptcha;
|
||||
}
|
||||
|
||||
public void setKaptcha(String kaptcha) {
|
||||
this.kaptcha = kaptcha;
|
||||
}
|
||||
|
||||
public String getOldKaptcha() {
|
||||
return oldKaptcha;
|
||||
}
|
||||
|
||||
public void setOldKaptcha(String oldKaptcha) {
|
||||
this.oldKaptcha = oldKaptcha;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/21.
|
||||
* 重新绑定手机号码实体
|
||||
*/
|
||||
@ApiModel(description = "重新绑定手机号码实体")
|
||||
public class BindNewMobileRequest {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private long customerId;
|
||||
|
||||
/**
|
||||
* 重新绑定的手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "重新绑定的手机号码")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 用户输入的验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 发送给手机的验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "发送给手机的验证码")
|
||||
private String originCode;
|
||||
|
||||
/**
|
||||
* 是否有凭证
|
||||
*/
|
||||
@ApiModelProperty(value = "是否有凭证")
|
||||
private String hasCert;
|
||||
|
||||
/**
|
||||
* 判断是否有凭证
|
||||
*
|
||||
* @return 有返回true
|
||||
*/
|
||||
public boolean hasOwnCert() {
|
||||
return !StringUtils.isEmpty(this.hasCert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断验证码是否正确
|
||||
*
|
||||
* @return 正确返回0
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
if (StringUtils.isEmpty(this.code)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.code.equals(this.originCode);
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getOriginCode() {
|
||||
return originCode;
|
||||
}
|
||||
|
||||
public void setOriginCode(String originCode) {
|
||||
this.originCode = originCode;
|
||||
}
|
||||
|
||||
public String getHasCert() {
|
||||
return hasCert;
|
||||
}
|
||||
|
||||
public void setHasCert(String hasCert) {
|
||||
this.hasCert = hasCert;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* 登入参数实体
|
||||
*/
|
||||
@ApiModel(description = "登入参数实体")
|
||||
public class BindParams extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
*/
|
||||
@ApiModelProperty(value = "运营商id")
|
||||
private String providerId;
|
||||
|
||||
/**
|
||||
* 用户角色
|
||||
*/
|
||||
@ApiModelProperty(value = "用户角色")
|
||||
private String userLevel;
|
||||
|
||||
|
||||
/**
|
||||
* 授权code
|
||||
*/
|
||||
@ApiModelProperty(value = "授权code")
|
||||
private String code;
|
||||
|
||||
|
||||
/**
|
||||
* 验证验证码 是否正确 (目前都不需要验证码)
|
||||
*
|
||||
* @return 正确返回true 否则返回false
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
|
||||
// 目前都不需要验证码
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getUserLevel() {
|
||||
return userLevel;
|
||||
}
|
||||
|
||||
public void setUserLevel(String userLevel) {
|
||||
this.userLevel = userLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BindParams{" +
|
||||
"userId='" + userId + '\'' +
|
||||
", providerId='" + providerId + '\'' +
|
||||
", userLevel='" + userLevel + '\'' +
|
||||
", code='" + code + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/5/19.
|
||||
* 会员搜索条件
|
||||
*/
|
||||
@ApiModel(description = "会员搜索条件")
|
||||
public class CustomerSearchCondition {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户的真实姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "用户的真实姓名")
|
||||
private String releName;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机是否验证 0 否 1 验证 默认0
|
||||
*/
|
||||
@ApiModelProperty(value = "手机是否验证 0 否 1 验证 默认0")
|
||||
private String isMobileVerification;
|
||||
|
||||
/**
|
||||
* 邮箱是否验证 0 否 1 验证 默认0
|
||||
*/
|
||||
@ApiModelProperty(value = "邮箱是否验证 0 否 1 验证 默认0")
|
||||
private String isEmailVerification;
|
||||
|
||||
/**
|
||||
* 用户状态 1 正常 2 冻结 默认1
|
||||
*/
|
||||
@ApiModelProperty(value = "用户状态 1 正常 2 冻结 默认1")
|
||||
private String status;
|
||||
|
||||
|
||||
/**
|
||||
* 1 普通用户 2 商家店铺用户
|
||||
*/
|
||||
@ApiModelProperty(value = "1 普通用户 2 商家店铺用户")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 归属门店id
|
||||
*/
|
||||
@ApiModelProperty(value = "归属门店id")
|
||||
private long beloneStoreId;
|
||||
|
||||
|
||||
/**
|
||||
* 获得搜索条件
|
||||
*
|
||||
* @return 返回搜索套件
|
||||
*/
|
||||
public Map<String, Object> getSearchParams() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("userName", userName);
|
||||
params.put("releName", releName);
|
||||
params.put("mobile", mobile);
|
||||
params.put("email", email);
|
||||
params.put("isMobileVerification", isMobileVerification);
|
||||
params.put("isEmailVerification", isEmailVerification);
|
||||
params.put("status", status);
|
||||
params.put("type", type);
|
||||
params.put("createTime", createTime);
|
||||
params.put("beloneStoreId", beloneStoreId);
|
||||
return params;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getReleName() {
|
||||
return releName;
|
||||
}
|
||||
|
||||
public void setReleName(String releName) {
|
||||
this.releName = releName;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getIsMobileVerification() {
|
||||
return isMobileVerification;
|
||||
}
|
||||
|
||||
public void setIsMobileVerification(String isMobileVerification) {
|
||||
this.isMobileVerification = isMobileVerification;
|
||||
}
|
||||
|
||||
public String getIsEmailVerification() {
|
||||
return isEmailVerification;
|
||||
}
|
||||
|
||||
public void setIsEmailVerification(String isEmailVerification) {
|
||||
this.isEmailVerification = isEmailVerification;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getBeloneStoreId() {
|
||||
return beloneStoreId;
|
||||
}
|
||||
|
||||
public void setBeloneStoreId(long beloneStoreId) {
|
||||
this.beloneStoreId = beloneStoreId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/22.
|
||||
* 忘记密码请求
|
||||
*/
|
||||
@ApiModel(description = "忘记密码请求")
|
||||
public class ForgetPwdRequest {
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 发送给手机的验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "发送给手机的验证码")
|
||||
private String originCode;
|
||||
|
||||
/**
|
||||
* 凭证
|
||||
*/
|
||||
@ApiModelProperty(value = "凭证")
|
||||
private String certificate;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 随机数
|
||||
*/
|
||||
@ApiModelProperty(value = "随机数")
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 请求来自 1:pc
|
||||
*/
|
||||
@ApiModelProperty(value = "请求来自 1:pc")
|
||||
private String requestFrom;
|
||||
|
||||
/**
|
||||
* 用户输入的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的图片验证码")
|
||||
private String kaptcha;
|
||||
|
||||
/**
|
||||
* 存在redis中的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存在redis中的图片验证码")
|
||||
private String oldKaptcha;
|
||||
|
||||
/**
|
||||
* 随机数(pc端图片验证码用)
|
||||
*/
|
||||
@ApiModelProperty(value = "随机数(pc端图片验证码用)")
|
||||
private String uuidForPcKaptcha;
|
||||
|
||||
/**
|
||||
* 是否有凭证
|
||||
*
|
||||
* @return 有返回true
|
||||
*/
|
||||
public boolean hasCertificate() {
|
||||
return !StringUtils.isEmpty(certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断验证码是否正确
|
||||
*
|
||||
* @return 正确返回true
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
if (StringUtils.isEmpty(this.code)) {
|
||||
return false;
|
||||
}
|
||||
return this.code.equals(this.originCode);
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getOriginCode() {
|
||||
return originCode;
|
||||
}
|
||||
|
||||
public void setOriginCode(String originCode) {
|
||||
this.originCode = originCode;
|
||||
}
|
||||
|
||||
public String getCertificate() {
|
||||
return certificate;
|
||||
}
|
||||
|
||||
public void setCertificate(String certificate) {
|
||||
this.certificate = certificate;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getRequestFrom() {
|
||||
return requestFrom;
|
||||
}
|
||||
|
||||
public void setRequestFrom(String requestFrom) {
|
||||
this.requestFrom = requestFrom;
|
||||
}
|
||||
|
||||
public String getKaptcha() {
|
||||
return kaptcha;
|
||||
}
|
||||
|
||||
public void setKaptcha(String kaptcha) {
|
||||
this.kaptcha = kaptcha;
|
||||
}
|
||||
|
||||
public String getOldKaptcha() {
|
||||
return oldKaptcha;
|
||||
}
|
||||
|
||||
public void setOldKaptcha(String oldKaptcha) {
|
||||
this.oldKaptcha = oldKaptcha;
|
||||
}
|
||||
|
||||
public String getUuidForPcKaptcha() {
|
||||
return uuidForPcKaptcha;
|
||||
}
|
||||
|
||||
public void setUuidForPcKaptcha(String uuidForPcKaptcha) {
|
||||
this.uuidForPcKaptcha = uuidForPcKaptcha;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import com.ruoyi.segchk.domain.SegchkUserBasicInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* 登入参数实体
|
||||
*/
|
||||
@ApiModel(description = "登入参数实体")
|
||||
public class LoginParams {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 回调函数
|
||||
*/
|
||||
@ApiModelProperty(value = "回调函数")
|
||||
private Consumer<SegchkUserBasicInfo> consumer;
|
||||
|
||||
/**
|
||||
* 用户输入的验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* session中的验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "session中的验证码")
|
||||
private String codeInSession;
|
||||
|
||||
/**
|
||||
* 登录来源 0 pc 1 app 2 mobile
|
||||
*/
|
||||
private int source;
|
||||
|
||||
public void setFromApp() {
|
||||
this.source = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证验证码 是否正确 (目前都不需要验证码)
|
||||
*
|
||||
* @return 正确返回true 否则返回false
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
|
||||
// 目前都不需要验证码
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Consumer<SegchkUserBasicInfo> getConsumer() {
|
||||
return consumer;
|
||||
}
|
||||
|
||||
public void setConsumer(Consumer<SegchkUserBasicInfo> consumer) {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCodeInSession() {
|
||||
return codeInSession;
|
||||
}
|
||||
|
||||
public void setCodeInSession(String codeInSession) {
|
||||
this.codeInSession = codeInSession;
|
||||
}
|
||||
|
||||
public int getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(int source) {
|
||||
this.source = source;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会员预存款查询条件
|
||||
*/
|
||||
@ApiModel(description = "会员预存款查询条件")
|
||||
public class QueryCriteria {
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
@ApiModelProperty(value = "会员id")
|
||||
private long customerId;
|
||||
|
||||
private int pageNum =0;
|
||||
/**
|
||||
* 会员名称
|
||||
*/
|
||||
@ApiModelProperty(value = "会员名称")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 交易单号
|
||||
*/
|
||||
@ApiModelProperty(value = "交易单号")
|
||||
private String transCode;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 查询类型 1全部 2 收入 3支出 默认全部
|
||||
*/
|
||||
@ApiModelProperty(value = "查询类型 1全部 2 收入 3支出 默认全部")
|
||||
private String filterType = "1";
|
||||
|
||||
/**
|
||||
* 获得查询条件
|
||||
*
|
||||
* @return 返回查询条件
|
||||
*/
|
||||
public Map<String, Object> getQueryMap() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("customerId", customerId);
|
||||
params.put("userName", userName);
|
||||
params.put("transCode", transCode);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("filterType", filterType);
|
||||
params.put("pageNum", pageNum);
|
||||
return params;
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(int pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getTransCode() {
|
||||
return transCode;
|
||||
}
|
||||
|
||||
public void setTransCode(String transCode) {
|
||||
this.transCode = transCode;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getFilterType() {
|
||||
return filterType;
|
||||
}
|
||||
|
||||
public void setFilterType(String filterType) {
|
||||
this.filterType = filterType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 免密登入参数实体
|
||||
*/
|
||||
@ApiModel(description = "免密登入参数实体")
|
||||
public class UnAuthLoginParams {
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phoneNo;
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@ApiModelProperty(value = "时间戳")
|
||||
private Long timeStamp;
|
||||
/**
|
||||
* 请求签名
|
||||
*/
|
||||
@ApiModelProperty(value = "请求签名")
|
||||
private String sign;
|
||||
|
||||
/**
|
||||
* 渠道类型
|
||||
*/
|
||||
@ApiModelProperty(value = "渠道类型")
|
||||
private String channelType;
|
||||
/**
|
||||
* 回调函数
|
||||
*/
|
||||
private Consumer<Long> consumer;
|
||||
|
||||
public String getPhoneNo() {
|
||||
return phoneNo;
|
||||
}
|
||||
|
||||
public void setPhoneNo(String phoneNo) {
|
||||
this.phoneNo = phoneNo;
|
||||
}
|
||||
|
||||
public Long getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(Long timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getChannelType() {
|
||||
return channelType;
|
||||
}
|
||||
|
||||
public void setChannelType(String channelType) {
|
||||
this.channelType = channelType;
|
||||
}
|
||||
|
||||
public Consumer<Long> getConsumer() {
|
||||
return consumer;
|
||||
}
|
||||
|
||||
public void setConsumer(Consumer<Long> consumer) {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/20.
|
||||
* 修改支付密码实体
|
||||
*/
|
||||
@ApiModel(description = "修改支付密码实体")
|
||||
public class UpdatePayPwdBean {
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
@ApiModelProperty(value = "会员id")
|
||||
private long customerId;
|
||||
|
||||
/**
|
||||
* 用户输入的手机验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的手机验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 存起来的手机验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存起来的手机验证码")
|
||||
private String originCode;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
|
||||
/**
|
||||
* 凭证
|
||||
*/
|
||||
@ApiModelProperty(value = "凭证")
|
||||
private String certificate;
|
||||
|
||||
/**
|
||||
* 请求来自 1:pc
|
||||
*/
|
||||
@ApiModelProperty(value = "请求来自 1:pc")
|
||||
private String requestFrom;
|
||||
|
||||
/**
|
||||
* 用户输入的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的图片验证码")
|
||||
private String kaptcha;
|
||||
|
||||
/**
|
||||
* 存在redis中的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存在redis中的图片验证码")
|
||||
private String oldKaptcha;
|
||||
|
||||
/**
|
||||
* 随机数
|
||||
*/
|
||||
@ApiModelProperty(value = "随机数")
|
||||
private String uuid;
|
||||
|
||||
|
||||
/**
|
||||
* 是否有凭证
|
||||
*
|
||||
* @return 有返回true
|
||||
*/
|
||||
public boolean hasCertificate() {
|
||||
return !StringUtils.isEmpty(certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户输入的验证码是否正确
|
||||
*
|
||||
* @return 正确返回true
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
return StringUtils.isEmpty(this.code) ? false : this.code.equals(this.originCode);
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getOriginCode() {
|
||||
return originCode;
|
||||
}
|
||||
|
||||
public void setOriginCode(String originCode) {
|
||||
this.originCode = originCode;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String getCertificate() {
|
||||
return certificate;
|
||||
}
|
||||
|
||||
public void setCertificate(String certificate) {
|
||||
this.certificate = certificate;
|
||||
}
|
||||
|
||||
public String getRequestFrom() {
|
||||
return requestFrom;
|
||||
}
|
||||
|
||||
public void setRequestFrom(String requestFrom) {
|
||||
this.requestFrom = requestFrom;
|
||||
}
|
||||
|
||||
public String getKaptcha() {
|
||||
return kaptcha;
|
||||
}
|
||||
|
||||
public void setKaptcha(String kaptcha) {
|
||||
this.kaptcha = kaptcha;
|
||||
}
|
||||
|
||||
public String getOldKaptcha() {
|
||||
return oldKaptcha;
|
||||
}
|
||||
|
||||
public void setOldKaptcha(String oldKaptcha) {
|
||||
this.oldKaptcha = oldKaptcha;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.ruoyi.member.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/20.
|
||||
* 修改密码实体
|
||||
*/
|
||||
@ApiModel(description = "修改密码实体")
|
||||
public class UpdatePwdBean {
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
@ApiModelProperty(value = "会员id")
|
||||
private long customerId;
|
||||
|
||||
/**
|
||||
* 用户输入的手机验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的手机验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 存起来的手机验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存起来的手机验证码")
|
||||
private String originCode;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 凭证
|
||||
*/
|
||||
@ApiModelProperty(value = "凭证")
|
||||
private String certificate;
|
||||
|
||||
/**
|
||||
* 请求来自 1:pc
|
||||
*/
|
||||
@ApiModelProperty(value = "请求来自 1:pc")
|
||||
private String requestFrom;
|
||||
|
||||
/**
|
||||
* 用户输入的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "用户输入的图片验证码")
|
||||
private String kaptcha;
|
||||
|
||||
/**
|
||||
* 存在redis中的图片验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "存在redis中的图片验证码")
|
||||
private String oldKaptcha;
|
||||
|
||||
/**
|
||||
* 随机数
|
||||
*/
|
||||
@ApiModelProperty(value = "随机数")
|
||||
private String uuid;
|
||||
|
||||
|
||||
/**
|
||||
* 是否有凭证
|
||||
*
|
||||
* @return 有返回true
|
||||
*/
|
||||
public boolean hasCertificate() {
|
||||
return !StringUtils.isEmpty(certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户输入的验证码是否正确
|
||||
*
|
||||
* @return 正确返回true
|
||||
*/
|
||||
public boolean validateCode() {
|
||||
return StringUtils.isEmpty(this.code) ? false : this.code.equals(this.originCode);
|
||||
}
|
||||
|
||||
public long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getOriginCode() {
|
||||
return originCode;
|
||||
}
|
||||
|
||||
public void setOriginCode(String originCode) {
|
||||
this.originCode = originCode;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String getCertificate() {
|
||||
return certificate;
|
||||
}
|
||||
|
||||
public void setCertificate(String certificate) {
|
||||
this.certificate = certificate;
|
||||
}
|
||||
|
||||
public String getRequestFrom() {
|
||||
return requestFrom;
|
||||
}
|
||||
|
||||
public void setRequestFrom(String requestFrom) {
|
||||
this.requestFrom = requestFrom;
|
||||
}
|
||||
|
||||
public String getKaptcha() {
|
||||
return kaptcha;
|
||||
}
|
||||
|
||||
public void setKaptcha(String kaptcha) {
|
||||
this.kaptcha = kaptcha;
|
||||
}
|
||||
|
||||
public String getOldKaptcha() {
|
||||
return oldKaptcha;
|
||||
}
|
||||
|
||||
public void setOldKaptcha(String oldKaptcha) {
|
||||
this.oldKaptcha = oldKaptcha;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.order.service.impl;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/12/22.
|
||||
* 支付接口
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface PaySupplier<T, U, D> {
|
||||
|
||||
/**
|
||||
* 获得支付返回的参数结果
|
||||
*
|
||||
* @return 返回支付参数结果
|
||||
*/
|
||||
D getPayParams(T t, U u);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ruoyi.order.vo;
|
||||
|
||||
/**
|
||||
* Created by 魔金商城 on 17/11/13.
|
||||
* 订单枚举
|
||||
*/
|
||||
public enum OrderItem {
|
||||
LOG, ATTR, SKUS, CANREFUND, CANRETRUN, EXPRESSURL, STORE_INFO, BACK_PROGRESS, CUSTOMER, COMMUNITYHEAD
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.ruoyi.segchk.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* seg首页轮播图管理对象 segchk_carouse_mgt
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
public class SegchkCarouseMgt extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 轮播图id */
|
||||
@Excel(name = "轮播图id")
|
||||
private Long carouseId;
|
||||
|
||||
/** 运营商id,全局唯一 */
|
||||
@Excel(name = "运营商id,全局唯一")
|
||||
private Long providerId;
|
||||
|
||||
/** 商家id,全局唯一 */
|
||||
@Excel(name = "商家id,全局唯一")
|
||||
private Long storeId;
|
||||
|
||||
/** 商家轮播图1路径,默认用于首页推荐轮播图 */
|
||||
@Excel(name = "商家轮播图1路径,默认用于首页推荐轮播图")
|
||||
private String storeCarousel;
|
||||
|
||||
/** 管理状态,0有效,-1失效 */
|
||||
@Excel(name = "管理状态,0有效,-1失效")
|
||||
private Integer mgtState;
|
||||
|
||||
/** 排序id */
|
||||
@Excel(name = "排序id")
|
||||
private Integer sortId;
|
||||
|
||||
/** 修改时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date modTime;
|
||||
|
||||
public void setCarouseId(Long carouseId)
|
||||
{
|
||||
this.carouseId = carouseId;
|
||||
}
|
||||
|
||||
public Long getCarouseId()
|
||||
{
|
||||
return carouseId;
|
||||
}
|
||||
public void setProviderId(Long providerId)
|
||||
{
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public Long getProviderId()
|
||||
{
|
||||
return providerId;
|
||||
}
|
||||
public void setStoreId(Long storeId)
|
||||
{
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public Long getStoreId()
|
||||
{
|
||||
return storeId;
|
||||
}
|
||||
public void setStoreCarousel(String storeCarousel)
|
||||
{
|
||||
this.storeCarousel = storeCarousel;
|
||||
}
|
||||
|
||||
public String getStoreCarousel()
|
||||
{
|
||||
return storeCarousel;
|
||||
}
|
||||
public void setMgtState(Integer mgtState)
|
||||
{
|
||||
this.mgtState = mgtState;
|
||||
}
|
||||
|
||||
public Integer getMgtState()
|
||||
{
|
||||
return mgtState;
|
||||
}
|
||||
public void setSortId(Integer sortId)
|
||||
{
|
||||
this.sortId = sortId;
|
||||
}
|
||||
|
||||
public Integer getSortId()
|
||||
{
|
||||
return sortId;
|
||||
}
|
||||
public void setModTime(Date modTime)
|
||||
{
|
||||
this.modTime = modTime;
|
||||
}
|
||||
|
||||
public Date getModTime()
|
||||
{
|
||||
return modTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("carouseId", getCarouseId())
|
||||
.append("providerId", getProviderId())
|
||||
.append("storeId", getStoreId())
|
||||
.append("storeCarousel", getStoreCarousel())
|
||||
.append("mgtState", getMgtState())
|
||||
.append("sortId", getSortId())
|
||||
.append("modTime", getModTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.ruoyi.segchk.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* seg充值卡管理对象 segchk_charge_card
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-08-23
|
||||
*/
|
||||
public class SegchkChargeCard extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 运营商id,全局唯一 */
|
||||
@Excel(name = "运营商id,全局唯一")
|
||||
private Long providerId;
|
||||
|
||||
/** 卡类型id */
|
||||
@Excel(name = "卡类型id")
|
||||
private Long cardTypeId;
|
||||
|
||||
/** 卡类型名称(9.9,99,199,299) */
|
||||
@Excel(name = "卡类型名称(9.9,99,199,299)")
|
||||
private String cardTypeName;
|
||||
|
||||
/** 卡面额 */
|
||||
@Excel(name = "卡面额")
|
||||
private BigDecimal cardTypeValue;
|
||||
|
||||
/** 有效期时长 */
|
||||
@Excel(name = "有效期时长")
|
||||
private Integer effectiveTime;
|
||||
|
||||
/** 可购买次数 */
|
||||
@Excel(name = "可购买次数")
|
||||
private Integer buyCount;
|
||||
|
||||
/** 卡类型总核消次数 */
|
||||
@Excel(name = "卡类型总核消次数")
|
||||
private Integer cardTypeChkcount;
|
||||
|
||||
public void setProviderId(Long providerId)
|
||||
{
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public Long getProviderId()
|
||||
{
|
||||
return providerId;
|
||||
}
|
||||
public void setCardTypeId(Long cardTypeId)
|
||||
{
|
||||
this.cardTypeId = cardTypeId;
|
||||
}
|
||||
|
||||
public Long getCardTypeId()
|
||||
{
|
||||
return cardTypeId;
|
||||
}
|
||||
public void setCardTypeName(String cardTypeName)
|
||||
{
|
||||
this.cardTypeName = cardTypeName;
|
||||
}
|
||||
|
||||
public String getCardTypeName()
|
||||
{
|
||||
return cardTypeName;
|
||||
}
|
||||
public void setCardTypeValue(BigDecimal cardTypeValue)
|
||||
{
|
||||
this.cardTypeValue = cardTypeValue;
|
||||
}
|
||||
|
||||
public BigDecimal getCardTypeValue()
|
||||
{
|
||||
return cardTypeValue;
|
||||
}
|
||||
public void setEffectiveTime(Integer effectiveTime)
|
||||
{
|
||||
this.effectiveTime = effectiveTime;
|
||||
}
|
||||
|
||||
public Integer getEffectiveTime()
|
||||
{
|
||||
return effectiveTime;
|
||||
}
|
||||
public void setBuyCount(Integer buyCount)
|
||||
{
|
||||
this.buyCount = buyCount;
|
||||
}
|
||||
|
||||
public Integer getBuyCount()
|
||||
{
|
||||
return buyCount;
|
||||
}
|
||||
public void setCardTypeChkcount(Integer cardTypeChkcount)
|
||||
{
|
||||
this.cardTypeChkcount = cardTypeChkcount;
|
||||
}
|
||||
|
||||
public Integer getCardTypeChkcount()
|
||||
{
|
||||
return cardTypeChkcount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("providerId", getProviderId())
|
||||
.append("cardTypeId", getCardTypeId())
|
||||
.append("cardTypeName", getCardTypeName())
|
||||
.append("cardTypeValue", getCardTypeValue())
|
||||
.append("effectiveTime", getEffectiveTime())
|
||||
.append("buyCount", getBuyCount())
|
||||
.append("cardTypeChkcount", getCardTypeChkcount())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.segchk.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* seg充值卡管理对象 segchk_charge_card
|
||||
*
|
||||
* @author yinzhiying
|
||||
* @date 2021-07-01
|
||||
*/
|
||||
public class SegchkChargeRet extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 充值id */
|
||||
@Excel(name = "充值id")
|
||||
private Long chargeId;
|
||||
|
||||
/** 卡id */
|
||||
@Excel(name = "卡id")
|
||||
private Long cardId;
|
||||
|
||||
public Long getChargeId() {
|
||||
return chargeId;
|
||||
}
|
||||
|
||||
public void setChargeId(Long chargeId) {
|
||||
this.chargeId = chargeId;
|
||||
}
|
||||
|
||||
public Long getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
public void setCardId(Long cardId) {
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SegchkChargeRet{" +
|
||||
"chargeId=" + chargeId +
|
||||
", cardId=" + cardId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue