Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
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
周健威
rs-cloud-platform
Commits
3d49e13a
Commit
3d49e13a
authored
Dec 15, 2020
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改问题
parent
e77b9fb8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
355 additions
and
3 deletions
+355
-3
AssertUtils.java
.../com/github/wxiaoqi/security/common/util/AssertUtils.java
+153
-0
DepthBeanToMap.java
...m/github/wxiaoqi/security/common/util/DepthBeanToMap.java
+161
-0
pom.xml
rs-datacenter/rs-datacenter-api/pom.xml
+1
-0
pom.xml
rs-datacenter/rs-datacenter-server/pom.xml
+2
-1
RscpImageDataTotalBiz.java
...uns/platform/rs/datacenter/biz/RscpImageDataTotalBiz.java
+13
-0
RscpAreaInfoController.java
...s/platform/rs/datacenter/rest/RscpAreaInfoController.java
+6
-0
RscpAreaImageTotalMapper.xml
...er/src/main/resources/mapper/RscpAreaImageTotalMapper.xml
+1
-1
RscpImageDataTotalMapper.xml
...er/src/main/resources/mapper/RscpImageDataTotalMapper.xml
+1
-1
pom.xml
rs-website/rs-website-server/pom.xml
+7
-0
CustomFormWebController.java
...rm/rs/website/controller/web/CustomFormWebController.java
+10
-0
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/AssertUtils.java
0 → 100644
View file @
3d49e13a
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.mockito.internal.util.collections.Sets
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
.
CommonConstants
.
SYS_FALSE
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
.
CommonConstants
.
SYS_JSON_TRUE
;
@Slf4j
public
class
AssertUtils
{
public
static
<
T
>
T
isBlank
(
T
object
,
BaseException
baseException
,
String
name
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isBlank : {}"
,
object
);
if
(
object
instanceof
Collection
)
{
if
(
CollUtil
.
isEmpty
((
List
)
object
))
{
throwException
(
baseException
,
name
);
}
}
else
if
(
object
==
null
)
{
throwException
(
baseException
,
name
);
}
return
object
;
}
public
static
<
T
>
T
isNotBlank
(
T
object
,
BaseException
baseException
,
String
name
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isNotBlank : {}"
,
object
);
if
(
object
!=
null
)
{
//如果是集合 并且 为空 着不抛异常
if
(
object
instanceof
Collection
&&
CollUtil
.
isEmpty
((
List
)
object
))
{
return
object
;
}
else
{
throwException
(
baseException
,
name
);
}
}
return
object
;
}
public
static
<
T
>
T
isBlank
(
T
object
,
BaseException
baseException
)
throws
BaseException
{
return
isBlank
(
object
,
baseException
,
null
);
}
public
static
<
T
>
T
isNotBlank
(
T
object
,
BaseException
baseException
)
throws
BaseException
{
return
isNotBlank
(
object
,
baseException
,
null
);
}
public
static
void
isBlankMulti
(
Object
...
objects
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isBlank : {}"
,
objects
);
isBlank
(
objects
);
for
(
Object
object
:
objects
)
{
isBlank
(
object
);
}
}
// public static void isEqual(Object a, Object b, BaseException bex) throws BaseException {
// log.info(" AssertUtils.isEqual : {} {}", a, b);
// if(a.equals(b)) {
// if(null != bex) {
// throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
// }else {
// throw bex;
// }
// }
// }
public
static
<
T
>
T
isBlank
(
T
object
)
throws
BaseException
{
return
isBlank
(
object
,
null
,
null
);
}
public
static
<
T
>
T
isBlankBean
(
T
object
)
throws
BaseException
{
Map
<
String
,
Object
>
beanMap
=
BeanUtil
.
beanToMap
(
object
);
isBlank
(
object
);
for
(
String
key
:
beanMap
.
keySet
())
{
isBlank
(
beanMap
.
get
(
key
),
null
,
null
);
}
return
object
;
}
public
static
<
T
>
T
isBlank
(
T
object
,
String
attrName
)
throws
BaseException
{
return
isBlank
(
object
,
null
,
attrName
);
}
public
static
Integer
isDBSucc
(
Integer
flag
,
BaseException
baseException
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isDBSucc : {}"
,
flag
);
if
(
SYS_FALSE
.
equals
(
flag
))
{
throwDBException
(
baseException
);
}
return
flag
;
}
public
static
Integer
isDBSucc
(
Integer
flag
)
throws
BaseException
{
return
isDBSucc
(
flag
,
null
);
}
public
static
<
T
>
ObjectRestResponse
<
T
>
isFeignSucc
(
ObjectRestResponse
<
T
>
orr
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isFeignSucc : {}"
,
orr
);
if
(!
SYS_JSON_TRUE
.
equals
(
orr
.
getStatus
()))
{
throw
new
BaseException
(
orr
.
getMessage
(),
orr
.
getStatus
());
}
return
orr
;
}
public
static
<
T
,
E
>
ObjectRestResponse
<
T
>
isFeignSuccGetObj
(
E
dto
,
Function
<
Map
,
ObjectRestResponse
<
T
>>
function
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isFeignSucc : {}"
,
dto
);
ObjectRestResponse
<
T
>
orr
=
function
.
apply
(
DepthBeanToMap
.
objectToMap
(
dto
));
//ObjectRestResponse<T> orr = function.apply( BeanUtil.beanToMap(dto, false, false));
if
(!
SYS_JSON_TRUE
.
equals
(
orr
.
getStatus
()))
{
throw
new
BaseException
(
orr
.
getMessage
(),
orr
.
getStatus
());
}
return
orr
;
}
public
static
<
T
,
E
>
List
<
T
>
isFeignSuccGetDataList
(
E
dto
,
Function
<
Map
,
ObjectRestResponse
<
List
<
T
>>>
function
,
Class
<
T
>
tClass
)
throws
BaseException
{
log
.
info
(
" AssertUtils.isFeignSucc : {}"
,
dto
);
ObjectRestResponse
<
List
<
T
>>
orr
=
function
.
apply
(
DepthBeanToMap
.
objectToMap
(
dto
));
//ObjectRestResponse<List<T>> orr = function.apply(BeanUtil.beanToMap(dto, false, false));
if
(!
SYS_JSON_TRUE
.
equals
(
orr
.
getStatus
()))
{
throw
new
BaseException
(
orr
.
getMessage
(),
orr
.
getStatus
());
}
orr
.
setData
(
orr
.
getData
().
parallelStream
().
map
(
t
->
BeanUtil
.
toBean
(
t
,
tClass
)).
collect
(
Collectors
.
toList
()));
return
orr
.
getData
();
}
public
static
<
T
,
E
>
T
isFeignSuccGetData
(
E
dto
,
Function
<
Map
,
ObjectRestResponse
<
T
>>
function
)
throws
BaseException
{
return
isFeignSuccGetObj
(
dto
,
function
).
getData
();
}
private
static
void
throwException
(
BaseException
baseException
,
String
name
)
{
if
(
null
!=
baseException
)
{
throw
baseException
;
}
else
{
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
,
Sets
.
newSet
(
name
));
}
}
private
static
void
throwDBException
(
BaseException
baseException
)
{
if
(
null
!=
baseException
)
{
throw
baseException
;
}
else
{
throw
new
BaseException
(
ResultCode
.
DB_OPERATION_FAIL_CODE
);
}
}
}
\ No newline at end of file
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/DepthBeanToMap.java
0 → 100644
View file @
3d49e13a
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
DepthBeanToMap
{
public
static
Map
objectToMap
(
Object
obj
){
try
{
Class
type
=
obj
.
getClass
();
Map
returnMap
=
new
HashMap
();
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
type
);
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
int
i
=
0
;
i
<
propertyDescriptors
.
length
;
i
++)
{
PropertyDescriptor
descriptor
=
propertyDescriptors
[
i
];
String
propertyName
=
descriptor
.
getName
();
if
(!
propertyName
.
equals
(
"class"
))
{
Method
readMethod
=
descriptor
.
getReadMethod
();
Object
result
=
readMethod
.
invoke
(
obj
,
new
Object
[
0
]);
if
(
result
==
null
){
continue
;
}
//判断是否为 基础类型 String,Boolean,Byte,Short,Integer,Long,Float,Double
//判断是否集合类,COLLECTION,MAP
if
(
result
instanceof
String
||
result
instanceof
Boolean
||
result
instanceof
Byte
||
result
instanceof
Short
||
result
instanceof
Integer
||
result
instanceof
Long
||
result
instanceof
Float
||
result
instanceof
Double
||
result
instanceof
Enum
){
if
(
result
!=
null
)
{
returnMap
.
put
(
propertyName
,
result
);
}
}
else
if
(
result
instanceof
Collection
){
Collection
<?>
lstObj
=
arrayToMap
((
Collection
<?>)
result
);
returnMap
.
put
(
propertyName
,
lstObj
);
}
else
if
(
result
instanceof
Map
){
Map
<
Object
,
Object
>
lstObj
=
mapToMap
((
Map
<
Object
,
Object
>)
result
);
returnMap
.
put
(
propertyName
,
lstObj
);
}
else
{
Map
mapResult
=
objectToMap
(
result
);
returnMap
.
put
(
propertyName
,
mapResult
);
}
}
}
return
returnMap
;
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
}
}
private
static
Map
<
Object
,
Object
>
mapToMap
(
Map
<
Object
,
Object
>
orignMap
)
{
Map
<
Object
,
Object
>
resultMap
=
new
HashMap
<
Object
,
Object
>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry:
orignMap
.
entrySet
()){
Object
key
=
entry
.
getKey
();
Object
resultKey
=
null
;
if
(
key
instanceof
Collection
){
resultKey
=
arrayToMap
((
Collection
)
key
);
}
else
if
(
key
instanceof
Map
){
resultKey
=
mapToMap
((
Map
)
key
);
}
else
{
if
(
key
instanceof
String
||
key
instanceof
Boolean
||
key
instanceof
Byte
||
key
instanceof
Short
||
key
instanceof
Integer
||
key
instanceof
Long
||
key
instanceof
Float
||
key
instanceof
Double
||
key
instanceof
Enum
){
if
(
key
!=
null
)
{
resultKey
=
key
;
}
}
else
{
resultKey
=
objectToMap
(
key
);
}
}
Object
value
=
entry
.
getValue
();
Object
resultValue
=
null
;
if
(
value
instanceof
Collection
){
resultValue
=
arrayToMap
((
Collection
)
value
);
}
else
if
(
value
instanceof
Map
){
resultValue
=
mapToMap
((
Map
)
value
);
}
else
{
if
(
value
instanceof
String
||
value
instanceof
Boolean
||
value
instanceof
Byte
||
value
instanceof
Short
||
value
instanceof
Integer
||
value
instanceof
Long
||
value
instanceof
Float
||
value
instanceof
Double
||
value
instanceof
Enum
){
if
(
value
!=
null
)
{
resultValue
=
value
;
}
}
else
{
resultValue
=
objectToMap
(
value
);
}
}
resultMap
.
put
(
resultKey
,
resultValue
);
}
return
resultMap
;
}
private
static
Collection
arrayToMap
(
Collection
lstObj
){
ArrayList
arrayList
=
new
ArrayList
();
for
(
Object
t
:
lstObj
)
{
if
(
t
instanceof
Collection
){
Collection
result
=
arrayToMap
((
Collection
)
t
);
arrayList
.
add
(
result
);
}
else
if
(
t
instanceof
Map
){
Map
result
=
mapToMap
((
Map
)
t
);
arrayList
.
add
(
result
);
}
else
{
if
(
t
instanceof
String
||
t
instanceof
Boolean
||
t
instanceof
Byte
||
t
instanceof
Short
||
t
instanceof
Integer
||
t
instanceof
Long
||
t
instanceof
Float
||
t
instanceof
Double
||
t
instanceof
Enum
){
if
(
t
!=
null
)
{
arrayList
.
add
(
t
);
}
}
else
{
Object
result
=
objectToMap
(
t
);
arrayList
.
add
(
result
);
}
}
}
return
arrayList
;
}
}
\ No newline at end of file
rs-datacenter/rs-datacenter-api/pom.xml
View file @
3d49e13a
...
...
@@ -9,6 +9,7 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.upyuns.platform.rs
</groupId>
<artifactId>
rs-datacenter-api
</artifactId>
<version>
2.0-rscp-SNAPSHOT
</version>
...
...
rs-datacenter/rs-datacenter-server/pom.xml
View file @
3d49e13a
...
...
@@ -9,11 +9,12 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.upyuns.platform.rs
</groupId>
<artifactId>
rs-datacenter-server
</artifactId>
<dependencies>
<dependency>
<groupId>
com.upyuns.
common
</groupId>
<groupId>
com.upyuns.
platform.rs
</groupId>
<artifactId>
rs-datacenter-api
</artifactId>
<version>
2.0-rscp-SNAPSHOT
</version>
<scope>
compile
</scope>
...
...
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/biz/RscpImageDataTotalBiz.java
View file @
3d49e13a
...
...
@@ -2,6 +2,7 @@ package com.upyuns.platform.rs.datacenter.biz;
import
cn.hutool.core.collection.CollUtil
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.upyuns.platform.rs.datacenter.entity.RscpAreaImageTotal
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal
;
import
com.upyuns.platform.rs.datacenter.mapper.RscpImageDataTotalMapper
;
import
com.upyuns.platform.rs.datacenter.rest.RscpImageDataTotalController
;
...
...
@@ -16,5 +17,17 @@ public class RscpImageDataTotalBiz extends BaseBiz<RscpImageDataTotalMapper, Rsc
return
mapper
.
queryDataList
(
dto
);
}
// public List<RscpAreaImageTotal> queryDataList(RscpImageDataTotalController.QueryDTO dto) {
// List<RscpImageDataTotal> list = mapper.queryDataList(dto);
// List<RscpAreaImageTotal> list2 = CollUtil.newArrayList();
// if(CollUtil.isNotEmpty(list)) {
// list.forEach(to -> {
// to.getC
// return ;
// });
// }
// return mapper.queryDataList(dto);
// }
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/rest/RscpAreaInfoController.java
View file @
3d49e13a
...
...
@@ -36,4 +36,10 @@ public class RscpAreaInfoController extends BaseController<RscpAreaInfoBiz, Rscp
public
ObjectRestResponse
<
RscpAreaInfo
>
queryAreaInfoByAreaId
(
String
areaCode
)
{
return
ObjectRestResponse
.
succ
(
baseBiz
.
queryAreaInfoByAreaId
(
areaCode
));
}
@RequestMapping
(
value
=
"/app/unauth/Fegin/queryByCodeFegin"
,
method
=
RequestMethod
.
GET
)
@IgnoreUserToken
public
ObjectRestResponse
<
RscpAreaInfo
>
queryByCode
(
String
areaCode
)
{
return
ObjectRestResponse
.
succ
(
baseBiz
.
queryAreaInfoByAreaId
(
areaCode
));
}
}
\ No newline at end of file
rs-datacenter/rs-datacenter-server/src/main/resources/mapper/RscpAreaImageTotalMapper.xml
View file @
3d49e13a
...
...
@@ -64,7 +64,7 @@
</foreach>
</if>
<if
test=
"resolution != null"
>
and #{
image_
resolution} = any(image_resolution)
and #{resolution} = any(image_resolution)
</if>
<if
test=
"startDateTime != null"
>
and begin_time
>
= #{startDateTime}
...
...
rs-datacenter/rs-datacenter-server/src/main/resources/mapper/RscpImageDataTotalMapper.xml
View file @
3d49e13a
...
...
@@ -113,7 +113,7 @@
</foreach>
</if>
<if
test=
"resolution != null"
>
and #{
image_
resolution} = any(image_resolution)
and #{resolution} = any(image_resolution)
</if>
<if
test=
"startDateTime != null"
>
and image_take_time
>
= #{startDateTime}
...
...
rs-website/rs-website-server/pom.xml
View file @
3d49e13a
...
...
@@ -24,6 +24,13 @@
<version>
2.0-rscp-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.upyuns.platform.rs
</groupId>
<artifactId>
rs-datacenter-api
</artifactId>
<version>
2.0-rscp-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
<build>
...
...
rs-website/rs-website-server/src/main/java/com/upyuns/platform/rs/website/controller/web/CustomFormWebController.java
View file @
3d49e13a
package
com
.
upyuns
.
platform
.
rs
.
website
.
controller
.
web
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.util.AssertUtils
;
import
com.upyuns.platform.rs.datacenter.fegin.DatacenterFeign
;
import
com.upyuns.platform.rs.website.biz.CustomFormBiz
;
import
com.upyuns.platform.rs.website.entity.CustomForm
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -13,8 +17,14 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"customForm/web"
)
public
class
CustomFormWebController
extends
BaseController
<
CustomFormBiz
,
CustomForm
>
{
@Autowired
DatacenterFeign
datacenterFegin
;
@RequestMapping
(
value
=
"customIndustry"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
customIndustry
(
@RequestBody
CustomForm
entity
)
{
// if(StrUtil.isNotBlank(entity.getProvinceCode())) {
// entity.setProvinceName(AssertUtils.isFeignSucc(datacenterFegin.queryByCode(entity.getProvinceCode()).getData());
// }
baseBiz
.
insertSelective
(
entity
);
return
ObjectRestResponse
.
succ
();
}
...
...
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