Commit 522e59ca by xmh

完善

1 parent e2c74f33
......@@ -18,6 +18,18 @@
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
......@@ -45,6 +57,18 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
......
......@@ -17,17 +17,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.addAllowedOrigin("*");
config.setAllowCredentials(true);
config.addAllowedMethod("*");
config.addAllowedHeader("*");
config.setMaxAge(3600L);
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
configSource.registerCorsConfiguration("/**", config);
return new CorsFilter(configSource);
}
// @Bean
// public CorsFilter corsFilter() {
// CorsConfiguration config = new CorsConfiguration();
// config.addAllowedOrigin("*");
// config.setAllowCredentials(true);
// config.addAllowedMethod("*");
// config.addAllowedHeader("*");
// config.setMaxAge(3600L);
// UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
// configSource.registerCorsConfiguration("/**", config);
// return new CorsFilter(configSource);
// }
}
package com.viontech.storage.controller;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.viontech.storage.entity.Message;
import com.viontech.storage.model.CaptionSet;
import com.viontech.storage.service.CaptionSetService;
import com.viontech.storage.vo.CaptionSetVo;
import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -29,8 +32,12 @@ public class CaptionSetController {
}
@GetMapping
public Message<List<CaptionSet>> listAll() {
List<CaptionSet> list = captionSetService.list();
public Message<List<CaptionSet>> listAll(CaptionSetVo captionSetVo) {
QueryChainWrapper<CaptionSet> query = captionSetService.query();
if (!StringUtils.isNullOrEmpty(captionSetVo.getNameLike())) {
query.like("name", captionSetVo.getNameLike());
}
List<CaptionSet> list = captionSetService.list(query.getWrapper());
return Message.success(list);
}
......
......@@ -2,11 +2,13 @@ package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.viontech.storage.entity.Context;
import com.viontech.storage.entity.Message;
import com.viontech.storage.model.PicConfig;
import com.viontech.storage.service.PicConfigService;
import com.viontech.storage.vo.PicConfigVo;
import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -36,8 +38,18 @@ public class PicConfigController {
}
@GetMapping
public Message<List<PicConfig>> listAll(PicConfigVo captionVo) {
List<PicConfig> list = picConfigService.list();
public Message<List<PicConfig>> listAll(PicConfigVo configVo) {
QueryChainWrapper<PicConfig> query = picConfigService.query();
if (!StringUtils.isNullOrEmpty(configVo.getNameLike())) {
query.like("name", configVo.getNameLike());
}
if (configVo.getPictureQualityGte() != null) {
query.ge("picture_quality", configVo.getPictureQualityGte());
}
if (configVo.getPictureQualityLte() != null) {
query.le("picture_quality", configVo.getPictureQualityLte());
}
List<PicConfig> list = picConfigService.list(query.getWrapper());
List<PicConfig> collect = list.stream().map(PicConfigVo::copy).collect(Collectors.toList());
return Message.success(collect);
}
......
......@@ -2,12 +2,14 @@ package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.viontech.storage.entity.Context;
import com.viontech.storage.entity.Generator;
import com.viontech.storage.entity.Message;
import com.viontech.storage.model.StorageConfig;
import com.viontech.storage.service.StorageConfigService;
import com.viontech.storage.vo.StorageConfigVo;
import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -36,8 +38,13 @@ public class StorageConfigController {
}
@GetMapping
public Message<List<StorageConfig>> listAll() {
List<StorageConfig> list = storageConfigService.list();
public Message<List<StorageConfig>> listAll(StorageConfigVo vo) {
QueryChainWrapper<StorageConfig> query = storageConfigService.query();
if (!StringUtils.isNullOrEmpty(vo.getNameLike())) {
query.like("name", vo.getNameLike());
}
List<StorageConfig> list = storageConfigService.list(query.getWrapper());
List<StorageConfig> collect = list.stream().map(StorageConfigVo::copy).collect(Collectors.toList());
return Message.success(collect);
}
......
......@@ -15,5 +15,6 @@ import lombok.Setter;
@Setter
public class CaptionSetVo extends CaptionSet {
private String nameLike;
}
......@@ -3,7 +3,6 @@ package com.viontech.storage.vo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.viontech.storage.entity.Context;
import com.viontech.storage.model.Caption;
import com.viontech.storage.model.PicConfig;
import lombok.Getter;
import lombok.Setter;
......@@ -19,9 +18,12 @@ import java.util.List;
@Getter
@Setter
public class PicConfigVo extends PicConfig{
public class PicConfigVo extends PicConfig {
List<Context> contexts;
private String nameLike;
private Integer pictureQualityGte;
private Integer pictureQualityLte;
public static PicConfigVo copy(PicConfig picConfig) {
......
......@@ -21,6 +21,7 @@ import java.util.List;
public class StorageConfigVo extends StorageConfig {
private List<Context> contexts;
private String nameLike;
public static StorageConfigVo copy(StorageConfig storageConfig) {
if (storageConfig == null) {
......
spring:
profiles:
active: dev
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
\ No newline at end of file
default-property-inclusion: non_null
cloud:
loadbalancer:
ribbon:
enabled: false
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 10s
# 设置健康检查失败多长时间后,取消注册
health-check-critical-timeout: 30s
# 健康检查的路径
health-check-path: /actuator/info
# 服务注册标识,格式为:应用名称:服务器IP:端口
instance-id: ${spring.application.name}:${spring.cloud.consul.discovery.ip-address}:${server.port}
ip-address: 192.168.9.146
metadata:
version: 0.0.1-SNAPSHOT
\ No newline at end of file
server:
port: 30015
spring:
profiles:
active:
${PROFILE}
application:
name: osd-server
cloud:
consul:
host: 192.168.9.233
port: 8500
discovery:
service-name: ${spring.application.name}
# config 在 consul > key/value 中命名规则: prefix/default-context,profiles.active/data-key
config:
enabled: true
format: YAML
prefix: fanxing
default-context: ${spring.application.name}
data-key: config
watch:
enabled: true
delay: 10000
wait-time: 30
......@@ -76,6 +76,7 @@ create table if not exists storage_config
id int8 not null primary key AUTO_INCREMENT,
unid varchar(36) not null default RANDOM_UUID(),
name varchar(128) not null,
type int4 not null default 0,
context text,
create_time timestamp not null default current_timestamp
);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!