Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
f248bc6a
Commit
f248bc6a
authored
Jul 09, 2021
by
李传峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接3.x,集成,改造
parent
ded17383
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
247 additions
and
37 deletions
+247
-37
README.md
README.md
+7
-0
GlobalHandlerInterceptor.java
...oud/common/core/interceptor/GlobalHandlerInterceptor.java
+10
-4
GlobalWebMvcConfigurerAdapter.java
...ommon/core/interceptor/GlobalWebMvcConfigurerAdapter.java
+2
-4
GrayRule.java
...e/src/main/java/com/pcloud/common/core/rule/GrayRule.java
+1
-5
pom.xml
pcloud-common/pom.xml
+5
-4
NacosConfigServiceInstance.java
.../com/pcloud/common/config/NacosConfigServiceInstance.java
+24
-0
PublicConfig.java
.../src/main/java/com/pcloud/common/config/PublicConfig.java
+56
-12
AliyunConstant.java
.../main/java/com/pcloud/common/constant/AliyunConstant.java
+2
-2
AppLabelConstant.java
...ain/java/com/pcloud/common/constant/AppLabelConstant.java
+2
-2
JedisClusterConfig.java
...m/pcloud/common/utils/cache/redis/JedisClusterConfig.java
+23
-3
FeignClient.java
.../org/springframework/cloud/netflix/feign/FeignClient.java
+115
-0
pom.xml
pom.xml
+0
-1
No files found.
README.md
View file @
f248bc6a
**Pcloud Common Pom 3.x**
*
Upgrade Spring Boot to 2.x
*
Upgrade Spring Cloud to Hoxton.SR11
## 各环境不同版本打包命令
```
sh
-Dreversion
=
3.1.0-SNAPSHOT
mvn clean install
-Denforcer
.skip
=
true
-Dmaven
.test.skip
=
true
-U
-Dreversion
=
指定版本号
```
\ No newline at end of file
pcloud-common-core/src/main/java/com/pcloud/common/core/interceptor/GlobalHandlerInterceptor.java
View file @
f248bc6a
...
...
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
@@ -18,6 +19,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.Permission
;
import
com.pcloud.common.utils.SessionUtil
;
import
org.springframework.web.servlet.resource.ResourceHttpRequestHandler
;
/**
*
...
...
@@ -40,6 +42,12 @@ public class GlobalHandlerInterceptor implements HandlerInterceptor {
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
if
(
handler
instanceof
ResourceHttpRequestHandler
||
handler
instanceof
BasicErrorController
)
{
return
true
;
}
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
Method
method
=
handlerMethod
.
getMethod
();
if
(
method
.
isAnnotationPresent
(
Permission
.
class
))
{
...
...
@@ -58,11 +66,9 @@ public class GlobalHandlerInterceptor implements HandlerInterceptor {
}
}
}
if
(!
flag
)
if
(!
flag
)
{
throw
BizException
.
PERMISSION_NOT_FOUND
;
LOGGER
.
info
(
"【权限验证】调用--"
+
method
.
getName
()
+
"--方法,token为-->"
+
token
);
}
else
{
LOGGER
.
info
(
"【权限验证】调用--"
+
method
.
getName
()
+
"--方法,不需要权限。"
);
}
}
return
true
;
}
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/interceptor/GlobalWebMvcConfigurerAdapter.java
View file @
f248bc6a
...
...
@@ -4,9 +4,7 @@ import com.pcloud.universe.monitor.provider.MonitorInterceptor;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.pcloud.common.core.interceptor.GlobalHandlerInterceptor
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
*
...
...
@@ -16,7 +14,7 @@ import com.pcloud.common.core.interceptor.GlobalHandlerInterceptor;
* @版本:1.0
*/
@Configuration
public
class
GlobalWebMvcConfigurerAdapter
extends
WebMvcConfigurerAdapt
er
{
public
class
GlobalWebMvcConfigurerAdapter
implements
WebMvcConfigur
er
{
@Value
(
"${spring.application.name}"
)
private
String
appCode
;
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/rule/GrayRule.java
View file @
f248bc6a
...
...
@@ -5,9 +5,8 @@ import com.netflix.loadbalancer.ILoadBalancer;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ZoneAvoidanceRule
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
...
...
@@ -15,13 +14,10 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.ThreadLocalRandom
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 自定义灰度发布规则 2019-11-19 by david
*/
@Slf4j
@Service
public
class
GrayRule
extends
ZoneAvoidanceRule
{
/**
...
...
pcloud-common/pom.xml
View file @
f248bc6a
...
...
@@ -48,10 +48,6 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<dependency>
...
...
@@ -406,6 +402,11 @@
<version>
5.3.2
</version>
</dependency>
<dependency>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-spring-context
</artifactId>
</dependency>
</dependencies>
</project>
pcloud-common/src/main/java/com/pcloud/common/config/NacosConfigServiceInstance.java
0 → 100644
View file @
f248bc6a
package
com
.
pcloud
.
common
.
config
;
import
com.alibaba.nacos.api.annotation.NacosInjected
;
import
com.alibaba.nacos.api.config.ConfigService
;
import
com.alibaba.nacos.api.exception.NacosException
;
import
org.springframework.stereotype.Component
;
@Component
public
class
NacosConfigServiceInstance
{
private
static
ConfigService
SERVICE
;
@NacosInjected
public
void
setConfigService
(
ConfigService
configService
)
throws
NacosException
{
if
(
SERVICE
==
null
)
{
SERVICE
=
configService
;
}
PublicConfig
.
loadPublicSystem
(
configService
);
}
public
static
ConfigService
getInstance
()
{
return
SERVICE
;
}
}
pcloud-common/src/main/java/com/pcloud/common/config/PublicConfig.java
View file @
f248bc6a
...
...
@@ -3,50 +3,94 @@
*/
package
com
.
pcloud
.
common
.
config
;
import
java.util.Map
;
import
com.alibaba.nacos.api.common.Constants
;
import
com.alibaba.nacos.api.config.ConfigService
;
import
com.alibaba.nacos.api.exception.NacosException
;
import
com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource
;
import
com.alibaba.nacos.spring.util.NacosUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
import
com.pcloud.common.utils.ResourceUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 环境配置基础类
* @author diseng
*
*/
@Configuration
@NacosPropertySource
(
dataId
=
"public_user.properties"
)
public
class
PublicConfig
{
/**
* 系统文件配置 加载。
*/
public
static
Map
<
String
,
String
>
PUBLIC_USER
=
ResourceUtils
.
getResource
(
"public_user"
).
getMap
();
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PublicConfig
.
class
);
/**
* 系统文件配置 加载。
*/
public
static
Map
<
String
,
String
>
PUBLIC_SYSTEM
=
ResourceUtils
.
getResource
(
"public_system"
).
getMap
();
@Value
(
"${IS_DEV_STATUS}"
)
public
void
setIsDevStatus
(
Boolean
v
)
{
IS_DEV_STATUS
=
v
;
}
@Value
(
"${PWD_TIMES_USE_KAPTCHA}"
)
public
void
setPwdTimesUseKaptcha
(
Integer
v
)
{
PWD_TIMES_USE_KAPTCHA
=
v
;
}
@Value
(
"${IS_USE_KAPTCHA}"
)
public
void
setIsUseKaptcha
(
Boolean
v
)
{
IS_USE_KAPTCHA
=
v
;
}
@Value
(
"${PWD_ERROR_LIMIT_TIME}"
)
public
void
setPwdErrorLimitTime
(
Integer
v
)
{
PWD_ERROR_LIMIT_TIME
=
v
;
}
@Value
(
"${PWD_ERROR_LIMIT_TIMES}"
)
public
void
setPwdErrorLimitTimes
(
Integer
v
)
{
PWD_ERROR_LIMIT_TIMES
=
v
;
}
/**
* 密码错误限制次数
*/
public
final
static
Integer
PWD_ERROR_LIMIT_TIMES
=
Integer
.
parseInt
(
PUBLIC_USER
.
get
(
"PWD_ERROR_LIMIT_TIMES"
))
;
public
static
Integer
PWD_ERROR_LIMIT_TIMES
;
/**
* 密码错误限制时间(分钟)
*/
public
final
static
Integer
PWD_ERROR_LIMIT_TIME
=
Integer
.
parseInt
(
PUBLIC_USER
.
get
(
"PWD_ERROR_LIMIT_TIME"
))
;
public
static
Integer
PWD_ERROR_LIMIT_TIME
;
/**
* 门户是否使用验证码 配合密码错误次数值使用
*/
public
final
static
boolean
IS_USE_KAPTCHA
=
Boolean
.
parseBoolean
(
PUBLIC_USER
.
get
(
"IS_USE_KAPTCHA"
))
;
public
static
boolean
IS_USE_KAPTCHA
;
/**
* 密码错误次数值 将 出现验证码,如果值为0 则永远不会出现验证码
*/
public
final
static
Integer
PWD_TIMES_USE_KAPTCHA
=
Integer
.
parseInt
(
PUBLIC_USER
.
get
(
"PWD_TIMES_USE_KAPTCHA"
))
;
public
static
Integer
PWD_TIMES_USE_KAPTCHA
;
/**
* 是否开发状态
*/
public
final
static
boolean
IS_DEV_STATUS
=
Boolean
.
parseBoolean
(
PUBLIC_USER
.
get
(
"IS_DEV_STATUS"
))
;
public
static
boolean
IS_DEV_STATUS
;
/**
* 系统文件配置 加载。
*/
public
static
Map
<
String
,
String
>
PUBLIC_SYSTEM
=
new
HashMap
<>();
public
static
void
loadPublicSystem
(
ConfigService
configService
)
throws
NacosException
{
String
config
=
configService
.
getConfig
(
"public_system.properties"
,
Constants
.
DEFAULT_GROUP
,
Constants
.
RECV_WAIT_TIMEOUT
);
Map
<
String
,
Object
>
p
=
NacosUtils
.
toProperties
(
config
);
p
.
forEach
((
k
,
v
)
->
{
PUBLIC_SYSTEM
.
put
(
k
,
v
.
toString
());
});
LOGGER
.
info
(
"public system loaded completed, size={}"
,
PUBLIC_SYSTEM
.
size
());
}
}
pcloud-common/src/main/java/com/pcloud/common/constant/AliyunConstant.java
View file @
f248bc6a
package
com
.
pcloud
.
common
.
constant
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.utils.FileUtils
;
...
...
@@ -15,7 +15,7 @@ import com.pcloud.common.utils.string.StringUtil;
* @date:2018年6月25日,下午7:30:21
*/
@Component
(
"aliyunConstant"
)
@
PropertySource
(
value
=
{
"classpath:aliyun.properties"
}
)
@
NacosPropertySource
(
dataId
=
"aliyun.properties"
)
public
class
AliyunConstant
{
/**
...
...
pcloud-common/src/main/java/com/pcloud/common/constant/AppLabelConstant.java
View file @
f248bc6a
package
com
.
pcloud
.
common
.
constant
;
import
com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
...
...
@@ -14,7 +14,7 @@ import java.util.List;
* @Date: 2019/11/25 14:28
*/
@Component
(
"appLabelConstant"
)
@
PropertySource
(
value
=
{
"classpath:app_label.properties"
}
)
@
NacosPropertySource
(
dataId
=
"app_label.properties"
)
public
class
AppLabelConstant
{
public
static
final
String
GRADE1
=
"一年级"
;
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/cache/redis/JedisClusterConfig.java
View file @
f248bc6a
...
...
@@ -4,6 +4,8 @@ import java.util.HashSet;
import
java.util.Set
;
import
java.util.regex.Pattern
;
import
com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.pool2.impl.GenericObjectPoolConfig
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -27,7 +29,7 @@ import redis.clients.jedis.JedisCluster;
*/
@Configuration
@EnableCaching
@
PropertySource
(
value
=
"classpath:
redis.properties"
)
@
NacosPropertySource
(
dataId
=
"
redis.properties"
)
public
class
JedisClusterConfig
{
/**
...
...
@@ -38,6 +40,9 @@ public class JedisClusterConfig {
@Value
(
"${redis.cluster.host}"
)
private
String
host
;
@Value
(
"${redis.cluster.password}"
)
private
String
password
;
@Value
(
"${redis.cluster.timeout}"
)
private
int
timeout
;
...
...
@@ -75,6 +80,7 @@ public class JedisClusterConfig {
@Bean
public
GenericObjectPoolConfig
jedisPoolConfig
()
{
LOGGER
.
info
(
"【redis】JedisPool注入成功,<START>"
);
GenericObjectPoolConfig
poolConfig
=
new
GenericObjectPoolConfig
();
poolConfig
.
setMaxTotal
(
maxTotal
);
poolConfig
.
setMinIdle
(
minIdle
);
...
...
@@ -90,8 +96,22 @@ public class JedisClusterConfig {
*/
@Bean
public
JedisCluster
JedisClusterFactory
()
{
LOGGER
.
info
(
"【redis】JedisCluster创建,<START>"
);
return
new
JedisCluster
(
parseHostAndPort
(),
timeout
,
maxRedirections
,
jedisPoolConfig
());
LOGGER
.
info
(
"【redis】JedisCluster创建,{},=>{}<=]"
,
timeout
,
password
);
try
{
JedisCluster
jc
=
new
JedisCluster
(
parseHostAndPort
(),
timeout
,
timeout
,
maxRedirections
,
StringUtils
.
trimToNull
(
password
),
jedisPoolConfig
());
LOGGER
.
info
(
"【redis】JedisCluster创建,echo={}"
,
jc
.
echo
(
"Echo Successfully."
));
return
jc
;
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"【redis】JedisCluster创建无密重试,{},=>{}<=],message={}"
,
timeout
,
password
,
e
.
getMessage
());
JedisCluster
jc
=
new
JedisCluster
(
parseHostAndPort
(),
timeout
,
maxRedirections
,
jedisPoolConfig
());
LOGGER
.
info
(
"【redis】JedisCluster创建无密重试,echo={}"
,
jc
.
echo
(
"Echo Successfully."
));
return
jc
;
}
}
/**
...
...
pcloud-common/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java
0 → 100644
View file @
f248bc6a
/*
* Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
.
feign
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.springframework.core.annotation.AliasFor
;
/**
* Annotation for interfaces declaring that a REST client with that interface should be
* created (e.g. for autowiring into another component). If ribbon is available it will be
* used to load balance the backend requests, and the load balancer can be configured
* using a <code>@RibbonClient</code> with the same name (i.e. value) as the feign client.
*
* @author Spencer Gibb
* @author Venil Noronha
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@org
.
springframework
.
cloud
.
openfeign
.
FeignClient
public
@interface
FeignClient
{
/**
* The name of the service with optional protocol prefix. Synonym for {@link #name()
* name}. A name must be specified for all clients, whether or not a url is provided.
* Can be specified as property key, eg: ${propertyKey}.
*/
@AliasFor
(
"name"
)
String
value
()
default
""
;
/**
* The service id with optional protocol prefix. Synonym for {@link #value() value}.
*
* @deprecated use {@link #name() name} instead
*/
@Deprecated
String
serviceId
()
default
""
;
/**
* The service id with optional protocol prefix. Synonym for {@link #value() value}.
*/
@AliasFor
(
"value"
)
String
name
()
default
""
;
/**
* Sets the <code>@Qualifier</code> value for the feign client.
*/
String
qualifier
()
default
""
;
/**
* An absolute URL or resolvable hostname (the protocol is optional).
*/
String
url
()
default
""
;
/**
* Whether 404s should be decoded instead of throwing FeignExceptions
*/
boolean
decode404
()
default
false
;
/**
* A custom <code>@Configuration</code> for the feign client. Can contain override
* <code>@Bean</code> definition for the pieces that make up the client, for instance
* {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}.
*
* @see FeignClientsConfiguration for the defaults
*/
Class
<?>[]
configuration
()
default
{};
/**
* Fallback class for the specified Feign client interface. The fallback class must
* implement the interface annotated by this annotation and be a valid spring bean.
*/
Class
<?>
fallback
()
default
void
.
class
;
/**
* Define a fallback factory for the specified Feign client interface. The fallback
* factory must produce instances of fallback classes that implement the interface
* annotated by {@link FeignClient}. The fallback factory must be a valid spring
* bean.
*
* @see feign.hystrix.FallbackFactory for details.
*/
Class
<?>
fallbackFactory
()
default
void
.
class
;
/**
* Path prefix to be used by all method-level mappings. Can be used with or without
* <code>@RibbonClient</code>.
*/
String
path
()
default
""
;
/**
* Whether to mark the feign proxy as a primary bean. Defaults to true.
*/
boolean
primary
()
default
true
;
}
pom.xml
View file @
f248bc6a
...
...
@@ -83,7 +83,6 @@
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.1.20
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment