mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
调整
This commit is contained in:
parent
234ecdccf5
commit
84e189a831
@ -1,26 +0,0 @@
|
|||||||
# 贝尔实验室 Spring 官方推荐镜像 JDK下载地址 https://bell-sw.com/pages/downloads/
|
|
||||||
FROM bellsoft/liberica-openjdk-debian:17.0.11-cds
|
|
||||||
#FROM bellsoft/liberica-openjdk-debian:21.0.3-cds
|
|
||||||
#FROM findepi/graalvm:java17-native
|
|
||||||
|
|
||||||
LABEL maintainer="lizhw"
|
|
||||||
|
|
||||||
RUN mkdir -p /ruoyi/resource/logs \
|
|
||||||
/ruoyi/resource/temp \
|
|
||||||
/ruoyi/skywalking/agent
|
|
||||||
|
|
||||||
WORKDIR /ruoyi/resource
|
|
||||||
|
|
||||||
ENV SERVER_PORT=19200 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""
|
|
||||||
|
|
||||||
EXPOSE ${SERVER_PORT}
|
|
||||||
|
|
||||||
ADD ./target/ruoyi-h5.jar ./app.jar
|
|
||||||
|
|
||||||
ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \
|
|
||||||
# 应用名称 如果想区分集群节点监控 改成不同的名称即可
|
|
||||||
#-Dskywalking.agent.service_name=ruoyi-h5 \
|
|
||||||
#-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \
|
|
||||||
-XX:+HeapDumpOnOutOfMemoryError -XX:+UseZGC ${JAVA_OPTS} \
|
|
||||||
-jar app.jar
|
|
||||||
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-site</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-user-sso</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
ruoyi-user-sso
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 租户模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-tenant</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mybatis -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-mybatis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-doc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 远程调用模块 TODO rename -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-api-system</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-encrypt</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
|
||||||
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- SpringBoot Web依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Apache Dubbo 配置 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dubbo</groupId>
|
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dubbo</groupId>
|
|
||||||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api;
|
|
||||||
|
|
||||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 鲁班H5 api启动类
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@EnableDubbo
|
|
||||||
@SpringBootApplication
|
|
||||||
public class MallH5Application {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(MallH5Application.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package com.luban.api.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON 配置,修改默认 时间序列化格式
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class JsonConfig {
|
|
||||||
@Bean
|
|
||||||
public ObjectMapper mapperObject() {
|
|
||||||
JavaTimeModule module = new JavaTimeModule();
|
|
||||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
module.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
||||||
module.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
|
||||||
return new ObjectMapper().registerModule(module);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api.config;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
|
||||||
import org.dromara.common.mybatis.config.MybatisPlusConfig;
|
|
||||||
import org.dromara.common.tenant.properties.TenantProperties;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnBean(MybatisPlusConfig.class)
|
|
||||||
@AutoConfiguration(after = {MybatisPlusConfig.class})
|
|
||||||
public class MybatisPlusAutoConfigTenant {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) {
|
|
||||||
return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
package com.luban.api.config;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
|
||||||
import net.sf.jsqlparser.expression.NullValue;
|
|
||||||
import net.sf.jsqlparser.expression.StringValue;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
|
||||||
import org.dromara.common.tenant.helper.TenantHelper;
|
|
||||||
import org.dromara.common.tenant.properties.TenantProperties;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义租户处理器
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PlusTenantLineHandler implements TenantLineHandler {
|
|
||||||
|
|
||||||
private final TenantProperties tenantProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Expression getTenantId() {
|
|
||||||
String tenantId = TenantHelper.getTenantId();
|
|
||||||
if (StringUtils.isBlank(tenantId)) {
|
|
||||||
log.error("无法获取有效的租户id -> Null");
|
|
||||||
return new NullValue();
|
|
||||||
}
|
|
||||||
// 返回固定租户
|
|
||||||
return new StringValue(tenantId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ignoreTable(String tableName) {
|
|
||||||
String tenantId = TenantHelper.getTenantId();
|
|
||||||
// 判断是否有租户
|
|
||||||
if (StringUtils.isNotBlank(tenantId)) {
|
|
||||||
// 不需要过滤租户的表
|
|
||||||
List<String> excludes = tenantProperties.getExcludes();
|
|
||||||
// 非业务表
|
|
||||||
List<String> tables = ListUtil.toList(
|
|
||||||
"gen_table",
|
|
||||||
"gen_table_column"
|
|
||||||
);
|
|
||||||
tables.addAll(excludes);
|
|
||||||
return tables.contains(tableName);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package com.luban.api.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebMvc
|
|
||||||
public class WebMvcConfig implements WebMvcConfigurer {
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
//兼容swagger老版本v1,v2
|
|
||||||
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
|
|
||||||
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
|
|
||||||
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
|
||||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
||||||
registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
|
||||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
|
||||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.luban.api.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 包名常量
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
public final class PackageConstant {
|
|
||||||
|
|
||||||
|
|
||||||
public static final String BASE_PACKAGE = "com.luban.api";
|
|
||||||
|
|
||||||
public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".controller";
|
|
||||||
|
|
||||||
public static final String DAO_PACKAGE = BASE_PACKAGE + ".dao";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
package com.luban.api.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.luban.api.entity.Scripts;
|
|
||||||
import com.luban.api.convert.ScriptsConvert;
|
|
||||||
import com.luban.api.service.ScriptsService;
|
|
||||||
import com.luban.api.vo.ScriptsVO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 作品 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author lizhengwei
|
|
||||||
* @since 2024-06-21
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/scripts")
|
|
||||||
public class ScriptsController {
|
|
||||||
|
|
||||||
|
|
||||||
private final ScriptsService scriptsService;
|
|
||||||
|
|
||||||
public ScriptsController(ScriptsService scriptsService) {
|
|
||||||
this.scriptsService = scriptsService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "根据scriptsId查询")
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public ScriptsVO findScriptsById(@PathVariable Long id) {
|
|
||||||
return ScriptsConvert.toVO(scriptsService.getById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询所有scripts")
|
|
||||||
@GetMapping
|
|
||||||
public List<ScriptsVO> listAllScriptss(@RequestParam Integer _limit) {
|
|
||||||
QueryWrapper<Scripts> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.last("limit " + _limit);
|
|
||||||
return scriptsService.list(wrapper).stream().map(ScriptsConvert::toVO).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
package com.luban.api.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import com.luban.api.exception.UnifiedException;
|
|
||||||
import com.luban.api.vo.FileVO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/upload")
|
|
||||||
@Tag(name = "上传文件")
|
|
||||||
@Slf4j
|
|
||||||
public class UploadController {
|
|
||||||
|
|
||||||
// @Value("${upload-path}") todo 改成公共文件上传下载
|
|
||||||
|
|
||||||
public String uploadPath = "data";
|
|
||||||
|
|
||||||
@Operation(summary = "文件上传")
|
|
||||||
@PostMapping
|
|
||||||
public List<FileVO> upload(@Validated MultipartFile files) {
|
|
||||||
String originalFilename = files.getOriginalFilename();
|
|
||||||
assert originalFilename != null;
|
|
||||||
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
|
|
||||||
String key = IdUtil.fastSimpleUUID() + "." + suffix;
|
|
||||||
try {
|
|
||||||
files.transferTo(new File(uploadPath + key));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new UnifiedException("文件上传失败");
|
|
||||||
}
|
|
||||||
return new ArrayList<FileVO>() {{
|
|
||||||
add(new FileVO() {{
|
|
||||||
setUrl(key);
|
|
||||||
}});
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,175 +0,0 @@
|
|||||||
package com.luban.api.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.luban.api.convert.WorkConvert;
|
|
||||||
import com.luban.api.dto.WorkCreateDTO;
|
|
||||||
import com.luban.api.dto.WorkQueryDTO;
|
|
||||||
import com.luban.api.dto.WorkUpdateDTO;
|
|
||||||
import com.luban.api.entity.Work;
|
|
||||||
import com.luban.api.service.WorkService;
|
|
||||||
import com.luban.api.vo.WorkVO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 前端控制器
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* 由于业务都非常简单,并没有把业务代码下沉到 service 层
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/works")
|
|
||||||
@Tag(name = "作品管理", description = "作品管理")
|
|
||||||
@Slf4j
|
|
||||||
public class WorkController {
|
|
||||||
|
|
||||||
|
|
||||||
private final WorkService workService;
|
|
||||||
|
|
||||||
public WorkController(WorkService workService) {
|
|
||||||
this.workService = workService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "根据workId查询")
|
|
||||||
@GetMapping("/has-forms")
|
|
||||||
public List<WorkVO> hasForms() {
|
|
||||||
return WorkConvert.toVO(workService.list());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "根据workId查询")
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public WorkVO findWorkById(@PathVariable Long id) {
|
|
||||||
return WorkConvert.toVO(workService.getById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询所有work")
|
|
||||||
@GetMapping
|
|
||||||
public List<WorkVO> listAllWorks(@Valid WorkQueryDTO dto) {
|
|
||||||
WorkVO vo = new WorkVO();
|
|
||||||
vo.setTemplate(Boolean.parseBoolean(dto.getIs_template()));
|
|
||||||
BeanUtils.copyProperties(dto, vo);
|
|
||||||
return workService.list(new QueryWrapper<>(WorkConvert.toEntity(vo))).stream().map(WorkConvert::toVO).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "分页查询works")
|
|
||||||
@GetMapping("/pageable")
|
|
||||||
public IPage<WorkVO> listWorks(@Valid WorkQueryDTO dto) {
|
|
||||||
WorkVO vo = new WorkVO();
|
|
||||||
vo.setTemplate(Boolean.parseBoolean(dto.getIs_template()));
|
|
||||||
BeanUtils.copyProperties(dto, vo);
|
|
||||||
IPage<Work> page = workService.page(new Page<>(dto.getCurrent(), dto.getSize()), new LambdaQueryWrapper<>(WorkConvert.toEntity(vo)).orderByDesc(Work::getCreateTime));
|
|
||||||
List<WorkVO> voList = page.getRecords().stream().map(WorkConvert::toVO).collect(Collectors.toList());
|
|
||||||
return new Page<WorkVO>(page.getCurrent(), page.getSize(), page.getTotal()).setPages(page.getPages()).setRecords(voList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "创建work")
|
|
||||||
@PostMapping
|
|
||||||
public WorkVO createWork(@RequestBody @Valid WorkCreateDTO dto) {
|
|
||||||
WorkVO vo = new WorkVO();
|
|
||||||
BeanUtils.copyProperties(dto, vo);
|
|
||||||
Work work = WorkConvert.toEntity(vo);
|
|
||||||
workService.save(work);
|
|
||||||
return WorkConvert.toVO(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "更新work")
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public WorkVO updateWork(@PathVariable Long id, @RequestBody @Valid WorkUpdateDTO dto) {
|
|
||||||
Work work = workService.getById(id);
|
|
||||||
if (!StringUtils.isEmpty(dto.getTitle())) {
|
|
||||||
work.setTitle(dto.getTitle());
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(dto.getDescription())) {
|
|
||||||
work.setDescription(dto.getDescription());
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(dto.getCoverImageUrl())) {
|
|
||||||
work.setCoverImageUrl(dto.getCoverImageUrl());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(dto.getPages())) {
|
|
||||||
work.setPages(JSONUtil.toJsonStr(dto.getPages()));
|
|
||||||
}
|
|
||||||
work.setIsTemplate(dto.isTemplate());
|
|
||||||
work.setIsPublish(dto.isPublish());
|
|
||||||
work.setWidth(dto.getWidth());
|
|
||||||
work.setHeight(dto.getWidth());
|
|
||||||
work.setPageMode(dto.getWidth());
|
|
||||||
|
|
||||||
work.setUpdateTime(LocalDateTime.now());
|
|
||||||
workService.saveOrUpdate(work);
|
|
||||||
return WorkConvert.toVO(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "删除work")
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public void deleteWorkById(@PathVariable Long id) {
|
|
||||||
workService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "设为模板")
|
|
||||||
@PostMapping("/set-as-template/{id}")
|
|
||||||
public WorkVO markWorkAsTemplate(@PathVariable Long id) {
|
|
||||||
Work work = workService.getById(id);
|
|
||||||
work.setIsTemplate(true);
|
|
||||||
work.setUpdateTime(LocalDateTime.now());
|
|
||||||
workService.updateById(work);
|
|
||||||
return WorkConvert.toVO(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "统计作品总数")
|
|
||||||
@GetMapping("/count")
|
|
||||||
public long countWork() {
|
|
||||||
return workService.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "使用模板")
|
|
||||||
@PostMapping("/use-template/{id}")
|
|
||||||
public WorkVO useTemplate(@PathVariable Long id) {
|
|
||||||
Work work = workService.getById(id);
|
|
||||||
work.setId(null);
|
|
||||||
work.setIsTemplate(false);
|
|
||||||
work.setIsPublish(false);
|
|
||||||
workService.save(work);
|
|
||||||
return WorkConvert.toVO(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "使用模板")
|
|
||||||
@GetMapping("/preview/{id}")
|
|
||||||
public ModelAndView useTemplate(@PathVariable Long id, @RequestParam(value = "view_mode", required = false) String viewMode) {
|
|
||||||
Work work = workService.getById(id);
|
|
||||||
|
|
||||||
// 非预览模式, 查看不到内容
|
|
||||||
boolean canRender = "preview".equals(viewMode) || work.getIsPublish();
|
|
||||||
|
|
||||||
if (!canRender) {
|
|
||||||
work.setPages("[]");
|
|
||||||
}
|
|
||||||
ModelAndView mv = new ModelAndView("engine");
|
|
||||||
//TODO 后端处理前端,这种方式不是很好,最后改成纯前端处理
|
|
||||||
mv.addObject("workString", JSONUtil.toJsonStr(WorkConvert.toVO(work)));
|
|
||||||
mv.addObject("work", work);
|
|
||||||
return mv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/work-forms")
|
|
||||||
public class WorkFormsController {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package com.luban.api.convert;
|
|
||||||
|
|
||||||
import com.luban.api.entity.Scripts;
|
|
||||||
import com.luban.api.vo.ScriptsVO;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scripts 转换器
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
public class ScriptsConvert {
|
|
||||||
|
|
||||||
|
|
||||||
public static ScriptsVO toVO(Scripts entity) {
|
|
||||||
ScriptsVO vo = new ScriptsVO();
|
|
||||||
BeanUtils.copyProperties(entity, vo);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
package com.luban.api.convert;
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.luban.api.entity.Work;
|
|
||||||
import com.luban.api.vo.WorkVO;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Work 转换器
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
public class WorkConvert {
|
|
||||||
|
|
||||||
|
|
||||||
public static WorkVO toVO(Work entity) {
|
|
||||||
WorkVO vo = new WorkVO();
|
|
||||||
BeanUtils.copyProperties(entity, vo);
|
|
||||||
if (!StringUtils.isEmpty(entity.getPages())) {
|
|
||||||
vo.setPages(JSONUtil.parseArray(entity.getPages()));
|
|
||||||
}
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static List<WorkVO> toVO(List<Work> entitys) {
|
|
||||||
List<WorkVO> workVOS = new ArrayList<>();
|
|
||||||
for (Work entity : entitys) {
|
|
||||||
workVOS.add(toVO(entity));
|
|
||||||
}
|
|
||||||
return workVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Work toEntity(WorkVO vo) {
|
|
||||||
Work work = new Work();
|
|
||||||
BeanUtils.copyProperties(vo, work);
|
|
||||||
if (!CollectionUtils.isEmpty(vo.getPages())) {
|
|
||||||
work.setPages(JSONUtil.toJsonStr(vo.getPages()));
|
|
||||||
}
|
|
||||||
return work;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.luban.api.dao;
|
|
||||||
|
|
||||||
import com.luban.api.entity.Scripts;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 作品 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author lizhengwei
|
|
||||||
* @since 2024-06-21
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface ScriptsDao extends BaseMapper<Scripts> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.luban.api.dao;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.luban.api.entity.Work;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface WorkDao extends BaseMapper<Work> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.luban.api.dao;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.luban.api.entity.WorkForms;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface WorkFormsDao extends BaseMapper<WorkForms> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
package com.luban.api.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页基类
|
|
||||||
*
|
|
||||||
* @author admin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class PageDtoBase {
|
|
||||||
/**
|
|
||||||
* 每页行数
|
|
||||||
*/
|
|
||||||
@Schema(title = "每页行数")
|
|
||||||
protected Integer size = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码
|
|
||||||
*/
|
|
||||||
@Schema(title = "页码")
|
|
||||||
protected Integer current = 1;
|
|
||||||
|
|
||||||
|
|
||||||
public void setSize(Integer size) {
|
|
||||||
if (size != null) {
|
|
||||||
this.size = size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrent(Integer current) {
|
|
||||||
if (current != null) {
|
|
||||||
this.current = current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.luban.api.dto;
|
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "WorkQueryDTO")
|
|
||||||
public class ScriptsQueryDTO {
|
|
||||||
private Integer _limit;
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.luban.api.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "WorkCreateDTO")
|
|
||||||
public class WorkCreateDTO {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String coverImageUrl;
|
|
||||||
|
|
||||||
private List<Object> pages;
|
|
||||||
|
|
||||||
private LocalDateTime createTime = LocalDateTime.now();
|
|
||||||
|
|
||||||
private LocalDateTime updateTime = LocalDateTime.now();
|
|
||||||
|
|
||||||
private boolean isPublish = false;
|
|
||||||
|
|
||||||
private boolean isTemplate = false;
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.luban.api.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "WorkQueryDTO")
|
|
||||||
public class WorkQueryDTO extends PageDtoBase {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String coverImageUrl;
|
|
||||||
|
|
||||||
private List<Object> pages;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
private String is_publish;
|
|
||||||
|
|
||||||
private String is_template;
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
package com.luban.api.dto;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "WorkQueryDTO")
|
|
||||||
public class WorkUpdateDTO {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String coverImageUrl;
|
|
||||||
|
|
||||||
private String width;
|
|
||||||
|
|
||||||
private String height;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面模式:h5_swipper、h5_long_page、h5_form
|
|
||||||
*/
|
|
||||||
private String pageMode;
|
|
||||||
|
|
||||||
private List<Object> pages;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime = LocalDateTime.now();
|
|
||||||
|
|
||||||
private boolean isPublish;
|
|
||||||
|
|
||||||
private boolean isTemplate;
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package com.luban.api.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 作品
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author lizhengwei
|
|
||||||
* @since 2024-06-21
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(name = "Scripts对象", description = "作品")
|
|
||||||
public class Scripts implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID=1L;
|
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Schema(title = "标题")
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
@Schema(title = "内容")
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
package com.luban.api.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "Work对象")
|
|
||||||
public class Work implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(title = "标题")
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
@Schema(title = "描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String coverImageUrl;
|
|
||||||
|
|
||||||
private String pages;
|
|
||||||
|
|
||||||
private String width;
|
|
||||||
|
|
||||||
private String height;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面模式:h5_swipper、h5_long_page、h5_form
|
|
||||||
*/
|
|
||||||
private String pageMode;
|
|
||||||
|
|
||||||
private Boolean isPublish;
|
|
||||||
|
|
||||||
private Boolean isTemplate;
|
|
||||||
|
|
||||||
@Schema(title = "创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@Schema(title = "更新时间")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
package com.luban.api.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "WorkForms对象")
|
|
||||||
public class WorkForms implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private String form;
|
|
||||||
|
|
||||||
private Long workId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,113 +0,0 @@
|
|||||||
package com.luban.api.exception;
|
|
||||||
|
|
||||||
|
|
||||||
import com.luban.api.util.JSON;
|
|
||||||
import com.luban.api.vo.Result;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.BindException;
|
|
||||||
import org.springframework.validation.FieldError;
|
|
||||||
import org.springframework.validation.ObjectError;
|
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异常处理
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestControllerAdvice
|
|
||||||
public class ExceptionHandle {
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JSON json;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一异常处理器
|
|
||||||
*
|
|
||||||
* @param e UnifiedException
|
|
||||||
* @return 响应实体
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(value = UnifiedException.class)
|
|
||||||
public ResponseEntity<Result<String>> unifiedExceptionHandle(UnifiedException e) {
|
|
||||||
Result<String> result = new Result<>(e.getMessage(), e.getStatus());
|
|
||||||
if (e.getStatus() == HttpStatus.INTERNAL_SERVER_ERROR) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
} else {
|
|
||||||
log.warn(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理参数校验异常
|
|
||||||
*
|
|
||||||
* @param e BindException
|
|
||||||
* @return 响应实体
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public Result<Object> methodArgumentNotValidExceptionHandle(MethodArgumentNotValidException e) {
|
|
||||||
// 获取全部错误对象
|
|
||||||
List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
|
|
||||||
String errorMsg = objectErrorHandle(allErrors);
|
|
||||||
log.warn("MethodArgumentNotValidException:", e);
|
|
||||||
return new Result<>().error(HttpStatus.BAD_REQUEST, errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String objectErrorHandle(List<ObjectError> allErrors) {
|
|
||||||
Map<String, String> map = new HashMap<>(allErrors.size());
|
|
||||||
// 把错误对象转成 k,v 存入Map
|
|
||||||
allErrors.forEach(error -> {
|
|
||||||
String key = error.getObjectName();
|
|
||||||
if (error instanceof FieldError) {
|
|
||||||
FieldError fieldError = (FieldError) error;
|
|
||||||
key = fieldError.getField();
|
|
||||||
}
|
|
||||||
map.put(key, error.getDefaultMessage());
|
|
||||||
});
|
|
||||||
return json.toJSON(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理参数校验异常
|
|
||||||
*
|
|
||||||
* @param e BindException
|
|
||||||
* @return 响应实体
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(value = BindException.class)
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public Result<Object> bindExceptionHandle(BindException e) {
|
|
||||||
// 获取全部错误对象
|
|
||||||
List<ObjectError> allErrors = e.getAllErrors();
|
|
||||||
String errorMsg = objectErrorHandle(allErrors);
|
|
||||||
log.warn("BindException:", e);
|
|
||||||
return new Result<>().error(HttpStatus.BAD_REQUEST, errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExceptionHandler(value = NoHandlerFoundException.class)
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public Result<Object> noHandlerFoundExceptionHandle(NoHandlerFoundException e) {
|
|
||||||
log.warn("NoHandlerFoundException 异常:", e);
|
|
||||||
return new Result<>().error(HttpStatus.NOT_FOUND, e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExceptionHandler(value = Exception.class)
|
|
||||||
@ResponseStatus(HttpStatus.OK)
|
|
||||||
public Result<Object> exceptionHandle(Exception e) {
|
|
||||||
log.error("Exception 异常:", e);
|
|
||||||
return new Result<>().error(HttpStatus.INTERNAL_SERVER_ERROR, "服务繁忙,请稍后再试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
package com.luban.api.exception;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一异常
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class UnifiedException extends RuntimeException {
|
|
||||||
private HttpStatus status;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unified exception
|
|
||||||
* 统一异常
|
|
||||||
*/
|
|
||||||
public UnifiedException() {
|
|
||||||
super("服务器忙,请稍候重试");
|
|
||||||
this.status = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
this.message = "服务器忙,请稍候重试";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一异常
|
|
||||||
*
|
|
||||||
* @param status 异常状态码
|
|
||||||
* @param message 异常消息
|
|
||||||
*/
|
|
||||||
public UnifiedException(HttpStatus status, String message) {
|
|
||||||
super(message);
|
|
||||||
this.status = status;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一异常
|
|
||||||
*
|
|
||||||
* @param message 异常消息
|
|
||||||
*/
|
|
||||||
public UnifiedException(String message) {
|
|
||||||
super(message);
|
|
||||||
this.status = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnifiedException(String message, Throwable e) {
|
|
||||||
super(message, e);
|
|
||||||
this.status = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnifiedException unauthorized(String message) {
|
|
||||||
return new UnifiedException(HttpStatus.UNAUTHORIZED, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnifiedException verifyError(Map map) {
|
|
||||||
JavaTimeModule module = new JavaTimeModule();
|
|
||||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
module.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
||||||
module.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
|
||||||
ObjectMapper mapper = new ObjectMapper().registerModule(module);
|
|
||||||
String asString = "";
|
|
||||||
try {
|
|
||||||
asString = mapper.writeValueAsString(map);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("JSON 转换异常", e);
|
|
||||||
}
|
|
||||||
return new UnifiedException(HttpStatus.BAD_REQUEST, asString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package com.luban.api.log;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
||||||
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* P6Spy 日志自定义处理
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class P6SpyLogger implements MessageFormattingStrategy {
|
|
||||||
@Override
|
|
||||||
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
|
||||||
return StringUtils.isNotEmpty(sql) ? " Consume Time:" + elapsed + " ms " + now +
|
|
||||||
"\n Execute SQL:" + sql.replaceAll("[\\s]+", " ") + "\n" : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api.log;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改SQL执行输出到 日志,便于分析
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class StdoutLogger extends com.p6spy.engine.spy.appender.StdoutLogger {
|
|
||||||
@Override
|
|
||||||
public void logText(String text) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package com.luban.api.service;
|
|
||||||
|
|
||||||
import com.luban.api.entity.Scripts;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 作品 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author lizhengwei
|
|
||||||
* @since 2024-06-21
|
|
||||||
*/
|
|
||||||
public interface ScriptsService extends IService<Scripts> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package com.luban.api.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.luban.api.entity.WorkForms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
public interface WorkFormsService extends IService<WorkForms> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package com.luban.api.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.luban.api.entity.Work;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
public interface WorkService extends IService<Work> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api.service.impl;
|
|
||||||
|
|
||||||
import com.luban.api.dao.ScriptsDao;
|
|
||||||
import com.luban.api.entity.Scripts;
|
|
||||||
import com.luban.api.service.ScriptsService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 作品 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author lizhengwei
|
|
||||||
* @since 2024-06-21
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class ScriptsServiceImpl extends ServiceImpl<ScriptsDao, Scripts> implements ScriptsService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.luban.api.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.luban.api.dao.WorkFormsDao;
|
|
||||||
import com.luban.api.entity.WorkForms;
|
|
||||||
import com.luban.api.service.WorkFormsService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class WorkFormsServiceImpl extends ServiceImpl<WorkFormsDao, WorkForms> implements WorkFormsService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package com.luban.api.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.luban.api.dao.WorkDao;
|
|
||||||
import com.luban.api.entity.Work;
|
|
||||||
import com.luban.api.service.WorkService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
* @since 2019-11-26
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class WorkServiceImpl extends ServiceImpl<WorkDao, Work> implements WorkService {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
package com.luban.api.util;
|
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON 转换工具
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class JSON {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
public String toJSON(Object jsonObj) {
|
|
||||||
try {
|
|
||||||
return objectMapper.writeValueAsString(jsonObj);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("JSON 转换异常 转换异常的数据类型: " + jsonObj.getClass().getName(), e);
|
|
||||||
}
|
|
||||||
return jsonObj.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Map toMap(String json) {
|
|
||||||
try {
|
|
||||||
return objectMapper.readValue(json, Map.class);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("JSON 转换异常", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<String, String>> toListMapStr(String json) {
|
|
||||||
try {
|
|
||||||
return objectMapper.readValue(json, new TypeReference<List<Map<String, String>>>() {
|
|
||||||
});
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("JSON 转换异常", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<String> toListString(String json) {
|
|
||||||
try {
|
|
||||||
return objectMapper.readValue(json, new TypeReference<List<String>>() {
|
|
||||||
});
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("JSON 转换异常", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package com.luban.api.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "文件视图对象")
|
|
||||||
public class FileVO {
|
|
||||||
private String url;
|
|
||||||
}
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
package com.luban.api.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一返回
|
|
||||||
*
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Schema(description = "返回响应数据")
|
|
||||||
@Component
|
|
||||||
@Data
|
|
||||||
public class Result<T> {
|
|
||||||
@Schema(title = "返回状态码")
|
|
||||||
private Integer code;
|
|
||||||
@Schema(title = "返回消息")
|
|
||||||
private String msg;
|
|
||||||
@Schema(title = "返回当前状态")
|
|
||||||
private HttpStatus status;
|
|
||||||
@Schema(title = "返回对象")
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
public Result() {
|
|
||||||
this.msg = "成功";
|
|
||||||
setStatus(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(HttpStatus status) {
|
|
||||||
this.status = status;
|
|
||||||
setCode(status.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result(T data) {
|
|
||||||
setStatus(HttpStatus.OK);
|
|
||||||
this.msg = "成功";
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result(String msg, HttpStatus status, T data) {
|
|
||||||
this.msg = msg;
|
|
||||||
setStatus(status);
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result(String msg, HttpStatus status) {
|
|
||||||
this.msg = msg;
|
|
||||||
setStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result<T> ok(T data) {
|
|
||||||
setStatus(HttpStatus.OK);
|
|
||||||
this.msg = "成功";
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result<T> error(HttpStatus status, String msg) {
|
|
||||||
setStatus(status);
|
|
||||||
this.msg = msg;
|
|
||||||
this.data = null;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOK() {
|
|
||||||
return this.getStatus() == HttpStatus.OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Result{" +
|
|
||||||
"code=" + code +
|
|
||||||
", msg='" + msg + '\'' +
|
|
||||||
", status=" + status +
|
|
||||||
", data=" + data +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.luban.api.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "Script视图对象")
|
|
||||||
public class ScriptsVO implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
package com.luban.api.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author WeiHongBin
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(title = "Work视图对象")
|
|
||||||
public class WorkVO {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String coverImageUrl;
|
|
||||||
|
|
||||||
private List<Object> pages;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
private boolean isPublish;
|
|
||||||
|
|
||||||
private boolean isTemplate;
|
|
||||||
}
|
|
||||||
@ -1,174 +0,0 @@
|
|||||||
--- # spring 配置
|
|
||||||
spring:
|
|
||||||
# 资源信息
|
|
||||||
messages:
|
|
||||||
# 国际化资源文件路径
|
|
||||||
basename: i18n/messages
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 10MB
|
|
||||||
thymeleaf:
|
|
||||||
cache: false
|
|
||||||
prefix: classpath:/templates/
|
|
||||||
check-template-location: true
|
|
||||||
mode: HTML
|
|
||||||
datasource:
|
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
|
||||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
|
||||||
dynamic:
|
|
||||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
|
||||||
p6spy: false
|
|
||||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
|
||||||
primary: master
|
|
||||||
# 严格模式 匹配不到数据源则报错
|
|
||||||
strict: true
|
|
||||||
datasource:
|
|
||||||
# 主库数据源
|
|
||||||
master:
|
|
||||||
type: ${spring.datasource.type}
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
|
||||||
url: jdbc:mysql://mysql:3306/mall-h5-core?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
# 从库数据源
|
|
||||||
slave:
|
|
||||||
lazy: true
|
|
||||||
type: ${spring.datasource.type}
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://mysql:3306/mall-h5-core?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
|
||||||
username:
|
|
||||||
password:
|
|
||||||
hikari:
|
|
||||||
# 最大连接池数量
|
|
||||||
maxPoolSize: 20
|
|
||||||
# 最小空闲线程数量
|
|
||||||
minIdle: 10
|
|
||||||
# 配置获取连接等待超时的时间
|
|
||||||
connectionTimeout: 30000
|
|
||||||
# 校验超时时间
|
|
||||||
validationTimeout: 5000
|
|
||||||
# 空闲连接存活最大时间,默认10分钟
|
|
||||||
idleTimeout: 600000
|
|
||||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
|
||||||
maxLifetime: 1800000
|
|
||||||
# 多久检查一次连接的活性
|
|
||||||
keepaliveTime: 30000
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
# Redis数据库索引(默认为0)
|
|
||||||
database: 0
|
|
||||||
# Redis服务器地址
|
|
||||||
host: redis
|
|
||||||
# Redis服务器连接端口
|
|
||||||
port: 6379
|
|
||||||
# Redis服务器连接密码(默认为空)
|
|
||||||
password: Lzw8800580/
|
|
||||||
# 连接超时时间
|
|
||||||
timeout: 10s
|
|
||||||
lettuce:
|
|
||||||
pool:
|
|
||||||
# 连接池最大连接数
|
|
||||||
max-active: 200
|
|
||||||
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
|
||||||
max-wait: -1ms
|
|
||||||
# 连接池中的最大空闲连接
|
|
||||||
max-idle: 10
|
|
||||||
# 连接池中的最小空闲连接
|
|
||||||
min-idle: 0
|
|
||||||
|
|
||||||
|
|
||||||
springdoc:
|
|
||||||
api-docs:
|
|
||||||
# 是否开启接口文档
|
|
||||||
enabled: true
|
|
||||||
# swagger-ui:
|
|
||||||
# # 持久化认证数据
|
|
||||||
# persistAuthorization: true
|
|
||||||
info:
|
|
||||||
# 标题
|
|
||||||
title: '标题:${spring.application.name}多租户管理系统_接口文档'
|
|
||||||
# 描述
|
|
||||||
description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
|
||||||
# 版本
|
|
||||||
version: '版本号: 1.0.0'
|
|
||||||
# 作者信息
|
|
||||||
contact:
|
|
||||||
name: Lion Li
|
|
||||||
email: crazylionli@163.com
|
|
||||||
url: https://gitee.com/dromara/RuoYi-Vue-Plus
|
|
||||||
components:
|
|
||||||
# 鉴权方式配置
|
|
||||||
security-schemes:
|
|
||||||
apiKey:
|
|
||||||
type: APIKEY
|
|
||||||
in: HEADER
|
|
||||||
name: Authorization
|
|
||||||
#这里定义了两个分组,可定义多个,也可以不定义
|
|
||||||
group-configs:
|
|
||||||
- group: 1.演示模块
|
|
||||||
packages-to-scan: org.dromara.demo
|
|
||||||
- group: 2.通用模块
|
|
||||||
packages-to-scan: org.dromara.web
|
|
||||||
- group: 3.系统模块
|
|
||||||
packages-to-scan: org.dromara.system
|
|
||||||
- group: 4.代码生成模块
|
|
||||||
packages-to-scan: org.dromara.generator
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 多租户配置
|
|
||||||
tenant:
|
|
||||||
# 是否开启
|
|
||||||
enable: true
|
|
||||||
# 排除表
|
|
||||||
excludes:
|
|
||||||
- sys_menu
|
|
||||||
- sys_tenant
|
|
||||||
- sys_tenant_package
|
|
||||||
- sys_saas_user_role
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MyBatisPlus配置
|
|
||||||
# https://baomidou.com/config/
|
|
||||||
mybatis-plus:
|
|
||||||
# 多包名使用 例如 org.dromara.**.mapper,org.xxx.**.mapper
|
|
||||||
mapperPackage: com.luban.api.dao
|
|
||||||
# # 实体扫描,多个package用逗号或者分号分隔
|
|
||||||
# typeAliasesPackage: com.luban.api.entity
|
|
||||||
global-config:
|
|
||||||
dbConfig:
|
|
||||||
# 主键类型
|
|
||||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
|
||||||
# 如需改为自增 需要将数据库表全部设置为自增
|
|
||||||
idType: ASSIGN_ID
|
|
||||||
|
|
||||||
# dubbo
|
|
||||||
dubbo:
|
|
||||||
protocol:
|
|
||||||
name: tri
|
|
||||||
port: 20880
|
|
||||||
application:
|
|
||||||
qos-enable: false
|
|
||||||
logger: slf4j
|
|
||||||
name: ${spring.application.name}
|
|
||||||
# 注册中心配置
|
|
||||||
registry:
|
|
||||||
address: nacos://nacos-registry:8848
|
|
||||||
group: DUBBO_GROUP
|
|
||||||
parameters:
|
|
||||||
namespace: c5c00044-93e6-4e66-8060-3f39aa7ab82b
|
|
||||||
# 消费者相关配置
|
|
||||||
consumer:
|
|
||||||
# 结果缓存(LRU算法)
|
|
||||||
# 会有数据不一致问题 建议在注解局部开启
|
|
||||||
cache: false
|
|
||||||
# 支持校验注解
|
|
||||||
validation: jvalidationNew
|
|
||||||
# 调用重试 不包括第一次 0为不需要重试
|
|
||||||
retries: 0
|
|
||||||
# 初始化检查
|
|
||||||
check: false
|
|
||||||
@ -1,174 +0,0 @@
|
|||||||
--- # spring 配置
|
|
||||||
spring:
|
|
||||||
# 资源信息
|
|
||||||
messages:
|
|
||||||
# 国际化资源文件路径
|
|
||||||
basename: i18n/messages
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 10MB
|
|
||||||
thymeleaf:
|
|
||||||
cache: false
|
|
||||||
prefix: classpath:/templates/
|
|
||||||
check-template-location: true
|
|
||||||
mode: HTML
|
|
||||||
datasource:
|
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
|
||||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
|
||||||
dynamic:
|
|
||||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
|
||||||
p6spy: false
|
|
||||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
|
||||||
primary: master
|
|
||||||
# 严格模式 匹配不到数据源则报错
|
|
||||||
strict: true
|
|
||||||
datasource:
|
|
||||||
# 主库数据源
|
|
||||||
master:
|
|
||||||
type: ${spring.datasource.type}
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
|
||||||
url: jdbc:mysql://localhost:3306/mall-h5-core?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
# 从库数据源
|
|
||||||
slave:
|
|
||||||
lazy: true
|
|
||||||
type: ${spring.datasource.type}
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://localhost:3306/mall-h5-core?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
|
||||||
username:
|
|
||||||
password:
|
|
||||||
hikari:
|
|
||||||
# 最大连接池数量
|
|
||||||
maxPoolSize: 20
|
|
||||||
# 最小空闲线程数量
|
|
||||||
minIdle: 10
|
|
||||||
# 配置获取连接等待超时的时间
|
|
||||||
connectionTimeout: 30000
|
|
||||||
# 校验超时时间
|
|
||||||
validationTimeout: 5000
|
|
||||||
# 空闲连接存活最大时间,默认10分钟
|
|
||||||
idleTimeout: 600000
|
|
||||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
|
||||||
maxLifetime: 1800000
|
|
||||||
# 多久检查一次连接的活性
|
|
||||||
keepaliveTime: 30000
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
# Redis数据库索引(默认为0)
|
|
||||||
database: 0
|
|
||||||
# Redis服务器地址
|
|
||||||
host: 127.0.0.1
|
|
||||||
# Redis服务器连接端口
|
|
||||||
port: 6379
|
|
||||||
# Redis服务器连接密码(默认为空)
|
|
||||||
password: Lzw8800580/
|
|
||||||
# 连接超时时间
|
|
||||||
timeout: 10s
|
|
||||||
lettuce:
|
|
||||||
pool:
|
|
||||||
# 连接池最大连接数
|
|
||||||
max-active: 200
|
|
||||||
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
|
||||||
max-wait: -1ms
|
|
||||||
# 连接池中的最大空闲连接
|
|
||||||
max-idle: 10
|
|
||||||
# 连接池中的最小空闲连接
|
|
||||||
min-idle: 0
|
|
||||||
|
|
||||||
|
|
||||||
springdoc:
|
|
||||||
api-docs:
|
|
||||||
# 是否开启接口文档
|
|
||||||
enabled: true
|
|
||||||
# swagger-ui:
|
|
||||||
# # 持久化认证数据
|
|
||||||
# persistAuthorization: true
|
|
||||||
info:
|
|
||||||
# 标题
|
|
||||||
title: '标题:${spring.application.name}多租户管理系统_接口文档'
|
|
||||||
# 描述
|
|
||||||
description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
|
||||||
# 版本
|
|
||||||
version: '版本号: 1.0.0'
|
|
||||||
# 作者信息
|
|
||||||
contact:
|
|
||||||
name: Lion Li
|
|
||||||
email: crazylionli@163.com
|
|
||||||
url: https://gitee.com/dromara/RuoYi-Vue-Plus
|
|
||||||
components:
|
|
||||||
# 鉴权方式配置
|
|
||||||
security-schemes:
|
|
||||||
apiKey:
|
|
||||||
type: APIKEY
|
|
||||||
in: HEADER
|
|
||||||
name: Authorization
|
|
||||||
#这里定义了两个分组,可定义多个,也可以不定义
|
|
||||||
group-configs:
|
|
||||||
- group: 1.演示模块
|
|
||||||
packages-to-scan: org.dromara.demo
|
|
||||||
- group: 2.通用模块
|
|
||||||
packages-to-scan: org.dromara.web
|
|
||||||
- group: 3.系统模块
|
|
||||||
packages-to-scan: org.dromara.system
|
|
||||||
- group: 4.代码生成模块
|
|
||||||
packages-to-scan: org.dromara.generator
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 多租户配置
|
|
||||||
tenant:
|
|
||||||
# 是否开启
|
|
||||||
enable: true
|
|
||||||
# 排除表
|
|
||||||
excludes:
|
|
||||||
- sys_menu
|
|
||||||
- sys_tenant
|
|
||||||
- sys_tenant_package
|
|
||||||
- sys_saas_user_role
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MyBatisPlus配置
|
|
||||||
# https://baomidou.com/config/
|
|
||||||
mybatis-plus:
|
|
||||||
# 多包名使用 例如 org.dromara.**.mapper,org.xxx.**.mapper
|
|
||||||
mapperPackage: com.luban.api.dao
|
|
||||||
# # 实体扫描,多个package用逗号或者分号分隔
|
|
||||||
# typeAliasesPackage: com.luban.api.entity
|
|
||||||
global-config:
|
|
||||||
dbConfig:
|
|
||||||
# 主键类型
|
|
||||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
|
||||||
# 如需改为自增 需要将数据库表全部设置为自增
|
|
||||||
idType: ASSIGN_ID
|
|
||||||
|
|
||||||
# dubbo
|
|
||||||
dubbo:
|
|
||||||
protocol:
|
|
||||||
name: tri
|
|
||||||
port: 20880
|
|
||||||
application:
|
|
||||||
qos-enable: false
|
|
||||||
logger: slf4j
|
|
||||||
name: ${spring.application.name}
|
|
||||||
# 注册中心配置
|
|
||||||
registry:
|
|
||||||
address: nacos://127.0.0.1:8848
|
|
||||||
group: DUBBO_GROUP
|
|
||||||
parameters:
|
|
||||||
namespace: c5c00044-93e6-4e66-8060-3f39aa7ab82b
|
|
||||||
# 消费者相关配置
|
|
||||||
consumer:
|
|
||||||
# 结果缓存(LRU算法)
|
|
||||||
# 会有数据不一致问题 建议在注解局部开启
|
|
||||||
cache: false
|
|
||||||
# 支持校验注解
|
|
||||||
validation: jvalidationNew
|
|
||||||
# 调用重试 不包括第一次 0为不需要重试
|
|
||||||
retries: 0
|
|
||||||
# 初始化检查
|
|
||||||
check: false
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 19200
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: mall-h5
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: @profiles.active@
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1,4 +0,0 @@
|
|||||||
#错误消息
|
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
|
||||||
user.jcaptcha.expire=验证码已失效
|
|
||||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#错误消息
|
|
||||||
not.null=* Required fill in
|
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
|
||||||
user.jcaptcha.expire=Captcha invalid
|
|
||||||
user.not.exists=Sorry, your account: {0} does not exist
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#错误消息
|
|
||||||
not.null=* 必须填写
|
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
|
||||||
user.jcaptcha.expire=验证码已失效
|
|
||||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
<?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.luban.api.dao.ScriptsDao">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="com.luban.api.entity.Scripts">
|
|
||||||
<id column="id" property="id" />
|
|
||||||
<result column="title" property="title" />
|
|
||||||
<result column="content" property="content" />
|
|
||||||
<result column="create_time" property="createTime" />
|
|
||||||
<result column="update_time" property="updateTime" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?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.luban.api.dao.WorkDao">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="com.luban.api.entity.Work">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="title" property="title"/>
|
|
||||||
<result column="description" property="description"/>
|
|
||||||
<result column="cover_image_url" property="coverImageUrl"/>
|
|
||||||
<result column="pages" property="pages"/>
|
|
||||||
<result column="is_publish" property="isPublish"/>
|
|
||||||
<result column="is_template" property="isTemplate"/>
|
|
||||||
<result column="create_time" property="createTime"/>
|
|
||||||
<result column="update_time" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
<?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.luban.api.dao.WorkFormsDao">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="com.luban.api.entity.WorkForms">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="form" property="form"/>
|
|
||||||
<result column="work_id" property="workId"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@ -1,323 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @Author: ly525
|
|
||||||
* @Date: 2019-12-04 20:24:04
|
|
||||||
* @LastEditors: ly525
|
|
||||||
* @LastEditTime: 2020-05-03 14:30:37
|
|
||||||
* @FilePath: /luban-h5/back-end/h5-api/views/engine.ejs
|
|
||||||
* @Github: https://github.com/ly525/luban-h5
|
|
||||||
* @Description: 手机端预览模板
|
|
||||||
* @Copyright 2018 - 2019 luban-h5. All Rights Reserved
|
|
||||||
-->
|
|
||||||
|
|
||||||
<html lang="ch" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title th:text="${work.title}">活动</title>
|
|
||||||
<meta name="viewport" id="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
|
||||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
|
||||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
|
||||||
<meta content="telephone=no" name="format-detection">
|
|
||||||
<meta content="email=no" name="format-detection">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vuex/dist/vuex.js"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css">
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/dist/css/swiper.min.css">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/swiper/dist/js/swiper.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/swiper-animation@2.0.2/build/swiper-animation.min.js"></script>
|
|
||||||
<!-- <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js" async></script> -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/v-charts/lib/index.min.js"></script>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/v-charts/lib/style.min.css">
|
|
||||||
<script type="text/javascript" th:inline="javascript">
|
|
||||||
window.__work = JSON.parse([[${workString}]]);
|
|
||||||
</script>
|
|
||||||
<script src="/static/engine-assets/engine.umd.js"></script>
|
|
||||||
<style th:inline="text">
|
|
||||||
/*
|
|
||||||
scss 文件,用来生成下面一段 style 中的 css
|
|
||||||
css 在线转 css:https://www.sassmeister.com/
|
|
||||||
*/
|
|
||||||
/* * {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-wrapper {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-wrapper {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
width: [[${work.width}]]px;
|
|
||||||
height: 568px;
|
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
|
|
||||||
.phone-wrapper {
|
|
||||||
position: absolute;
|
|
||||||
width: [[${work.width}]]px;
|
|
||||||
height: 568px;
|
|
||||||
display: inline-block;
|
|
||||||
background: #fff;
|
|
||||||
box-sizing: content-box;
|
|
||||||
border: 10px solid #f6f6f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.float-shortcuts {
|
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
|
||||||
right: 0;
|
|
||||||
|
|
||||||
.page-controller {
|
|
||||||
position: absolute;
|
|
||||||
left: 0 !important;
|
|
||||||
display: block;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 22px;
|
|
||||||
height: 60px;
|
|
||||||
padding: 4px;
|
|
||||||
border-top-right-radius: 5px;
|
|
||||||
border-bottom-right-radius: 5px;
|
|
||||||
|
|
||||||
cursor: pointer;
|
|
||||||
background: #2096f9;
|
|
||||||
font-size: 12px;
|
|
||||||
border: 1px solid #2096f9;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
&.next {
|
|
||||||
top: 80px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-info {
|
|
||||||
color: #4a4a4a;
|
|
||||||
font-size: 14px;
|
|
||||||
margin-left: 380px;
|
|
||||||
|
|
||||||
.qrcode-wrapper {
|
|
||||||
.qrcode-label {
|
|
||||||
}
|
|
||||||
|
|
||||||
.qrcode-img {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
</style>
|
|
||||||
<style th:inline="text">
|
|
||||||
* {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-wrapper {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
|
|
||||||
}
|
|
||||||
/* .swiper-container {
|
|
||||||
width: 100%;
|
|
||||||
height: 100vh;
|
|
||||||
} */
|
|
||||||
|
|
||||||
.preview-wrapper {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
width: [[${work.width}]]px;
|
|
||||||
height: [[${work.height}]]px;
|
|
||||||
/* position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
margin: auto; */
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
.preview-wrapper .phone-wrapper {
|
|
||||||
position: absolute;
|
|
||||||
width: [[${work.width}]]px;
|
|
||||||
height: [[${work.height}]]px;
|
|
||||||
display: inline-block;
|
|
||||||
background: #fff;
|
|
||||||
box-sizing: content-box;
|
|
||||||
border: 10px solid #f6f6f6;
|
|
||||||
}
|
|
||||||
.preview-wrapper .float-shortcuts {
|
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
.preview-wrapper .float-shortcuts .page-controller {
|
|
||||||
position: absolute;
|
|
||||||
left: 0 !important;
|
|
||||||
display: block;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 22px;
|
|
||||||
height: 60px;
|
|
||||||
padding: 4px;
|
|
||||||
border-top-right-radius: 5px;
|
|
||||||
border-bottom-right-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
background: #2096f9;
|
|
||||||
font-size: 12px;
|
|
||||||
/* border: 1px solid #2096f9; */
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.preview-wrapper .float-shortcuts .page-controller.next {
|
|
||||||
top: 80px;
|
|
||||||
}
|
|
||||||
.preview-wrapper .work-info {
|
|
||||||
color: #4a4a4a;
|
|
||||||
font-size: 14px;
|
|
||||||
margin-left: 380px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="bg-wrapper"></div>
|
|
||||||
<div class="preview-wrapper">
|
|
||||||
<div class="phone-wrapper">
|
|
||||||
<div class="float-shortcuts">
|
|
||||||
<a class="page-controller swiper-button-prev prev">上一页</a>
|
|
||||||
<a class="page-controller swiper-button-next next">下一页</a>
|
|
||||||
</div>
|
|
||||||
<div id="app">
|
|
||||||
<engine />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="work-info">
|
|
||||||
<div class="qrcode-wrapper">
|
|
||||||
<div class="qrcode-label">
|
|
||||||
<span>手机扫码分享给好友</span>
|
|
||||||
</div>
|
|
||||||
<div class="qrcode-img">
|
|
||||||
<canvas style="float: left" id="qrcode-canvas"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script th:inline="javascript">
|
|
||||||
!function () {
|
|
||||||
function isMobile() {
|
|
||||||
var mobileDeviceReg = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobi/i
|
|
||||||
return mobileDeviceReg.test(navigator.userAgent) || window.innerWidth < 500
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateViewport() {
|
|
||||||
var scale = 1;
|
|
||||||
var w = document.documentElement.clientWidth || window.__work.width;
|
|
||||||
// var h = document.documentElement.clientHeight || 568;
|
|
||||||
// scale = w/h >= window.__work.width/568 ? h/568 : w/window.__work.width;
|
|
||||||
scale = w/window.__work.width;
|
|
||||||
var viewport = "width=" + window.__work.width
|
|
||||||
+ ", initial-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no";
|
|
||||||
document.getElementById("viewport").setAttribute("content", viewport)
|
|
||||||
}
|
|
||||||
|
|
||||||
function doMobileActions () {
|
|
||||||
updateViewport();
|
|
||||||
var app = document.getElementById('app');
|
|
||||||
document.body.innerHTML = '';
|
|
||||||
document.body.appendChild(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
var loadJS = function (url, callback, location) {
|
|
||||||
location = location || document.head
|
|
||||||
|
|
||||||
var scriptTag = document.createElement('script');
|
|
||||||
scriptTag.onload = callback;
|
|
||||||
// scriptTag.onreadystatechange = callback;
|
|
||||||
scriptTag.src = url;
|
|
||||||
location.appendChild(scriptTag);
|
|
||||||
};
|
|
||||||
|
|
||||||
function drawQRcode () {
|
|
||||||
var canvas = document.getElementById('qrcode-canvas')
|
|
||||||
QRCode.toCanvas(canvas, window.location.href, {
|
|
||||||
scale: 4
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function doPCActions() {
|
|
||||||
loadJS('https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js', drawQRcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
isMobile() ? doMobileActions() : doPCActions();
|
|
||||||
}();
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
// Vue.component('engine', window.Engine)
|
|
||||||
new Vue({
|
|
||||||
el: '#app',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
const swiperAnimation = new SwiperAnimation();
|
|
||||||
|
|
||||||
var mySwiper = new Swiper('.swiper-container', {
|
|
||||||
// Optional parameters
|
|
||||||
direction: 'vertical',
|
|
||||||
loop: false,
|
|
||||||
// If we need pagination
|
|
||||||
pagination: {
|
|
||||||
el: '.swiper-pagination',
|
|
||||||
},
|
|
||||||
// Navigation arrows
|
|
||||||
navigation: {
|
|
||||||
nextEl: '.swiper-button-next',
|
|
||||||
prevEl: '.swiper-button-prev',
|
|
||||||
},
|
|
||||||
// And if we need scrollbar
|
|
||||||
scrollbar: {
|
|
||||||
el: '.swiper-scrollbar',
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
init: function () {
|
|
||||||
swiperAnimation.init(this).animate();
|
|
||||||
},
|
|
||||||
slideChange: function () {
|
|
||||||
swiperAnimation.init(this).animate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function title(str) {
|
|
||||||
if (str.length <= 1) return str.toUpperCase()
|
|
||||||
return str.slice(0,1).toUpperCase() + str.slice(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayMessage ({ origin, data }) {
|
|
||||||
if (['next', 'prev'].includes(data) && origin === window.location.origin) {
|
|
||||||
// 不采用下面的原因:在移动端和小屏幕上,会移除:.swiper-button-prev, .swiper-button-next 按钮
|
|
||||||
// document.querySelector(`.swiper-button-${data}`).click()
|
|
||||||
|
|
||||||
var action = `slide${title(data)}`
|
|
||||||
mySwiper[action]()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.addEventListener) {
|
|
||||||
window.addEventListener("message", displayMessage, false);
|
|
||||||
} else {
|
|
||||||
window.attachEvent("onmessage", displayMessage);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<!-- build:js scripts/vendor.js -->
|
|
||||||
<!-- endbuild -->
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue
Block a user