This commit is contained in:
六如
2024-12-22 23:09:46 +08:00
parent 02fb5a9e85
commit 403e8111f4
1239 changed files with 4764 additions and 702 deletions

18
sop-website/pom.xml Executable file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>sop-website</artifactId>
<packaging>pom</packaging>
<modules>
<module>sop-website-backend</module>
</modules>
</project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>sop-website-backend</artifactId>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>website-common</module>
<module>website-service</module>
<module>website-dao</module>
<module>website-boot</module>
<module>website-web</module>
</modules>
</project>

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website-backend</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>website-boot</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>website-web</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- provided -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 打包时跳过测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SopWebsiteApplication {
public static void main(String[] args) {
SpringApplication.run(SopWebsiteApplication.class, args);
}
}

View File

@@ -0,0 +1,79 @@
package com.gitee.sop.website.config;
import com.gitee.sop.website.common.context.SpringContext;
import com.gitee.sop.website.common.util.SystemUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author 六如
*/
@Configuration
@Slf4j
public class SopWebsiteConfiguration implements ApplicationContextAware, WebMvcConfigurer {
@Value("${front-location:}")
private String frontLocation;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContext.setApplicationContext(applicationContext);
}
/**
* 跨域设置
*/
@Bean
public CorsFilter corsFilter(
@Value("${torna.cors.allowed-origin-pattern:*}") String allowedOriginPattern,
@Value("${torna.cors.allowed-header:*}") String allowedHeader
) {
CorsConfiguration corsConfiguration = new CorsConfiguration();
// SpringBoot升级2.4.0之后,跨域配置中的.allowedOrigins不再可用,改成addAllowedOriginPattern
corsConfiguration.addAllowedOriginPattern(allowedOriginPattern);
corsConfiguration.addAllowedHeader(allowedHeader);
corsConfiguration.addAllowedMethod(CorsConfiguration.ALL);
corsConfiguration.addExposedHeader("Content-Disposition");
corsConfiguration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(source);
}
/**
* 配置静态资源
*
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String homeDir = SystemUtil.getBinPath();
String frontRoot;
if (StringUtils.hasText(frontLocation)) {
frontRoot = StringUtils.trimTrailingCharacter(frontLocation, '/');
} else {
frontRoot = homeDir + "/dist";
}
log.info("前端资源目录:{}", frontRoot);
String location = "file:" + frontRoot;
registry.addResourceHandler("/index.html").addResourceLocations(location + "/index.html");
registry.addResourceHandler("/favicon.ico").addResourceLocations(location + "/favicon.ico");
registry.addResourceHandler("/logo.png").addResourceLocations(location + "/logo.png");
registry.addResourceHandler("/platform-config.json").addResourceLocations(location + "/platform-config.json");
registry.addResourceHandler("/static/**").addResourceLocations(location + "/static/");
registry.addResourceHandler("/assets/**").addResourceLocations(location + "/assets/");
}
}

View File

@@ -0,0 +1,6 @@
mybatis.print-sql=true
# mysql config
mysql.host=127.0.0.1:3306
mysql.username=root
mysql.password=root

View File

@@ -0,0 +1,6 @@
mybatis.print-sql=true
# mysql config
mysql.host=127.0.0.1:3306
mysql.username=root
mysql.password=root

View File

@@ -0,0 +1,28 @@
server.port=8083
spring.profiles.active=dev
spring.application.name=sop-website
####### mysql config #######
mysql.host=127.0.0.1:3306
mysql.username=
mysql.password=
mysql.db=sop
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://${mysql.host}/${mysql.db}?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
spring.datasource.username=${mysql.username}
spring.datasource.password=${mysql.password}
####### mybatis config #######
mybatis.fill.com.gitee.fastmybatis.core.support.LocalDateTimeFillInsert=add_time
mybatis.fill.com.gitee.fastmybatis.core.support.LocalDateTimeFillUpdate=update_time
# mybatis config file
mybatis.config-location=classpath:mybatis/mybatisConfig.xml
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
# print SQL
logging.level.com.gitee.sop.website.dao=error
logging.level.com.gitee.fastmybatis=info
mybatis.print-sql=false

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website-backend</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>website-common</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
<dependency>
<groupId>io.gitee.durcframework</groupId>
<artifactId>fastmybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,46 @@
package com.gitee.sop.website.common.config;
import com.gitee.sop.website.common.context.SpringContext;
import com.gitee.sop.website.common.enums.ConfigKeyEnum;
import java.util.function.Supplier;
/**
* @author 六如
*/
public class Configs {
/**
* 获取配置参数
*
* @param keyGetter 配置key
* @return 返回配参数没有则返回null
*/
public static String getValue(ConfigKeyEnum keyGetter) {
return getValue(keyGetter, keyGetter.getDefaultValue());
}
/**
* 获取配置参数
*
* @param keyGetter 配置key
* @param defaultValue 默认值
* @return 返回配参数,没有则返回默认值
*/
public static String getValue(ConfigKeyEnum keyGetter, String defaultValue) {
return SpringContext.getBean(IConfig.class).getConfig(keyGetter.getKey(), defaultValue);
}
/**
* 获取配置参数
*
* @param keyGetter 配置key
* @param defaultValue 默认值
* @return 返回配参数,没有则返回默认值
*/
public static String getValue(ConfigKeyEnum keyGetter, Supplier<String> defaultValue) {
return getValue(keyGetter, defaultValue.get());
}
}

View File

@@ -0,0 +1,9 @@
package com.gitee.sop.website.common.config;
public interface IConfig {
String getConfig(String key);
String getConfig(String key, String defaultValue);
}

View File

@@ -0,0 +1,20 @@
package com.gitee.sop.website.common.constants;
import java.util.Objects;
/**
* @author 六如
*/
public class YesOrNo {
public static final int YES = 1;
public static final int NO = 0;
public static boolean yes(Number value) {
return value != null && value.intValue() == YES;
}
public static int of(Boolean b) {
return Objects.equals(b, true) ? YES : NO;
}
}

View File

@@ -0,0 +1,31 @@
package com.gitee.sop.website.common.context;
import org.springframework.context.ApplicationContext;
/**
* @author 六如
*/
public class SpringContext {
private static ApplicationContext ctx;
public static <T> T getBean(Class<T> clazz) {
return ctx.getBean(clazz);
}
public static Object getBean(String beanName) {
return ctx.getBean(beanName);
}
public static void setApplicationContext(ApplicationContext ctx) {
SpringContext.ctx = ctx;
}
public static ApplicationContext getApplicationContext() {
return ctx;
}
public static void publishEvent(Object event) {
ctx.publishEvent(event);
}
}

View File

@@ -0,0 +1,33 @@
package com.gitee.sop.website.common.enums;
import com.gitee.sop.website.common.config.Configs;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author 六如
*/
@AllArgsConstructor
@Getter
public enum ConfigKeyEnum {
PASSWORD_SALT("admin.password-salt", ""),
JWT_TIMEOUT_DAYS("admin.jwt-timeout-days", "365"),
JWT_SECRET("admin.jwt.secret", ""),
TORNA_SERVER_ADDR("admin.torna-server-addr", ""),
OPEN_PROD_URL("admin.open-prod-url", ""),
OPEN_SANDBOX_URL("admin.open-sandbox-url", "");
private final String key;
private final String defaultValue;
public String getValue() {
return getValue(this.defaultValue);
}
public String getValue(String defaultValue) {
return Configs.getValue(this, defaultValue);
}
}

View File

@@ -0,0 +1,47 @@
package com.gitee.sop.website.common.resp;
import lombok.Data;
import java.util.Objects;
/**
* @param <T> 数据
* @author thc
*/
@Data
public class Result<T> {
private static final Result<?> RESULT = new Result<>();
private String code = "0";
private T data;
private String msg = "success";
public static Result<?> ok() {
return RESULT;
}
public static <E> Result<E> ok(E obj) {
Result<E> result = new Result<>();
result.setData(obj);
return result;
}
public static <E> Result<E> err(String msg) {
Result<E> result = new Result<>();
result.setCode("1");
result.setMsg(msg);
return result;
}
public static <E> Result<E> err(String code, String msg) {
Result<E> result = new Result<>();
result.setCode(code);
result.setMsg(msg);
return result;
}
public boolean getSuccess() {
return Objects.equals("0", code);
}
}

View File

@@ -0,0 +1,360 @@
package com.gitee.sop.website.common.util;
import com.alibaba.fastjson2.JSON;
import com.gitee.fastmybatis.core.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
* 属性拷贝工具类
*
* @author 六如
*/
public class CopyUtil extends BeanUtils {
/**
* 属性拷贝,第一个参数中的属性值拷贝到第二个参数中<br>
* 注意:当第一个参数中的属性有null值时,不会拷贝进去
*
* @param from 源对象
* @param to 目标对象
* @param ignoreProperties 忽略的字段
* @throws BeansException
*/
public static void copyPropertiesIgnoreNull(Object from, Object to, String... ignoreProperties)
throws BeansException {
Assert.notNull(from, "Source must not be null");
Assert.notNull(to, "Target must not be null");
Class<?> actualEditable = to.getClass();
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : Collections.emptyList());
for (PropertyDescriptor targetPd : targetPds) {
if (ignoreList.contains(targetPd.getName())) {
continue;
}
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null) {
PropertyDescriptor sourcePd = getPropertyDescriptor(from.getClass(), targetPd.getName());
if (sourcePd != null) {
Method readMethod = sourcePd.getReadMethod();
if (readMethod != null &&
ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], readMethod.getReturnType())) {
try {
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(from);
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
}
// 这里判断value是否为空 当然这里也能进行一些特殊要求的处理
// 例如绑定时格式转换等等
if (value != null) {
writeMethod.invoke(to, value);
}
} catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + targetPd.getName() + "' from source to target", ex);
}
}
}
}
}
}
/**
* 拷贝指定的字段
*
* @param from 源对象
* @param to 目标对象
* @param includeFields 指定字段
*/
public static void copyPropertiesInclude(Object from, Object to, Set<String> includeFields) {
Objects.requireNonNull(includeFields, "includeFields can not null");
Assert.notNull(from, "Source must not be null");
Assert.notNull(to, "Target must not be null");
if (includeFields.isEmpty()) {
return;
}
Class<?> actualEditable = to.getClass();
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
for (PropertyDescriptor targetPd : targetPds) {
if (!includeFields.contains(targetPd.getName())) {
continue;
}
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null) {
PropertyDescriptor sourcePd = getPropertyDescriptor(from.getClass(), targetPd.getName());
if (sourcePd != null) {
Method readMethod = sourcePd.getReadMethod();
if (readMethod != null &&
ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], readMethod.getReturnType())) {
try {
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(from);
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
}
writeMethod.invoke(to, value);
} catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + targetPd.getName() + "' from source to target", ex);
}
}
}
}
}
}
/**
* 拷贝属性
*
* @param from 被拷贝类
* @param to 目标类
*/
public static void copyProperties(Object from, Object to) {
BeanUtils.copyProperties(from, to);
}
/**
* 拷贝bean成为一个新类
*
* @param from 被拷贝类
* @param supplier 新的类获取回调
* @param <T> 新的类
* @return 返回新的类实例from为null时返回null
*/
public static <T> T copyBean(Object from, Supplier<T> supplier) {
if (from == null) {
return null;
}
T to = supplier.get();
BeanUtils.copyProperties(from, to);
return to;
}
/**
* 拷贝实例
*
* @param from 被拷贝类
* @param supplier 新的类获取回调
* @param after 对新的类最后续处理回调
* @param <T> 新的类
* @return 返回新的类
*/
public static <T> T copyBean(Object from, Supplier<T> supplier, Consumer<T> after) {
if (from == null) {
return null;
}
T to = supplier.get();
BeanUtils.copyProperties(from, to);
after.accept(to);
return to;
}
/**
* 拷贝List将list中的类转换成新的对象
*
* @param collection 被拷贝的集合
* @param toElement List新元素
* @param <T> 新元素类型
* @return 返回新的List
*/
public static <T> List<T> copyList(Collection<?> collection, Supplier<T> toElement) {
if (collection == null || collection.isEmpty()) {
return new ArrayList<>();
}
return collection.stream()
.map(source -> {
T target = toElement.get();
BeanUtils.copyProperties(source, target);
return target;
})
.collect(Collectors.toList());
}
public static <E, R> List<R> copyList(Collection<E> fromList, Function<E, R> function) {
if (fromList == null) {
return new ArrayList<>();
}
return fromList.stream()
.map(source -> {
R target = function.apply(source);
BeanUtils.copyProperties(source, target);
return target;
})
.collect(Collectors.toList());
}
/**
* 拷贝List并做后续处理
*
* @param fromList 被拷贝的list
* @param toElement 新元素
* @param after 对新元素做后续处理
* @param <T> 新类型
* @return 返回新的List
*/
public static <T> List<T> copyList(Collection<?> fromList, Supplier<T> toElement, Consumer<T> after) {
if (fromList == null) {
return new ArrayList<>();
}
return fromList.stream()
.map(source -> {
T target = toElement.get();
BeanUtils.copyProperties(source, target);
after.accept(target);
return target;
})
.collect(Collectors.toList());
}
/**
* 拷贝List并做后续处理
*
* @param fromList 被拷贝的list
* @param toElement 新元素
* @param after 对新元素做后续处理
* @param <T> 新类型
* @return 返回新的List
*/
public static <T, F> List<T> copyList(Collection<F> fromList, Supplier<T> toElement, CopyConsumer<F, T> after) {
if (fromList == null) {
return new ArrayList<>();
}
return fromList.stream()
.map(source -> {
T target = toElement.get();
BeanUtils.copyProperties(source, target);
after.apply(source, target);
return target;
})
.collect(Collectors.toList());
}
/**
* 深层次拷贝通过json转换的方式实现
*
* @param from 待转换的类
* @param toClass 目标类class
* @param <T> 目标类
* @return 返回目标类
*/
public static <T> T deepCopy(Object from, Class<T> toClass) {
String json = JSON.toJSONString(from);
return JSON.parseObject(json, toClass);
}
/**
* 深层次拷贝通过json转换的方式实现
*
* @param from 待转换的类
* @param toClass 目标类class
* @param <T> 目标类
* @return 返回目标类
*/
public static <T> List<T> deepCopyList(Object from, Class<T> toClass) {
String json = JSON.toJSONString(from);
return JSON.parseArray(json, toClass);
}
/**
* 拷贝map
*
* @param srcMap 原map
* @param valueGetter 值转换
* @param <K> Key类型
* @param <V> Value类型
* @return 返回新map
*/
public static <K, V> Map<K, V> copyMap(Map<K, ?> srcMap, Supplier<V> valueGetter) {
Map<K, V> ret = new LinkedHashMap<>(srcMap.size() * 2);
for (Map.Entry<K, ?> entry : srcMap.entrySet()) {
V value = copyBean(entry.getValue(), valueGetter);
ret.put(entry.getKey(), value);
}
return ret;
}
/**
* 拷贝map
*
* @param srcMap 原map
* @param function 值转换
* @param <K> Key类型
* @param <V> Value类型
* @return 返回新map
*/
public static <K, V, V0> Map<K, V> copyMap(Map<K, V0> srcMap, Function<V0, V> function) {
Map<K, V> ret = new LinkedHashMap<>(srcMap.size() * 2);
for (Map.Entry<K, V0> entry : srcMap.entrySet()) {
V value = function.apply(entry.getValue());
ret.put(entry.getKey(), value);
}
return ret;
}
/**
* 拷贝map,value是list
*
* @param srcMap 原map
* @param valueGetter 值转换
* @param <K> Key类型
* @param <V> Value类型
* @return 返回新map
*/
public static <K, V, V2> Map<K, List<V2>> copyMapList(Map<K, List<V>> srcMap, Function<List<V>, List<V2>> valueGetter) {
Map<K, List<V2>> ret = new LinkedHashMap<>(srcMap.size() * 2);
for (Map.Entry<K, List<V>> entry : srcMap.entrySet()) {
List<V2> value = valueGetter.apply(entry.getValue());
ret.put(entry.getKey(), value);
}
return ret;
}
public static <R, T> PageInfo<R> copyPageInfo(PageInfo<T> srcPageInfo, Function<List<T>, List<R>> function) {
PageInfo<R> pageInfo = new PageInfo<>();
List<T> list = srcPageInfo.getList();
if (list != null && !list.isEmpty()) {
pageInfo.setList(function.apply(list));
} else {
pageInfo.setList(new ArrayList<>(0));
}
pageInfo.setPageCount(srcPageInfo.getPageCount());
pageInfo.setPageIndex(srcPageInfo.getPageIndex());
pageInfo.setPageSize(srcPageInfo.getPageSize());
pageInfo.setTotal(srcPageInfo.getTotal());
return pageInfo;
}
public interface CopyConsumer<F, T> {
void apply(F from, T to);
}
}

View File

@@ -0,0 +1,32 @@
package com.gitee.sop.website.common.util;
import org.springframework.boot.system.ApplicationHome;
import java.io.File;
/**
* @author tanghc
*/
public class SystemUtil {
/**
* 获取程序执行目录即jar包所在的目录。此方法只在部署后有用开发模式下这里返回target路径
* @return 返回路径
*/
public static String getBinPath() {
ApplicationHome applicationHome = new ApplicationHome(SystemUtil.class);
File file = applicationHome.getSource();
if (file == null) {
return getUserDir();
}
return file.getParentFile().toString();
}
public static String getUserDir() {
return System.getProperty("user.dir");
}
public static String getUserHome() {
return System.getProperty("user.home");
}
}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website-backend</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>website-dao</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.gitee.durcframework</groupId>
<artifactId>fastmybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,111 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名api_info
* 备注:接口信息表
*
* @author 六如
*/
@Table(name = "api_info", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class ApiInfo {
/**
* id
*/
private Long id;
/**
* 所属应用
*/
private String application;
/**
* 接口名称
*/
private String apiName;
/**
* 版本号
*/
private String apiVersion;
/**
* 接口描述
*/
private String description;
/**
* 备注
*/
private String remark;
/**
* 接口class
*/
private String interfaceClassName;
/**
* 方法名称
*/
private String methodName;
/**
* 参数信息
*/
private String paramInfo;
/**
* 接口是否需要授权访问
*/
private Integer isPermission;
/**
* 是否需要appAuthToken
*/
private Integer isNeedToken;
/**
* 是否有公共响应参数
*/
private Integer hasCommonResponse;
/**
* 注册来源1-系统注册,2-手动注册
*/
private Integer regSource;
/**
* 1启用0禁用
*/
private Integer status;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,63 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名doc_app
* 备注:文档应用
*
* @author 六如
*/
@Table(name = "doc_app", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class DocApp {
/**
* id
*/
private Long id;
/**
* 应用名称
*/
private String appName;
/**
* Torna应用token
*/
private String token;
/**
* 状态, 0-未发布,1-已发布
*/
private Integer isPublish;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,58 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名doc_content
* 备注:文档内容
*
* @author 六如
*/
@Table(name = "doc_content", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class DocContent {
/**
* id
*/
private Long id;
/**
* doc_info.id
*/
private Long docInfoId;
/**
* 文档内容
*/
private String content;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,108 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名doc_info
* 备注:文档信息
*
* @author 六如
*/
@Table(name = "doc_info", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class DocInfo {
/**
* id
*/
private Long id;
/**
* doc_app.id
*/
private Long docAppId;
/**
* 远程文档id
*/
private Long docId;
/**
* 文档标题
*/
private String docTitle;
/**
* 文档code
*/
private String docCode;
/**
* 文档类型,1-dubbo,2-富文本,3-Markdown
*/
private Integer docType;
/**
* 来源类型,1-torna,2-自建
*/
private Integer sourceType;
/**
* 文档名称
*/
private String docName;
/**
* 版本号
*/
private String docVersion;
/**
* 描述
*/
private String description;
/**
* 是否分类
*/
private Integer isFolder;
/**
* 状态, 0-未发布,1-已发布
*/
private Integer isPublish;
/**
* 父节点id, 对应docId
*/
private Long parentId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,60 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名isv_info
* 备注isv信息表
*
* @author 六如
*/
@Table(name = "isv_info", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class IsvInfo {
/**
* id
*/
private Long id;
/**
* appKey
*/
private String appId;
/**
* 1启用2禁用
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,75 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名isv_keys
* 备注ISV秘钥管理
*
* @author 六如
*/
@Table(name = "isv_keys", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class IsvKeys {
/**
* id
*/
private Long id;
/**
* isv_info.id
*/
private Long isvId;
/**
* 秘钥格式1PKCS8(JAVA适用)2PKCS1(非JAVA适用)
*/
private Integer keyFormat;
/**
* 开发者生成的公钥
*/
private String publicKeyIsv;
/**
* 开发者生成的私钥(交给开发者)
*/
private String privateKeyIsv;
/**
* 平台生成的公钥(交给开发者)
*/
private String publicKeyPlatform;
/**
* 平台生成的私钥
*/
private String privateKeyPlatform;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,56 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名perm_group
* 备注:分组表
*
* @author 六如
*/
@Table(name = "perm_group", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class PermGroup {
/**
* id
*/
private Long id;
/**
* 分组名称
*/
private String groupName;
/**
* 是否删除
*/
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
private Integer isDeleted;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,55 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名perm_group_permission
* 备注:组权限表
*
* @author 六如
*/
@Table(name = "perm_group_permission", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class PermGroupPermission {
/**
* id
*/
private Long id;
/**
* 组id
*/
private Long groupId;
/**
* api_info.id
*/
private Long apiId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,46 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名perm_isv_group
* 备注isv分组
*
* @author 六如
*/
@Table(name = "perm_isv_group", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class PermIsvGroup {
private Long id;
/**
* isv_info表id
*/
private Long isvId;
/**
* 组id
*/
private Long groupId;
private LocalDateTime addTime;
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,80 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名sys_admin_user
* 备注:系统用户表
*
* @author 六如
*/
@Table(name = "sys_admin_user", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysAdminUser {
/**
* id
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 用户名
*/
private String nickname;
/**
* 邮箱
*/
private String email;
/**
* 头像
*/
private String avatar;
/**
* 状态1启用2禁用
*/
private Integer status;
/**
* 注册类型1-系统2-手动
*/
private String regType;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,45 @@
package com.gitee.sop.website.dao.entity;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 表名sys_config
* 备注:系统配置表
*
* @author 六如
*/
@Table(name = "sys_config", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysConfig {
private Long id;
private String configKey;
private String configValue;
private String remark;
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
private Integer isDeleted;
private LocalDateTime addTime;
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 最后更新人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,73 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_dept
* 备注:部门表
*
* @author 六如
*/
@Table(name = "sys_dept", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysDept {
/**
* id
*/
private Long id;
/**
* 部门名称
*/
private String name;
/**
* 排序
*/
private Integer sort;
/**
* 状态1启用2禁用
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 父级id
*/
private Long parentId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,159 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_resource
* 备注:菜单资源表
*
* @author 六如
*/
@Table(name = "sys_resource", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysResource {
/**
* id
*/
private Long id;
/**
* 菜单类型0代表菜单、1代表iframe、2代表外链、3代表按钮
*/
private Integer menuType;
/**
* 菜单名称
*/
private String title;
/**
* 路由名称
*/
private String name;
/**
* 路由路径
*/
private String path;
/**
* 路由路径
*/
private String component;
/**
* 排序
*/
private Integer rank;
/**
* 路由重定向
*/
private String redirect;
/**
* 菜单图标
*/
private String icon;
/**
* 右侧图标
*/
private String extraIcon;
/**
* 进场动画(页面加载动画)
*/
private String enterTransition;
/**
* 离场动画(页面加载动画)
*/
private String leaveTransition;
/**
* 菜单激活
*/
private String activePath;
/**
* 权限标识
*/
private String auths;
/**
* 链接地址(需要内嵌的`iframe`链接地址)
*/
private String frameSrc;
/**
* 加载动画(内嵌的`iframe`页面是否开启首次加载动画)
*/
private Integer frameLoading;
/**
* 缓存页面
*/
private Integer keepAlive;
/**
* 标签页(当前菜单名称或自定义信息禁止添加到标签页)
*/
private Integer hiddenTag;
/**
* 固定标签页(当前菜单名称是否固定显示在标签页且不可关闭)
*/
private Integer fixedTag;
/**
* 菜单(是否显示该菜单)
*/
private Integer showLink;
/**
* 父级菜单(是否显示父级菜单
*/
private Integer showParent;
/**
* 父级id
*/
private Long parentId;
/**
* 是否删除
*/
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
private Integer isDeleted;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,71 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_role
* 备注:角色表
*
* @author 六如
*/
@Table(name = "sys_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysRole {
/**
* id
*/
private Long id;
/**
* 角色名称
*/
private String name;
/**
* 角色code
*/
private String code;
/**
* 备注
*/
private String remark;
/**
* 状态1启用2禁用
*/
private Integer status;
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
private Integer isDeleted;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,58 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_role_resource
* 备注:角色资源关联表
*
* @author 六如
*/
@Table(name = "sys_role_resource", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysRoleResource {
/**
* id
*/
private Long id;
/**
* sys_role.id
*/
private Long roleId;
/**
* sys_resource.id
*/
private Long resourceId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,98 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_user
* 备注:系统用户表
*
* @author 六如
*/
@Table(name = "sys_user", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysUser {
/**
* id
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 昵称
*/
private String nickname;
/**
* 邮箱
*/
private String phone;
/**
* 邮箱
*/
private String email;
/**
* 头像
*/
private String avatar;
/**
* 性别,0-未知,1-男,2-女
*/
private Integer gender;
/**
* 状态1启用2禁用
*/
private Integer status;
/**
* 注册类型1-系统2-手动
*/
private String regType;
/**
* 备注
*/
private String remark;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,58 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_user_dept
* 备注:用户部门关联表
*
* @author 六如
*/
@Table(name = "sys_user_dept", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysUserDept {
/**
* id
*/
private Long id;
/**
* sys_user.id
*/
private Long userId;
/**
* sys_dept.id
*/
private Long deptId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,58 @@
package com.gitee.sop.website.dao.entity;
import java.time.LocalDateTime;
import com.gitee.fastmybatis.annotation.Pk;
import com.gitee.fastmybatis.annotation.PkStrategy;
import com.gitee.fastmybatis.annotation.Table;
import lombok.Data;
/**
* 表名sys_user_role
* 备注:用户角色关联表
*
* @author 六如
*/
@Table(name = "sys_user_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
@Data
public class SysUserRole {
/**
* id
*/
private Long id;
/**
* sys_role.id
*/
private Long roleId;
/**
* sys_user.id
*/
private Long userId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,21 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.ApiInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface ApiInfoMapper extends BaseMapper<ApiInfo> {
default ApiInfo getByNameVersion(String apiName, String apiVersion) {
return this.query()
.eq(ApiInfo::getApiName, apiName)
.eq(ApiInfo::getApiVersion, apiVersion)
.get();
}
}

View File

@@ -0,0 +1,17 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.DocApp;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface DocAppMapper extends BaseMapper<DocApp> {
default String getToken(Long id) {
return this.query()
.eq(DocApp::getId, id)
.getValue(DocApp::getToken);
}
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.DocContent;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface DocContentMapper extends BaseMapper<DocContent> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.DocInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface DocInfoMapper extends BaseMapper<DocInfo> {
}

View File

@@ -0,0 +1,17 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.IsvInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface IsvInfoMapper extends BaseMapper<IsvInfo> {
default IsvInfo getByAppId(String appId) {
return this.get(IsvInfo::getAppId, appId);
}
}

View File

@@ -0,0 +1,15 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.IsvKeys;
/**
* @author 六如
*/
public interface IsvKeysMapper extends BaseMapper<IsvKeys> {
default IsvKeys getByIsvInfoId(Long isvId) {
return this.get(IsvKeys::getIsvId, isvId);
}
}

View File

@@ -0,0 +1,11 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.PermGroup;
/**
* @author 六如
*/
public interface PermGroupMapper extends BaseMapper<PermGroup> {
}

View File

@@ -0,0 +1,11 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.PermGroupPermission;
/**
* @author 六如
*/
public interface PermGroupPermissionMapper extends BaseMapper<PermGroupPermission> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.PermIsvGroup;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface PermIsvGroupMapper extends BaseMapper<PermIsvGroup> {
}

View File

@@ -0,0 +1,11 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysAdminUser;
/**
* @author 六如
*/
public interface SysAdminUserMapper extends BaseMapper<SysAdminUser> {
}

View File

@@ -0,0 +1,11 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysConfig;
/**
* @author 六如
*/
public interface SysConfigMapper extends BaseMapper<SysConfig> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysDeptMapper extends BaseMapper<SysDept> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysResource;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysResourceMapper extends BaseMapper<SysResource> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysRole;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysRoleResource;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysRoleResourceMapper extends BaseMapper<SysRoleResource> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysUserDept;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysUserDeptMapper extends BaseMapper<SysUserDept> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@@ -0,0 +1,13 @@
package com.gitee.sop.website.dao.mapper;
import com.gitee.fastmybatis.core.mapper.BaseMapper;
import com.gitee.sop.website.dao.entity.SysUserRole;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 六如
*/
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
}

View File

@@ -0,0 +1,27 @@
package com.gitee.sop.website.dao.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author tanghc
*/
@Mapper
public interface UpgradeMapper {
void runSql(@Param("sql") String sql);
/**
* 查看MYSQL表字段信息
* @param tableName 表名
* @return 返回字段信息
*/
List<Map<String, Object>> listColumnInfo(@Param("tableName") String tableName);
List<String> listTableName();
List<Map<String, Object>> listTableIndex(@Param("tableName") String tableName);
}

View File

@@ -0,0 +1,22 @@
<?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="com.gitee.sop.adminbackend.dao.mapper.UpgradeMapper">
<update id="runSql">
${sql}
</update>
<select id="listColumnInfo" resultType="java.util.Map">
SHOW COLUMNS FROM ${tableName}
</select>
<select id="listTableName" resultType="String">
SHOW TABLES
</select>
<select id="listTableIndex" resultType="java.util.Map">
show index from ${tableName}
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 全局映射器启用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 查询时,关闭关联对象即时加载以提高性能 -->
<setting name="lazyLoadingEnabled" value="true" />
<!-- 对于未知的SQL查询允许返回不同的结果集以达到通用的效果 -->
<setting name="multipleResultSetsEnabled" value="true" />
<!-- 允许使用列标签代替列名 -->
<setting name="useColumnLabel" value="true" />
<!-- 允许使用自定义的主键值(比如由程序生成的UUID 32位编码作为键值)数据表的PK生成策略将被覆盖 -->
<setting name="useGeneratedKeys" value="false" />
<!-- 对于批量更新操作缓存SQL以提高性能:BATCH -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 超时设置 -->
<setting name="defaultStatementTimeout" value="25000" />
</settings>
<plugins>
<plugin interceptor="com.gitee.fastmybatis.core.support.plugin.SqlFormatterPlugin">
</plugin>
</plugins>
</configuration>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website-backend</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>website-service</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>website-common</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>website-dao</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,15 @@
package com.gitee.sop.website.service.doc;
import com.gitee.fastmybatis.core.support.LambdaService;
import com.gitee.sop.website.dao.entity.DocApp;
import com.gitee.sop.website.dao.mapper.DocAppMapper;
import org.springframework.stereotype.Service;
/**
* @author 六如
*/
@Service
public class DocAppService implements LambdaService<DocApp, DocAppMapper> {
}

View File

@@ -0,0 +1,23 @@
package com.gitee.sop.website.service.doc;
import com.gitee.fastmybatis.core.support.LambdaService;
import com.gitee.sop.website.dao.entity.DocContent;
import com.gitee.sop.website.dao.mapper.DocContentMapper;
import org.springframework.stereotype.Service;
/**
* @author 六如
*/
@Service
public class DocContentService implements LambdaService<DocContent, DocContentMapper> {
public String getContent(Long docInfoId) {
return this.query()
.eq(DocContent::getDocInfoId, docInfoId)
.getValueOptional(DocContent::getContent)
.orElse("");
}
}

View File

@@ -0,0 +1,33 @@
package com.gitee.sop.website.service.doc;
import com.alibaba.fastjson2.JSON;
import com.gitee.fastmybatis.core.support.LambdaService;
import com.gitee.sop.website.common.constants.YesOrNo;
import com.gitee.sop.website.dao.entity.DocInfo;
import com.gitee.sop.website.dao.mapper.DocInfoMapper;
import com.gitee.sop.website.service.doc.dto.torna.TornaDocInfoViewDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author 六如
*/
@Service
public class DocInfoService implements LambdaService<DocInfo, DocInfoMapper> {
@Autowired
private DocContentService docContentService;
public TornaDocInfoViewDTO getDocDetail(Long id) {
DocInfo docInfo = this.getById(id);
if (docInfo == null || !YesOrNo.yes(docInfo.getIsPublish())) {
throw new IllegalArgumentException("文档不存在");
}
String content = docContentService.getContent(docInfo.getId());
return JSON.parseObject(content, TornaDocInfoViewDTO.class);
}
}

View File

@@ -0,0 +1,22 @@
package com.gitee.sop.website.service.doc;
import com.gitee.sop.website.common.enums.ConfigKeyEnum;
import com.gitee.sop.website.service.doc.dto.DocSettingDTO;
import org.springframework.stereotype.Service;
/**
* @author 六如
*/
@Service
public class DocSettingService {
public DocSettingDTO getDocSetting() {
DocSettingDTO docSettingDTO = new DocSettingDTO();
docSettingDTO.setTornaServerAddr(ConfigKeyEnum.TORNA_SERVER_ADDR.getValue());
docSettingDTO.setOpenProdUrl(ConfigKeyEnum.OPEN_PROD_URL.getValue());
docSettingDTO.setOpenSandboxUrl(ConfigKeyEnum.OPEN_SANDBOX_URL.getValue());
return docSettingDTO;
}
}

View File

@@ -0,0 +1,52 @@
package com.gitee.sop.admin.service.doc.dto;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 备注:文档应用
*
* @author 六如
*/
@Data
public class DocAppDTO {
/**
* id
*/
private Long id;
/**
* 应用名称
*/
private String appName;
/**
* Torna应用token
*/
private String token;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建人id
*/
private Long addBy;
/**
* 修改人id
*/
private Long updateBy;
}

View File

@@ -0,0 +1,14 @@
package com.gitee.sop.website.service.doc.dto;
import lombok.Data;
/**
* @author 六如
*/
@Data
public class DocInfoConfigDTO {
private String openProdUrl;
private String openSandboxUrl;
}

View File

@@ -0,0 +1,106 @@
package com.gitee.sop.website.service.doc.dto;
import com.gitee.fastmybatis.core.support.TreeNode;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 备注:文档信息
*
* @author 六如
*/
@Data
public class DocInfoTreeDTO implements TreeNode<DocInfoTreeDTO, Long> {
/**
* id
*/
private Long id;
/**
* doc_app.id
*/
private Long docAppId;
/**
* 文档id
*/
private Long docId;
/**
* 文档标题
*/
private String docTitle;
/**
* 文档code
*/
private String docCode;
/**
* 文档类型,1-dubbo,2-富文本,3-Markdown
*/
private Integer docType;
/**
* 来源类型,1-torna,2-自建
*/
private Integer sourceType;
/**
* 文档名称
*/
private String docName;
/**
* 版本号
*/
private String docVersion;
/**
* 描述
*/
private String description;
/**
* 是否分类
*/
private Integer isFolder;
/**
* 状态, 0-未发布,1-已发布
*/
private Integer isPublish;
/**
* 父节点id
*/
private Long parentId;
/**
* 添加时间
*/
private LocalDateTime addTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
private List<DocInfoTreeDTO> children;
@Override
public Long takeId() {
return docId;
}
@Override
public Long takeParentId() {
return parentId;
}
}

View File

@@ -0,0 +1,16 @@
package com.gitee.sop.website.service.doc.dto;
import com.gitee.sop.website.service.doc.dto.torna.TornaDocInfoViewDTO;
import lombok.Data;
/**
* @author 六如
*/
@Data
public class DocInfoViewDTO {
private TornaDocInfoViewDTO docInfoView;
private DocInfoConfigDTO docInfoConfig;
}

View File

@@ -0,0 +1,16 @@
package com.gitee.sop.website.service.doc.dto;
import lombok.Data;
/**
* @author 六如
*/
@Data
public class DocSettingDTO {
private String tornaServerAddr;
private String openProdUrl;
private String openSandboxUrl;
}

View File

@@ -0,0 +1,178 @@
package com.gitee.sop.website.service.doc.dto.torna;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
/**
* @author tanghc
*/
@Data
public class TornaDocInfoViewDTO {
private Long id;
/**
* 文档名称
*/
private String name;
/**
* 文档概述
*/
private String description;
/**
* 0:http,1:dubbo,2:富文本,3:Markdown
*/
private Byte type;
/**
* 访问URL
*/
private String url;
/**
* 版本号
*/
private String version = "";
private String docKey;
/**
* http方法
*/
private String httpMethod;
/**
* contentType
*/
private String contentType;
/**
* 是否是分类0不是1
*/
private Byte isFolder;
/**
* 父节点
*/
private Long parentId;
/**
* 模块idmodule.id
*/
private Long moduleId;
/**
* 项目id
*/
private Long projectId;
/**
* 是否使用全局请求参数
*/
private Byte isUseGlobalHeaders;
/**
* 是否使用全局请求参数
*/
private Byte isUseGlobalParams;
/**
* 是否使用全局返回参数
*/
private Byte isUseGlobalReturns;
/**
* 是否请求数组
*/
private Byte isRequestArray;
/**
* 是否返回数组
*/
private Byte isResponseArray;
/**
* 请求数组时元素类型
*/
private String requestArrayType;
/**
* 返回数组时元素类型
*/
private String responseArrayType;
/**
* 文档状态
*/
private Byte status;
private String remark;
private Integer orderIndex;
/**
* 数据库字段gmt_create
*/
private LocalDateTime gmtCreate;
/**
* 数据库字段gmt_modified
*/
private LocalDateTime gmtModified;
private List<TornaDocParamDTO> pathParams = Collections.emptyList();
private List<TornaDocParamDTO> headerParams = Collections.emptyList();
private List<TornaDocParamDTO> headerParamsRaw = Collections.emptyList();
private List<TornaDocParamDTO> queryParams = Collections.emptyList();
private List<TornaDocParamDTO> requestParams = Collections.emptyList();
private List<TornaDocParamDTO> responseParams = Collections.emptyList();
private List<TornaDocParamDTO> errorCodeParams = Collections.emptyList();
private List<TornaDocParamDTO> globalHeaders = Collections.emptyList();
private List<TornaDocParamDTO> globalParams = Collections.emptyList();
private List<TornaDocParamDTO> globalReturns = Collections.emptyList();
private String errorCodeInfo;
private List<TornaDocInfoViewDTO> children = Collections.emptyList();
public String getDocName() {
return name;
}
public String getDocTitle() {
return name;
}
}

View File

@@ -0,0 +1,128 @@
package com.gitee.sop.website.service.doc.dto.torna;
import com.gitee.fastmybatis.core.support.TreeNode;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
/**
* @author tanghc
*/
@Data
public class TornaDocParamDTO implements TreeNode<TornaDocParamDTO, Long> {
private Long id;
/**
* 字段名称
*/
private String name;
/**
* 字段类型
*/
private String type;
/**
* 是否必须10
*/
private Byte required;
/**
* 最大长度
*/
private String maxLength;
/**
* 示例值
*/
private String example;
/**
* 描述
*/
private String description;
private Long enumId;
/**
* doc_info.id
*/
private Long docId;
/**
* 父节点
*/
private Long parentId;
/**
* 0header, 1请求参数2返回参数3错误码
*/
private Byte style;
/**
* 新增操作方式0人工操作1开放平台推送
*/
private Byte createMode;
/**
* 修改操作方式0人工操作1开放平台推送
*/
private Byte modifyMode;
/**
* 创建人
*/
private String creatorName;
/**
* 修改人
*/
private String modifierName;
/**
* 排序
*/
private Integer orderIndex;
private Byte isDeleted;
/**
* 数据库字段gmt_create
*/
private LocalDateTime gmtCreate;
/**
* 数据库字段gmt_modified
*/
private LocalDateTime gmtModified;
private boolean global;
private List<TornaDocParamDTO> children;
public boolean getRequire() {
return Objects.equals(this.required, 1);
}
@Override
public Long takeId() {
return id;
}
@Override
public Long takeParentId() {
return parentId;
}
}

View File

@@ -0,0 +1,107 @@
package com.gitee.sop.website.service.sys;
import com.gitee.fastmybatis.core.support.BaseLambdaService;
import com.gitee.sop.website.common.config.IConfig;
import com.gitee.sop.website.common.util.CopyUtil;
import com.gitee.sop.website.dao.entity.SysConfig;
import com.gitee.sop.website.dao.mapper.SysConfigMapper;
import com.gitee.sop.website.service.sys.dto.SystemConfigDTO;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
/**
* @author 六如
*/
@Service
public class SysConfigService extends BaseLambdaService<SysConfig, SysConfigMapper> implements IConfig {
@Autowired
private Environment environment;
// key: configKey, value: configValue
private final LoadingCache<String, Optional<String>> configCache = CacheBuilder.newBuilder()
.expireAfterAccess(15, TimeUnit.MINUTES)
.build(new CacheLoader<String, Optional<String>>() {
@Override
public Optional<String> load(String key) throws Exception {
return Optional.ofNullable(getConfigValue(key, null));
}
});
public void save(Collection<SystemConfigDTO> configs) {
configs.forEach(this::setConfig);
}
public String getRawValue(String key) {
return this.query()
.eq(SysConfig::getConfigKey, key)
.getValue(SysConfig::getConfigValue);
}
public void setConfig(String key, String value) {
setConfig(key, value, "");
}
public void setConfig(String key, String value, String remark) {
SystemConfigDTO systemConfigDTO = new SystemConfigDTO();
systemConfigDTO.setConfigKey(key);
systemConfigDTO.setConfigValue(value);
systemConfigDTO.setRemark(remark);
setConfig(systemConfigDTO);
}
public void setConfig(SystemConfigDTO systemConfigDTO) {
Objects.requireNonNull(systemConfigDTO.getConfigKey(), "need key");
Objects.requireNonNull(systemConfigDTO.getConfigValue(), "need value");
SysConfig systemConfig = get(SysConfig::getConfigKey, systemConfigDTO.getConfigKey());
if (systemConfig == null) {
systemConfig = CopyUtil.copyBean(systemConfigDTO, SysConfig::new);
this.save(systemConfig);
} else {
CopyUtil.copyPropertiesIgnoreNull(systemConfigDTO, systemConfig);
this.update(systemConfig);
}
configCache.invalidate(systemConfigDTO.getConfigKey());
}
/**
* 获取配置信息
* <pre>
* 优先级:
* 数据库
* Environment
* 默认配置
* </pre>
*
* @param key 配置key
* @param defaultValue 没有获取到返回的默认值
* @return 返回配置信息,如果没有获取到值,则返回默认值
*/
public String getConfigValue(String key, String defaultValue) {
Objects.requireNonNull(key, "need key");
SysConfig systemConfig = get(SysConfig::getConfigKey, key);
return Optional.ofNullable(systemConfig)
.map(SysConfig::getConfigValue)
.orElseGet(() -> environment.getProperty(key, defaultValue));
}
@Override
public String getConfig(String key) {
return configCache.getUnchecked(key).orElse(null);
}
@Override
public String getConfig(String key, String defaultValue) {
return configCache.getUnchecked(key).orElse(defaultValue);
}
}

View File

@@ -0,0 +1,19 @@
package com.gitee.sop.website.service.sys.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tanghc
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SystemConfigDTO {
private String configKey;
private String configValue;
private String remark;
}

View File

@@ -0,0 +1,64 @@
package com.gitee.sop.website.service.website;
import com.gitee.fastmybatis.core.util.TreeUtil;
import com.gitee.sop.admin.service.doc.dto.DocAppDTO;
import com.gitee.sop.website.common.constants.YesOrNo;
import com.gitee.sop.website.common.util.CopyUtil;
import com.gitee.sop.website.dao.entity.DocApp;
import com.gitee.sop.website.dao.entity.DocInfo;
import com.gitee.sop.website.service.doc.DocAppService;
import com.gitee.sop.website.service.doc.DocInfoService;
import com.gitee.sop.website.service.doc.DocSettingService;
import com.gitee.sop.website.service.doc.dto.DocInfoConfigDTO;
import com.gitee.sop.website.service.doc.dto.DocInfoTreeDTO;
import com.gitee.sop.website.service.doc.dto.DocInfoViewDTO;
import com.gitee.sop.website.service.doc.dto.DocSettingDTO;
import com.gitee.sop.website.service.doc.dto.torna.TornaDocInfoViewDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author 六如
*/
@Service
public class WebsiteService {
@Autowired
private DocAppService docAppService;
@Autowired
private DocInfoService docInfoService;
@Autowired
private DocSettingService docSettingService;
public List<DocAppDTO> listDocApp() {
List<DocApp> docApps = docAppService.list(DocApp::getIsPublish, YesOrNo.YES);
return CopyUtil.copyList(docApps, DocAppDTO::new);
}
public List<DocInfoTreeDTO> listDocMenuTree(Long docAppId) {
List<DocInfo> list = docInfoService.query()
.eq(DocInfo::getDocAppId, docAppId)
.eq(DocInfo::getIsPublish, YesOrNo.YES)
.list();
List<DocInfoTreeDTO> treeList = CopyUtil.copyList(list, DocInfoTreeDTO::new);
return TreeUtil.convertTree(treeList, 0L);
}
public DocInfoViewDTO getDocDetail(Long id) {
TornaDocInfoViewDTO tornaDocInfoViewDTO = docInfoService.getDocDetail(id);
DocInfoConfigDTO docInfoConfigDTO = buildDocInfoConfig();
DocInfoViewDTO docInfoViewDTO = new DocInfoViewDTO();
docInfoViewDTO.setDocInfoView(tornaDocInfoViewDTO);
docInfoViewDTO.setDocInfoConfig(docInfoConfigDTO);
return docInfoViewDTO;
}
private DocInfoConfigDTO buildDocInfoConfig() {
DocSettingDTO docSetting = docSettingService.getDocSetting();
return CopyUtil.copyBean(docSetting, DocInfoConfigDTO::new);
}
}

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website-backend</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>website-web</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>website-service</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,65 @@
package com.gitee.sop.website.controller.website;
import com.gitee.sop.admin.service.doc.dto.DocAppDTO;
import com.gitee.sop.website.controller.website.vo.DocAppVO;
import com.gitee.sop.website.controller.website.vo.DocInfoTreeVO;
import com.gitee.sop.website.controller.website.vo.DocInfoViewVO;
import com.gitee.sop.website.common.resp.Result;
import com.gitee.sop.website.common.util.CopyUtil;
import com.gitee.sop.website.service.doc.dto.DocInfoTreeDTO;
import com.gitee.sop.website.service.doc.dto.DocInfoViewDTO;
import com.gitee.sop.website.service.website.WebsiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 提供给网站的接口,不需要校验token
*
* @author 六如
*/
@RestController
@RequestMapping("website")
public class WebsiteController {
@Autowired
private WebsiteService websiteService;
/**
* 获取文档应用列表
*/
@GetMapping("docapp/list")
public Result<List<DocAppVO>> listDocApp() {
List<DocAppDTO> docAppDTOS = websiteService.listDocApp();
List<DocAppVO> docAppVOS = CopyUtil.deepCopyList(docAppDTOS, DocAppVO.class);
return Result.ok(docAppVOS);
}
/**
* 获取文档菜单树
*
* @param docAppId 应用id
*/
@GetMapping("docinfo/tree")
public Result<List<DocInfoTreeVO>> listDocMenuTree(Long docAppId) {
List<DocInfoTreeDTO> docInfoTreeDTOS = websiteService.listDocMenuTree(docAppId);
List<DocInfoTreeVO> docAppVOS = CopyUtil.deepCopyList(docInfoTreeDTOS, DocInfoTreeVO.class);
return Result.ok(docAppVOS);
}
/**
* 获取文档详情
*
* @param id id
*/
@GetMapping("docinfo/detail")
public Result<DocInfoViewVO> getDocDetail(Long id) {
DocInfoViewDTO docInfoViewDTO = websiteService.getDocDetail(id);
DocInfoViewVO docInfoViewVO = CopyUtil.deepCopy(docInfoViewDTO, DocInfoViewVO.class);
return Result.ok(docInfoViewVO);
}
}

View File

@@ -0,0 +1,17 @@
package com.gitee.sop.website.controller.website;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class WebsiteHomeController {
private static final String REDIRECT_INDEX = "forward:index.html";
// 后台admin入口地址
@GetMapping("/")
public String index() {
return REDIRECT_INDEX;
}
}

View File

@@ -0,0 +1,24 @@
package com.gitee.sop.website.controller.website.vo;
import lombok.Data;
/**
* 备注:文档应用
*
* @author 六如
*/
@Data
public class DocAppVO {
/**
* id
*/
private Long id;
/**
* 应用名称
*/
private String appName;
}

View File

@@ -0,0 +1,14 @@
package com.gitee.sop.website.controller.website.vo;
import lombok.Data;
/**
* @author 六如
*/
@Data
public class DocInfoConfigVO {
private String openProdUrl;
private String openSandboxUrl;
}

View File

@@ -0,0 +1,99 @@
package com.gitee.sop.website.controller.website.vo;
import com.gitee.fastmybatis.core.support.TreeNode;
import lombok.Data;
import java.util.List;
import java.util.Objects;
/**
* 备注:文档信息
*
* @author 六如
*/
@Data
public class DocInfoTreeVO implements TreeNode<DocInfoTreeVO, Long> {
/**
* id
*/
private Long id;
/**
* doc_app.id
*/
private Long docAppId;
/**
* 文档id
*/
private Long docId;
/**
* 文档标题
*/
private String docTitle;
/**
* 文档code
*/
private String docCode;
/**
* 文档类型,1-dubbo,2-富文本,3-Markdown
*/
private Integer docType;
/**
* 来源类型,1-torna,2-自建
*/
private Integer sourceType;
/**
* 文档名称
*/
private String docName;
/**
* 版本号
*/
private String docVersion;
/**
* 描述
*/
private String description;
/**
* 是否分类
*/
private Integer isFolder;
/**
* 父节点id
*/
private Long parentId;
private List<DocInfoTreeVO> children;
@Override
public Long takeId() {
return docId;
}
@Override
public Long takeParentId() {
return parentId;
}
public String getDocName() {
if (Objects.equals(isFolder, 1)) {
return "";
}
return docName;
}
}

View File

@@ -0,0 +1,15 @@
package com.gitee.sop.website.controller.website.vo;
import lombok.Data;
/**
* @author 六如
*/
@Data
public class DocInfoViewVO {
private TornaDocInfoViewVO docInfoView;
private DocInfoConfigVO docInfoConfig;
}

View File

@@ -0,0 +1,179 @@
package com.gitee.sop.website.controller.website.vo;
import com.gitee.sop.website.service.doc.dto.torna.TornaDocParamDTO;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
/**
* @author tanghc
*/
@Data
public class TornaDocInfoViewVO {
private Long id;
/**
* 文档名称
*/
private String name;
/**
* 文档概述
*/
private String description;
/**
* 0:http,1:dubbo
*/
private Byte type;
/**
* 访问URL
*/
private String url;
/**
* 版本号
*/
private String version = "";
private String docKey;
/**
* http方法
*/
private String httpMethod;
/**
* contentType
*/
private String contentType;
/**
* 是否是分类0不是1
*/
private Byte isFolder;
/**
* 父节点
*/
private Long parentId;
/**
* 模块idmodule.id
*/
private Long moduleId;
/**
* 项目id
*/
private Long projectId;
/**
* 是否使用全局请求参数
*/
private Byte isUseGlobalHeaders;
/**
* 是否使用全局请求参数
*/
private Byte isUseGlobalParams;
/**
* 是否使用全局返回参数
*/
private Byte isUseGlobalReturns;
/**
* 是否请求数组
*/
private Byte isRequestArray;
/**
* 是否返回数组
*/
private Byte isResponseArray;
/**
* 请求数组时元素类型
*/
private String requestArrayType;
/**
* 返回数组时元素类型
*/
private String responseArrayType;
/**
* 文档状态
*/
private Byte status;
private String remark;
private Integer orderIndex;
/**
* 数据库字段gmt_create
*/
private LocalDateTime gmtCreate;
/**
* 数据库字段gmt_modified
*/
private LocalDateTime gmtModified;
private List<TornaDocParamDTO> pathParams = Collections.emptyList();
private List<TornaDocParamDTO> headerParams = Collections.emptyList();
private List<TornaDocParamDTO> headerParamsRaw = Collections.emptyList();
private List<TornaDocParamDTO> queryParams = Collections.emptyList();
private List<TornaDocParamDTO> requestParams = Collections.emptyList();
private List<TornaDocParamDTO> responseParams = Collections.emptyList();
private List<TornaDocParamDTO> errorCodeParams = Collections.emptyList();
private List<TornaDocParamDTO> globalHeaders = Collections.emptyList();
private List<TornaDocParamDTO> globalParams = Collections.emptyList();
private List<TornaDocParamDTO> globalReturns = Collections.emptyList();
private String errorCodeInfo;
private List<TornaDocInfoViewVO> children = Collections.emptyList();
public String getDocName() {
return url;
}
public String getDocTitle() {
return name;
}
}

0
sop-website/sop-website-frontend/.browserslistrc Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.dockerignore Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.editorconfig Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.env Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.env.development Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.env.staging Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.gitignore vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.husky/common.sh Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.lintstagedrc Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.markdownlint.json Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.npmrc Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.nvmrc Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.prettierrc.js Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.stylelintignore Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.vscode/extensions.json vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.vscode/settings.json vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.vscode/vue3.0.code-snippets vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.vscode/vue3.2.code-snippets vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/.vscode/vue3.3.code-snippets vendored Normal file → Executable file
View File

0
sop-website/sop-website-frontend/Dockerfile Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More