Initial commit
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Example sysUserDetails template template
|
||||
### Example sysUserDetails template
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
*.iml
|
||||
out
|
||||
gen
|
||||
target
|
||||
*.log
|
||||
logs
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.datao</groupId>
|
||||
<artifactId>swadmin</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<name>swadmin</name>
|
||||
<description>swadmin</description>
|
||||
<properties>
|
||||
<java.version>1.17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>druid-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>1.2.11</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!--添加jwt-->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- io包 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons</groupId>-->
|
||||
<!-- <artifactId>commons-io</artifactId>-->
|
||||
<!-- <version>1.3.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- Apache Commons FileUpload组件依赖, 由于不属于Spirng Boot,所以需要加上版本 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.whvcse</groupId>
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
<version>15.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>junit</groupId>-->
|
||||
<!-- <artifactId>junit</artifactId>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.34.0.ALL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
<version>0.2.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<layout>ZIP</layout>
|
||||
<includes>
|
||||
<include>
|
||||
<groupId>nothing</groupId>
|
||||
<artifactId>nothing</artifactId>
|
||||
</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.datao.Result;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 操作消息提醒
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class AjaxResult extends HashMap<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 状态码 */
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
/** 返回内容 */
|
||||
public static final String MSG_TAG = "msg";
|
||||
|
||||
/** 数据对象 */
|
||||
public static final String DATA_TAG = "data";
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
public AjaxResult()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
*/
|
||||
public AjaxResult(int code, String msg)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
*/
|
||||
public AjaxResult(int code, String msg, Object data)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
if (data!=null)
|
||||
{
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success()
|
||||
{
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功数据
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(Object data)
|
||||
{
|
||||
return AjaxResult.success("操作成功", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg)
|
||||
{
|
||||
return AjaxResult.success(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(HttpStatus.OK.value(), msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static AjaxResult error()
|
||||
{
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg)
|
||||
{
|
||||
return AjaxResult.error(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg)
|
||||
{
|
||||
return new AjaxResult(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 数据对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value)
|
||||
{
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.datao;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SwadminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SwadminApplication.class, args);
|
||||
|
||||
try {
|
||||
// ===== 在项目初始化bean后检验数据库连接是否
|
||||
DataSource dataSource = (DataSource) context.getBean("dataSource");
|
||||
dataSource.getConnection().close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// ===== 当检测数据库连接失败时, 停止项目启动
|
||||
System.exit(-1);
|
||||
// context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
|
||||
public class AlipayUtil {
|
||||
public static final String APP_ID = "2016041901311447";
|
||||
//支付宝私钥
|
||||
private static final String APP_PRIVATE_KEY = """
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDKIIMWunigVf65\
|
||||
5us9PWlMKebBlDwU8mkJHLWqSj35HWugWEq4lQkkCQOegUIHCvVGaQIyha9WpWdi\
|
||||
wxGQZTfry+VxGtA/TiFKD1K5hGQw7Wnf5yMqM/iFZGyORdWdtE1ajESrxHYqp05h\
|
||||
qqfk922qRgKtlFdHxU/52MCXhauhmvARrHHrFpe3QIXpFh5U05WyWqs2VhTGNihM\
|
||||
83sOvu6D8uEru412cMnbe0iu5Rc+nc0Uzy+YaJEVKtDBueu8IMZmTsJenK8eizrU\
|
||||
6gRZrgAB+bCJc4l1ZtA00/ygI6IawJf3S67fwb4+hL4fDyuhyCWU4lRGW8+mM8DP\
|
||||
tFaI9ciPAgMBAAECggEBAJ134MinM2yuMknARgoqusr0ZervwjMLe5r2u+zT9B4M\
|
||||
tplvz56ntTxWrXQh/T+hYN6e1nBnx+b362h80kUtJfjUm4aXPh/jjXm2IFuZcbjQ\
|
||||
bUhbOQEbBgVd7FiWvUokepMNbj5nSywFtcHPAwgVX2FlM5bpV2n5pUnffINPRxwZ\
|
||||
RverEmpcqZf1L5yPG8+axAh3RJdsM5PYp4D8erkD9bp0vU1Tq7hQ+MU9HHM/i9D8\
|
||||
L3kGSz/xah3l68QvI91MiyF3Qg1EMHyz4tqxq0Db63Err6s8v0Y0n8F9SCrzP2d5\
|
||||
d3Xh8MMuVNPtQnIEAG084IpK1HLy2pL9CDb47cRsyWkCgYEA7/E0ga9CFzMt6kAc\
|
||||
2qolXbX1jopwjVFpmfdWjyrrrDgke+eC19bFP/BR7MpLEKanTY8azKKU3VInIHFy\
|
||||
uddp/ZJqrMNHV0BtaiRWqJMw5VnuQTgTo1BNJ128bfLDep6F4I103csQncu9I6/S\
|
||||
Am2GSKPRvKu1CrzOJpige0jQx9UCgYEA16dwtnrw4vKeFvsTC2LOkiQ9YC/EFKkP\
|
||||
EKPhtHuTXeaxBQ1scZgBVTr65pfz3cl3VKbIfxFM5TflSl5K72KtxGPn/2wUh0fV\
|
||||
ud+E5LM76mGSe5pBjoPyFY2i/Qyic+AA8L8vfHQwKqFo1OqfDBEJkmrsXgjQBtyX\
|
||||
1Oi3zj9axNMCgYEA4J7FsMII9P8MdMcgO/QcluXIw3AGfcVBPsm1VsGvbsIAJZ5N\
|
||||
dxGwBnNLvoiCTUw2Qv088WUiRy6pQk3yQNfQeXmgM6t8FcpSo5LxLU7d71eJG7UL\
|
||||
bU+3aqrtw2AIb7oHSngid5+qJo6cudPWnj85/radmiqEiVDHDIrFcaRxDyECgYBW\
|
||||
TUDTFiIegH95rOKzNMh8PZp+Sr9KkVlhDGR/6NBRzMdcwUF7uBwYcrED5R2HzV8+\
|
||||
9jvYdiDyvkq5V0DfyfrGVED8u9D/TmUerG+vYncA1ilb46CGmxEfRP5MDGlau/NE\
|
||||
ZQ5o3MqF1PBx/K7Hkm3lNXsAKsCtbkwovTUJidsWVwKBgQC9BED3+SJIKmGnP107\
|
||||
piz0hCvT/5HkfOXYgP8K0IAATW26h81k5QFEGfWHGSKqam9oB+Jz2YToh7gwuS6E\
|
||||
Zo6zc0xzYPR5QJvbZC/YYOMmfjz0F9Z7uFC2Tq+143bCkg9XlDwY8KKTxAfb80t7\
|
||||
m9zGkwDF59l1GEV9QNmh1q7jKA==""";
|
||||
// public static final String ALIPAY_PUBLIC_KEY = "***********";//这个为你在支付宝上的商户的公钥,而不是支付宝公钥
|
||||
//支付宝公钥
|
||||
public static final String ALIPAY_PUBLIC_KEY = """
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi2w/yQ9QCkAeKD1mQDkN\
|
||||
tZ5GY83FQ2x+mEVmVMF1c2a4eb8btYd62WOzaCFb0Is8BP2up1B8GElTmoDEO44V\
|
||||
tuC+2elHYezSRXhiBcrnnRjZebFh+k5SG4pgIBXVsSR/2fL94p8reYadTmV18wLd\
|
||||
W7Mqi54S16WNlw+PXkg8o4bnYxvJj6K8/lhgZg5As5cfsWK4WMQ1osnlPkSUb4uj\
|
||||
ye4KB2RWkVla+cZmswu8gWA1M9ygtcjCpvTyT2oVIoFQkWIU3IO9CxVPWhF7l8nP\
|
||||
OJW2fj9qIWWISPNA4PJCeTvGwN7lwE4oASGnag0CSJxpgz8SmKKAFtOm4rB08aCG\
|
||||
4QIDAQAB""";
|
||||
public static final String SIGNTYPE = "RSA2";
|
||||
//支付宝回调的接口
|
||||
public static final String NOTIFYURL = "http://www.ichangzuo.com/index.php/Client/alipayOrderNotify";
|
||||
public static final String SERVERURL = "https://openapi.alipay.com/gateway.do";
|
||||
private static AlipayClient alipayClient = null;
|
||||
|
||||
//因为支付宝alipayClient本身是线程安全的,因此只用创建一个,创建成单例的模式
|
||||
public static AlipayClient getAlipayClient() {
|
||||
synchronized (AlipayUtil.class) {
|
||||
if (null == alipayClient) {
|
||||
alipayClient = new DefaultAlipayClient(SERVERURL, APP_ID, APP_PRIVATE_KEY,
|
||||
AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8,
|
||||
ALIPAY_PUBLIC_KEY, SIGNTYPE);
|
||||
}
|
||||
}
|
||||
return alipayClient;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
|
||||
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MpConfig {
|
||||
@Bean // MP 3.5.2版格式
|
||||
public MybatisPlusInterceptor paginationInterceptor() {
|
||||
MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();
|
||||
mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return mpInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除插件
|
||||
*/
|
||||
// @Bean
|
||||
// public ISqlInjector sqlInjector() {
|
||||
// return new LogicSqlInjector();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 分页插件 MP 3.2.0版格式
|
||||
* @return
|
||||
*/
|
||||
// @Bean
|
||||
// public PaginationInterceptor paginationInterceptor(){
|
||||
// return new PaginationInterceptor();
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.datao.config;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PassToken {
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.auth0.jwt.exceptions.AlgorithmMismatchException;
|
||||
import com.auth0.jwt.exceptions.InvalidClaimException;
|
||||
import com.auth0.jwt.exceptions.SignatureVerificationException;
|
||||
import com.auth0.jwt.exceptions.TokenExpiredException;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.util.TokenUtil;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 添加拦截器
|
||||
*/
|
||||
@Component
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
// System.out.println(String.format("[%s]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
|
||||
// +" preHandle "+request.getRequestURL());
|
||||
//如果不是映射到方法直接放行
|
||||
if(!(handler instanceof HandlerMethod)){
|
||||
return true;
|
||||
}
|
||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||
Method method = handlerMethod.getMethod();
|
||||
|
||||
HashMap<String,String> hashMap = new HashMap<>();
|
||||
String token = request.getHeader("Authorization");
|
||||
if((token == null || token.isEmpty())
|
||||
&& method.isAnnotationPresent(PassToken.class)) { //带有PassToken注解的方法不处理
|
||||
return true;
|
||||
}
|
||||
|
||||
String msg = "";
|
||||
try {
|
||||
if(token != null && token!="") {
|
||||
TokenUtil.verifyToken(token.substring(7));
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
msg = "token无效";
|
||||
}
|
||||
}catch (SignatureVerificationException e){
|
||||
// e.printStackTrace();
|
||||
msg = "签名不一致";
|
||||
}catch (TokenExpiredException e){
|
||||
// e.printStackTrace();
|
||||
msg = "令牌过期异常";
|
||||
}catch (AlgorithmMismatchException e) {
|
||||
// e.printStackTrace();
|
||||
msg = "算法不匹配异常";
|
||||
}catch (InvalidClaimException e){
|
||||
// e.printStackTrace();
|
||||
msg = "失效的claim异常";
|
||||
}catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
msg = "token无效";
|
||||
}
|
||||
|
||||
AjaxResult result = new AjaxResult(HttpStatus.UNAUTHORIZED.value(),msg);
|
||||
|
||||
String resultJson = JSON.toJSONString(result);
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
response.getWriter().print(resultJson);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
// System.out.println("postHandle");
|
||||
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) throws Exception {
|
||||
// System.out.println("afterCompletion");
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.datao.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
|
||||
//配置拦截事件
|
||||
@Configuration
|
||||
public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private TokenInterceptor tokenInterceptor;
|
||||
|
||||
/**
|
||||
* 配置跨域请求
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
//定义哪些URL接受跨域
|
||||
registry.addMapping("/**")
|
||||
//定义哪些origin可以跨域请求
|
||||
// .allowedOrigins("*")
|
||||
.allowedOriginPatterns("*")
|
||||
//定义接受的跨域请求方法
|
||||
.allowedMethods("POST", "GET", "PUT", "DELETE")
|
||||
.exposedHeaders("Set-Token")
|
||||
.allowCredentials(true)
|
||||
.allowedHeaders("*")
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("/error");
|
||||
list.add("/Api/**");
|
||||
|
||||
registry.addInterceptor(tokenInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
|
||||
public class WxpayUtil {
|
||||
/** App号 */
|
||||
public static String appId = "wx8f83a7f750d63431";
|
||||
/** 商户号 */
|
||||
public static String merchantId = "1266239101";
|
||||
/** 商户API私钥路径 */
|
||||
public static String privateKeyPath = "/opt/datao/ssl/apiclient_key.pem"; //"F:/唱作网工作交接/Wxpay/apiclient_key.pem";
|
||||
/** 商户证书序列号 */
|
||||
public static String merchantSerialNumber = "18650196CADB6AB05753AFF90B5C60EBFDDB9858";
|
||||
/** 商户APIV3密钥 */
|
||||
public static String apiV3Key = "aS1yC4sS3xM8hI3oF1qD2uZ7kH8mO3uB";
|
||||
//回调地址
|
||||
public static final String NOTIFYURL = "http://www.ichangzuo.com/index.php/Client/wxpayOrderNotify";
|
||||
//Wxpayconfig
|
||||
private static Config wxpayConfig = null;
|
||||
|
||||
public static Config getWxpayConfig() {
|
||||
synchronized (AlipayUtil.class) {
|
||||
if (null == wxpayConfig) {
|
||||
wxpayConfig = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(merchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3Key)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
return wxpayConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.config.PassToken;
|
||||
import com.datao.controller.dto.PwdDto;
|
||||
import com.datao.controller.dto.LoginDto;
|
||||
import com.datao.service.LoginService;
|
||||
import com.datao.util.CaptchaUtil;
|
||||
import com.datao.util.TokenUtil;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
// @Autowired
|
||||
final private LoginService loginService;
|
||||
|
||||
public AdminController(LoginService loginService) {
|
||||
this.loginService = loginService;
|
||||
}
|
||||
|
||||
@GetMapping("/captcha")
|
||||
@PassToken
|
||||
public AjaxResult captcha(){
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("uuid", uuid);
|
||||
ajax.put("img", CaptchaUtil.getCaptcha(uuid));
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@PassToken
|
||||
public AjaxResult login(@RequestBody LoginDto dto){
|
||||
if( !CaptchaUtil.verifyCaptcha(dto.getUuid(), dto.getCode())) {
|
||||
return AjaxResult.error(HttpStatus.NOT_ACCEPTABLE.value(), "登录失败!验证码不正确。");
|
||||
}
|
||||
|
||||
if (loginService.login(dto)) {
|
||||
HashMap<String, String> claim = new HashMap();
|
||||
claim.put("name", dto.getUsername());
|
||||
String token = TokenUtil.createToken(claim);
|
||||
|
||||
return AjaxResult.success().put("token", token);
|
||||
}
|
||||
|
||||
return AjaxResult.error(HttpStatus.NOT_ACCEPTABLE.value(), "登录失败!账号或者密码不正确。");
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
public AjaxResult password(@RequestBody PwdDto dto) {
|
||||
if(loginService.updatePassword(dto.getUsername(), dto.getPassword(), dto.getNewPassword())) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.config.PassToken;
|
||||
import com.datao.service.ApiService;
|
||||
import com.datao.util.ParamDecoder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/Api")
|
||||
public class ApiController {
|
||||
@Autowired
|
||||
private ParamDecoder decoder;
|
||||
|
||||
@Autowired
|
||||
private ApiService apiService;
|
||||
|
||||
@GetMapping("/chkServer")
|
||||
public String chkServer(){
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/getUpgradeUrl")
|
||||
public String getUpgradeUrl(@RequestParam Integer sid){
|
||||
return apiService.getUpgradePath(sid);
|
||||
}
|
||||
|
||||
@PostMapping("/verifyAppleReceipt")
|
||||
public AjaxResult verifyAppleReceipt(@RequestBody String param) {
|
||||
// System.out.println(param);
|
||||
return apiService.verifyAppleReceipt(param, false);
|
||||
}
|
||||
|
||||
// @PostMapping("/getOrderInfo")
|
||||
// public AjaxResult getOrderInfo(@RequestParam String user, @RequestParam String password, @RequestParam String money) {
|
||||
// String order = "20240609-ali_ad-328577-230635";
|
||||
// return apiService.getAlipayInfo(money, order);
|
||||
// }
|
||||
@PostMapping("/getPrepayInfo")
|
||||
public AjaxResult getPrepayInfo(@RequestParam String order, @RequestParam String money, @RequestParam String type) {
|
||||
System.out.println("getPrepayInfo: " + order + " " + money + " " + type);
|
||||
if(Objects.equals(type, "ali_ad"))
|
||||
return apiService.getAliPayInfo(money, order);
|
||||
else if(Objects.equals(type, "wx_ad"))
|
||||
return apiService.getWxPayInfo(money, order);
|
||||
|
||||
return AjaxResult.error("无效的支付类型参数");
|
||||
}
|
||||
|
||||
// @PostMapping("/getAlipaySign")
|
||||
// public AjaxResult getAlipaySign(@RequestParam String order, @RequestParam String money) {
|
||||
// System.out.println("getAlipaySign: " + order + " " + money);
|
||||
// return apiService.getAliPayInfo(money, order);
|
||||
// }
|
||||
|
||||
@PostMapping("/notifyAlipayOrder")
|
||||
public AjaxResult notifyAlipayOrder(HttpServletRequest request) {
|
||||
return apiService.handleAlipayNotify(request);
|
||||
}
|
||||
|
||||
@PostMapping("/notifyWxpayOrder")
|
||||
public AjaxResult notifyWxpayOrder(HttpServletRequest request) {
|
||||
return apiService.handleWxpayNotify(request);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String handleApiRequest(@RequestBody String param) {
|
||||
HashMap<String, String> map = decoder.Decode(param);
|
||||
|
||||
if(map==null || map.isEmpty() || !map.containsKey("op")) return "err:103";
|
||||
|
||||
String op = map.get("op");
|
||||
switch (op) {
|
||||
case "getInfo": {
|
||||
Integer sid = Integer.parseInt(map.get("sid"));
|
||||
Integer ver = Integer.parseInt(map.get("ver"));
|
||||
|
||||
System.out.println(String.format("[%s]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
|
||||
+ map.toString());
|
||||
|
||||
return apiService.getInfo(sid, ver);
|
||||
}
|
||||
case "userLogin": {
|
||||
String uname = map.get("un").trim().toLowerCase();
|
||||
Integer sid = Integer.parseInt(map.get("sid"));
|
||||
String web = map.get("web");
|
||||
|
||||
System.out.println(String.format("[%s]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
|
||||
+ map.toString());
|
||||
|
||||
return apiService.userLogin(uname, sid, web);
|
||||
}
|
||||
case "setSlpAmo": {
|
||||
// return "err:102";
|
||||
Integer srv = Integer.parseInt(map.get("srv"));
|
||||
Integer tim = Integer.parseInt(map.get("tim"));
|
||||
Integer amo = Integer.parseInt(map.get("amo"));
|
||||
Integer ver = Integer.parseInt(map.get("ver"));
|
||||
|
||||
return apiService.setSlpAmo(srv, tim, amo, ver);
|
||||
}
|
||||
case "chkSlp":
|
||||
return apiService.chkSlp();
|
||||
case "getWebsite": {
|
||||
Integer sid = Integer.parseInt(map.get("sid"));
|
||||
String web = map.get("web");
|
||||
|
||||
return apiService.getWebsite(sid, web);
|
||||
}
|
||||
case "userRegister": {
|
||||
Integer sid = Integer.parseInt(map.get("sid"));
|
||||
String uname = map.get("un").trim().toLowerCase();
|
||||
String web = map.get("web");
|
||||
|
||||
System.out.println(String.format("[%s]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
|
||||
+ map.toString());
|
||||
|
||||
return apiService.userRegister(uname, sid, web);
|
||||
}
|
||||
case "predMatches": {
|
||||
Integer sid = Integer.parseInt(map.get("sid"));
|
||||
return apiService.getPredMatches(sid);
|
||||
}
|
||||
}
|
||||
|
||||
return "err:101";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.controller.dto.MsgDto;
|
||||
import com.datao.domain.Msg;
|
||||
import com.datao.service.MsgService;
|
||||
import com.datao.util.page.BasePage;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admin/message")
|
||||
public class MessageController {
|
||||
// @Autowired
|
||||
final private MsgService msgService;
|
||||
|
||||
public MessageController(MsgService msgService) {
|
||||
this.msgService = msgService;
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public AjaxResult pageList(@RequestBody BasePage dto){
|
||||
IPage<Msg> page = msgService.pageList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", page);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody MsgDto dto){
|
||||
Integer id = msgService.update(dto);
|
||||
if( id > 0 ) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", id);
|
||||
return ajax;
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult delete(@PathVariable Integer id){
|
||||
if(msgService.setHide(id)) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.config.PassToken;
|
||||
import com.datao.controller.dto.LoginDto;
|
||||
import com.datao.controller.dto.MsgDto;
|
||||
import com.datao.controller.dto.MsgListDto;
|
||||
import com.datao.controller.dto.PwdDto;
|
||||
import com.datao.domain.vo.MsgVo;
|
||||
import com.datao.service.MsgService;
|
||||
import com.datao.util.TokenUtil;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/msger")
|
||||
public class MsgerController {
|
||||
// @Autowired
|
||||
final private MsgService msgService;
|
||||
|
||||
public MsgerController(MsgService msgService) {
|
||||
this.msgService = msgService;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@PassToken
|
||||
public AjaxResult login(@RequestBody LoginDto dto){
|
||||
Integer uid = msgService.login(dto);
|
||||
if (uid > 0) {
|
||||
HashMap<String, String> claim = new HashMap();
|
||||
claim.put("name", dto.getUsername());
|
||||
String token = TokenUtil.createToken(claim);
|
||||
|
||||
return AjaxResult.success()
|
||||
.put("uid", uid)
|
||||
.put("token", token);
|
||||
}
|
||||
|
||||
return AjaxResult.error(HttpStatus.NOT_ACCEPTABLE.value(), "登录失败!账号或者密码不正确。");
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
public AjaxResult password(@RequestBody PwdDto dto) {
|
||||
if(msgService.updatePassword(dto.getUsername().trim(), dto.getPassword(), dto.getNewPassword())) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public AjaxResult getList(@RequestBody MsgListDto dto){
|
||||
List<MsgVo> lst = msgService.getList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", lst);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PostMapping("/send")
|
||||
public AjaxResult send(@RequestBody MsgDto dto){
|
||||
Integer id = msgService.update(dto);
|
||||
if( id > 0 ) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", id);
|
||||
return ajax;
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.domain.Server;
|
||||
import com.datao.service.ServerService;
|
||||
import com.datao.util.page.BasePage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admin/server")
|
||||
public class ServerController {
|
||||
@Autowired
|
||||
ServerService serverService;
|
||||
|
||||
@PostMapping("/page")
|
||||
public AjaxResult pageList(@RequestBody BasePage dto){
|
||||
IPage<Server> swPage = serverService.page(new Page(dto.getPageNum(),dto.getPageSize())); // .pageList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", swPage);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody Server dto){
|
||||
if( serverService.saveOrUpdate(dto)){// .update(dto) ) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{sid}")
|
||||
public AjaxResult delete(@PathVariable Integer sid){
|
||||
if(serverService.removeById(sid)){//.delete(sid)) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.controller.dto.SlpPageDto;
|
||||
import com.datao.domain.vo.SlpVo;
|
||||
import com.datao.service.SlpService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.datao.Result.AjaxResult.DATA_TAG;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/slp")
|
||||
public class SlpController {
|
||||
// @Autowired
|
||||
final private SlpService slpService;
|
||||
|
||||
public SlpController(SlpService slpService) {
|
||||
this.slpService = slpService;
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public AjaxResult pageList(@RequestBody SlpPageDto dto){
|
||||
IPage<SlpVo> page = slpService.pageList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put(DATA_TAG, page);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PostMapping("/sum")
|
||||
public AjaxResult sumList(@RequestBody(required=false) String mon){
|
||||
Map<String, Object> data = slpService.sumList(mon);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put(DATA_TAG, data);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.domain.Software;
|
||||
import com.datao.service.SoftwareService;
|
||||
import com.datao.util.page.BasePage;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/software")
|
||||
public class SoftwareController {
|
||||
// @Autowired
|
||||
private final SoftwareService softwareService;
|
||||
|
||||
// @Autowired
|
||||
public SoftwareController(SoftwareService softwareService) {
|
||||
this.softwareService = softwareService;
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public AjaxResult pageList(@RequestBody BasePage dto){
|
||||
IPage<Software> swPage = softwareService.page(new Page<>(dto.getPageNum(),dto.getPageSize())); // .pageList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", swPage);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody Software dto){
|
||||
if( softwareService.saveOrUpdate(dto) ){ //.update(dto) ) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{sid}")
|
||||
public AjaxResult deprecated(@PathVariable Integer sid){
|
||||
if(softwareService.deprecated(sid)) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.controller.dto.MemberDto;
|
||||
import com.datao.controller.dto.MemberPageDto;
|
||||
import com.datao.domain.vo.MemberVo;
|
||||
import com.datao.service.MemberService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/swmember")
|
||||
public class SwMemberController {
|
||||
// @Autowired
|
||||
final private MemberService memberService;
|
||||
|
||||
public SwMemberController(MemberService memberService) {
|
||||
this.memberService = memberService;
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public AjaxResult pageList(@RequestBody MemberPageDto dto){
|
||||
IPage<MemberVo> memberIPage = memberService.pageList(dto);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", memberIPage);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody MemberDto dto){
|
||||
if( memberService.update(dto) ) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult remove(@PathVariable Integer id){
|
||||
if(memberService.removeById(id)){// .remove(id)) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.datao.Result.AjaxResult;
|
||||
import com.datao.config.PassToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/upload")
|
||||
public class UploadController {
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@PostMapping
|
||||
public AjaxResult upload(MultipartFile file){
|
||||
if (file == null) return AjaxResult.error("文件获取失败");
|
||||
|
||||
String originalName = file.getOriginalFilename();
|
||||
if( originalName==null || originalName=="") return AjaxResult.error("文件获取失败");
|
||||
|
||||
StringBuilder url = new StringBuilder("/upload/");//返回值封装
|
||||
try {
|
||||
String uploadPath = env.getProperty("spring.servlet.multipart.location");
|
||||
// String[] strArray = originalName.split("\\.");
|
||||
int pos = originalName.lastIndexOf(".");
|
||||
String prefix = originalName.substring(0, pos),
|
||||
suffix = originalName.substring(pos+1);
|
||||
|
||||
File dir = new File(uploadPath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
Integer num = Integer.valueOf(1);
|
||||
String newName = originalName;
|
||||
File targetFile = new File(dir, originalName);
|
||||
while( targetFile.exists() ){
|
||||
newName = prefix + "(" + num + ")."+ suffix;
|
||||
targetFile = new File(dir, newName);
|
||||
num++;
|
||||
}
|
||||
|
||||
file.transferTo(targetFile);
|
||||
url.append(newName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error("文件保存失败");
|
||||
}
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("data", url);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user