feat: init
This commit is contained in:
parent
e5d7aa2e52
commit
01e8257efe
19
README.md
19
README.md
|
@ -1,19 +0,0 @@
|
|||
1、修改数据库配置
|
||||
数据库文件为sqllite》goview.db
|
||||
|
||||
|
||||
application-dev.yml
|
||||
修改为自己对于的存放地址
|
||||
url: jdbc:sqlite:D:\\eclipse-workspace\v2-goview-bate\sqllite\goview.db
|
||||
|
||||
|
||||
|
||||
|
||||
2、修改配置文件图片存放地址(3个值必须对,oss与fileurl 路径一样写法不一样别搞错了 有file:)
|
||||
|
||||
v2>oss值
|
||||
v2>fileurl值
|
||||
v2>httpurl值
|
||||
|
||||
|
||||
httpurl为图片上传的访问地址
|
|
@ -0,0 +1,27 @@
|
|||
<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>
|
||||
<parent>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>goview_admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-config</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>common-config</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>common-pojo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package cn.bunny.config.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*
|
||||
* @author fuce
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "bunny")
|
||||
@Data
|
||||
public class BunnyConfig {
|
||||
private String fileUrl;// 存储路径
|
||||
private String httpUrl;// 请求url
|
||||
private Map<String, String> xnljmap;// 虚拟路径map
|
||||
private String defaultFormat;// 默认文件格式
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.bunny.config.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
// 重写WebMvcConfigurer实现全局跨域配置
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
// 是否发送Cookie
|
||||
.allowCredentials(true)
|
||||
// 放行哪些原始域
|
||||
.allowedOrigins("*")
|
||||
// 放行哪些请求方式
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE")
|
||||
// 放行哪些原始请求头部信息
|
||||
.allowedHeaders("*")
|
||||
// 暴露哪些头部信息
|
||||
.exposedHeaders("*");
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.com.v2.common.config;
|
||||
package cn.bunny.config.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
/**
|
||||
/**
|
||||
* 新的分页插件,一缓和二缓遵循mybatis的规则,
|
||||
*/
|
||||
@Bean
|
|
@ -1,6 +1,7 @@
|
|||
package cn.com.v2.common.interceptor;
|
||||
package cn.bunny.config.interceptor;
|
||||
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -11,11 +12,11 @@ public class Interceptor implements HandlerInterceptor {
|
|||
/**
|
||||
* 在请求处理之前进行调用(Controller方法调用之前)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
return true;//如果设置为false时,被请求时,拦截器执行到此处将不会继续操作
|
||||
//如果设置为true时,请求将会继续执行后面的操作
|
||||
return true;// 如果设置为false时,被请求时,拦截器执行到此处将不会继续操作
|
||||
// 如果设置为true时,请求将会继续执行后面的操作
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +1,39 @@
|
|||
package cn.com.v2.common.interceptor;
|
||||
package cn.bunny.config.interceptor;
|
||||
|
||||
import cn.bunny.config.config.BunnyConfig;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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.InterceptorRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import cn.com.v2.common.config.V2Config;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
|
||||
@Configuration
|
||||
public class WebMvcConfig extends WebMvcConfigurationSupport {
|
||||
|
||||
@Autowired
|
||||
private V2Config v2Config;
|
||||
@Autowired
|
||||
private BunnyConfig bunnyConfig;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("error.html").addResourceLocations("classpath:/META-INF/resources/static/error.html");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
|
||||
List<String> list1=new ArrayList<String>();
|
||||
List<String> list2=new ArrayList<String>();
|
||||
List<String> list1 = new ArrayList<String>();
|
||||
List<String> list2 = new ArrayList<String>();
|
||||
|
||||
Map<String, String> map= v2Config.getXnljmap();
|
||||
Map<String, String> map = bunnyConfig.getXnljmap();
|
||||
|
||||
Set<String> set = map.keySet();
|
||||
for (String o : set) {
|
||||
list1.add("/"+o+"/**");
|
||||
list1.add("/" + o + "/**");
|
||||
list2.add(map.get(o));
|
||||
}
|
||||
registry.addResourceHandler(ArrayUtil.toArray(list1, String.class)).addResourceLocations(ArrayUtil.toArray(list2, String.class));
|
||||
registry.addResourceHandler(ArrayUtil.toArray(list1, String.class)).addResourceLocations(ArrayUtil.toArray(list2, String.class));
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,18 +46,18 @@ public class WebMvcConfig extends WebMvcConfigurationSupport {
|
|||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
|
||||
// 设置允许多个域名请求
|
||||
//String[] allowDomains = {"http://www.toheart.xin","http://192.168.11.213:8080","http://localhost:8080"};
|
||||
// 设置允许多个域名请求
|
||||
// String[] allowDomains = {"http://www.toheart.xin","http://192.168.11.213:8080","http://localhost:8080"};
|
||||
|
||||
//指哪些接口URL需要增加跨域设置
|
||||
// 指哪些接口URL需要增加跨域设置
|
||||
registry.addMapping("/**")
|
||||
//.allowedOrigins("*")//指的是前端哪些域名被允许跨域
|
||||
.allowedOriginPatterns("*")
|
||||
//需要带cookie等凭证时,设置为true,就会把cookie的相关信息带上
|
||||
// 需要带cookie等凭证时,设置为true,就会把cookie的相关信息带上
|
||||
.allowCredentials(true)
|
||||
//指的是允许哪些方法
|
||||
// 指的是允许哪些方法
|
||||
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
//cookie的失效时间,单位为秒(s),若设置为-1,则关闭浏览器就失效
|
||||
// cookie的失效时间,单位为秒(s),若设置为-1,则关闭浏览器就失效
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
|
@ -72,19 +69,19 @@ public class WebMvcConfig extends WebMvcConfigurationSupport {
|
|||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//注册Interceptor拦截器(Interceptor这个类是我们自己写的拦截器类)
|
||||
// 注册Interceptor拦截器(Interceptor这个类是我们自己写的拦截器类)
|
||||
InterceptorRegistration registration = registry.addInterceptor(new Interceptor());
|
||||
//addPathPatterns()方法添加需要拦截的路径
|
||||
//所有路径都被拦截
|
||||
// addPathPatterns()方法添加需要拦截的路径
|
||||
// 所有路径都被拦截
|
||||
registration.addPathPatterns("/**");
|
||||
//excludePathPatterns()方法添加不拦截的路径
|
||||
// excludePathPatterns()方法添加不拦截的路径
|
||||
|
||||
|
||||
String[] excludePatterns = new String[]{"/error","/error.html","/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**",
|
||||
String[] excludePatterns = new String[]{"/error", "/error.html", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**",
|
||||
"/api", "/api-docs", "/api-docs/**", "/doc.html/**",
|
||||
"/api/file/*"};
|
||||
|
||||
//添加不拦截路径
|
||||
// 添加不拦截路径
|
||||
registration.excludePathPatterns(excludePatterns);
|
||||
}
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
package cn.bunny.config.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
* @author fc
|
||||
*/
|
||||
public class ConvertUtil {
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return new Integer[]{};
|
||||
}
|
||||
String[] strings = str.split(split);
|
||||
final Integer[] ints = new Integer[strings.length];
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
final Integer v = toInt(strings[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为List<String>数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static List<String> toListStrArray(String str) {
|
||||
String[] stringArray = toStrArray(str);
|
||||
List<String> stringB = Arrays.asList(stringArray);
|
||||
return stringB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为List<Long>数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static List<Long> toListLongArray(String str) {
|
||||
Long[] stringArray = toLongArray(str);
|
||||
List<Long> stringB = Arrays.asList(stringArray);
|
||||
return stringB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str) {
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str) {
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return new Long[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return new BigDecimal((Long) value);
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return BigDecimal.valueOf((Double) value);
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.bunny.config.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
import com.baomidou.mybatisplus.generator.fill.Column;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class MybatisPlusGenerator {
|
||||
public static void main(String[] args) {
|
||||
FastAutoGenerator.create(
|
||||
"jdbc:sqlite:D:\\eclipse-workspace\\v2-goview-bate\\sqllite\\goview.db",
|
||||
"", "").globalConfig(builder -> {
|
||||
builder.author("fc") // 设置作者
|
||||
// .enableSwagger() // 开启 swagger 模式
|
||||
.fileOverride() // 覆盖已生成文件
|
||||
.disableOpenDir() // 禁止打开输出目录
|
||||
.outputDir(System.getProperty("user.dir") + "/src/main/java"); // 指定输出目录
|
||||
}).packageConfig(builder -> {
|
||||
builder.parent("cn.com") // 设置父包名
|
||||
.moduleName("v2") // 设置父包模块名
|
||||
.entity("model")
|
||||
// .service() // 设置自定义service路径,不设置就是默认路径
|
||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml,
|
||||
System.getProperty("user.dir") + "/src/main/resources/mapper/")); // 设置mapperXml生成路径
|
||||
}).strategyConfig(builder -> {
|
||||
builder.addInclude("t_goview_project_data") // 设置需要生成的表名
|
||||
.addTablePrefix("t_", "c_")
|
||||
// 设置自动填充的时间字段
|
||||
.entityBuilder().addTableFills(new Column("create_time", FieldFill.INSERT),
|
||||
new Column("update_time", FieldFill.INSERT_UPDATE)); // 设置过滤表前缀
|
||||
|
||||
}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||
.execute();
|
||||
}
|
||||
}
|
|
@ -1,51 +1,50 @@
|
|||
package cn.com.v2.util;
|
||||
package cn.bunny.config.utils;
|
||||
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import cn.com.v2.model.SysUser;
|
||||
import cn.bunny.domain.entity.SysUser;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/**
|
||||
* 封装 Sa-Token 常用操作
|
||||
* @author kong
|
||||
*
|
||||
* @author kong
|
||||
*/
|
||||
public class SaTokenUtil {
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取登录用户model
|
||||
*/
|
||||
public static SysUser getUser() {
|
||||
Object object=StpUtil.getSession().get("user");
|
||||
if(object!=null){
|
||||
SysUser tsysUser=new SysUser();
|
||||
BeanUtils.copyProperties(tsysUser, object);
|
||||
return tsysUser;
|
||||
}
|
||||
return null;
|
||||
Object object = StpUtil.getSession().get("user");
|
||||
if (object != null) {
|
||||
SysUser tsysUser = new SysUser();
|
||||
BeanUtils.copyProperties(tsysUser, object);
|
||||
return tsysUser;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* set用户
|
||||
*/
|
||||
public static void setUser(SysUser user) {
|
||||
StpUtil.getSession().set("user", user);
|
||||
StpUtil.getSession().set("user", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public static String getUserId() {
|
||||
return StpUtil.getLoginIdAsString();
|
||||
}
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public static String getUserId() {
|
||||
return StpUtil.getLoginIdAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户name
|
||||
*/
|
||||
public static String getLoginName() {
|
||||
SysUser tsysUser = getUser();
|
||||
if (tsysUser == null){
|
||||
SysUser tsysUser = getUser();
|
||||
if (tsysUser == null) {
|
||||
throw new RuntimeException("用户不存在!");
|
||||
}
|
||||
return tsysUser.getUsername();
|
||||
|
@ -53,6 +52,7 @@ public class SaTokenUtil {
|
|||
|
||||
/**
|
||||
* 获取登录用户ip
|
||||
*
|
||||
* @return
|
||||
* @author fuce
|
||||
* @Date 2019年11月21日 上午9:58:26
|
||||
|
@ -61,8 +61,10 @@ public class SaTokenUtil {
|
|||
|
||||
return StpUtil.getTokenSession().getString("login_ip");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否登录
|
||||
*
|
||||
* @return
|
||||
* @author fuce
|
||||
* @Date 2019年11月21日 上午9:58:26
|
|
@ -1,4 +1,4 @@
|
|||
package cn.com.v2.util;
|
||||
package cn.bunny.config.utils;
|
||||
|
||||
/**
|
||||
* Twitter_Snowflake<br>
|
||||
|
@ -15,54 +15,84 @@ package cn.com.v2.util;
|
|||
public class SnowflakeIdWorker {
|
||||
|
||||
// ==============================Fields===========================================
|
||||
/** 开始时间截 (2015-01-01) */
|
||||
/**
|
||||
* 开始时间截 (2015-01-01)
|
||||
*/
|
||||
private final long twepoch = 1489111610226L;
|
||||
|
||||
/** 机器id所占的位数 */
|
||||
/**
|
||||
* 机器id所占的位数
|
||||
*/
|
||||
private final long workerIdBits = 5L;
|
||||
|
||||
/** 数据标识id所占的位数 */
|
||||
/**
|
||||
* 数据标识id所占的位数
|
||||
*/
|
||||
private final long dataCenterIdBits = 5L;
|
||||
|
||||
/** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
|
||||
/**
|
||||
* 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
|
||||
*/
|
||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
|
||||
/** 支持的最大数据标识id,结果是31 */
|
||||
/**
|
||||
* 支持的最大数据标识id,结果是31
|
||||
*/
|
||||
private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits);
|
||||
|
||||
/** 序列在id中占的位数 */
|
||||
/**
|
||||
* 序列在id中占的位数
|
||||
*/
|
||||
private final long sequenceBits = 12L;
|
||||
|
||||
/** 机器ID向左移12位 */
|
||||
/**
|
||||
* 机器ID向左移12位
|
||||
*/
|
||||
private final long workerIdShift = sequenceBits;
|
||||
|
||||
/** 数据标识id向左移17位(12+5) */
|
||||
/**
|
||||
* 数据标识id向左移17位(12+5)
|
||||
*/
|
||||
private final long dataCenterIdShift = sequenceBits + workerIdBits;
|
||||
|
||||
/** 时间截向左移22位(5+5+12) */
|
||||
/**
|
||||
* 时间截向左移22位(5+5+12)
|
||||
*/
|
||||
private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
|
||||
|
||||
/** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
|
||||
/**
|
||||
* 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
|
||||
*/
|
||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
|
||||
/** 工作机器ID(0~31) */
|
||||
private long workerId;
|
||||
/**
|
||||
* 工作机器ID(0~31)
|
||||
*/
|
||||
private final long workerId;
|
||||
|
||||
/** 数据中心ID(0~31) */
|
||||
private long dataCenterId;
|
||||
/**
|
||||
* 数据中心ID(0~31)
|
||||
*/
|
||||
private final long dataCenterId;
|
||||
|
||||
/** 毫秒内序列(0~4095) */
|
||||
/**
|
||||
* 毫秒内序列(0~4095)
|
||||
*/
|
||||
private long sequence = 0L;
|
||||
|
||||
/** 上次生成ID的时间截 */
|
||||
/**
|
||||
* 上次生成ID的时间截
|
||||
*/
|
||||
private long lastTimestamp = -1L;
|
||||
|
||||
|
||||
static SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1);
|
||||
//==============================Constructors=====================================
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param workerId 工作ID (0~31)
|
||||
*
|
||||
* @param workerId 工作ID (0~31)
|
||||
* @param dataCenterId 数据中心ID (0~31)
|
||||
*/
|
||||
public SnowflakeIdWorker(long workerId, long dataCenterId) {
|
||||
|
@ -77,37 +107,39 @@ public class SnowflakeIdWorker {
|
|||
}
|
||||
|
||||
// ==============================Methods==========================================
|
||||
|
||||
/**
|
||||
* 获得下一个ID (该方法是线程安全的)
|
||||
*
|
||||
* @return SnowflakeId
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long timestamp = timeGen();
|
||||
|
||||
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
||||
// 如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(
|
||||
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
//如果是同一时间生成的,则进行毫秒内序列
|
||||
// 如果是同一时间生成的,则进行毫秒内序列
|
||||
if (lastTimestamp == timestamp) {
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
//毫秒内序列溢出
|
||||
// 毫秒内序列溢出
|
||||
if (sequence == 0) {
|
||||
//阻塞到下一个毫秒,获得新的时间戳
|
||||
// 阻塞到下一个毫秒,获得新的时间戳
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
}
|
||||
//时间戳改变,毫秒内序列重置
|
||||
// 时间戳改变,毫秒内序列重置
|
||||
else {
|
||||
sequence = 0L;
|
||||
}
|
||||
|
||||
//上次生成ID的时间截
|
||||
// 上次生成ID的时间截
|
||||
lastTimestamp = timestamp;
|
||||
|
||||
//移位并通过或运算拼到一起组成64位的ID
|
||||
// 移位并通过或运算拼到一起组成64位的ID
|
||||
return ((timestamp - twepoch) << timestampLeftShift) //
|
||||
| (dataCenterId << dataCenterIdShift) //
|
||||
| (workerId << workerIdShift) //
|
||||
|
@ -116,6 +148,7 @@ public class SnowflakeIdWorker {
|
|||
|
||||
/**
|
||||
* 阻塞到下一个毫秒,直到获得新的时间戳
|
||||
*
|
||||
* @param lastTimestamp 上次生成ID的时间截
|
||||
* @return 当前时间戳
|
||||
*/
|
||||
|
@ -129,6 +162,7 @@ public class SnowflakeIdWorker {
|
|||
|
||||
/**
|
||||
* 返回以毫秒为单位的当前时间
|
||||
*
|
||||
* @return 当前时间(毫秒)
|
||||
*/
|
||||
protected long timeGen() {
|
||||
|
@ -136,7 +170,10 @@ public class SnowflakeIdWorker {
|
|||
}
|
||||
|
||||
//==============================Test=============================================
|
||||
/** 测试 */
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println(System.currentTimeMillis());
|
||||
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1);
|
||||
|
@ -145,11 +182,11 @@ public class SnowflakeIdWorker {
|
|||
long id = idWorker.nextId();
|
||||
System.out.println(id);
|
||||
}
|
||||
System.out.println((System.nanoTime()-startTime)/1000000+"ms");
|
||||
System.out.println((System.nanoTime() - startTime) / 1000000 + "ms");
|
||||
}
|
||||
|
||||
public static String getUUID() {
|
||||
long id = idWorker.nextId();
|
||||
return String.valueOf(id);
|
||||
long id = idWorker.nextId();
|
||||
return String.valueOf(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cn.bunny;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<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>
|
||||
<parent>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>goview_admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-pojo</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>common-pojo</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,91 @@
|
|||
package cn.bunny.domain.dto;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GoviewProjectDto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value = "项目状态[-1未发布,1发布]")
|
||||
private Integer state;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "创建人id")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty(value = "删除状态[1删除,-1未删除]")
|
||||
private Integer isDelete;
|
||||
|
||||
@ApiModelProperty(value = "首页图片")
|
||||
private String indexImage;
|
||||
|
||||
@ApiModelProperty(value = "项目介绍")
|
||||
private String remarks;
|
||||
private String content;
|
||||
|
||||
@JsonProperty("id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonProperty("projectName")
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@JsonProperty("state")
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@JsonProperty("createTime")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@JsonProperty("createUserId")
|
||||
public String getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
@JsonProperty("isDelete")
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
@JsonProperty("indexImage")
|
||||
public String getIndexImage() {
|
||||
return indexImage;
|
||||
}
|
||||
|
||||
@JsonProperty("remarks")
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public String dateToStringConvert(Date date) {
|
||||
if (date != null) {
|
||||
return DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.bunny.domain.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysFileDto {
|
||||
private String id;
|
||||
private String fileName;
|
||||
private Integer fileSize;
|
||||
private String createTime;
|
||||
private String relativePath;// 相对路径
|
||||
private String virtualKey;// 虚拟路径key
|
||||
private String fileurl;// 请求url
|
||||
}
|
|
@ -1,45 +1,28 @@
|
|||
package cn.com.v2.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
package cn.bunny.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@TableName("t_goview_project")
|
||||
@Data
|
||||
public class GoviewProject implements Serializable {
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GoViewProject implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String projectName;
|
||||
|
||||
private Integer state;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createTime;
|
||||
|
||||
private String createUserId;
|
||||
|
||||
private Integer isDelete;
|
||||
|
||||
private String indexImage;
|
||||
|
||||
private String remarks;
|
||||
|
||||
}
|
|
@ -1,39 +1,25 @@
|
|||
package cn.com.v2.model;
|
||||
package cn.bunny.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Blob;
|
||||
import java.sql.SQLException;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@TableName("t_goview_project_data")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GoviewProjectData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createTime;
|
||||
|
||||
private String createUserId;
|
||||
|
||||
private String content;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package cn.bunny.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2022-12-22
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("t_sys_file")
|
||||
public class SysFile implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
private String fileName;
|
||||
private Integer fileSize;
|
||||
private String fileSuffix;
|
||||
private String virtualKey;// 虚拟路径
|
||||
private String relativePath;// 相对路径
|
||||
private String absolutePath;// 绝对路径
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createTime;
|
||||
}
|
|
@ -1,39 +1,27 @@
|
|||
package cn.com.v2.model;
|
||||
package cn.bunny.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@TableName("t_sys_user")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SysUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private Integer depId;
|
||||
|
||||
private String posId;
|
||||
|
||||
|
||||
}
|
|
@ -1,23 +1,14 @@
|
|||
package cn.com.v2.common.domain;
|
||||
package cn.bunny.domain.vo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @ClassName: AjaxResult
|
||||
* @Description: ajax操作消息提醒
|
||||
* @author fuce
|
||||
* @date 2018年8月18日
|
||||
*
|
||||
*/
|
||||
public class AjaxResult extends HashMap<String, Object>
|
||||
{
|
||||
public class AjaxResult extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 Message 对象
|
||||
*/
|
||||
public AjaxResult()
|
||||
{
|
||||
public AjaxResult() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,8 +16,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error()
|
||||
{
|
||||
public static AjaxResult error() {
|
||||
return error(500, "操作失败");
|
||||
}
|
||||
|
||||
|
@ -36,8 +26,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* @param msg 内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error(String msg)
|
||||
{
|
||||
public static AjaxResult error(String msg) {
|
||||
return error(500, msg);
|
||||
}
|
||||
|
||||
|
@ -45,11 +34,10 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* 返回错误消息
|
||||
*
|
||||
* @param code 错误码
|
||||
* @param msg 内容
|
||||
* @param msg 内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg)
|
||||
{
|
||||
public static AjaxResult error(int code, String msg) {
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
|
@ -62,8 +50,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* @param msg 内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg)
|
||||
{
|
||||
public static AjaxResult success(String msg) {
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("msg", msg);
|
||||
json.put("code", 200);
|
||||
|
@ -75,29 +62,27 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success()
|
||||
{
|
||||
public static AjaxResult success() {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
|
||||
public static AjaxResult successData(int code, Object value){
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("code", code);
|
||||
json.put("data", value);
|
||||
return json;
|
||||
public static AjaxResult successData(int code, Object value) {
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("code", code);
|
||||
json.put("data", value);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param key 键值
|
||||
* @param key 键值
|
||||
* @param value 内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value)
|
||||
{
|
||||
public AjaxResult put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package cn.bunny.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResultTable {
|
||||
private Integer code;// 状态码
|
||||
private String msg;// 提示消息
|
||||
private Long count;// 消息总量
|
||||
private Object data;// 数据对象
|
||||
|
||||
/**
|
||||
* 构 建
|
||||
*/
|
||||
public static ResultTable pageTable(long count, Object data) {
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.setData(data);
|
||||
resultTable.setCode(0);
|
||||
resultTable.setCount(count);
|
||||
if (data != null) {
|
||||
resultTable.setMsg("获取成功");
|
||||
} else {
|
||||
resultTable.setMsg("获取失败");
|
||||
}
|
||||
return resultTable;
|
||||
}
|
||||
|
||||
public static ResultTable dataTable(Object data) {
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.setData(data);
|
||||
resultTable.setCode(0);
|
||||
if (data != null) {
|
||||
resultTable.setMsg("获取成功");
|
||||
} else {
|
||||
resultTable.setMsg("获取失败");
|
||||
}
|
||||
return resultTable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package cn.bunny.domain.vo;
|
||||
|
||||
/**
|
||||
* boostrap table post 参数
|
||||
*
|
||||
* @author fc
|
||||
*/
|
||||
public class Tablepar {
|
||||
private int page;// 页码
|
||||
private int limit;// 数量
|
||||
private String orderByColumn;// 排序字段
|
||||
private String isAsc;// 排序字符 asc desc
|
||||
private String searchText;// 列表table里面的搜索
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getOrderByColumn() {
|
||||
return orderByColumn;
|
||||
}
|
||||
|
||||
public void setOrderByColumn(String orderByColumn) {
|
||||
this.orderByColumn = orderByColumn;
|
||||
}
|
||||
|
||||
public String getIsAsc() {
|
||||
return isAsc;
|
||||
}
|
||||
|
||||
public void setIsAsc(String isAsc) {
|
||||
this.isAsc = isAsc;
|
||||
}
|
||||
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
|
||||
public void setSearchText(String searchText) {
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
277
pom.xml
277
pom.xml
|
@ -1,160 +1,151 @@
|
|||
<?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.6</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>cn.com</groupId>
|
||||
<artifactId>goview_admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>oss</name>
|
||||
<description>goview后台系统</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||
<commons.io.version>2.7</commons.io.version>
|
||||
</properties>
|
||||
<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 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.6</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>goview_admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>oss</name>
|
||||
<description>goview后台系统</description>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<modules>
|
||||
<module>common-pojo</module>
|
||||
<module>common-config</module>
|
||||
<module>view-serve</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||
<commons.io.version>2.7</commons.io.version>
|
||||
</properties>
|
||||
|
||||
<!--io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<!--文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Hutool是一个Java工具包 http://hutool.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.3.3</version>
|
||||
</dependency>
|
||||
<!-- Hutool是一个Java工具包 http://hutool.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- >mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!--SQLite-->
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.44.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 热部署 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--SQLite-->
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.21.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 热部署 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.34.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- 打包不带版本号 -->
|
||||
<!-- <finalName>springboot_v2</finalName> -->
|
||||
<plugins>
|
||||
<!-- JUnit 配置 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<!--忽略测试启动类 -->
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- jar运行配置 正常打包-->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.34.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- 打包不带版本号 -->
|
||||
<!-- <finalName>springboot_v2</finalName> -->
|
||||
<plugins>
|
||||
<!-- JUnit 配置 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<!--忽略测试启动类 -->
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- jar运行配置 正常打包-->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
Binary file not shown.
|
@ -1,118 +0,0 @@
|
|||
package cn.com.v2.common.base;
|
||||
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import cn.com.v2.common.domain.AjaxResult;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @ClassName: BaseController
|
||||
* @author fuce
|
||||
* @date 2018年8月18日
|
||||
*
|
||||
*/
|
||||
|
||||
public class BaseController {
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new MyDateEditor());
|
||||
}
|
||||
|
||||
private class MyDateEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
// 通过两次异常的处理可以,绑定两次日期的格式
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date date = null;
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e) {
|
||||
format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e1) {
|
||||
format = new SimpleDateFormat("yyyy/MM/dd H:mm");
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
setValue(date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
return rows > 0 ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public AjaxResult success() {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error() {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
public AjaxResult successData(int code, Object value) {
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("code", code);
|
||||
json.put("data", value);
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(String message) {
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message) {
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误码消息
|
||||
*/
|
||||
public AjaxResult error(int code, String message) {
|
||||
return AjaxResult.error(code, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回object数据
|
||||
*/
|
||||
public AjaxResult retobject(int code, Object data) {
|
||||
return AjaxResult.successData(code, data);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cn.com.v2.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
//重写WebMvcConfigurer实现全局跨域配置
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer{
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
// 是否发送Cookie
|
||||
.allowCredentials(true)
|
||||
// 放行哪些原始域
|
||||
.allowedOrigins("*")
|
||||
// 放行哪些请求方式
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE")
|
||||
// 放行哪些原始请求头部信息
|
||||
.allowedHeaders("*")
|
||||
// 暴露哪些头部信息
|
||||
.exposedHeaders("*");
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package cn.com.v2.common.config;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*
|
||||
* @author fuce
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "v2")
|
||||
public class V2Config {
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String fileurl;
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
private String httpurl;
|
||||
/**
|
||||
* 虚拟路径map
|
||||
*/
|
||||
private Map<String, String> xnljmap;
|
||||
|
||||
/**
|
||||
* 默认文件格式
|
||||
*/
|
||||
private String defaultFormat;
|
||||
|
||||
|
||||
public String getFileurl() {
|
||||
return fileurl;
|
||||
}
|
||||
|
||||
public void setFileurl(String fileurl) {
|
||||
this.fileurl = fileurl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getHttpurl() {
|
||||
return httpurl;
|
||||
}
|
||||
|
||||
public void setHttpurl(String httpurl) {
|
||||
this.httpurl = httpurl;
|
||||
}
|
||||
|
||||
public Map<String, String> getXnljmap() {
|
||||
return xnljmap;
|
||||
}
|
||||
|
||||
public void setXnljmap(Map<String, String> xnljmap) {
|
||||
this.xnljmap = xnljmap;
|
||||
}
|
||||
|
||||
public String getDefaultFormat() {
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
public void setDefaultFormat(String defaultFormat) {
|
||||
this.defaultFormat = defaultFormat;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package cn.com.v2.common.domain;
|
||||
|
||||
public class ResultTable {
|
||||
/**
|
||||
* 状态码
|
||||
* */
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
* */
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 消息总量
|
||||
* */
|
||||
private Long count;
|
||||
|
||||
/**
|
||||
* 数据对象
|
||||
* */
|
||||
private Object data;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构 建
|
||||
* */
|
||||
public static ResultTable pageTable(long count,Object data){
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.setData(data);
|
||||
resultTable.setCode(0);
|
||||
resultTable.setCount(count);
|
||||
if(data!=null) {
|
||||
resultTable.setMsg("获取成功");
|
||||
}else {
|
||||
resultTable.setMsg("获取失败");
|
||||
}
|
||||
return resultTable;
|
||||
}
|
||||
|
||||
public static ResultTable dataTable(Object data){
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.setData(data);
|
||||
resultTable.setCode(0);
|
||||
if(data!=null) {
|
||||
resultTable.setMsg("获取成功");
|
||||
}else {
|
||||
resultTable.setMsg("获取失败");
|
||||
}
|
||||
|
||||
return resultTable;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package cn.com.v2.common.domain;
|
||||
|
||||
/**
|
||||
* boostrap table post 参数
|
||||
* @author fc
|
||||
*
|
||||
*/
|
||||
public class Tablepar {
|
||||
private int page;//页码
|
||||
private int limit;//数量
|
||||
private String orderByColumn;//排序字段
|
||||
private String isAsc;//排序字符 asc desc
|
||||
private String searchText;//列表table里面的搜索
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getOrderByColumn() {
|
||||
return orderByColumn;
|
||||
}
|
||||
public void setOrderByColumn(String orderByColumn) {
|
||||
this.orderByColumn = orderByColumn;
|
||||
}
|
||||
public String getIsAsc() {
|
||||
return isAsc;
|
||||
}
|
||||
public void setIsAsc(String isAsc) {
|
||||
this.isAsc = isAsc;
|
||||
}
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
public void setSearchText(String searchText) {
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package cn.com.v2.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import cn.com.v2.common.base.BaseController;
|
||||
import cn.com.v2.common.domain.AjaxResult;
|
||||
import cn.com.v2.model.SysUser;
|
||||
import cn.com.v2.service.ISysUserService;
|
||||
import cn.com.v2.util.SaTokenUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/goview/sys")
|
||||
public class ApiController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@ApiOperation(value = "登陆", notes = "登陆")
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public AjaxResult APIlogin(@RequestBody SysUser user, HttpServletRequest request) {
|
||||
|
||||
// 判断是否登陆
|
||||
if (StpUtil.isLogin()) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("userinfo", SaTokenUtil.getUser());
|
||||
map.put("token", StpUtil.getTokenInfo());
|
||||
return success().put("data", map);
|
||||
} else {
|
||||
if (StrUtil.isNotBlank(user.getUsername()) && StrUtil.isNotBlank(user.getPassword())) {
|
||||
SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, user.getUsername()).eq(SysUser::getPassword, SecureUtil.md5(user.getPassword())).last("LIMIT 1"));
|
||||
if (sysUser != null) {
|
||||
StpUtil.login(sysUser.getId());
|
||||
SaTokenUtil.setUser(sysUser);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("userinfo", sysUser);
|
||||
map.put("token", StpUtil.getTokenInfo());
|
||||
|
||||
return success().put("data", map);
|
||||
} else {
|
||||
return error(500, "账户或者密码错误");
|
||||
}
|
||||
} else {
|
||||
return error(500, "账户密码不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "登陆", notes = "登陆")
|
||||
@GetMapping("/logout")
|
||||
@ResponseBody
|
||||
public AjaxResult logout() {
|
||||
|
||||
// 判断是否登陆
|
||||
StpUtil.logout();
|
||||
|
||||
return success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取oss地址", notes = "获取oss地址")
|
||||
@GetMapping("/getOssInfo")
|
||||
@ResponseBody
|
||||
public AjaxResult getOssInfo() {
|
||||
|
||||
return success();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,376 +0,0 @@
|
|||
package cn.com.v2.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import cn.com.v2.common.base.BaseController;
|
||||
import cn.com.v2.common.config.V2Config;
|
||||
import cn.com.v2.common.domain.AjaxResult;
|
||||
import cn.com.v2.model.SysFile;
|
||||
import cn.com.v2.model.vo.SysFileVo;
|
||||
import cn.com.v2.service.ISysFileService;
|
||||
import cn.com.v2.util.SnowflakeIdWorker;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 文件上传controller
|
||||
* @author fuce
|
||||
* @date: 2018年9月16日 下午4:23:50
|
||||
*/
|
||||
@Api(value = "文件上传")
|
||||
@RestController
|
||||
@RequestMapping("/api/file")
|
||||
@Slf4j
|
||||
public class FileController extends BaseController{
|
||||
|
||||
|
||||
@Autowired
|
||||
private V2Config v2Config;
|
||||
@Autowired
|
||||
private ISysFileService iSysFileService;
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@DeleteMapping("/remove")
|
||||
public AjaxResult remove(String ids){
|
||||
Boolean b=iSysFileService.removeByIds(StrUtil.split(ids, ',',-1));
|
||||
if(b){
|
||||
return success();
|
||||
}else{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "修改", notes = "修改")
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(String id,@RequestBody MultipartFile object) throws IllegalStateException, IOException{
|
||||
SysFile sysFile=iSysFileService.getById(id);
|
||||
if(sysFile!=null){
|
||||
String fileurl=sysFile.getAbsolutePath()+sysFile.getRelativePath()+File.separator+sysFile.getFileName();
|
||||
object.transferTo(new File(fileurl));
|
||||
return success("修改成功");
|
||||
}else{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param object 文件流对象
|
||||
* @param bucketName 桶名
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult upload(@RequestBody MultipartFile object) throws IOException{
|
||||
String fileName = object.getOriginalFilename();
|
||||
//默认文件格式
|
||||
String suffixName=v2Config.getDefaultFormat();
|
||||
String mediaKey="";
|
||||
Long filesize= object.getSize();
|
||||
//文件名字
|
||||
String fileSuffixName="";
|
||||
if(fileName.lastIndexOf(".")!=-1) {//有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
//mediaKey=MD5.create().digestHex(fileName);
|
||||
mediaKey=SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName=mediaKey+suffixName;
|
||||
}else {//无后缀
|
||||
//取得唯一id
|
||||
//mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
mediaKey=SnowflakeIdWorker.getUUID();
|
||||
//fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey=getFirstNotNull(v2Config.getXnljmap());
|
||||
String absolutePath=v2Config.getXnljmap().get(getFirstNotNull(v2Config.getXnljmap()));
|
||||
SysFile sysFile=new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize+""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath=DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:",""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = getAbsoluteFile(v2Config.getFileurl()+File.separator+filepath,fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileVo sysFileVo=BeanUtil.copyProperties(sysFile, SysFileVo.class);
|
||||
sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName());
|
||||
return AjaxResult.successData(200, sysFileVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Base64字符串转成图片
|
||||
* @param str
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/uploadbase64")
|
||||
public synchronized AjaxResult uploadbase64(String base64str) throws IOException{
|
||||
if(StrUtil.isNotBlank(base64str)){
|
||||
String suffixName=v2Config.getDefaultFormat();
|
||||
String mediaKey=SnowflakeIdWorker.getUUID();
|
||||
String fileSuffixName=mediaKey+suffixName;
|
||||
String virtualKey=getFirstNotNull(v2Config.getXnljmap());
|
||||
String absolutePath=v2Config.getXnljmap().get(getFirstNotNull(v2Config.getXnljmap()));
|
||||
SysFile sysFile=new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath=DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:",""));
|
||||
File desc = getAbsoluteFile(v2Config.getFileurl()+File.separator+filepath,fileSuffixName);
|
||||
File file=null;
|
||||
try {
|
||||
file=Base64.decodeToFile(base64str, desc);
|
||||
} catch (Exception e) {
|
||||
System.out.println("错误base64:"+base64str);
|
||||
e.printStackTrace();
|
||||
}
|
||||
sysFile.setFileSize(Integer.parseInt(file.length()+""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
SysFileVo sysFileVo=BeanUtil.copyProperties(sysFile, SysFileVo.class);
|
||||
sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName());
|
||||
return AjaxResult.successData(200, sysFileVo);
|
||||
}
|
||||
return AjaxResult.error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定制方法
|
||||
* 根据关键字与相对路径获取文件内容
|
||||
* @param key 访问关键字
|
||||
* @param rpf 相对路径+文件名字
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getFileText")
|
||||
public AjaxResult getFileText(String key,String relativePath){
|
||||
String absolutePath= v2Config.getXnljmap().get(key).replace("file:", "");
|
||||
String fileurl=absolutePath+relativePath;
|
||||
try {
|
||||
String text=FileUtil.readUtf8String(fileurl);
|
||||
return AjaxResult.successData(200, text);
|
||||
}catch (IORuntimeException e) {
|
||||
return AjaxResult.error("没有该文件");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return AjaxResult.error("报错:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定制方法
|
||||
* 根据关键字与相对路径获取文件内容
|
||||
* @param key 访问关键字
|
||||
* @param rpf 相对路径+文件名字
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/getFileText302")
|
||||
public void getFileText302(String key,String relativePath,HttpServletResponse response) throws IOException{
|
||||
String str=v2Config.getHttpurl()+key+"/"+relativePath;
|
||||
response.sendRedirect(str);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 覆盖上传文件 key与指定路径
|
||||
* @param object 文件流对象
|
||||
* @param bucketName 桶名
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/coverupload")
|
||||
public AjaxResult coverupload(@RequestBody MultipartFile object,String key,String relativePath) throws IOException{
|
||||
|
||||
String fileName = object.getOriginalFilename();
|
||||
String suffixName=v2Config.getDefaultFormat();
|
||||
Long filesize= object.getSize();
|
||||
//文件名字
|
||||
String fileSuffixName="";
|
||||
if(fileName.lastIndexOf(".")!=-1) {//有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
//mediaKey=MD5.create().digestHex(fileName);
|
||||
//mediaKey=SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName=relativePath.substring(relativePath.lastIndexOf("/")+1,relativePath.length());
|
||||
}else {//无后缀
|
||||
//取得唯一id
|
||||
//mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
//mediaKey=SnowflakeIdWorker.getUUID();
|
||||
//fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey=key;
|
||||
String absolutePath=v2Config.getXnljmap().get(key).replace("file:", "");
|
||||
SysFile sysFile=new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize+""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath=relativePath.substring(0,relativePath.lastIndexOf("/"));
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath);
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = getAbsoluteFile(absolutePath+filepath,fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileVo sysFileVo=BeanUtil.copyProperties(sysFile, SysFileVo.class);
|
||||
sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName());
|
||||
return AjaxResult.successData(200, sysFileVo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据文件id查询文件信息json
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getFileid/{id}")
|
||||
public AjaxResult getFileid(@PathVariable("id") String id){
|
||||
SysFile sysFile=iSysFileService.getById(id);
|
||||
if(sysFile!=null){
|
||||
SysFileVo sysFileVo=BeanUtil.copyProperties(sysFile, SysFileVo.class);
|
||||
sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName());
|
||||
return AjaxResult.successData(200, sysFileVo);
|
||||
}
|
||||
return AjaxResult.error("没有该文件");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件id 302跳转到绝对地址
|
||||
* @param id
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping("/getFileid/302/{id}")
|
||||
public void getFileid302(@PathVariable("id") String id,HttpServletResponse response) throws IOException{
|
||||
SysFile sysFile=iSysFileService.getById(id);
|
||||
if(sysFile!=null){
|
||||
String str=v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName();
|
||||
response.sendRedirect(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param current
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(long current, long size){
|
||||
Page<SysFile> page= new Page<SysFile>(current, size);
|
||||
IPage<SysFile> sysFile=iSysFileService.page(page, new LambdaQueryWrapper<SysFile>());
|
||||
return sysFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取map中第一个非空数据key
|
||||
*
|
||||
* @param <K> Key的类型
|
||||
* @param <V> Value的类型
|
||||
* @param map 数据源
|
||||
* @return 返回的值
|
||||
*/
|
||||
public static <K, V> K getFirstNotNull(Map<K, V> map) {
|
||||
K obj = null;
|
||||
for (Entry<K, V> entry : map.entrySet()) {
|
||||
obj = entry.getKey();
|
||||
if (obj != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
public final static File getAbsoluteFile(String uploadDir, String filename) throws IOException
|
||||
{
|
||||
File desc = new File(uploadDir+File.separator + filename);
|
||||
|
||||
if (!desc.getParentFile().exists())
|
||||
{
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
if (!desc.exists())
|
||||
{
|
||||
desc.createNewFile();
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取上传文件的md5
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public String getMd5(MultipartFile file) {
|
||||
try {
|
||||
//获取文件的byte信息
|
||||
byte[] uploadBytes = file.getBytes();
|
||||
// 拿到一个MD5转换器
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md5.digest(uploadBytes);
|
||||
//转换为16进制
|
||||
return new BigInteger(1, digest).toString(16);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,257 +0,0 @@
|
|||
package cn.com.v2.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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.multipart.MultipartFile;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.com.v2.common.base.BaseController;
|
||||
import cn.com.v2.common.config.V2Config;
|
||||
import cn.com.v2.common.domain.AjaxResult;
|
||||
import cn.com.v2.common.domain.ResultTable;
|
||||
import cn.com.v2.common.domain.Tablepar;
|
||||
import cn.com.v2.model.GoviewProject;
|
||||
import cn.com.v2.model.GoviewProjectData;
|
||||
import cn.com.v2.model.SysFile;
|
||||
import cn.com.v2.model.vo.GoviewProjectVo;
|
||||
import cn.com.v2.model.vo.SysFileVo;
|
||||
import cn.com.v2.service.IGoviewProjectDataService;
|
||||
import cn.com.v2.service.IGoviewProjectService;
|
||||
import cn.com.v2.service.ISysFileService;
|
||||
import cn.com.v2.util.ConvertUtil;
|
||||
import cn.com.v2.util.SnowflakeIdWorker;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/goview/project")
|
||||
public class GoviewProjectController extends BaseController{
|
||||
@Autowired
|
||||
private ISysFileService iSysFileService;
|
||||
@Autowired
|
||||
private V2Config v2Config;
|
||||
@Autowired
|
||||
private IGoviewProjectService iGoviewProjectService;
|
||||
@Autowired
|
||||
private IGoviewProjectDataService iGoviewProjectDataService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分页跳转", notes = "分页跳转")
|
||||
@GetMapping("/list")
|
||||
@ResponseBody
|
||||
public ResultTable list(Tablepar tablepar){
|
||||
Page<GoviewProject> page= new Page<GoviewProject>(tablepar.getPage(), tablepar.getLimit());
|
||||
IPage<GoviewProject> iPages=iGoviewProjectService.page(page, new LambdaQueryWrapper<GoviewProject>());
|
||||
ResultTable resultTable=new ResultTable();
|
||||
resultTable.setData(iPages.getRecords());
|
||||
resultTable.setCode(200);
|
||||
resultTable.setCount(iPages.getTotal());
|
||||
resultTable.setMsg("获取成功");
|
||||
return resultTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@Log(title = "项目表新增", action = "111")
|
||||
@ApiOperation(value = "新增", notes = "新增")
|
||||
@PostMapping("/create")
|
||||
@ResponseBody
|
||||
public AjaxResult add(@RequestBody GoviewProject goviewProject){
|
||||
goviewProject.setCreateTime(DateUtil.now());
|
||||
goviewProject.setState(-1);
|
||||
boolean b=iGoviewProjectService.save(goviewProject);
|
||||
if(b){
|
||||
return successData(200, goviewProject).put("msg", "创建成功");
|
||||
}else{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目表删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@Log(title = "项目表删除", action = "111")
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids){
|
||||
List<String> lista=ConvertUtil.toListStrArray(ids);
|
||||
Boolean b=iGoviewProjectService.removeByIds(lista);
|
||||
if(b){
|
||||
return success();
|
||||
}else{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改保存", notes = "修改保存")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(@RequestBody GoviewProject goviewProject)
|
||||
{
|
||||
Boolean b= iGoviewProjectService.updateById(goviewProject);
|
||||
if(b){
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "项目重命名", notes = "项目重命名")
|
||||
@PostMapping("/rename")
|
||||
@ResponseBody
|
||||
public AjaxResult rename(@RequestBody GoviewProject goviewProject)
|
||||
{
|
||||
|
||||
LambdaUpdateWrapper<GoviewProject> updateWrapper=new LambdaUpdateWrapper<GoviewProject>();
|
||||
updateWrapper.eq(GoviewProject::getId, goviewProject.getId());
|
||||
updateWrapper.set(GoviewProject::getProjectName, goviewProject.getProjectName());
|
||||
Boolean b=iGoviewProjectService.update(updateWrapper);
|
||||
if(b){
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
|
||||
|
||||
//发布/取消项目状态
|
||||
@PutMapping("/publish")
|
||||
@ResponseBody
|
||||
public AjaxResult updateVisible(@RequestBody GoviewProject goviewProject){
|
||||
if(goviewProject.getState()==-1||goviewProject.getState()==1) {
|
||||
|
||||
LambdaUpdateWrapper<GoviewProject> updateWrapper=new LambdaUpdateWrapper<GoviewProject>();
|
||||
updateWrapper.eq(GoviewProject::getId, goviewProject.getId());
|
||||
updateWrapper.set(GoviewProject::getState, goviewProject.getState());
|
||||
Boolean b=iGoviewProjectService.update(updateWrapper);
|
||||
if(b){
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
return error("警告非法字段");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取项目存储数据", notes = "获取项目存储数据")
|
||||
@GetMapping("/getData")
|
||||
@ResponseBody
|
||||
public AjaxResult getData(String projectId, ModelMap map)
|
||||
{
|
||||
GoviewProject goviewProject= iGoviewProjectService.getById(projectId);
|
||||
|
||||
GoviewProjectData blogText=iGoviewProjectDataService.getProjectid(projectId);
|
||||
if(blogText!=null) {
|
||||
GoviewProjectVo goviewProjectVo=new GoviewProjectVo();
|
||||
BeanUtils.copyProperties(goviewProject,goviewProjectVo);
|
||||
goviewProjectVo.setContent(blogText.getContent());
|
||||
return AjaxResult.successData(200,goviewProjectVo).put("msg","获取成功");
|
||||
}
|
||||
return AjaxResult.successData(200, null).put("msg","无数据");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "保存项目数据", notes = "保存项目数据")
|
||||
@PostMapping("/save/data")
|
||||
@ResponseBody
|
||||
public AjaxResult saveData(GoviewProjectData data) {
|
||||
|
||||
GoviewProject goviewProject= iGoviewProjectService.getById(data.getProjectId());
|
||||
if(goviewProject==null) {
|
||||
return error("没有该项目ID");
|
||||
}
|
||||
GoviewProjectData goviewProjectData= iGoviewProjectDataService.getOne(new LambdaQueryWrapper<GoviewProjectData>().eq(GoviewProjectData::getProjectId, goviewProject.getId()));
|
||||
if(goviewProjectData!=null) {
|
||||
data.setId(goviewProjectData.getId());
|
||||
iGoviewProjectDataService.updateById(data);
|
||||
return success("数据保存成功");
|
||||
}else {
|
||||
iGoviewProjectDataService.save(data);
|
||||
return success("数据保存成功");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param object 文件流对象
|
||||
* @param bucketName 桶名
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult upload(@RequestBody MultipartFile object) throws IOException{
|
||||
String fileName = object.getOriginalFilename();
|
||||
//默认文件格式
|
||||
String suffixName=v2Config.getDefaultFormat();
|
||||
String mediaKey="";
|
||||
Long filesize= object.getSize();
|
||||
//文件名字
|
||||
String fileSuffixName="";
|
||||
if(fileName.lastIndexOf(".")!=-1) {//有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
//mediaKey=MD5.create().digestHex(fileName);
|
||||
mediaKey=SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName=mediaKey+suffixName;
|
||||
}else {//无后缀
|
||||
//取得唯一id
|
||||
//mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
mediaKey=SnowflakeIdWorker.getUUID();
|
||||
//fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey=FileController.getFirstNotNull(v2Config.getXnljmap());
|
||||
String absolutePath=v2Config.getXnljmap().get(FileController.getFirstNotNull(v2Config.getXnljmap()));
|
||||
SysFile sysFile=new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize+""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath=DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:",""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = FileController.getAbsoluteFile(v2Config.getFileurl()+File.separator+filepath,fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileVo sysFileVo=BeanUtil.copyProperties(sysFile, SysFileVo.class);
|
||||
sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName());
|
||||
return successData(200, sysFileVo);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cn.com.v2.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class Indexcontroller {
|
||||
|
||||
@GetMapping("/")
|
||||
public void index(HttpServletResponse response) throws IOException {
|
||||
response.setContentType("text/html; charset=utf-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println("<p style='color:orange'>goview后台首页</p>");
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.com.v2.mapper;
|
||||
|
||||
import cn.com.v2.model.GoviewProject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface GoviewProjectMapper extends BaseMapper<GoviewProject> {
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package cn.com.v2.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2022-12-22
|
||||
*/
|
||||
@TableName("t_sys_file")
|
||||
public class SysFile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private Integer fileSize;
|
||||
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 虚拟路径
|
||||
*/
|
||||
private String virtualKey;
|
||||
|
||||
/**
|
||||
* 相对路径
|
||||
*/
|
||||
private String relativePath;
|
||||
|
||||
/**
|
||||
* 绝对路径
|
||||
*/
|
||||
private String absolutePath;
|
||||
|
||||
|
||||
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createTime;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public Integer getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(Integer fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
public String getFileSuffix() {
|
||||
return fileSuffix;
|
||||
}
|
||||
|
||||
public void setFileSuffix(String fileSuffix) {
|
||||
this.fileSuffix = fileSuffix;
|
||||
}
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
public String getVirtualKey() {
|
||||
return virtualKey;
|
||||
}
|
||||
|
||||
public void setVirtualKey(String virtualKey) {
|
||||
this.virtualKey = virtualKey;
|
||||
}
|
||||
|
||||
public String getAbsolutePath() {
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
public void setAbsolutePath(String absolutePath) {
|
||||
this.absolutePath = absolutePath;
|
||||
}
|
||||
|
||||
public String getRelativePath() {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
public void setRelativePath(String relativePath) {
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package cn.com.v2.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class GoviewProjectVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value = "项目状态[-1未发布,1发布]")
|
||||
private Integer state;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "创建人id")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty(value = "删除状态[1删除,-1未删除]")
|
||||
private Integer isDelete;
|
||||
|
||||
@ApiModelProperty(value = "首页图片")
|
||||
private String indexImage;
|
||||
|
||||
@ApiModelProperty(value = "项目介绍")
|
||||
private String remarks;
|
||||
|
||||
private String content;
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@JsonProperty("projectName")
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
@JsonProperty("state")
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
@JsonProperty("createTime")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
@JsonProperty("createUserId")
|
||||
public String getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(String createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
@JsonProperty("isDelete")
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(Integer isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
@JsonProperty("indexImage")
|
||||
public String getIndexImage() {
|
||||
return indexImage;
|
||||
}
|
||||
|
||||
public void setIndexImage(String indexImage) {
|
||||
this.indexImage = indexImage;
|
||||
}
|
||||
@JsonProperty("remarks")
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String dateToStringConvert(Date date) {
|
||||
if(date!=null) {
|
||||
return DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package cn.com.v2.model.vo;
|
||||
|
||||
|
||||
public class SysFileVo {
|
||||
|
||||
private String id;
|
||||
private String fileName;
|
||||
private Integer fileSize;
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 相对路径
|
||||
*/
|
||||
private String relativePath;
|
||||
|
||||
/**
|
||||
* 虚拟路径key
|
||||
*/
|
||||
private String virtualKey;
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
private String fileurl;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
public Integer getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
public void setFileSize(Integer fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public String getRelativePath() {
|
||||
return relativePath;
|
||||
}
|
||||
public void setRelativePath(String relativePath) {
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
public String getVirtualKey() {
|
||||
return virtualKey;
|
||||
}
|
||||
public void setVirtualKey(String virtualKey) {
|
||||
this.virtualKey = virtualKey;
|
||||
}
|
||||
public String getFileurl() {
|
||||
return fileurl;
|
||||
}
|
||||
public void setFileurl(String fileurl) {
|
||||
this.fileurl = fileurl;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.com.v2.service;
|
||||
|
||||
import cn.com.v2.model.GoviewProject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IGoviewProjectService extends IService<GoviewProject> {
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package cn.com.v2.service.impl;
|
||||
|
||||
import cn.com.v2.model.GoviewProjectData;
|
||||
import cn.com.v2.mapper.GoviewProjectDataMapper;
|
||||
import cn.com.v2.service.IGoviewProjectDataService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@Service
|
||||
public class GoviewProjectDataServiceImpl extends ServiceImpl<GoviewProjectDataMapper, GoviewProjectData> implements IGoviewProjectDataService {
|
||||
@Autowired
|
||||
GoviewProjectDataMapper dataMapper;
|
||||
@Override
|
||||
public GoviewProjectData getProjectid(String projectId) {
|
||||
LambdaQueryWrapper<GoviewProjectData> lambdaQueryWrapper=new LambdaQueryWrapper<GoviewProjectData>();
|
||||
lambdaQueryWrapper.eq(GoviewProjectData::getProjectId, projectId);
|
||||
return dataMapper.selectOne(lambdaQueryWrapper);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,252 +0,0 @@
|
|||
package cn.com.v2.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
* @author fc
|
||||
*
|
||||
*/
|
||||
public class ConvertUtil {
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return new Integer[] {};
|
||||
}
|
||||
String[] strings = str.split(split);
|
||||
final Integer[] ints = new Integer[strings.length];
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
final Integer v = toInt(strings[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为List<String>数组<br>
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static List<String> toListStrArray(String str) {
|
||||
String[] stringArray = toStrArray(str);
|
||||
List<String> stringB = Arrays.asList(stringArray);
|
||||
return stringB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 转换为List<Long>数组<br>
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static List<Long> toListLongArray(String str) {
|
||||
Long[] stringArray = toLongArray(str);
|
||||
List<Long> stringB = Arrays.asList(stringArray);
|
||||
return stringB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str)
|
||||
{
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str)
|
||||
{
|
||||
if (StrUtil.isEmpty(str))
|
||||
{
|
||||
return new Long[] {};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++)
|
||||
{
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Long)
|
||||
{
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigDecimal)
|
||||
{
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof Long)
|
||||
{
|
||||
return new BigDecimal((Long) value);
|
||||
}
|
||||
if (value instanceof Double)
|
||||
{
|
||||
return new BigDecimal((Double) value);
|
||||
}
|
||||
if (value instanceof Integer)
|
||||
{
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrUtil.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigDecimal(valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package cn.com.v2.util;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
import com.baomidou.mybatisplus.generator.fill.Column;
|
||||
|
||||
|
||||
public class MybatisPlusGenerator {
|
||||
public static void main(String[] args) {
|
||||
FastAutoGenerator.create(
|
||||
"jdbc:sqlite:D:\\eclipse-workspace\\v2-goview-bate\\sqllite\\goview.db",
|
||||
"", "").globalConfig(builder -> {
|
||||
builder.author("fc") // 设置作者
|
||||
// .enableSwagger() // 开启 swagger 模式
|
||||
.fileOverride() // 覆盖已生成文件
|
||||
.disableOpenDir() //禁止打开输出目录
|
||||
.outputDir(System.getProperty("user.dir") + "/src/main/java"); // 指定输出目录
|
||||
}).packageConfig(builder -> {
|
||||
builder.parent("cn.com") // 设置父包名
|
||||
.moduleName("v2") // 设置父包模块名
|
||||
.entity("model")
|
||||
// .service() // 设置自定义service路径,不设置就是默认路径
|
||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml,
|
||||
System.getProperty("user.dir") + "/src/main/resources/mapper/")); // 设置mapperXml生成路径
|
||||
}).strategyConfig(builder -> {
|
||||
builder.addInclude("t_goview_project_data") // 设置需要生成的表名
|
||||
.addTablePrefix("t_", "c_")
|
||||
// 设置自动填充的时间字段
|
||||
.entityBuilder().addTableFills(new Column("create_time", FieldFill.INSERT),
|
||||
new Column("update_time", FieldFill.INSERT_UPDATE)); // 设置过滤表前缀
|
||||
|
||||
}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||
.execute();
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package cn.com.jetshine.oos;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class OosApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<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>
|
||||
<parent>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>goview_admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>view-serve</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>view-serve</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>common-pojo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>common-config</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,15 +1,13 @@
|
|||
package cn.com;
|
||||
package cn.bunny;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("cn.com.v2.mapper")
|
||||
@MapperScan("cn.bunny.mapper")
|
||||
public class GogoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GogoApplication.class, args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GogoApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
package cn.com;
|
||||
package cn.bunny;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(GogoApplication.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(GogoApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
import cn.bunny.config.utils.SaTokenUtil;
|
||||
import cn.bunny.domain.entity.SysUser;
|
||||
import cn.bunny.domain.vo.AjaxResult;
|
||||
import cn.bunny.service.ISysUserService;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/goview/sys")
|
||||
public class ApiController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@ApiOperation(value = "登陆", notes = "登陆")
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public AjaxResult APIlogin(@RequestBody SysUser user, HttpServletRequest request) {
|
||||
|
||||
// 判断是否登陆
|
||||
if (StpUtil.isLogin()) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("userinfo", SaTokenUtil.getUser());
|
||||
map.put("token", StpUtil.getTokenInfo());
|
||||
return success().put("data", map);
|
||||
} else {
|
||||
if (StrUtil.isNotBlank(user.getUsername()) && StrUtil.isNotBlank(user.getPassword())) {
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, user.getUsername()).eq(SysUser::getPassword, SecureUtil.md5(user.getPassword())).last("LIMIT 1");
|
||||
SysUser sysUser = iSysUserService.getOne(queryWrapper);
|
||||
if (sysUser != null) {
|
||||
StpUtil.login(sysUser.getId());
|
||||
SaTokenUtil.setUser(sysUser);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("userinfo", sysUser);
|
||||
map.put("token", StpUtil.getTokenInfo());
|
||||
|
||||
return success().put("data", map);
|
||||
} else {
|
||||
return error(500, "账户或者密码错误");
|
||||
}
|
||||
} else {
|
||||
return error(500, "账户密码不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "登陆", notes = "登陆")
|
||||
@GetMapping("/logout")
|
||||
@ResponseBody
|
||||
public AjaxResult logout() {
|
||||
// 判断是否登陆
|
||||
StpUtil.logout();
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取oss地址", notes = "获取oss地址")
|
||||
@GetMapping("/getOssInfo")
|
||||
@ResponseBody
|
||||
public AjaxResult getOssInfo() {
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
import cn.bunny.domain.vo.AjaxResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author fuce
|
||||
* @ClassName: BaseController
|
||||
* @date 2018年8月18日
|
||||
*/
|
||||
|
||||
public class BaseController {
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new MyDateEditor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
return rows > 0 ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public AjaxResult success() {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error() {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
public AjaxResult successData(int code, Object value) {
|
||||
AjaxResult json = new AjaxResult();
|
||||
json.put("code", code);
|
||||
json.put("data", value);
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(String message) {
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message) {
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误码消息
|
||||
*/
|
||||
public AjaxResult error(int code, String message) {
|
||||
return AjaxResult.error(code, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回object数据
|
||||
*/
|
||||
public AjaxResult retobject(int code, Object data) {
|
||||
return AjaxResult.successData(code, data);
|
||||
}
|
||||
|
||||
private class MyDateEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
// 通过两次异常的处理可以,绑定两次日期的格式
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date date = null;
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e) {
|
||||
format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e1) {
|
||||
format = new SimpleDateFormat("yyyy/MM/dd H:mm");
|
||||
try {
|
||||
date = format.parse(text);
|
||||
} catch (ParseException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
setValue(date);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,347 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
|
||||
import cn.bunny.config.config.BunnyConfig;
|
||||
import cn.bunny.config.utils.SnowflakeIdWorker;
|
||||
import cn.bunny.domain.dto.SysFileDto;
|
||||
import cn.bunny.domain.entity.SysFile;
|
||||
import cn.bunny.domain.vo.AjaxResult;
|
||||
import cn.bunny.service.ISysFileService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* 文件上传controller
|
||||
*
|
||||
* @author fuce
|
||||
* @date: 2018年9月16日 下午4:23:50
|
||||
*/
|
||||
@Api(value = "文件上传")
|
||||
@RestController
|
||||
@RequestMapping("/api/file")
|
||||
@Slf4j
|
||||
public class FileController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private BunnyConfig bunnyConfig;
|
||||
@Autowired
|
||||
private ISysFileService iSysFileService;
|
||||
|
||||
/**
|
||||
* 获取map中第一个非空数据key
|
||||
*
|
||||
* @param <K> Key的类型
|
||||
* @param <V> Value的类型
|
||||
* @param map 数据源
|
||||
* @return 返回的值
|
||||
*/
|
||||
public static <K, V> K getFirstNotNull(Map<K, V> map) {
|
||||
K obj = null;
|
||||
for (Entry<K, V> entry : map.entrySet()) {
|
||||
obj = entry.getKey();
|
||||
if (obj != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public final static File getAbsoluteFile(String uploadDir, String filename) throws IOException {
|
||||
File desc = new File(uploadDir + File.separator + filename);
|
||||
|
||||
if (!desc.getParentFile().exists()) {
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
if (!desc.exists()) {
|
||||
desc.createNewFile();
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@DeleteMapping("/remove")
|
||||
public AjaxResult remove(String ids) {
|
||||
boolean b = iSysFileService.removeByIds(StrUtil.split(ids, ',', -1));
|
||||
if (b) {
|
||||
return success();
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改", notes = "修改")
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(String id, @RequestBody MultipartFile object) throws IllegalStateException, IOException {
|
||||
SysFile sysFile = iSysFileService.getById(id);
|
||||
if (sysFile != null) {
|
||||
String fileurl = sysFile.getAbsolutePath() + sysFile.getRelativePath() + File.separator + sysFile.getFileName();
|
||||
object.transferTo(new File(fileurl));
|
||||
return success("修改成功");
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param object 文件流对象
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult upload(@RequestBody MultipartFile object) throws IOException {
|
||||
String fileName = object.getOriginalFilename();
|
||||
// 默认文件格式
|
||||
String suffixName = bunnyConfig.getDefaultFormat();
|
||||
String mediaKey = "";
|
||||
Long filesize = object.getSize();
|
||||
// 文件名字
|
||||
String fileSuffixName = "";
|
||||
if (fileName.lastIndexOf(".") != -1) {// 有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
// mediaKey=MD5.create().digestHex(fileName);
|
||||
mediaKey = SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName = mediaKey + suffixName;
|
||||
} else {// 无后缀
|
||||
// 取得唯一id
|
||||
// mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
mediaKey = SnowflakeIdWorker.getUUID();
|
||||
// fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey = getFirstNotNull(bunnyConfig.getXnljmap());
|
||||
String absolutePath = bunnyConfig.getXnljmap().get(getFirstNotNull(bunnyConfig.getXnljmap()));
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize + ""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath = DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:", ""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = getAbsoluteFile(bunnyConfig.getFileUrl() + File.separator + filepath, fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileDto SysFileDto = BeanUtil.copyProperties(sysFile, SysFileDto.class);
|
||||
SysFileDto.setFileurl(bunnyConfig.getFileUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName());
|
||||
return AjaxResult.successData(200, SysFileDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64字符串转成图片
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/uploadbase64")
|
||||
public synchronized AjaxResult uploadbase64(String base64str) throws IOException {
|
||||
if (StrUtil.isNotBlank(base64str)) {
|
||||
String suffixName = bunnyConfig.getDefaultFormat();
|
||||
String mediaKey = SnowflakeIdWorker.getUUID();
|
||||
String fileSuffixName = mediaKey + suffixName;
|
||||
String virtualKey = getFirstNotNull(bunnyConfig.getXnljmap());
|
||||
String absolutePath = bunnyConfig.getXnljmap().get(getFirstNotNull(bunnyConfig.getXnljmap()));
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath = DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:", ""));
|
||||
File desc = getAbsoluteFile(bunnyConfig.getFileUrl() + File.separator + filepath, fileSuffixName);
|
||||
File file = null;
|
||||
try {
|
||||
file = Base64.decodeToFile(base64str, desc);
|
||||
} catch (Exception e) {
|
||||
System.out.println("错误base64:" + base64str);
|
||||
e.printStackTrace();
|
||||
}
|
||||
sysFile.setFileSize(Integer.parseInt(file.length() + ""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
SysFileDto SysFileDto = BeanUtil.copyProperties(sysFile, SysFileDto.class);
|
||||
SysFileDto.setFileurl(bunnyConfig.getHttpUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName());
|
||||
return AjaxResult.successData(200, SysFileDto);
|
||||
}
|
||||
return AjaxResult.error();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 定制方法
|
||||
* 根据关键字与相对路径获取文件内容
|
||||
*
|
||||
* @param key 访问关键字
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getFileText")
|
||||
public AjaxResult getFileText(String key, String relativePath) {
|
||||
String absolutePath = bunnyConfig.getXnljmap().get(key).replace("file:", "");
|
||||
String fileurl = absolutePath + relativePath;
|
||||
try {
|
||||
String text = FileUtil.readUtf8String(fileurl);
|
||||
return AjaxResult.successData(200, text);
|
||||
} catch (IORuntimeException e) {
|
||||
return AjaxResult.error("没有该文件");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("报错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定制方法
|
||||
* 根据关键字与相对路径获取文件内容
|
||||
*
|
||||
* @param key 访问关键字
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/getFileText302")
|
||||
public void getFileText302(String key, String relativePath, HttpServletResponse response) throws IOException {
|
||||
String str = bunnyConfig.getHttpUrl() + key + "/" + relativePath;
|
||||
response.sendRedirect(str);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖上传文件 key与指定路径
|
||||
*
|
||||
* @param object 文件流对象
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/coverupload")
|
||||
public AjaxResult coverupload(@RequestBody MultipartFile object, String key, String relativePath) throws IOException {
|
||||
|
||||
String fileName = object.getOriginalFilename();
|
||||
String suffixName = bunnyConfig.getDefaultFormat();
|
||||
Long filesize = object.getSize();
|
||||
// 文件名字
|
||||
String fileSuffixName = "";
|
||||
if (fileName.lastIndexOf(".") != -1) {// 有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
// mediaKey=MD5.create().digestHex(fileName);
|
||||
// mediaKey=SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName = relativePath.substring(relativePath.lastIndexOf("/") + 1);
|
||||
} else {// 无后缀
|
||||
// 取得唯一id
|
||||
// mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
// mediaKey=SnowflakeIdWorker.getUUID();
|
||||
// fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey = key;
|
||||
String absolutePath = bunnyConfig.getXnljmap().get(key).replace("file:", "");
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize + ""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath = relativePath.substring(0, relativePath.lastIndexOf("/"));
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath);
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = getAbsoluteFile(absolutePath + filepath, fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileDto SysFileDto = BeanUtil.copyProperties(sysFile, SysFileDto.class);
|
||||
SysFileDto.setFileurl(bunnyConfig.getHttpUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName());
|
||||
return AjaxResult.successData(200, SysFileDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件id查询文件信息json
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getFileid/{id}")
|
||||
public AjaxResult getFileid(@PathVariable("id") String id) {
|
||||
SysFile sysFile = iSysFileService.getById(id);
|
||||
if (sysFile != null) {
|
||||
SysFileDto SysFileDto = BeanUtil.copyProperties(sysFile, SysFileDto.class);
|
||||
SysFileDto.setFileurl(bunnyConfig.getHttpUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName());
|
||||
return AjaxResult.successData(200, SysFileDto);
|
||||
}
|
||||
return AjaxResult.error("没有该文件");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件id 302跳转到绝对地址
|
||||
*
|
||||
* @param id
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping("/getFileid/302/{id}")
|
||||
public void getFileid302(@PathVariable("id") String id, HttpServletResponse response) throws IOException {
|
||||
SysFile sysFile = iSysFileService.getById(id);
|
||||
if (sysFile != null) {
|
||||
String str = bunnyConfig.getHttpUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName();
|
||||
response.sendRedirect(str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(long current, long size) {
|
||||
Page<SysFile> page = new Page<SysFile>(current, size);
|
||||
return iSysFileService.page(page, new LambdaQueryWrapper<SysFile>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传文件的md5
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public String getMd5(MultipartFile file) {
|
||||
try {
|
||||
// 获取文件的byte信息
|
||||
byte[] uploadBytes = file.getBytes();
|
||||
// 拿到一个MD5转换器
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md5.digest(uploadBytes);
|
||||
// 转换为16进制
|
||||
return new BigInteger(1, digest).toString(16);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
|
||||
import cn.bunny.config.config.BunnyConfig;
|
||||
import cn.bunny.config.utils.ConvertUtil;
|
||||
import cn.bunny.config.utils.SnowflakeIdWorker;
|
||||
import cn.bunny.domain.dto.GoviewProjectDto;
|
||||
import cn.bunny.domain.dto.SysFileDto;
|
||||
import cn.bunny.domain.entity.GoViewProject;
|
||||
import cn.bunny.domain.entity.GoviewProjectData;
|
||||
import cn.bunny.domain.entity.SysFile;
|
||||
import cn.bunny.domain.vo.AjaxResult;
|
||||
import cn.bunny.domain.vo.ResultTable;
|
||||
import cn.bunny.domain.vo.Tablepar;
|
||||
import cn.bunny.service.IGoviewProjectDataService;
|
||||
import cn.bunny.service.IGoviewProjectService;
|
||||
import cn.bunny.service.ISysFileService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/goview/project")
|
||||
public class GoviewProjectController extends BaseController {
|
||||
@Autowired
|
||||
private ISysFileService iSysFileService;
|
||||
@Autowired
|
||||
private BunnyConfig bunnyConfig;
|
||||
@Autowired
|
||||
private IGoviewProjectService iGoviewProjectService;
|
||||
@Autowired
|
||||
private IGoviewProjectDataService iGoviewProjectDataService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分页跳转", notes = "分页跳转")
|
||||
@GetMapping("/list")
|
||||
@ResponseBody
|
||||
public ResultTable list(Tablepar tablepar) {
|
||||
Page<GoViewProject> page = new Page<GoViewProject>(tablepar.getPage(), tablepar.getLimit());
|
||||
IPage<GoViewProject> iPages = iGoviewProjectService.page(page, new LambdaQueryWrapper<GoViewProject>());
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.setData(iPages.getRecords());
|
||||
resultTable.setCode(200);
|
||||
resultTable.setCount(iPages.getTotal());
|
||||
resultTable.setMsg("获取成功");
|
||||
return resultTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@Log(title = "项目表新增", action = "111")
|
||||
@ApiOperation(value = "新增", notes = "新增")
|
||||
@PostMapping("/create")
|
||||
@ResponseBody
|
||||
public AjaxResult add(@RequestBody GoViewProject goviewProject) {
|
||||
goviewProject.setCreateTime(DateUtil.now());
|
||||
goviewProject.setState(-1);
|
||||
boolean b = iGoviewProjectService.save(goviewProject);
|
||||
if (b) {
|
||||
return successData(200, goviewProject).put("msg", "创建成功");
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目表删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@Log(title = "项目表删除", action = "111")
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids) {
|
||||
List<String> lista = ConvertUtil.toListStrArray(ids);
|
||||
Boolean b = iGoviewProjectService.removeByIds(lista);
|
||||
if (b) {
|
||||
return success();
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改保存", notes = "修改保存")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(@RequestBody GoViewProject goviewProject) {
|
||||
boolean b = iGoviewProjectService.updateById(goviewProject);
|
||||
if (b) {
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "项目重命名", notes = "项目重命名")
|
||||
@PostMapping("/rename")
|
||||
@ResponseBody
|
||||
public AjaxResult rename(@RequestBody GoViewProject goviewProject) {
|
||||
|
||||
LambdaUpdateWrapper<GoViewProject> updateWrapper = new LambdaUpdateWrapper<GoViewProject>();
|
||||
updateWrapper.eq(GoViewProject::getId, goviewProject.getId());
|
||||
updateWrapper.set(GoViewProject::getProjectName, goviewProject.getProjectName());
|
||||
boolean b = iGoviewProjectService.update(updateWrapper);
|
||||
if (b) {
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
|
||||
|
||||
// 发布/取消项目状态
|
||||
@PutMapping("/publish")
|
||||
@ResponseBody
|
||||
public AjaxResult updateVisible(@RequestBody GoViewProject goviewProject) {
|
||||
if (goviewProject.getState() == -1 || goviewProject.getState() == 1) {
|
||||
|
||||
LambdaUpdateWrapper<GoViewProject> updateWrapper = new LambdaUpdateWrapper<GoViewProject>();
|
||||
updateWrapper.eq(GoViewProject::getId, goviewProject.getId());
|
||||
updateWrapper.set(GoViewProject::getState, goviewProject.getState());
|
||||
boolean b = iGoviewProjectService.update(updateWrapper);
|
||||
if (b) {
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
return error("警告非法字段");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取项目存储数据", notes = "获取项目存储数据")
|
||||
@GetMapping("/getData")
|
||||
@ResponseBody
|
||||
public AjaxResult getData(String projectId, ModelMap map) {
|
||||
GoViewProject goviewProject = iGoviewProjectService.getById(projectId);
|
||||
|
||||
GoviewProjectData blogText = iGoviewProjectDataService.getProjectid(projectId);
|
||||
if (blogText != null) {
|
||||
GoviewProjectDto goviewProjectVo = new GoviewProjectDto();
|
||||
BeanUtils.copyProperties(goviewProject, goviewProjectVo);
|
||||
goviewProjectVo.setContent(blogText.getContent());
|
||||
return AjaxResult.successData(200, goviewProjectVo).put("msg", "获取成功");
|
||||
}
|
||||
return AjaxResult.successData(200, null).put("msg", "无数据");
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存项目数据", notes = "保存项目数据")
|
||||
@PostMapping("/save/data")
|
||||
@ResponseBody
|
||||
public AjaxResult saveData(GoviewProjectData data) {
|
||||
|
||||
GoViewProject goviewProject = iGoviewProjectService.getById(data.getProjectId());
|
||||
if (goviewProject == null) {
|
||||
return error("没有该项目ID");
|
||||
}
|
||||
GoviewProjectData goviewProjectData = iGoviewProjectDataService.getOne(new LambdaQueryWrapper<GoviewProjectData>().eq(GoviewProjectData::getProjectId, goviewProject.getId()));
|
||||
if (goviewProjectData != null) {
|
||||
data.setId(goviewProjectData.getId());
|
||||
iGoviewProjectDataService.updateById(data);
|
||||
return success("数据保存成功");
|
||||
} else {
|
||||
iGoviewProjectDataService.save(data);
|
||||
return success("数据保存成功");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param object 文件流对象
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult upload(@RequestBody MultipartFile object) throws IOException {
|
||||
String fileName = object.getOriginalFilename();
|
||||
// 默认文件格式
|
||||
String suffixName = bunnyConfig.getDefaultFormat();
|
||||
String mediaKey = "";
|
||||
Long filesize = object.getSize();
|
||||
// 文件名字
|
||||
String fileSuffixName = "";
|
||||
if (fileName.lastIndexOf(".") != -1) {// 有后缀
|
||||
suffixName = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
|
||||
// mediaKey=MD5.create().digestHex(fileName);
|
||||
mediaKey = SnowflakeIdWorker.getUUID();
|
||||
fileSuffixName = mediaKey + suffixName;
|
||||
} else {// 无后缀
|
||||
// 取得唯一id
|
||||
// mediaKey = MD5.create().digestHex(fileName+suffixName);
|
||||
mediaKey = SnowflakeIdWorker.getUUID();
|
||||
// fileSuffixName=mediaKey+suffixName;
|
||||
}
|
||||
String virtualKey = FileController.getFirstNotNull(bunnyConfig.getXnljmap());
|
||||
String absolutePath = bunnyConfig.getXnljmap().get(FileController.getFirstNotNull(bunnyConfig.getXnljmap()));
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setId(SnowflakeIdWorker.getUUID());
|
||||
sysFile.setFileName(fileSuffixName);
|
||||
sysFile.setFileSize(Integer.parseInt(filesize + ""));
|
||||
sysFile.setFileSuffix(suffixName);
|
||||
sysFile.setCreateTime(DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
String filepath = DateUtil.formatDate(new Date());
|
||||
sysFile.setRelativePath(filepath);
|
||||
sysFile.setVirtualKey(virtualKey);
|
||||
sysFile.setAbsolutePath(absolutePath.replace("file:", ""));
|
||||
iSysFileService.saveOrUpdate(sysFile);
|
||||
File desc = FileController.getAbsoluteFile(bunnyConfig.getFileUrl() + File.separator + filepath, fileSuffixName);
|
||||
object.transferTo(desc);
|
||||
SysFileDto sysFileDto = BeanUtil.copyProperties(sysFile, SysFileDto.class);
|
||||
sysFileDto.setFileurl(bunnyConfig.getHttpUrl() + sysFile.getVirtualKey() + "/" + sysFile.getRelativePath() + "/" + sysFile.getFileName());
|
||||
return successData(200, sysFileDto);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@RestController
|
||||
public class Indexcontroller {
|
||||
|
||||
@GetMapping("/")
|
||||
public void index(HttpServletResponse response) throws IOException {
|
||||
response.setContentType("text/html; charset=utf-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println("<p style='color:orange'>goview后台首页</p>");
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package cn.com.v2.controller;
|
||||
package cn.bunny.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -1,11 +1,11 @@
|
|||
package cn.com.v2.mapper;
|
||||
package cn.bunny.mapper;
|
||||
|
||||
import cn.com.v2.model.GoviewProjectData;
|
||||
import cn.bunny.domain.entity.GoviewProjectData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -0,0 +1,16 @@
|
|||
package cn.bunny.mapper;
|
||||
|
||||
import cn.bunny.domain.entity.GoViewProject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface GoviewProjectMapper extends BaseMapper<GoViewProject> {
|
||||
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
package cn.com.v2.mapper;
|
||||
package cn.bunny.mapper;
|
||||
|
||||
import cn.bunny.domain.entity.SysFile;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import cn.com.v2.model.SysFile;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -1,11 +1,11 @@
|
|||
package cn.com.v2.mapper;
|
||||
package cn.bunny.mapper;
|
||||
|
||||
import cn.com.v2.model.SysUser;
|
||||
import cn.bunny.domain.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -1,11 +1,11 @@
|
|||
package cn.com.v2.service;
|
||||
package cn.bunny.service;
|
||||
|
||||
import cn.com.v2.model.GoviewProjectData;
|
||||
import cn.bunny.domain.entity.GoviewProjectData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
|
@ -13,6 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface IGoviewProjectDataService extends IService<GoviewProjectData> {
|
||||
|
||||
public GoviewProjectData getProjectid(String projectId);
|
||||
GoviewProjectData getProjectid(String projectId);
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package cn.bunny.service;
|
||||
|
||||
import cn.bunny.domain.entity.GoViewProject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IGoviewProjectService extends IService<GoViewProject> {
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package cn.com.v2.service;
|
||||
package cn.bunny.service;
|
||||
|
||||
import cn.bunny.domain.entity.SysFile;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.com.v2.model.SysFile;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
|
@ -14,5 +14,5 @@ import cn.com.v2.model.SysFile;
|
|||
public interface ISysFileService extends IService<SysFile> {
|
||||
|
||||
|
||||
public SysFile selectByExamplefileName(String filename);
|
||||
SysFile selectByExamplefileName(String filename);
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package cn.com.v2.service;
|
||||
package cn.bunny.service;
|
||||
|
||||
import cn.com.v2.model.SysUser;
|
||||
import cn.bunny.domain.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -0,0 +1,30 @@
|
|||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.bunny.domain.entity.GoviewProjectData;
|
||||
import cn.bunny.mapper.GoviewProjectDataMapper;
|
||||
import cn.bunny.service.IGoviewProjectDataService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@Service
|
||||
public class GoviewProjectDataServiceImpl extends ServiceImpl<GoviewProjectDataMapper, GoviewProjectData> implements IGoviewProjectDataService {
|
||||
@Autowired
|
||||
GoviewProjectDataMapper dataMapper;
|
||||
|
||||
@Override
|
||||
public GoviewProjectData getProjectid(String projectId) {
|
||||
LambdaQueryWrapper<GoviewProjectData> lambdaQueryWrapper = new LambdaQueryWrapper<GoviewProjectData>();
|
||||
lambdaQueryWrapper.eq(GoviewProjectData::getProjectId, projectId);
|
||||
return dataMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package cn.com.v2.service.impl;
|
||||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.com.v2.model.GoviewProject;
|
||||
import cn.com.v2.mapper.GoviewProjectMapper;
|
||||
import cn.com.v2.service.IGoviewProjectService;
|
||||
import cn.bunny.domain.entity.GoViewProject;
|
||||
import cn.bunny.mapper.GoviewProjectMapper;
|
||||
import cn.bunny.service.IGoviewProjectService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
@Service
|
||||
public class GoviewProjectServiceImpl extends ServiceImpl<GoviewProjectMapper, GoviewProject> implements IGoviewProjectService {
|
||||
public class GoviewProjectServiceImpl extends ServiceImpl<GoviewProjectMapper, GoViewProject> implements IGoviewProjectService {
|
||||
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package cn.com.v2.service.impl;
|
||||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.bunny.domain.entity.SysFile;
|
||||
import cn.bunny.mapper.SysFileMapper;
|
||||
import cn.bunny.service.ISysFileService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.com.v2.mapper.SysFileMapper;
|
||||
import cn.com.v2.model.SysFile;
|
||||
import cn.com.v2.service.ISysFileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
||||
|
@ -18,13 +18,13 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> implements ISysFileService {
|
||||
@Autowired
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Autowired
|
||||
private SysFileMapper sysFileMapper;
|
||||
|
||||
@Override
|
||||
public SysFile selectByExamplefileName(String filename) {
|
||||
SysFile sysFile=sysFileMapper.selectOne(new LambdaQueryWrapper<SysFile>().eq(SysFile::getFileName, filename));
|
||||
@Override
|
||||
public SysFile selectByExamplefileName(String filename) {
|
||||
SysFile sysFile = sysFileMapper.selectOne(new LambdaQueryWrapper<SysFile>().eq(SysFile::getFileName, filename));
|
||||
return sysFile;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package cn.com.v2.service.impl;
|
||||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.com.v2.model.SysUser;
|
||||
import cn.com.v2.mapper.SysUserMapper;
|
||||
import cn.com.v2.service.ISysUserService;
|
||||
import cn.bunny.domain.entity.SysUser;
|
||||
import cn.bunny.mapper.SysUserMapper;
|
||||
import cn.bunny.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author fc
|
|
@ -2,7 +2,7 @@
|
|||
spring:
|
||||
datasource:
|
||||
driver-class-name: org.sqlite.JDBC
|
||||
url: jdbc:sqlite:D:\\eclipse-workspace\v2-goview-bate\sqllite\goview.db
|
||||
url: jdbc:sqlite:G:\File\WebCombat\go-view\go-view-serve\sqllite\goview.db
|
||||
#linux服务器
|
||||
#url: jdbc:sqlite://home/cqfy/project/OSSDATABASE/oss.db
|
||||
username:
|
|
@ -1,46 +1,45 @@
|
|||
v2:
|
||||
bunny:
|
||||
#虚拟路径映射路径 2个文件路径一一对应 第一个为主存储,其他为配置相关
|
||||
xnljmap:
|
||||
#win服务器 本地 注意!! 记住这个结尾有一个/
|
||||
oss: file:D:/upload/
|
||||
#linux服务器
|
||||
#oss: file:/home/webapps/oss/
|
||||
xnlJMap:
|
||||
#win服务器 本地 注意!! 记住这个结尾有一个/
|
||||
oss: file:D:/upload/
|
||||
#linux服务器
|
||||
#oss: file:/home/webapps/oss/
|
||||
#虚拟路径映射路径 end
|
||||
#本地存放地址 注意!! 记住这个结尾没有/
|
||||
fileurl: D:/upload
|
||||
#http://127.0.0.1:8080/oss/{yy}/2022-12-22/c83a77ae134a540c30daa6a0666fa945.md
|
||||
httpurl: http://127.0.0.1:8083/
|
||||
httpUrl: http://127.0.0.1:8083/
|
||||
defaultFormat: .png
|
||||
fileUrl: D:/upload
|
||||
#tomcat config
|
||||
server :
|
||||
port : 8083
|
||||
server:
|
||||
port: 8083
|
||||
##项目名字配置
|
||||
servlet :
|
||||
context-path : /
|
||||
servlet:
|
||||
context-path: /
|
||||
#session过期
|
||||
session:
|
||||
timeout: PT4H
|
||||
#cookie:
|
||||
# name: jxfgzs
|
||||
tomcat :
|
||||
uri-encoding : UTF-8
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
#xx 报错修改的地方
|
||||
max-connections: 200000
|
||||
max-http-form-post-size: 9000000
|
||||
threads:
|
||||
max: 128
|
||||
min-spare: 5
|
||||
spring :
|
||||
spring:
|
||||
# 环境 dev|test|prod
|
||||
profiles :
|
||||
active : dev
|
||||
profiles:
|
||||
active: dev
|
||||
servlet:
|
||||
multipart:
|
||||
#设置总上传的数据大小
|
||||
max-request-size: 100MB
|
||||
#单个文件大小
|
||||
maxFileSize : 30MB
|
||||
#xx 报错修改的地方
|
||||
maxFileSize: 30MB
|
||||
#xx 报错修改的地方
|
||||
max-connections: 200000
|
||||
max-http-post-size: 9000000
|
||||
#热部署模块
|
||||
|
@ -52,8 +51,8 @@ spring :
|
|||
additional-paths: src/main/java
|
||||
#指定目录不更新
|
||||
exclude: test/**
|
||||
mvc: #静态文件
|
||||
static-path-pattern : /static/**
|
||||
mvc: #静态文件
|
||||
static-path-pattern: /static/**
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
#模板引擎
|
||||
|
@ -92,19 +91,20 @@ mybatis-plus:
|
|||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: satoken
|
||||
# token有效期,单位s 默认30天, -1代表永不过期
|
||||
timeout: 2592000
|
||||
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
|
||||
activity-timeout: -1
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: true
|
||||
# token风格
|
||||
token-style: uuid
|
||||
# 是否输出操作日志
|
||||
is-log: false
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: satoken
|
||||
# token有效期,单位s 默认30天, -1代表永不过期
|
||||
timeout: 2592000
|
||||
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
|
||||
activity-timeout: -1
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: true
|
||||
# token风格
|
||||
token-style: uuid
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.com.v2.mapper.GoviewProjectDataMapper">
|
||||
<mapper namespace="cn.bunny.mapper.GoviewProjectDataMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.com.v2.mapper.GoviewProjectMapper">
|
||||
<mapper namespace="cn.bunny.mapper.GoviewProjectMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.com.v2oss.mapper.SysFileMapper">
|
||||
<mapper namespace="cn.bunny.mapper.SysFileMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.com.v2.mapper.SysUserMapper">
|
||||
<mapper namespace="cn.bunny.mapper.SysUserMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue