Commit 2b825b0d by xmh

初版

1 parent 522e59ca
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<skipTests>true</skipTests>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -36,10 +37,6 @@ ...@@ -36,10 +37,6 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>5.7.16</version> <version>5.7.16</version>
...@@ -84,4 +81,22 @@ ...@@ -84,4 +81,22 @@
<version>3.4.3.4</version> <version>3.4.3.4</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>osd-server</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>*.yml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -37,7 +37,7 @@ public class CaptionController { ...@@ -37,7 +37,7 @@ public class CaptionController {
@GetMapping @GetMapping
public Message<List<Caption>> listAll(CaptionVo captionVo) { public Message<List<Caption>> listAll(CaptionVo captionVo) {
List<Caption> list = captionService.list( List<Caption> list = captionService.list(
captionService.query().ge("caption_set_id", captionVo.getCaptionSetId()) captionService.query().eq("caption_set_id", captionVo.getCaptionSetId())
.getWrapper() .getWrapper()
); );
List<Caption> collect = list.stream().map(CaptionVo::copy).collect(Collectors.toList()); List<Caption> collect = list.stream().map(CaptionVo::copy).collect(Collectors.toList());
......
package com.viontech.storage.controller; package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FastByteArrayOutputStream;
import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.viontech.storage.entity.Context; import com.viontech.storage.entity.Context;
...@@ -10,11 +12,17 @@ import com.viontech.storage.model.StorageConfig; ...@@ -10,11 +12,17 @@ import com.viontech.storage.model.StorageConfig;
import com.viontech.storage.service.StorageConfigService; import com.viontech.storage.service.StorageConfigService;
import com.viontech.storage.vo.StorageConfigVo; import com.viontech.storage.vo.StorageConfigVo;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* . * .
...@@ -38,14 +46,21 @@ public class StorageConfigController { ...@@ -38,14 +46,21 @@ public class StorageConfigController {
} }
@GetMapping @GetMapping
public Message<List<StorageConfig>> listAll(StorageConfigVo vo) { public Message<List<StorageConfig>> listAll(StorageConfigVo vo, @RequestParam(required = false, defaultValue = "true") Boolean withoutConfig) {
QueryChainWrapper<StorageConfig> query = storageConfigService.query(); QueryChainWrapper<StorageConfig> query = storageConfigService.query();
if (!StringUtils.isNullOrEmpty(vo.getNameLike())) { if (!StringUtils.isNullOrEmpty(vo.getNameLike())) {
query.like("name", vo.getNameLike()); query.like("name", vo.getNameLike());
} }
if (vo.getType() != null) {
query.eq("type", vo.getType());
}
List<StorageConfig> list = storageConfigService.list(query.getWrapper()); List<StorageConfig> list = storageConfigService.list(query.getWrapper());
List<StorageConfig> collect = list.stream().map(StorageConfigVo::copy).collect(Collectors.toList()); Stream<StorageConfigVo> stream = list.stream().map(StorageConfigVo::copy);
if (withoutConfig) {
stream = stream.peek(x -> x.setConfig(null));
}
List<StorageConfig> collect = stream.collect(Collectors.toList());
return Message.success(collect); return Message.success(collect);
} }
...@@ -83,4 +98,23 @@ public class StorageConfigController { ...@@ -83,4 +98,23 @@ public class StorageConfigController {
return Message.success(build); return Message.success(build);
} }
@PostMapping("/upload")
public Message<Object> upload(String name, MultipartFile file) throws IOException {
FastByteArrayOutputStream read = IoUtil.read(file.getInputStream());
StorageConfig storageConfig = new StorageConfig().setName(name).setConfig(read.toByteArray()).setType(1);
storageConfigService.save(storageConfig);
return Message.success();
}
@GetMapping("/download")
public void download(Long id, HttpServletResponse response) throws IOException {
StorageConfig byId = storageConfigService.getById(id);
byte[] bytes = byId.getConfig();
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(byId.getName() + ".xml", "utf-8"));
response.setCharacterEncoding("GBK");
IoUtil.write(response.getOutputStream(), false, bytes);
}
} }
package com.viontech.storage.controller;
import cn.hutool.json.JSONObject;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* .
*
* @author 谢明辉
* @date 2021/12/15
*/
@RestController
@RequestMapping("/tool")
public class ToolController {
@Resource
private JdbcTemplate jdbcTemplate;
@PostMapping("execSQL")
public Object execSQL(@RequestBody JSONObject jsonObject) {
String sql = jsonObject.getStr("sql");
jdbcTemplate.execute(sql);
return "sdfsd";
}
}
...@@ -28,6 +28,10 @@ public class Caption extends BaseModel { ...@@ -28,6 +28,10 @@ public class Caption extends BaseModel {
private Integer fontSize; private Integer fontSize;
private Integer fgColor; private Integer fgColor;
private String dateFormat; private String dateFormat;
private Boolean millisecond;
private Integer positionType;
private String x;
private String y;
@JsonIgnore @JsonIgnore
private String context; private String context;
} }
...@@ -22,5 +22,7 @@ public class StorageConfig extends BaseModel { ...@@ -22,5 +22,7 @@ public class StorageConfig extends BaseModel {
private String name; private String name;
@JsonIgnore @JsonIgnore
private String context; private String context;
private byte[] config;
private Integer type;
} }
#spring.datasource.url=jdbc:h2:file:./h2/storageConfig
spring.datasource.url=jdbc:h2:tcp://localhost:9092/F:\\myIDEAworkspace\\\u7E41\u661F\\storage-config\\h2\\storageConfig
spring.datasource.username=root
spring.datasource.password=vion
spring.datasource.schema=classpath:db/init.sql
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
\ No newline at end of file \ No newline at end of file
spring.datasource.url=jdbc:h2:tcp://localhost:9092/F:\\myIDEAworkspace\\\u7E41\u661F\\storage-config\\h2\\storageConfig
spring.datasource.username=root
spring.datasource.password=vion
\ No newline at end of file \ No newline at end of file
...@@ -28,4 +28,14 @@ spring: ...@@ -28,4 +28,14 @@ spring:
instance-id: ${spring.application.name}:${spring.cloud.consul.discovery.ip-address}:${server.port} instance-id: ${spring.application.name}:${spring.cloud.consul.discovery.ip-address}:${server.port}
ip-address: 192.168.9.146 ip-address: 192.168.9.146
metadata: metadata:
version: 0.0.1-SNAPSHOT
\ No newline at end of file \ No newline at end of file
version: 0.0.1-SNAPSHOT
datasource:
url: jdbc:h2:tcp://localhost:9092/F:\\myIDEAworkspace\\繁星\\storage-config\\h2\\storageConfig
username: root
password: vion
schema: classpath:db/init.sql
h2:
console:
enabled: true
settings:
web-allow-others: true
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,11 @@ create table if not exists caption ...@@ -26,7 +26,11 @@ create table if not exists caption
font int4, font int4,
font_size int4, font_size int4,
fg_color int4, fg_color int4,
date_format varchar(48), date_format varchar(64),
millisecond boolean not null default false,
position_type int4 not null default 0,
x varchar(64) not null default 0,
y varchar(64) not null default 0,
context text, context text,
create_time timestamp not null default current_timestamp, create_time timestamp not null default current_timestamp,
foreign key (caption_set_id) references caption_set (id) on delete cascade on update no action foreign key (caption_set_id) references caption_set (id) on delete cascade on update no action
...@@ -41,6 +45,9 @@ comment on column caption.font is '字体'; ...@@ -41,6 +45,9 @@ comment on column caption.font is '字体';
comment on column caption.font_size is '字体大小'; comment on column caption.font_size is '字体大小';
comment on column caption.fg_color is '字体颜色'; comment on column caption.fg_color is '字体颜色';
comment on column caption.date_format is '日期格式'; comment on column caption.date_format is '日期格式';
comment on column caption.position_type is '坐标类型,0外上边缘,1外下边缘,2内上边缘,3内下边缘,4自定义';
comment on column caption.x is '字幕相对图片的x坐标';
comment on column caption.y is '字幕相对图片的y坐标';
comment on column caption.context is '叠加信息(JSON)'; comment on column caption.context is '叠加信息(JSON)';
create index if not exists caption_caption_set_id_idx on caption (caption_set_id); create index if not exists caption_caption_set_id_idx on caption (caption_set_id);
create index if not exists caption_unid_idx on caption (unid); create index if not exists caption_unid_idx on caption (unid);
...@@ -78,10 +85,13 @@ create table if not exists storage_config ...@@ -78,10 +85,13 @@ create table if not exists storage_config
name varchar(128) not null, name varchar(128) not null,
type int4 not null default 0, type int4 not null default 0,
context text, context text,
config MEDIUMBLOB,
create_time timestamp not null default current_timestamp create_time timestamp not null default current_timestamp
); );
comment on table storage_config is '存储方案表'; comment on table storage_config is '存储方案表';
comment on column storage_config.name is '名称'; comment on column storage_config.name is '名称';
comment on column storage_config.context is '排列方式(JSON)'; comment on column storage_config.context is '关联(JSON)';
comment on column storage_config.config is '生成或上传的存储配置';
comment on column storage_config.create_time is '创建时间'; comment on column storage_config.create_time is '创建时间';
comment on column storage_config.type is '类型,0代表页面创建的,1代表上传的';
create index if not exists storage_config_unid_idx on storage_config (unid); create index if not exists storage_config_unid_idx on storage_config (unid);
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<contextName>logback</contextName>
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<logger name="com.viontech" level="debug" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.viontech.fanxing.task.mapper" level="off">
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
<!-- 设置字符集 -->
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.viontech" level="debug">
<appender-ref ref="DEBUG_FILE"/>
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!