Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
szpt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
以墨为白
szpt
Commits
744dd937
Commit
744dd937
authored
Jan 09, 2025
by
夏敏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://192.168.168.218/wcyuee/szpt
parents
698d67ae
14ea6406
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
299 additions
and
68 deletions
+299
-68
src/main/java/com/zksy/szpt/aspect/GlobalExceptionHandler.java
...ain/java/com/zksy/szpt/aspect/GlobalExceptionHandler.java
+14
-0
src/main/java/com/zksy/szpt/controller/AppStoreController.java
...ain/java/com/zksy/szpt/controller/AppStoreController.java
+6
-0
src/main/java/com/zksy/szpt/controller/XxShxxyController.java
...main/java/com/zksy/szpt/controller/XxShxxyController.java
+3
-7
src/main/java/com/zksy/szpt/controller/XxShxxyDwController.java
...in/java/com/zksy/szpt/controller/XxShxxyDwController.java
+3
-3
src/main/java/com/zksy/szpt/controller/XxYjdwdmController.java
...ain/java/com/zksy/szpt/controller/XxYjdwdmController.java
+3
-3
src/main/java/com/zksy/szpt/controller/XxYjrwController.java
src/main/java/com/zksy/szpt/controller/XxYjrwController.java
+3
-3
src/main/java/com/zksy/szpt/controller/XxZhjfbgController.java
...ain/java/com/zksy/szpt/controller/XxZhjfbgController.java
+3
-3
src/main/java/com/zksy/szpt/controller/XxZhxxController.java
src/main/java/com/zksy/szpt/controller/XxZhxxController.java
+2
-2
src/main/java/com/zksy/szpt/domain/dto/AppStoreDTO.java
src/main/java/com/zksy/szpt/domain/dto/AppStoreDTO.java
+13
-0
src/main/java/com/zksy/szpt/domain/dto/CommonDelParamDTO.java
...main/java/com/zksy/szpt/domain/dto/CommonDelParamDTO.java
+23
-0
src/main/java/com/zksy/szpt/domain/po/AppStore.java
src/main/java/com/zksy/szpt/domain/po/AppStore.java
+10
-0
src/main/java/com/zksy/szpt/domain/po/XxYjrw.java
src/main/java/com/zksy/szpt/domain/po/XxYjrw.java
+3
-1
src/main/java/com/zksy/szpt/filter/SignatureVerificationFilter.java
...ava/com/zksy/szpt/filter/SignatureVerificationFilter.java
+12
-1
src/main/java/com/zksy/szpt/handler/SzptMetaObjectHandler.java
...ain/java/com/zksy/szpt/handler/SzptMetaObjectHandler.java
+2
-1
src/main/java/com/zksy/szpt/service/AppStoreService.java
src/main/java/com/zksy/szpt/service/AppStoreService.java
+5
-0
src/main/java/com/zksy/szpt/service/XxShxxyDwService.java
src/main/java/com/zksy/szpt/service/XxShxxyDwService.java
+2
-2
src/main/java/com/zksy/szpt/service/XxShxxyService.java
src/main/java/com/zksy/szpt/service/XxShxxyService.java
+2
-2
src/main/java/com/zksy/szpt/service/XxYjdwdmService.java
src/main/java/com/zksy/szpt/service/XxYjdwdmService.java
+2
-2
src/main/java/com/zksy/szpt/service/XxYjrwService.java
src/main/java/com/zksy/szpt/service/XxYjrwService.java
+2
-1
src/main/java/com/zksy/szpt/service/XxZhjfbgService.java
src/main/java/com/zksy/szpt/service/XxZhjfbgService.java
+2
-3
src/main/java/com/zksy/szpt/service/XxZhxxService.java
src/main/java/com/zksy/szpt/service/XxZhxxService.java
+1
-1
src/main/java/com/zksy/szpt/util/RedisKeyValidator.java
src/main/java/com/zksy/szpt/util/RedisKeyValidator.java
+40
-0
src/test/java/com/zksy/szpt/MainTest.java
src/test/java/com/zksy/szpt/MainTest.java
+33
-33
src/test/java/com/zksy/szpt/TestAppStore.java
src/test/java/com/zksy/szpt/TestAppStore.java
+110
-0
No files found.
src/main/java/com/zksy/szpt/aspect/GlobalExceptionHandler.java
View file @
744dd937
...
...
@@ -21,6 +21,7 @@ import org.springframework.web.servlet.NoHandlerFoundException;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.ConstraintViolationException
;
import
java.sql.SQLIntegrityConstraintViolationException
;
import
java.util.stream.Collectors
;
...
...
@@ -133,6 +134,17 @@ public class GlobalExceptionHandler {
state
.
setMessage
(
e
.
getCause
().
getMessage
());
return
new
HttpResult
<>(
state
);
}
//违反唯一约束
@ResponseBody
@ExceptionHandler
({
SQLIntegrityConstraintViolationException
.
class
})
public
HttpResult
<
HttpResultState
>
DuplicateKeyExceptionHandler
(
SQLIntegrityConstraintViolationException
e
)
{
logger
.
warn
(
e
.
getMessage
());
HttpResultState
state
=
HttpResultState
.
DUPLICATED_KEY
;
state
.
setMessage
(
e
.
getCause
().
getMessage
());
return
new
HttpResult
<>(
state
);
}
//endregion
...
...
@@ -143,4 +155,6 @@ public class GlobalExceptionHandler {
state
.
setMessage
(
e
.
getMessage
());
return
new
HttpResult
<>(
state
);
}
}
src/main/java/com/zksy/szpt/controller/AppStoreController.java
View file @
744dd937
...
...
@@ -32,4 +32,10 @@ public class AppStoreController {
public
Integer
insertAppStore
(
@RequestBody
@Valid
AppStoreDTO
appStoreDTO
)
{
return
appStoreService
.
insertAppStore
(
appStoreDTO
);
}
@ApiOperation
(
value
=
"更新appKey"
,
notes
=
"更新appKey"
)
@PostMapping
(
"/updateAppIdSecret"
)
public
Integer
updateAppStore
(
@RequestBody
@Valid
AppStoreDTO
appStoreDTO
)
{
return
appStoreService
.
updateAppStore
(
appStoreDTO
);
}
}
src/main/java/com/zksy/szpt/controller/XxShxxyController.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
controller
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.XxShxxyDTO
;
import
com.zksy.szpt.domain.dto.XxShxxyDwDTO
;
import
com.zksy.szpt.domain.dto.XxYjrwDTO
;
import
com.zksy.szpt.service.XxShxxyDwService
;
import
com.zksy.szpt.domain.dto.*
;
import
com.zksy.szpt.service.XxShxxyService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -36,9 +32,9 @@ public class XxShxxyController {
return
service
.
update
(
dto
);
}
@ApiOperation
(
value
=
"删除社会信息员数据"
)
@ApiOperation
(
value
=
"
根据社会信息员ID
删除社会信息员数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/controller/XxShxxyDwController.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
controller
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxShxxyDwDTO
;
import
com.zksy.szpt.service.XxShxxyDwService
;
import
io.swagger.annotations.Api
;
...
...
@@ -32,9 +32,9 @@ public class XxShxxyDwController {
return
service
.
update
(
dto
);
}
@ApiOperation
(
value
=
"删除社会信息员队伍数据"
)
@ApiOperation
(
value
=
"
根据信息员队伍ID
删除社会信息员队伍数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/controller/XxYjdwdmController.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
controller
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxYjdwdmDTO
;
import
com.zksy.szpt.service.XxYjdwdmService
;
import
io.swagger.annotations.Api
;
...
...
@@ -31,9 +31,9 @@ public class XxYjdwdmController {
return
service
.
update
(
dto
);
}
@ApiOperation
(
value
=
"删除义警队伍数据"
)
@ApiOperation
(
value
=
"
根据义警队伍代码ID
删除义警队伍数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/controller/XxYjrwController.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
controller
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxYjrwDTO
;
import
com.zksy.szpt.service.XxYjrwService
;
import
io.swagger.annotations.Api
;
...
...
@@ -31,9 +31,9 @@ public class XxYjrwController {
return
service
.
update
(
dto
);
}
@ApiOperation
(
value
=
"删除义警任务信息数据"
)
@ApiOperation
(
value
=
"
根据任务ID
删除义警任务信息数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/controller/XxZhjfbgController.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
controller
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxZhjfbgDTO
;
import
com.zksy.szpt.service.XxZhjfbgService
;
import
io.swagger.annotations.Api
;
...
...
@@ -32,9 +32,9 @@ public class XxZhjfbgController {
}
@ApiOperation
(
value
=
"删除账户积分变更数据"
)
@ApiOperation
(
value
=
"
根据兑换ID
删除账户积分变更数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/controller/XxZhxxController.java
View file @
744dd937
...
...
@@ -31,9 +31,9 @@ public class XxZhxxController {
}
@ApiOperation
(
value
=
"删除账号信息数据"
)
@ApiOperation
(
value
=
"
根据账户ID
删除账号信息数据"
)
@PostMapping
(
"/delete"
)
public
Integer
delete
(
@RequestBody
@Validated
CommonDelDTO
dto
)
{
public
Integer
delete
(
@RequestBody
@Validated
CommonDel
Param
DTO
dto
)
{
return
service
.
delete
(
dto
);
}
...
...
src/main/java/com/zksy/szpt/domain/dto/AppStoreDTO.java
View file @
744dd937
package
com
.
zksy
.
szpt
.
domain
.
dto
;
import
javax.validation.constraints.NotBlank
;
public
class
AppStoreDTO
{
private
Long
id
;
@NotBlank
private
String
appKey
;
@NotBlank
private
String
appSecret
;
private
String
deptCode
;
public
String
getDeptCode
()
{
return
deptCode
;
}
public
void
setDeptCode
(
String
deptCode
)
{
this
.
deptCode
=
deptCode
;
}
public
Long
getId
()
{
return
id
;
...
...
src/main/java/com/zksy/szpt/domain/dto/CommonDelParamDTO.java
0 → 100644
View file @
744dd937
package
com
.
zksy
.
szpt
.
domain
.
dto
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.List
;
public
class
CommonDelParamDTO
{
/**
* 账户ID
*/
@NotEmpty
(
message
=
"ID不能为空"
)
private
List
<
String
>
ids
;
public
@NotEmpty
(
message
=
"ID不能为空"
)
List
<
String
>
getIds
()
{
return
ids
;
}
public
void
setIds
(
@NotEmpty
(
message
=
"ID不能为空"
)
List
<
String
>
ids
)
{
this
.
ids
=
ids
;
}
}
\ No newline at end of file
src/main/java/com/zksy/szpt/domain/po/AppStore.java
View file @
744dd937
...
...
@@ -14,6 +14,16 @@ public class AppStore {
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
private
String
deptCode
;
@TableField
(
fill
=
FieldFill
.
UPDATE
)
private
Date
updateTime
;
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Long
getId
()
{
return
id
;
...
...
src/main/java/com/zksy/szpt/domain/po/XxYjrw.java
View file @
744dd937
...
...
@@ -148,7 +148,7 @@ public class XxYjrw {
* 更新时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT_
UPDATE
)
@TableField
(
fill
=
FieldFill
.
UPDATE
)
private
Date
gxsj
;
/**
...
...
@@ -379,4 +379,6 @@ public class XxYjrw {
public
void
setPictureUrls
(
String
pictureUrls
)
{
this
.
pictureUrls
=
pictureUrls
==
null
?
null
:
pictureUrls
.
trim
();
}
}
\ No newline at end of file
src/main/java/com/zksy/szpt/filter/SignatureVerificationFilter.java
View file @
744dd937
...
...
@@ -11,6 +11,7 @@ import com.zksy.szpt.domain.HttpResultState;
import
com.zksy.szpt.domain.po.AppStore
;
import
com.zksy.szpt.service.AppStoreService
;
import
com.zksy.szpt.util.EncryptUtil
;
import
com.zksy.szpt.util.RedisKeyValidator
;
import
com.zksy.szpt.util.SignatureUtil
;
import
com.zksy.szpt.util.UserContextHolder
;
import
org.slf4j.Logger
;
...
...
@@ -83,6 +84,16 @@ public class SignatureVerificationFilter extends OncePerRequestFilter {
return
false
;
}
// 验证nonce和timestamp合法性
if
(!
RedisKeyValidator
.
isValidString
(
nonce
))
{
this
.
write
(
response
,
"不是合法的由数字和字母以及下划线组成的nonce:"
+
nonce
);
return
false
;
}
if
(!
RedisKeyValidator
.
isValidTimestamp
(
timestampStr
))
{
this
.
write
(
response
,
"不是合法的十位秒级时间戳timestamp:"
+
timestampStr
);
return
false
;
}
// timestamp 10分钟内有效
long
timestamp
=
Long
.
parseLong
(
timestampStr
);
long
currentTimestamp
=
System
.
currentTimeMillis
()
/
1000
;
...
...
@@ -111,7 +122,7 @@ public class SignatureVerificationFilter extends OncePerRequestFilter {
Map
<
String
,
Object
>
objectMap
=
objectMapper
.
readValue
(
body
,
Map
.
class
);
//验证单位
if
(
objectMap
.
get
(
"
deptCode
"
)
!=
null
&&
!
objectMap
.
get
(
"sjgsdwdm"
).
toString
().
startsWith
(
appStore
.
getDeptCode
().
replaceAll
(
"0+$"
,
""
)))
{
if
(
objectMap
.
get
(
"
sjgsdwdm
"
)
!=
null
&&
!
objectMap
.
get
(
"sjgsdwdm"
).
toString
().
startsWith
(
appStore
.
getDeptCode
().
replaceAll
(
"0+$"
,
""
)))
{
write
(
response
,
"AppId和传入的单位不匹配,appId:"
+
appId
+
",deptCode:"
+
objectMap
.
get
(
"deptCode"
));
return
false
;
}
...
...
src/main/java/com/zksy/szpt/handler/SzptMetaObjectHandler.java
View file @
744dd937
...
...
@@ -13,6 +13,7 @@ import java.util.List;
/**
* 自动填充 create_time, update_time 字段
* 该类策略如下:有值则不填充,无值则填充写入值,
*/
@Component
public
class
SzptMetaObjectHandler
implements
MetaObjectHandler
{
...
...
@@ -67,7 +68,7 @@ public class SzptMetaObjectHandler implements MetaObjectHandler {
StrictFill
.
of
(
"update_ip"
,
String
.
class
,
currentUserInfo
.
getIp
())
// StrictFill.of("del_flag", Integer.class,0)
);
this
.
strict
Insert
Fill
(
findTableInfo
(
metaObject
),
metaObject
,
fields
);
this
.
strict
Update
Fill
(
findTableInfo
(
metaObject
),
metaObject
,
fields
);
// this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
}
}
src/main/java/com/zksy/szpt/service/AppStoreService.java
View file @
744dd937
...
...
@@ -41,4 +41,9 @@ public class AppStoreService {
}
return
null
;
}
public
Integer
updateAppStore
(
AppStoreDTO
appStoreDTO
)
{
AppStore
appStore
=
BeanMapperUtil
.
map
(
appStoreDTO
,
AppStore
.
class
);
return
appStoreMapper
.
update
(
appStore
,
new
LambdaQueryWrapper
<
AppStore
>().
eq
(
AppStore:
:
getAppKey
,
appStore
.
getAppKey
()));
}
}
src/main/java/com/zksy/szpt/service/XxShxxyDwService.java
View file @
744dd937
...
...
@@ -2,7 +2,7 @@ package com.zksy.szpt.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxShxxyDwDTO
;
import
com.zksy.szpt.domain.po.XxShxxyDw
;
import
com.zksy.szpt.mapper.XxShxxyDwMapper
;
...
...
@@ -31,7 +31,7 @@ public class XxShxxyDwService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxShxxyDw
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxShxxyDw:
:
getId
,
dto
.
getIds
());
return
xxShxxyDwMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/service/XxShxxyService.java
View file @
744dd937
...
...
@@ -2,7 +2,7 @@ package com.zksy.szpt.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxShxxyDTO
;
import
com.zksy.szpt.domain.po.XxShxxy
;
import
com.zksy.szpt.mapper.XxShxxyMapper
;
...
...
@@ -31,7 +31,7 @@ public class XxShxxyService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxShxxy
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxShxxy:
:
getXxyid
,
dto
.
getIds
());
return
xxShxxyMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/service/XxYjdwdmService.java
View file @
744dd937
...
...
@@ -2,7 +2,7 @@ package com.zksy.szpt.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxYjdwdmDTO
;
import
com.zksy.szpt.domain.po.XxYjdwdm
;
import
com.zksy.szpt.mapper.XxYjdwdmMapper
;
...
...
@@ -30,7 +30,7 @@ public class XxYjdwdmService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxYjdwdm
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxYjdwdm:
:
getId
,
dto
.
getIds
());
return
xxYjdwdmMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/service/XxYjrwService.java
View file @
744dd937
...
...
@@ -3,6 +3,7 @@ package com.zksy.szpt.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDelParamDTO
;
import
com.zksy.szpt.domain.dto.XxYjrwDTO
;
import
com.zksy.szpt.domain.po.XxYjrw
;
import
com.zksy.szpt.mapper.XxYjrwMapper
;
...
...
@@ -30,7 +31,7 @@ public class XxYjrwService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxYjrw
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxYjrw:
:
getRwid
,
dto
.
getIds
());
return
xxYjrwMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/service/XxZhjfbgService.java
View file @
744dd937
...
...
@@ -2,13 +2,12 @@ package com.zksy.szpt.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.zksy.szpt.domain.dto.CommonDelDTO
;
import
com.zksy.szpt.domain.dto.CommonDel
Param
DTO
;
import
com.zksy.szpt.domain.dto.XxZhjfbgDTO
;
import
com.zksy.szpt.domain.po.XxZhjfbg
;
import
com.zksy.szpt.mapper.XxZhjfbgMapper
;
import
com.zksy.szpt.util.BeanMapperUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
javax.annotation.Resource
;
...
...
@@ -31,7 +30,7 @@ public class XxZhjfbgService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxZhjfbg
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxZhjfbg:
:
getDhid
,
dto
.
getIds
());
return
xxZhjfbgMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/service/XxZhxxService.java
View file @
744dd937
...
...
@@ -28,7 +28,7 @@ public class XxZhxxService {
}
public
Integer
delete
(
CommonDelDTO
dto
)
{
public
Integer
delete
(
CommonDel
Param
DTO
dto
)
{
LambdaQueryWrapper
<
XxZhxx
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
XxZhxx:
:
getZhid
,
dto
.
getIds
());
return
xxZhxxMapper
.
delete
(
wrapper
);
...
...
src/main/java/com/zksy/szpt/util/RedisKeyValidator.java
0 → 100644
View file @
744dd937
package
com
.
zksy
.
szpt
.
util
;
import
java.util.regex.Pattern
;
public
class
RedisKeyValidator
{
private
static
final
String
INVALID_CHARACTERS
=
"[\\x00\\x20\\x0A\\x0D\\x09]"
;
// 常见的无效字符
public
static
boolean
isValidKey
(
String
key
)
{
if
(
key
==
null
||
key
.
isEmpty
())
{
return
false
;
}
return
!
key
.
matches
(
INVALID_CHARACTERS
);
}
/**
*
* @param str
* @return
*/
public
static
boolean
isValidString
(
String
str
)
{
// 定义正则表达式,匹配字母、数字和下划线
String
regex
=
"\\w+"
;
return
Pattern
.
matches
(
regex
,
str
);
}
/**
* 检查是否为有效的秒级时间戳
* @param timestamp
* @return
*/
public
static
boolean
isValidTimestamp
(
String
timestamp
)
{
// 检查是否为数字
if
(!
timestamp
.
matches
(
"\\d+"
))
{
return
false
;
}
// 检查长度是否为10位(秒)
return
timestamp
.
length
()
==
10
;
}
}
src/test/java/com/zksy/szpt/MainTest.java
View file @
744dd937
...
...
@@ -29,7 +29,7 @@ public class MainTest {
String
nonce
=
"2"
;
String
timestampStr
=
"21"
;
String
appId
=
"1872576325743943682"
;
String
appSecret
=
"2
1
"
;
String
appSecret
=
"2"
;
@Resource
...
...
@@ -41,19 +41,19 @@ public class MainTest {
/**
* 任务完成情况
*/
@Test
//
@Test
@DisplayName
(
"任务完成情况"
)
public
void
xxRwwcqkTest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
// String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
Assertions
.
assertNotNull
(
appId
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxRwwcqkDTO
xxRwwcqkDTO
=
new
XxRwwcqkDTO
();
xxRwwcqkDTO
.
setRwid
(
"1234
56
"
);
xxRwwcqkDTO
.
setXxyid
(
"12345
6
"
);
xxRwwcqkDTO
.
setShrid
(
"12345
6
"
);
xxRwwcqkDTO
.
setRwid
(
"1234"
);
xxRwwcqkDTO
.
setXxyid
(
"12345"
);
xxRwwcqkDTO
.
setShrid
(
"12345"
);
xxRwwcqkDTO
.
setWczt
(
"1"
);
xxRwwcqkDTO
.
setBmzt
(
"1"
);
String
json
=
null
;
...
...
@@ -91,13 +91,13 @@ public class MainTest {
@DisplayName
(
"账户信息"
)
public
void
zhxxtest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxZhxxDTO
dto
=
new
XxZhxxDTO
();
dto
.
setZhid
(
"1234
56
"
);
dto
.
setZhid
(
"1234"
);
dto
.
setXxyid
(
"11"
);
dto
.
setZt
(
"2"
);
dto
.
setClbz
(
"2"
);
...
...
@@ -117,7 +117,7 @@ public class MainTest {
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhxx/
update
"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhxx/
add
"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
...
@@ -136,14 +136,14 @@ public class MainTest {
@DisplayName
(
"账户积分变更"
)
public
void
test1
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxZhjfbgDTO
dto
=
new
XxZhjfbgDTO
();
// dto.setZhid("1234
56
");
dto
.
setDhid
(
"1234
56
"
);
// dto.setZhid("1234");
dto
.
setDhid
(
"1234"
);
dto
.
setQbid
(
"2"
);
dto
.
setBgsj
(
new
Date
());
String
json
=
null
;
...
...
@@ -162,7 +162,7 @@ public class MainTest {
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhjfbg/
update
"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhjfbg/
add
"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
...
@@ -225,13 +225,13 @@ public class MainTest {
@DisplayName
(
"义警任务"
)
public
void
test4
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxYjrwDTO
dto
=
new
XxYjrwDTO
();
// dto.setZhid("1234
56
");
// dto.setZhid("1234");
dto
.
setRwid
(
"123456"
);
dto
.
setRwbt
(
"1"
);
dto
.
setRwnr
(
"11111"
);
...
...
@@ -273,15 +273,15 @@ public class MainTest {
@DisplayName
(
"义警队伍代码"
)
public
void
test5
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxYjdwdmDTO
dto
=
new
XxYjdwdmDTO
();
// dto.setZhid("1234
56
");
// dto.setZhid("1234");
dto
.
setDwlx
(
Integer
.
valueOf
(
1
));
dto
.
setId
(
"1"
);
dto
.
setId
(
"1
234
"
);
dto
.
setMchid
(
"11111"
);
dto
.
setZt
(
"1"
);
dto
.
setYjdwmc
(
"test"
);
...
...
@@ -301,7 +301,7 @@ public class MainTest {
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxYjdwdm/
update
"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/xxYjdwdm/
add
"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
...
@@ -317,14 +317,14 @@ public class MainTest {
@DisplayName
(
"社会信息员队伍"
)
public
void
test6
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDwDTO
dto
=
new
XxShxxyDwDTO
();
dto
.
setId
(
"1234
56
"
);
dto
.
setDwdm
(
"1234
56
"
);
dto
.
setShxxyid
(
"1234
56
"
);
dto
.
setId
(
"1234"
);
dto
.
setDwdm
(
"1234"
);
dto
.
setShxxyid
(
"1234"
);
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
dto
);
...
...
@@ -341,7 +341,7 @@ public class MainTest {
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxyDw/
update
"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxyDw/
add
"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
...
@@ -357,12 +357,12 @@ public class MainTest {
@DisplayName
(
"社会信息员"
)
public
void
test7
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDTO
dto
=
new
XxShxxyDTO
();
dto
.
setXxyid
(
"1234
56
"
);
dto
.
setXxyid
(
"1234"
);
dto
.
setZt
(
"1"
);
dto
.
setSbfszt
(
"1"
);
dto
.
setShrid
(
"1"
);
...
...
@@ -382,7 +382,7 @@ public class MainTest {
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxy/
update
"
)
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxy/
add
"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
...
...
@@ -399,15 +399,15 @@ public class MainTest {
@DisplayName
(
"删除服务"
)
public
void
testdelete
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
(
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
String
json
=
null
;
List
<
String
>
ids
=
new
ArrayList
<>();
ids
.
add
(
"1"
);
CommonDel
DTO
dto
=
new
CommonDel
DTO
();
ids
.
add
(
"1
234
"
);
ids
.
add
(
"12345"
);
CommonDel
ParamDTO
dto
=
new
CommonDelParam
DTO
();
dto
.
setIds
(
ids
);
try
{
...
...
@@ -430,10 +430,10 @@ public class MainTest {
// String url="xxYjdwdm/delete";
// String url="xxYjrw/delete";
//
String
url
=
"xxZhjfbg/delete"
;
//
String url="xxZhjfbg/delete";
//
//
String url = "xxZhxx/delete";
String
url
=
"xxZhxx/delete"
;
String
response
=
webClient
.
post
().
uri
(
"/rest/"
+
url
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
...
...
src/test/java/com/zksy/szpt/TestAppStore.java
0 → 100644
View file @
744dd937
package
com
.
zksy
.
szpt
;
import
cn.hutool.crypto.digest.DigestUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.zksy.szpt.domain.dto.*
;
import
com.zksy.szpt.util.EncryptUtil
;
import
com.zksy.szpt.util.SignatureUtil
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
reactor.core.publisher.Mono
;
import
javax.annotation.Resource
;
@SpringBootTest
()
public
class
TestAppStore
{
String
nonce
=
"2"
;
String
timestampStr
=
"21"
;
String
appId
=
"1872576325743943682"
;
String
appSecret
=
"2"
;
@Resource
private
ObjectMapper
objectMapper
;
/**
* 新增AppId
*/
@Test
@DisplayName
(
"新增AppId"
)
public
void
addAppId
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
Assertions
.
assertNotNull
(
appId
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
AppStoreDTO
appStoreDTO
=
new
AppStoreDTO
();
appStoreDTO
.
setAppKey
(
"us"
);
appStoreDTO
.
setAppSecret
(
DigestUtil
.
md5Hex
(
"us"
));
appStoreDTO
.
setDeptCode
(
"123456"
);
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
appStoreDTO
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
appSecret
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/appStore/insertAppStore"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
appStoreDTO
),
XxRwwcqkDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
@Test
@DisplayName
(
"更新AppId的密钥"
)
public
void
updateAppIdSecret
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
Assertions
.
assertNotNull
(
appId
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
AppStoreDTO
appStoreDTO
=
new
AppStoreDTO
();
appStoreDTO
.
setAppKey
(
"us"
);
appStoreDTO
.
setAppSecret
(
DigestUtil
.
md5Hex
(
"us11"
));
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
appStoreDTO
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
appSecret
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/appStore/updateAppIdSecret"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
appStoreDTO
),
XxRwwcqkDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
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