diff --git a/ruoyi-extend/pom.xml b/ruoyi-extend/pom.xml index f5348cc13..3acce6898 100644 --- a/ruoyi-extend/pom.xml +++ b/ruoyi-extend/pom.xml @@ -14,6 +14,7 @@ ruoyi-monitor-admin ruoyi-powerjob-server + ruoyi-go-view-admin diff --git a/ruoyi-extend/ruoyi-go-view-admin/pom.xml b/ruoyi-extend/ruoyi-go-view-admin/pom.xml new file mode 100644 index 000000000..0dd97d3c4 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/pom.xml @@ -0,0 +1,89 @@ + + + + org.dromara + ruoyi-extend + ${revision} + + 4.0.0 + jar + ruoyi-go-view-admin + + + + + org.springframework.boot + spring-boot-starter-parent + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + com.mysql + mysql-connector-j + + + + com.baomidou + mybatis-plus-boot-starter + + + + + cn.dev33 + sa-token-spring-boot-starter + 1.34.0 + + + + org.projectlombok + lombok + + + + cn.hutool + hutool-core + + + cn.hutool + hutool-crypto + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/GoViewApplication.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/GoViewApplication.java new file mode 100644 index 000000000..1e0fd5d64 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/GoViewApplication.java @@ -0,0 +1,11 @@ +package com.go.view.admin; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GoViewApplication { + public static void main(String[] args) { + SpringApplication.run(GoViewApplication.class, args); + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/base/BaseController.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/base/BaseController.java new file mode 100644 index 000000000..f2ca7ea2b --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/base/BaseController.java @@ -0,0 +1,117 @@ +package com.go.view.admin.common.base; + +import com.go.view.admin.common.domain.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层通用数据处理 + * + * @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); + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/CorsConfig.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/CorsConfig.java new file mode 100644 index 000000000..4633c2466 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/CorsConfig.java @@ -0,0 +1,24 @@ +package com.go.view.admin.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("*"); + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/V2Config.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/V2Config.java new file mode 100644 index 000000000..c0ffb0bfb --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/config/V2Config.java @@ -0,0 +1,73 @@ +package com.go.view.admin.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 读取项目相关配置 + * + * @author fuce + */ +@Component +@ConfigurationProperties(prefix = "v2") +public class V2Config { + + /** + * 存储路径 + */ + private String fileurl; + /** + * 请求url + */ + private String httpurl; + /** + * 虚拟路径map + */ + private Map 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 getXnljmap() { + return xnljmap; + } + + public void setXnljmap(Map xnljmap) { + this.xnljmap = xnljmap; + } + + public String getDefaultFormat() { + return defaultFormat; + } + + public void setDefaultFormat(String defaultFormat) { + this.defaultFormat = defaultFormat; + } + + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/AjaxResult.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/AjaxResult.java new file mode 100644 index 000000000..8f164d232 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/AjaxResult.java @@ -0,0 +1,104 @@ +package com.go.view.admin.common.domain; + +import java.util.HashMap; + +/** +* @ClassName: AjaxResult +* @Description: ajax操作消息提醒 +* @author fuce +* @date 2018年8月18日 +* + */ +public class AjaxResult extends HashMap +{ + private static final long serialVersionUID = 1L; + + /** + * 初始化一个新创建的 Message 对象 + */ + public AjaxResult() + { + } + + /** + * 返回错误消息 + * + * @return 错误消息 + */ + public static AjaxResult error() + { + return error(500, "操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 内容 + * @return 错误消息 + */ + public static AjaxResult error(String msg) + { + return error(500, msg); + } + + /** + * 返回错误消息 + * + * @param code 错误码 + * @param msg 内容 + * @return 错误消息 + */ + public static AjaxResult error(int code, String msg) + { + AjaxResult json = new AjaxResult(); + json.put("code", code); + json.put("msg", msg); + return json; + } + + /** + * 返回成功消息 + * + * @param msg 内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) + { + AjaxResult json = new AjaxResult(); + json.put("msg", msg); + json.put("code", 200); + return json; + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + 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; + } + + + /** + * 返回成功消息 + * + * @param key 键值 + * @param value 内容 + * @return 成功消息 + */ + @Override + public AjaxResult put(String key, Object value) + { + super.put(key, value); + return this; + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/ResultTable.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/ResultTable.java new file mode 100644 index 000000000..8623761ad --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/ResultTable.java @@ -0,0 +1,84 @@ +package com.go.view.admin.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; + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/Tablepar.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/Tablepar.java new file mode 100644 index 000000000..b0aee70c5 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/domain/Tablepar.java @@ -0,0 +1,50 @@ +package com.go.view.admin.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; + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/Interceptor.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/Interceptor.java new file mode 100644 index 000000000..28f2ff42b --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/Interceptor.java @@ -0,0 +1,22 @@ +package com.go.view.admin.common.interceptor; + +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 拦截器 + */ +public class Interceptor implements HandlerInterceptor { + /** + * 在请求处理之前进行调用(Controller方法调用之前) + */ + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + + return true;//如果设置为false时,被请求时,拦截器执行到此处将不会继续操作 + //如果设置为true时,请求将会继续执行后面的操作 + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/WebMvcConfig.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/WebMvcConfig.java new file mode 100644 index 000000000..c8ad9992f --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/interceptor/WebMvcConfig.java @@ -0,0 +1,87 @@ +package com.go.view.admin.common.interceptor; + +import cn.hutool.core.util.ArrayUtil; +import com.go.view.admin.common.config.V2Config; +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; + +@Configuration +public class WebMvcConfig extends WebMvcConfigurationSupport { + + @Autowired + private V2Config v2Config; + @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 list1=new ArrayList(); + List list2=new ArrayList(); + + Map map= v2Config.getXnljmap(); + + Set set = map.keySet(); + for (String o : set) { + list1.add("/"+o+"/**"); + list2.add(map.get(o)); + } + registry.addResourceHandler(ArrayUtil.toArray(list1, String.class)).addResourceLocations(ArrayUtil.toArray(list2, String.class)); + } + + + /** + * 重写addCorsMappings()解决跨域问题 + * 配置:允许http请求进行跨域访问 + * + * @param registry + */ + @Override + public void addCorsMappings(CorsRegistry registry) { + + // 设置允许多个域名请求 + //String[] allowDomains = {"http://www.toheart.xin","http://192.168.11.213:8080","http://localhost:8080"}; + + //指哪些接口URL需要增加跨域设置 + registry.addMapping("/**") + //.allowedOrigins("*")//指的是前端哪些域名被允许跨域 + .allowedOriginPatterns("*") + //需要带cookie等凭证时,设置为true,就会把cookie的相关信息带上 + .allowCredentials(true) + //指的是允许哪些方法 + .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") + //cookie的失效时间,单位为秒(s),若设置为-1,则关闭浏览器就失效 + .maxAge(3600); + } + + /** + * 重写addInterceptors()实现拦截器 + * 配置:要拦截的路径以及不拦截的路径 + * + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + //注册Interceptor拦截器(Interceptor这个类是我们自己写的拦截器类) + InterceptorRegistration registration = registry.addInterceptor(new Interceptor()); + //addPathPatterns()方法添加需要拦截的路径 + //所有路径都被拦截 + registration.addPathPatterns("/**"); + //excludePathPatterns()方法添加不拦截的路径 + + + 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); + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/ConvertUtil.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/ConvertUtil.java new file mode 100644 index 000000000..18060af30 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/ConvertUtil.java @@ -0,0 +1,253 @@ +package com.go.view.admin.common.util; + +import cn.hutool.core.util.StrUtil; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; + +/** + * 类型转换器 + * + * @author fc + * + */ +public class ConvertUtil { + + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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数组
+ * @param split 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String str) { + return toIntArray(",", str); + } + + /** + * 转换为Integer数组
+ * @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
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * @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数组
+ * @param split 被转换的值 + * @return 结果 + */ + public static List toListStrArray(String str) { + String[] stringArray = toStrArray(str); + List stringB = Arrays.asList(stringArray); + return stringB; + } + + + + /** + * 转换为List数组
+ * @param split 被转换的值 + * @return 结果 + */ + public static List toListLongArray(String str) { + Long[] stringArray = toLongArray(str); + List stringB = Arrays.asList(stringArray); + return stringB; + } + + + /** + * 转换为String数组
+ * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String str) { + return toStrArray(",", str); + } + + /** + * 转换为String数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String split, String str) { + return str.split(split); + } + /** + * 转换为Long数组
+ * + * @param split 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String str) + { + return toLongArray(",", str); + } + /** + * 转换为Long数组
+ * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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; + } + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SaTokenUtil.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SaTokenUtil.java new file mode 100644 index 000000000..59a0b2aca --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SaTokenUtil.java @@ -0,0 +1,73 @@ +package com.go.view.admin.common.util; + + +import cn.dev33.satoken.stp.StpUtil; +import com.go.view.admin.domain.GoviewUser; +import org.springframework.beans.BeanUtils; + +/** + * 封装 Sa-Token 常用操作 + * @author kong + * + */ +public class SaTokenUtil { + + /** + * 获取登录用户model + */ + public static GoviewUser getUser() { + Object object=StpUtil.getSession().get("user"); + if(object!=null){ + GoviewUser tsysUser=new GoviewUser(); + BeanUtils.copyProperties(tsysUser, object); + return tsysUser; + } + return null; + } + + /** + * set用户 + */ + public static void setUser(GoviewUser user) { + StpUtil.getSession().set("user", user); + } + + /** + * 获取登录用户id + */ + public static String getUserId() { + return StpUtil.getLoginIdAsString(); + } + + /** + * 获取登录用户name + */ + public static String getLoginName() { + GoviewUser tsysUser = getUser(); + if (tsysUser == null){ + throw new RuntimeException("用户不存在!"); + } + return tsysUser.getUsername(); + } + + /** + * 获取登录用户ip + * @return + * @author fuce + * @Date 2019年11月21日 上午9:58:26 + */ + public static String getIp() { + + return StpUtil.getTokenSession().getString("login_ip"); + } + /** + * 判断是否登录 + * @return + * @author fuce + * @Date 2019年11月21日 上午9:58:26 + */ + public static boolean isLogin() { + return StpUtil.isLogin(); + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SnowflakeIdWorker.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SnowflakeIdWorker.java new file mode 100644 index 000000000..80bde4809 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/common/util/SnowflakeIdWorker.java @@ -0,0 +1,155 @@ +package com.go.view.admin.common.util; + +/** + * Twitter_Snowflake
+ * SnowFlake的结构如下(每部分用-分开):
+ * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000
+ * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0
+ * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截) + * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69
+ * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId
+ * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号
+ * 加起来刚好64位,为一个Long型。
+ * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。 + */ +public class SnowflakeIdWorker { + + // ==============================Fields=========================================== + /** 开始时间截 (2015-01-01) */ + private final long twepoch = 1489111610226L; + + /** 机器id所占的位数 */ + private final long workerIdBits = 5L; + + /** 数据标识id所占的位数 */ + private final long dataCenterIdBits = 5L; + + /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */ + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + + /** 支持的最大数据标识id,结果是31 */ + private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits); + + /** 序列在id中占的位数 */ + private final long sequenceBits = 12L; + + /** 机器ID向左移12位 */ + private final long workerIdShift = sequenceBits; + + /** 数据标识id向左移17位(12+5) */ + private final long dataCenterIdShift = sequenceBits + workerIdBits; + + /** 时间截向左移22位(5+5+12) */ + private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits; + + /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */ + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + + /** 工作机器ID(0~31) */ + private long workerId; + + /** 数据中心ID(0~31) */ + private long dataCenterId; + + /** 毫秒内序列(0~4095) */ + private long sequence = 0L; + + /** 上次生成ID的时间截 */ + private long lastTimestamp = -1L; + + + static SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1); + //==============================Constructors===================================== + /** + * 构造函数 + * @param workerId 工作ID (0~31) + * @param dataCenterId 数据中心ID (0~31) + */ + public SnowflakeIdWorker(long workerId, long dataCenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("workerId can't be greater than %d or less than 0", maxWorkerId)); + } + if (dataCenterId > maxDataCenterId || dataCenterId < 0) { + throw new IllegalArgumentException(String.format("dataCenterId can't be greater than %d or less than 0", maxDataCenterId)); + } + this.workerId = workerId; + this.dataCenterId = dataCenterId; + } + + // ==============================Methods========================================== + /** + * 获得下一个ID (该方法是线程安全的) + * @return SnowflakeId + */ + public synchronized long nextId() { + long timestamp = timeGen(); + + //如果当前时间小于上一次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的时间截 + lastTimestamp = timestamp; + + //移位并通过或运算拼到一起组成64位的ID + return ((timestamp - twepoch) << timestampLeftShift) // + | (dataCenterId << dataCenterIdShift) // + | (workerId << workerIdShift) // + | sequence; + } + + /** + * 阻塞到下一个毫秒,直到获得新的时间戳 + * @param lastTimestamp 上次生成ID的时间截 + * @return 当前时间戳 + */ + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + /** + * 返回以毫秒为单位的当前时间 + * @return 当前时间(毫秒) + */ + protected long timeGen() { + return System.currentTimeMillis(); + } + + //==============================Test============================================= + /** 测试 */ + public static void main(String[] args) { + System.out.println(System.currentTimeMillis()); + SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1); + long startTime = System.nanoTime(); + for (int i = 0; i < 500; i++) { + long id = idWorker.nextId(); + System.out.println(id); + } + System.out.println((System.nanoTime()-startTime)/1000000+"ms"); + } + + public static String getUUID() { + long id = idWorker.nextId(); + return String.valueOf(id); + } +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewFileController.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewFileController.java new file mode 100644 index 000000000..b80e3c3fd --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewFileController.java @@ -0,0 +1,368 @@ +package com.go.view.admin.controller; + +import com.go.view.admin.common.base.BaseController; +import com.go.view.admin.common.config.V2Config; +import com.go.view.admin.common.domain.AjaxResult; +import com.go.view.admin.domain.GoviewFile; +import com.go.view.admin.domain.vo.GoviewFileVo; +import com.go.view.admin.service.IGoviewFileService; +import com.go.view.admin.common.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; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.RequiredArgsConstructor; +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 + */ +@RestController +@RequestMapping("/goview/file") +@Slf4j +@RequiredArgsConstructor +public class GoviewFileController extends BaseController { + + final V2Config v2Config; + + final IGoviewFileService iGoviewFileService; + + /** + * 删除文件 + * @param ids + * @return + */ + @DeleteMapping("/remove") + public AjaxResult remove(String ids){ + Boolean b=iGoviewFileService.removeByIds(StrUtil.split(ids, ',',-1)); + if(b){ + return success(); + }else{ + return error(); + } + } + + + @PutMapping("/update") + public AjaxResult update(String id,@RequestBody MultipartFile object) throws IllegalStateException, IOException{ + GoviewFile sysFile=iGoviewFileService.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=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())); + GoviewFile sysFile=new GoviewFile(); + sysFile.setId(SnowflakeIdWorker.getUUID()); + sysFile.setFileName(fileSuffixName); + sysFile.setFileSize(Integer.parseInt(filesize+"")); + sysFile.setFileSuffix(suffixName); + String filepath=DateUtil.formatDate(new Date()); + sysFile.setRelativePath(filepath); + sysFile.setVirtualKey(virtualKey); + sysFile.setAbsolutePath(absolutePath.replace("file:","")); + iGoviewFileService.saveOrUpdate(sysFile); + File desc = getAbsoluteFile(v2Config.getFileurl()+File.separator+filepath,fileSuffixName); + object.transferTo(desc); + GoviewFileVo sysFileVo=BeanUtil.copyProperties(sysFile, GoviewFileVo.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())); + GoviewFile sysFile=new GoviewFile(); + sysFile.setId(SnowflakeIdWorker.getUUID()); + sysFile.setFileName(fileSuffixName); + sysFile.setFileSuffix(suffixName); + 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()+"")); + iGoviewFileService.saveOrUpdate(sysFile); + GoviewFileVo sysFileVo=BeanUtil.copyProperties(sysFile, GoviewFileVo.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:", ""); + GoviewFile sysFile=new GoviewFile(); + sysFile.setId(SnowflakeIdWorker.getUUID()); + sysFile.setFileName(fileSuffixName); + sysFile.setFileSize(Integer.parseInt(filesize+"")); + sysFile.setFileSuffix(suffixName); + String filepath=relativePath.substring(0,relativePath.lastIndexOf("/")); + sysFile.setRelativePath(filepath); + sysFile.setVirtualKey(virtualKey); + sysFile.setAbsolutePath(absolutePath); + iGoviewFileService.saveOrUpdate(sysFile); + File desc = getAbsoluteFile(absolutePath+filepath,fileSuffixName); + object.transferTo(desc); + GoviewFileVo sysFileVo=BeanUtil.copyProperties(sysFile, GoviewFileVo.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){ + GoviewFile sysFile=iGoviewFileService.getById(id); + if(sysFile!=null){ + GoviewFileVo sysFileVo=BeanUtil.copyProperties(sysFile, GoviewFileVo.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{ + GoviewFile sysFile=iGoviewFileService.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 page= new Page(current, size); + IPage sysFile=iGoviewFileService.page(page, new LambdaQueryWrapper()); + return sysFile; + } + + + + + + /** + * 获取map中第一个非空数据key + * + * @param Key的类型 + * @param Value的类型 + * @param map 数据源 + * @return 返回的值 + */ + public static K getFirstNotNull(Map map) { + K obj = null; + for (Entry 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; + } + + + + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewProjectController.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewProjectController.java new file mode 100644 index 000000000..213e8f013 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewProjectController.java @@ -0,0 +1,238 @@ +package com.go.view.admin.controller; + +import com.go.view.admin.common.base.BaseController; +import com.go.view.admin.common.config.V2Config; +import com.go.view.admin.common.domain.AjaxResult; +import com.go.view.admin.common.domain.ResultTable; +import com.go.view.admin.common.domain.Tablepar; +import com.go.view.admin.common.util.ConvertUtil; +import com.go.view.admin.common.util.SnowflakeIdWorker; +import com.go.view.admin.domain.GoviewFile; +import com.go.view.admin.domain.GoviewProject; +import com.go.view.admin.domain.GoviewProjectData; +import com.go.view.admin.domain.vo.GoviewFileVo; +import com.go.view.admin.domain.vo.GoviewProjectVo; +import com.go.view.admin.service.IGoviewFileService; +import com.go.view.admin.service.IGoviewProjectDataService; +import com.go.view.admin.service.IGoviewProjectService; +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 lombok.RequiredArgsConstructor; +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; + +/** + *

+ * 前端控制器 + *

+ * + * @author fc + * @since 2023-04-30 + */ +@RestController +@RequestMapping("/goview/project") +@RequiredArgsConstructor +public class GoviewProjectController extends BaseController { + final IGoviewFileService iGoviewFileService; + + final V2Config v2Config; + + final IGoviewProjectService iGoviewProjectService; + + final IGoviewProjectDataService iGoviewProjectDataService; + + + @GetMapping("/list") + @ResponseBody + public ResultTable list(Tablepar tablepar){ + Page page= new Page(tablepar.getPage(), tablepar.getLimit()); + IPage iPages=iGoviewProjectService.page(page, new LambdaQueryWrapper()); + ResultTable resultTable=new ResultTable(); + resultTable.setData(iPages.getRecords()); + resultTable.setCode(200); + resultTable.setCount(iPages.getTotal()); + resultTable.setMsg("获取成功"); + return resultTable; + } + + + /** + * 新增保存 + * @param + * @return + */ + @PostMapping("/create") + @ResponseBody + public AjaxResult add(@RequestBody GoviewProject goviewProject){ + goviewProject.setState(-1); + boolean b=iGoviewProjectService.save(goviewProject); + if(b){ + return successData(200, goviewProject).put("msg", "创建成功"); + }else{ + return error(); + } + } + + + /** + * 项目表删除 + * @param ids + * @return + */ + @DeleteMapping("/delete") + @ResponseBody + public AjaxResult remove(String ids){ + List lista= ConvertUtil.toListStrArray(ids); + Boolean b=iGoviewProjectService.removeByIds(lista); + if(b){ + return success(); + }else{ + return error(); + } + } + + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@RequestBody GoviewProject goviewProject) + { + Boolean b= iGoviewProjectService.updateById(goviewProject); + if(b){ + return success(); + } + return error(); + } + + + @PostMapping("/rename") + @ResponseBody + public AjaxResult rename(@RequestBody GoviewProject goviewProject) + { + + LambdaUpdateWrapper updateWrapper=new LambdaUpdateWrapper(); + 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 updateWrapper=new LambdaUpdateWrapper(); + 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("警告非法字段"); + } + + + @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","无数据"); + + } + + + + @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().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 文件流对象 + * @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=GoviewFileController.getFirstNotNull(v2Config.getXnljmap()); + String absolutePath=v2Config.getXnljmap().get(GoviewFileController.getFirstNotNull(v2Config.getXnljmap())); + GoviewFile sysFile=new GoviewFile(); + sysFile.setId(SnowflakeIdWorker.getUUID()); + sysFile.setFileName(fileSuffixName); + sysFile.setFileSize(Integer.parseInt(filesize+"")); + sysFile.setFileSuffix(suffixName); + String filepath=DateUtil.formatDate(new Date()); + sysFile.setRelativePath(filepath); + sysFile.setVirtualKey(virtualKey); + sysFile.setAbsolutePath(absolutePath.replace("file:","")); + iGoviewFileService.saveOrUpdate(sysFile); + File desc = GoviewFileController.getAbsoluteFile(v2Config.getFileurl()+File.separator+filepath,fileSuffixName); + object.transferTo(desc); + GoviewFileVo sysFileVo=BeanUtil.copyProperties(sysFile, GoviewFileVo.class); + sysFileVo.setFileurl(v2Config.getHttpurl()+sysFile.getVirtualKey()+"/"+sysFile.getRelativePath()+"/"+sysFile.getFileName()); + return successData(200, sysFileVo); + } + + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewUserController.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewUserController.java new file mode 100644 index 000000000..59521f267 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/controller/GoviewUserController.java @@ -0,0 +1,78 @@ +package com.go.view.admin.controller; + +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 com.go.view.admin.common.base.BaseController; +import com.go.view.admin.common.domain.AjaxResult; +import com.go.view.admin.common.util.SaTokenUtil; +import com.go.view.admin.domain.GoviewUser; +import com.go.view.admin.service.IGoviewUserService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/goview/sys") +@RequiredArgsConstructor +public class GoviewUserController extends BaseController { + final IGoviewUserService goViewUserService; + + @PostMapping("/login") + @ResponseBody + public AjaxResult login(@RequestBody GoviewUser user, HttpServletRequest request) { + + // 判断是否登陆 + if (StpUtil.isLogin()) { + + Map map = new HashMap(); + 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())) { + GoviewUser sysUser = goViewUserService.getOne(new LambdaQueryWrapper().eq(GoviewUser::getUsername, user.getUsername()).eq(GoviewUser::getPassword, SecureUtil.md5(user.getUsername())).last("LIMIT 1")); + if (sysUser != null) { + StpUtil.login(sysUser.getId()); + SaTokenUtil.setUser(sysUser); + Map map = new HashMap(); + map.put("userinfo", sysUser); + map.put("token", StpUtil.getTokenInfo()); + + return success().put("data", map); + } else { + return error(500, "账户或者密码错误"); + } + } else { + return error(500, "账户密码不能为空"); + } + } + + } + + + @GetMapping("/logout") + @ResponseBody + public AjaxResult logout() { + + // 判断是否登陆 + StpUtil.logout(); + + return success(); + + } + + + @GetMapping("/getOssInfo") + @ResponseBody + public AjaxResult getOssInfo() { + + return success(); + + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewFile.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewFile.java new file mode 100644 index 000000000..8659befaa --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewFile.java @@ -0,0 +1,103 @@ +package com.go.view.admin.domain; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author fc + * @since 2022-12-22 + */ +@TableName("go_view_file") +public class GoviewFile 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; + + + 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 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; + } + + + + + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProject.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProject.java new file mode 100644 index 000000000..e5d158cfa --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProject.java @@ -0,0 +1,31 @@ +package com.go.view.admin.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +@TableName("go_view_project") +@Data +public class GoviewProject implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String projectName; + + private Integer state; + + private String indexImage; + + @TableLogic + private Integer delFlag; + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProjectData.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProjectData.java new file mode 100644 index 000000000..5196e44b0 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewProjectData.java @@ -0,0 +1,29 @@ +package com.go.view.admin.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +@TableName("go_view_project_data") +@Data +public class GoviewProjectData implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private Long projectId; + + private String content; + + @TableLogic + private Integer delFlag; + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewUser.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewUser.java new file mode 100644 index 000000000..2e1f72062 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/GoviewUser.java @@ -0,0 +1,29 @@ +package com.go.view.admin.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; + +@TableName("go_view_user") +@Data +public class GoviewUser implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String username; + + private String password; + + @TableLogic + private Integer delFlag; +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewFileVo.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewFileVo.java new file mode 100644 index 000000000..44f1e2d26 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewFileVo.java @@ -0,0 +1,28 @@ +package com.go.view.admin.domain.vo; + +import lombok.Data; + +@Data +public class GoviewFileVo { + + private String id; + private String fileName; + private Integer fileSize; + private String createTime; + + /** + * 相对路径 + */ + private String relativePath; + + /** + * 虚拟路径key + */ + private String virtualKey; + + /** + * 请求url + */ + private String fileurl; + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewProjectVo.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewProjectVo.java new file mode 100644 index 000000000..f144d977b --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/domain/vo/GoviewProjectVo.java @@ -0,0 +1,25 @@ +package com.go.view.admin.domain.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class GoviewProjectVo implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String projectName; + + private Integer state; + + private Integer delFlag; + + private String indexImage; + + private String content; +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewFileMapper.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewFileMapper.java new file mode 100644 index 000000000..14c1a4d13 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewFileMapper.java @@ -0,0 +1,10 @@ +package com.go.view.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.go.view.admin.domain.GoviewFile; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoviewFileMapper extends BaseMapper { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectDataMapper.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectDataMapper.java new file mode 100644 index 000000000..4d531aa46 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectDataMapper.java @@ -0,0 +1,10 @@ +package com.go.view.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.go.view.admin.domain.GoviewProjectData; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoviewProjectDataMapper extends BaseMapper { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectMapper.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectMapper.java new file mode 100644 index 000000000..4966983a3 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewProjectMapper.java @@ -0,0 +1,10 @@ +package com.go.view.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.go.view.admin.domain.GoviewProject; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoviewProjectMapper extends BaseMapper { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewUserMapper.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewUserMapper.java new file mode 100644 index 000000000..eee99c717 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/mapper/GoviewUserMapper.java @@ -0,0 +1,10 @@ +package com.go.view.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.go.view.admin.domain.GoviewUser; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoviewUserMapper extends BaseMapper { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewFileService.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewFileService.java new file mode 100644 index 000000000..3eeb004e6 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewFileService.java @@ -0,0 +1,10 @@ +package com.go.view.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.go.view.admin.domain.GoviewFile; + +public interface IGoviewFileService extends IService { + + + public GoviewFile selectByExamplefileName(String filename); +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectDataService.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectDataService.java new file mode 100644 index 000000000..0b74c51dd --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectDataService.java @@ -0,0 +1,10 @@ +package com.go.view.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.go.view.admin.domain.GoviewProjectData; + +public interface IGoviewProjectDataService extends IService { + + public GoviewProjectData getProjectid(String projectId); + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectService.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectService.java new file mode 100644 index 000000000..0033bdf33 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewProjectService.java @@ -0,0 +1,8 @@ +package com.go.view.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.go.view.admin.domain.GoviewProject; + +public interface IGoviewProjectService extends IService { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewUserService.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewUserService.java new file mode 100644 index 000000000..70badaa7f --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/IGoviewUserService.java @@ -0,0 +1,8 @@ +package com.go.view.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.go.view.admin.domain.GoviewUser; + +public interface IGoviewUserService extends IService { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewFileServiceImpl.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewFileServiceImpl.java new file mode 100644 index 000000000..854eccbaa --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewFileServiceImpl.java @@ -0,0 +1,22 @@ +package com.go.view.admin.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.go.view.admin.domain.GoviewFile; +import com.go.view.admin.mapper.GoviewFileMapper; +import com.go.view.admin.service.IGoviewFileService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class GoviewFileServiceImpl extends ServiceImpl implements IGoviewFileService { + final GoviewFileMapper sysFileMapper; + + @Override + public GoviewFile selectByExamplefileName(String filename) { + GoviewFile sysFile=sysFileMapper.selectOne(new LambdaQueryWrapper().eq(GoviewFile::getFileName, filename)); + return sysFile; + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectDataServiceImpl.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectDataServiceImpl.java new file mode 100644 index 000000000..d09792f4a --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectDataServiceImpl.java @@ -0,0 +1,24 @@ +package com.go.view.admin.service.impl; + +import com.go.view.admin.mapper.GoviewProjectDataMapper; +import com.go.view.admin.domain.GoviewProjectData; +import com.go.view.admin.service.IGoviewProjectDataService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + + +@Service +@RequiredArgsConstructor +public class GoviewProjectDataServiceImpl extends ServiceImpl implements IGoviewProjectDataService { + final GoviewProjectDataMapper dataMapper; + @Override + public GoviewProjectData getProjectid(String projectId) { + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); + lambdaQueryWrapper.eq(GoviewProjectData::getProjectId, projectId); + return dataMapper.selectOne(lambdaQueryWrapper); + + } + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectServiceImpl.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectServiceImpl.java new file mode 100644 index 000000000..4f134d301 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewProjectServiceImpl.java @@ -0,0 +1,12 @@ +package com.go.view.admin.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.go.view.admin.domain.GoviewProject; +import com.go.view.admin.mapper.GoviewProjectMapper; +import com.go.view.admin.service.IGoviewProjectService; +import org.springframework.stereotype.Service; + +@Service +public class GoviewProjectServiceImpl extends ServiceImpl implements IGoviewProjectService { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewUserServiceImpl.java b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewUserServiceImpl.java new file mode 100644 index 000000000..bf9f548dd --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/java/com/go/view/admin/service/impl/GoviewUserServiceImpl.java @@ -0,0 +1,12 @@ +package com.go.view.admin.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.go.view.admin.domain.GoviewUser; +import com.go.view.admin.mapper.GoviewUserMapper; +import com.go.view.admin.service.IGoviewUserService; +import org.springframework.stereotype.Service; + +@Service +public class GoviewUserServiceImpl extends ServiceImpl implements IGoviewUserService { + +} diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application-dev.yml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application-dev.yml new file mode 100644 index 000000000..2e99a6082 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application-dev.yml @@ -0,0 +1,39 @@ +v2: + #虚拟路径映射路径 2个文件路径一一对应 第一个为主存储,其他为配置相关 + xnljmap: + #win服务器 本地 注意!! 记住这个结尾有一个/ + oss: file:C:/Users/Administrator/IdeaProjects/go-view-serve-master/upload/ + #linux服务器 + #oss: file:/home/webapps/oss/ + #虚拟路径映射路径 end + #本地存放地址 注意!! 记住这个结尾没有/ + fileurl: C:/Users/Administrator/IdeaProjects/go-view-serve-master/upload + #http://127.0.0.1:8080/oss/{yy}/2022-12-22/c83a77ae134a540c30daa6a0666fa945.md + httpurl: http://127.0.0.1:8083/ + defaultFormat: .png + +--- # 数据库配置 +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai + username: root + password: root + hikari: + # 最大连接池数量 + maxPoolSize: 20 + # 最小空闲线程数量 + minIdle: 10 + # 配置获取连接等待超时的时间 + connectionTimeout: 30000 + # 校验超时时间 + validationTimeout: 5000 + # 空闲连接存活最大时间,默认10分钟 + idleTimeout: 600000 + # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟 + maxLifetime: 1800000 + # 连接测试query(配置检测连接是否有效) + connectionTestQuery: SELECT 1 + # 多久检查一次连接的活性 + keepaliveTime: 30000 diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application.yml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application.yml new file mode 100644 index 000000000..2497eaf09 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/application.yml @@ -0,0 +1,81 @@ +#tomcat config +server : + port : 8083 + ##项目名字配置 + servlet : + context-path : / + +spring : + # 环境 dev|test|prod + profiles : + active : @profiles.active@ + servlet: + multipart: + #设置总上传的数据大小 + max-request-size: 100MB + #单个文件大小 + maxFileSize : 30MB + +logging: + config: classpath:logback-plus.xml + +# MyBatisPlus配置 +# https://baomidou.com/config/ +mybatis-plus: + # 不支持多包, 如有需要可在注解配置 或 提升扫包等级 + # 例如 com.**.**.mapper + mapperPackage: com.go.view.admin.mapper + # 对应的 XML 文件位置 + mapperLocations: classpath*:mapper/*Mapper.xml + # 实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.go.view.admin.domain + # 启动时是否检查 MyBatis XML 文件的存在,默认不检查 + checkConfigLocation: false + configuration: + # 自动驼峰命名规则(camel case)映射 + mapUnderscoreToCamelCase: true + # MyBatis 自动映射策略 + # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 + autoMappingBehavior: PARTIAL + # MyBatis 自动映射时未知列或未知属性处理策 + # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息 + autoMappingUnknownColumnBehavior: NONE + # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl + # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl + # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl + logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl + global-config: + # 是否打印 Logo banner + banner: true + dbConfig: + # 主键类型 + # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID + idType: ASSIGN_ID + # 逻辑已删除值 + logicDeleteValue: 2 + # 逻辑未删除值 + logicNotDeleteValue: 0 + # 字段验证策略之 insert,在 insert 的时候的字段验证策略 + # IGNORED 忽略 NOT_NULL 非NULL NOT_EMPTY 非空 DEFAULT 默认 NEVER 不加入 SQL + insertStrategy: NOT_NULL + # 字段验证策略之 update,在 update 的时候的字段验证策略 + updateStrategy: NOT_NULL + # 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件 + where-strategy: NOT_NULL + +############## 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 diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/logback-plus.xml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/logback-plus.xml new file mode 100644 index 000000000..9c2e77233 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/logback-plus.xml @@ -0,0 +1,34 @@ + + + + logback + + + + + + + ${console.log.pattern} + utf-8 + + + + + ${log.path}.log + + ${log.path}.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewFileMapper.xml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewFileMapper.xml new file mode 100644 index 000000000..efd62b9d1 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewFileMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectDataMapper.xml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectDataMapper.xml new file mode 100644 index 000000000..b3e32c0a4 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectDataMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectMapper.xml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectMapper.xml new file mode 100644 index 000000000..532f52d94 --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewProjectMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewUserMapper.xml b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewUserMapper.xml new file mode 100644 index 000000000..ee0cba06e --- /dev/null +++ b/ruoyi-extend/ruoyi-go-view-admin/src/main/resources/mapper/GoviewUserMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/script/sql/tables_go_view.sql b/script/sql/tables_go_view.sql new file mode 100644 index 000000000..495223bed --- /dev/null +++ b/script/sql/tables_go_view.sql @@ -0,0 +1,82 @@ +SET NAMES utf8mb4; +SET +FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for go_view_file +-- ---------------------------- +DROP TABLE IF EXISTS `go_view_file`; +CREATE TABLE `go_view_file` +( + `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号', + `file_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件名', + `file_size` int(11) NOT NULL COMMENT '文件大小', + `file_suffix` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件后缀', + `virtual_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '虚拟路径', + `relative_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '相对路径', + `absolute_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '绝对路径', + `state` int(1) NOT NULL DEFAULT -1 COMMENT '发布(1发布-1取消发布)', + `del_flag` int(1) NOT NULL DEFAULT 0 COMMENT '删除(0正常2删除)', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '大屏文件表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of go_view_file +-- ---------------------------- + +-- ---------------------------- +-- Table structure for go_view_project +-- ---------------------------- +DROP TABLE IF EXISTS `go_view_project`; +CREATE TABLE `go_view_project` +( + `id` bigint(20) NOT NULL COMMENT '编号', + `project_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目名', + `index_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '封面', + `state` int(1) NOT NULL DEFAULT -1 COMMENT '发布(1发布-1取消发布)', + `del_flag` int(1) NOT NULL DEFAULT 0 COMMENT '删除(0正常2删除)', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '大屏项目表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of go_view_project +-- ---------------------------- + +-- ---------------------------- +-- Table structure for go_view_project_data +-- ---------------------------- +DROP TABLE IF EXISTS `go_view_project_data`; +CREATE TABLE `go_view_project_data` +( + `id` bigint(20) NOT NULL COMMENT '编号', + `project_id` bigint(20) NOT NULL COMMENT '项目', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '内容', + `del_flag` int(1) NOT NULL DEFAULT 0 COMMENT '删除(0正常2删除)', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '大屏项目表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of go_view_project_data +-- ---------------------------- + +-- ---------------------------- +-- Table structure for go_view_user +-- ---------------------------- +DROP TABLE IF EXISTS `go_view_user`; +CREATE TABLE `go_view_user` +( + `id` bigint(20) NOT NULL COMMENT '编号', + `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名', + `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码', + `del_flag` int(1) NOT NULL DEFAULT 0 COMMENT '删除(0正常2删除)', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '大屏账号表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of go_view_user +-- ---------------------------- +INSERT INTO `go_view_user` +VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 0); + +SET +FOREIGN_KEY_CHECKS = 1;