Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
存储配置服务
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 522e59ca
authored
Dec 06, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完善
1 parent
e2c74f33
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
127 additions
and
23 deletions
pom.xml
src/main/java/com/viontech/storage/config/WebConfig.java
src/main/java/com/viontech/storage/controller/CaptionSetController.java
src/main/java/com/viontech/storage/controller/PicConfigController.java
src/main/java/com/viontech/storage/controller/StorageConfigController.java
src/main/java/com/viontech/storage/vo/CaptionSetVo.java
src/main/java/com/viontech/storage/vo/PicConfigVo.java
src/main/java/com/viontech/storage/vo/StorageConfigVo.java
src/main/resources/application.yml
src/main/resources/bootstrap.yml
src/main/resources/db/init.sql
pom.xml
View file @
522e59c
...
@@ -18,6 +18,18 @@
...
@@ -18,6 +18,18 @@
<maven.compiler.target>
8
</maven.compiler.target>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
</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>
<dependencies>
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
...
@@ -45,6 +57,18 @@
...
@@ -45,6 +57,18 @@
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependency>
<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>
<groupId>
org.dom4j
</groupId>
<artifactId>
dom4j
</artifactId>
<artifactId>
dom4j
</artifactId>
<version>
2.1.3
</version>
<version>
2.1.3
</version>
...
...
src/main/java/com/viontech/storage/config/WebConfig.java
View file @
522e59c
...
@@ -17,17 +17,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
...
@@ -17,17 +17,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
public
class
WebConfig
implements
WebMvcConfigurer
{
@Bean
//
@Bean
public
CorsFilter
corsFilter
()
{
//
public CorsFilter corsFilter() {
CorsConfiguration
config
=
new
CorsConfiguration
();
//
CorsConfiguration config = new CorsConfiguration();
config
.
addAllowedOrigin
(
"*"
);
//
config.addAllowedOrigin("*");
config
.
setAllowCredentials
(
true
);
//
config.setAllowCredentials(true);
config
.
addAllowedMethod
(
"*"
);
//
config.addAllowedMethod("*");
config
.
addAllowedHeader
(
"*"
);
//
config.addAllowedHeader("*");
config
.
setMaxAge
(
3600L
);
//
config.setMaxAge(3600L);
UrlBasedCorsConfigurationSource
configSource
=
new
UrlBasedCorsConfigurationSource
();
//
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
configSource
.
registerCorsConfiguration
(
"/**"
,
config
);
//
configSource.registerCorsConfiguration("/**", config);
return
new
CorsFilter
(
configSource
);
//
return new CorsFilter(configSource);
}
//
}
}
}
src/main/java/com/viontech/storage/controller/CaptionSetController.java
View file @
522e59c
package
com
.
viontech
.
storage
.
controller
;
package
com
.
viontech
.
storage
.
controller
;
import
com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.model.CaptionSet
;
import
com.viontech.storage.model.CaptionSet
;
import
com.viontech.storage.service.CaptionSetService
;
import
com.viontech.storage.service.CaptionSetService
;
import
com.viontech.storage.vo.CaptionSetVo
;
import
org.h2.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -29,8 +32,12 @@ public class CaptionSetController {
...
@@ -29,8 +32,12 @@ public class CaptionSetController {
}
}
@GetMapping
@GetMapping
public
Message
<
List
<
CaptionSet
>>
listAll
()
{
public
Message
<
List
<
CaptionSet
>>
listAll
(
CaptionSetVo
captionSetVo
)
{
List
<
CaptionSet
>
list
=
captionSetService
.
list
();
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
);
return
Message
.
success
(
list
);
}
}
...
...
src/main/java/com/viontech/storage/controller/PicConfigController.java
View file @
522e59c
...
@@ -2,11 +2,13 @@ package com.viontech.storage.controller;
...
@@ -2,11 +2,13 @@ package com.viontech.storage.controller;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.model.PicConfig
;
import
com.viontech.storage.model.PicConfig
;
import
com.viontech.storage.service.PicConfigService
;
import
com.viontech.storage.service.PicConfigService
;
import
com.viontech.storage.vo.PicConfigVo
;
import
com.viontech.storage.vo.PicConfigVo
;
import
org.h2.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -36,8 +38,18 @@ public class PicConfigController {
...
@@ -36,8 +38,18 @@ public class PicConfigController {
}
}
@GetMapping
@GetMapping
public
Message
<
List
<
PicConfig
>>
listAll
(
PicConfigVo
captionVo
)
{
public
Message
<
List
<
PicConfig
>>
listAll
(
PicConfigVo
configVo
)
{
List
<
PicConfig
>
list
=
picConfigService
.
list
();
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
());
List
<
PicConfig
>
collect
=
list
.
stream
().
map
(
PicConfigVo:
:
copy
).
collect
(
Collectors
.
toList
());
return
Message
.
success
(
collect
);
return
Message
.
success
(
collect
);
}
}
...
...
src/main/java/com/viontech/storage/controller/StorageConfigController.java
View file @
522e59c
...
@@ -2,12 +2,14 @@ package com.viontech.storage.controller;
...
@@ -2,12 +2,14 @@ package com.viontech.storage.controller;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.entity.Generator
;
import
com.viontech.storage.entity.Generator
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.entity.Message
;
import
com.viontech.storage.model.StorageConfig
;
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.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -36,8 +38,13 @@ public class StorageConfigController {
...
@@ -36,8 +38,13 @@ public class StorageConfigController {
}
}
@GetMapping
@GetMapping
public
Message
<
List
<
StorageConfig
>>
listAll
()
{
public
Message
<
List
<
StorageConfig
>>
listAll
(
StorageConfigVo
vo
)
{
List
<
StorageConfig
>
list
=
storageConfigService
.
list
();
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
());
List
<
StorageConfig
>
collect
=
list
.
stream
().
map
(
StorageConfigVo:
:
copy
).
collect
(
Collectors
.
toList
());
return
Message
.
success
(
collect
);
return
Message
.
success
(
collect
);
}
}
...
...
src/main/java/com/viontech/storage/vo/CaptionSetVo.java
View file @
522e59c
...
@@ -15,5 +15,6 @@ import lombok.Setter;
...
@@ -15,5 +15,6 @@ import lombok.Setter;
@Setter
@Setter
public
class
CaptionSetVo
extends
CaptionSet
{
public
class
CaptionSetVo
extends
CaptionSet
{
private
String
nameLike
;
}
}
src/main/java/com/viontech/storage/vo/PicConfigVo.java
View file @
522e59c
...
@@ -3,7 +3,6 @@ package com.viontech.storage.vo;
...
@@ -3,7 +3,6 @@ package com.viontech.storage.vo;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.entity.Context
;
import
com.viontech.storage.model.Caption
;
import
com.viontech.storage.model.PicConfig
;
import
com.viontech.storage.model.PicConfig
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
...
@@ -19,9 +18,12 @@ import java.util.List;
...
@@ -19,9 +18,12 @@ import java.util.List;
@Getter
@Getter
@Setter
@Setter
public
class
PicConfigVo
extends
PicConfig
{
public
class
PicConfigVo
extends
PicConfig
{
List
<
Context
>
contexts
;
List
<
Context
>
contexts
;
private
String
nameLike
;
private
Integer
pictureQualityGte
;
private
Integer
pictureQualityLte
;
public
static
PicConfigVo
copy
(
PicConfig
picConfig
)
{
public
static
PicConfigVo
copy
(
PicConfig
picConfig
)
{
...
...
src/main/java/com/viontech/storage/vo/StorageConfigVo.java
View file @
522e59c
...
@@ -21,6 +21,7 @@ import java.util.List;
...
@@ -21,6 +21,7 @@ import java.util.List;
public
class
StorageConfigVo
extends
StorageConfig
{
public
class
StorageConfigVo
extends
StorageConfig
{
private
List
<
Context
>
contexts
;
private
List
<
Context
>
contexts
;
private
String
nameLike
;
public
static
StorageConfigVo
copy
(
StorageConfig
storageConfig
)
{
public
static
StorageConfigVo
copy
(
StorageConfig
storageConfig
)
{
if
(
storageConfig
==
null
)
{
if
(
storageConfig
==
null
)
{
...
...
src/main/resources/application.yml
View file @
522e59c
spring
:
spring
:
profiles
:
active
:
dev
jackson
:
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
date-format
:
yyyy-MM-dd HH:mm:ss
time-zone
:
GMT+8
time-zone
:
GMT+8
default-property-inclusion
:
non_null
\ No newline at end of file
\ 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
\ No newline at end of file
src/main/resources/bootstrap.yml
0 → 100644
View file @
522e59c
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
src/main/resources/db/init.sql
View file @
522e59c
...
@@ -76,6 +76,7 @@ create table if not exists storage_config
...
@@ -76,6 +76,7 @@ create table if not exists storage_config
id
int8
not
null
primary
key
AUTO_INCREMENT
,
id
int8
not
null
primary
key
AUTO_INCREMENT
,
unid
varchar
(
36
)
not
null
default
RANDOM_UUID
(),
unid
varchar
(
36
)
not
null
default
RANDOM_UUID
(),
name
varchar
(
128
)
not
null
,
name
varchar
(
128
)
not
null
,
type
int4
not
null
default
0
,
context
text
,
context
text
,
create_time
timestamp
not
null
default
current_timestamp
create_time
timestamp
not
null
default
current_timestamp
);
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment