Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3-integration
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 816bd579
authored
May 13, 2022
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<fix>:优化
1 parent
e173bc41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
fanxing-docking-gb1400/src/main/java/com/viontech/controller/Gb1400Controller.java
fanxing-docking-gb1400/src/main/java/com/viontech/utils/Gb1400ResponseUtil.java
fanxing-docking-gb1400/src/main/java/com/viontech/controller/Gb1400Controller.java
View file @
816bd57
...
...
@@ -7,6 +7,7 @@ import com.viontech.utils.Gb1400ResponseUtil;
import
com.viontech.utils.JsonMessage
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.HandlerMapping
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -14,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@RestController
...
...
@@ -71,17 +73,50 @@ public class Gb1400Controller {
* @param ID
* @return
*/
// @RequestMapping(value = "/Subscribes/{ID}" ,method = RequestMethod.PUT)
// @ResponseBody
// public JSONObject unSubscribes(@PathVariable String ID, @RequestBody String params){
// log.info("收到请求[unSubscribes.request]:{}-{}", ID, params);
// JsonMessage vo = gb1400Service.unSubscribes(ID, params);
// log.info("响应[unSubscribes.request]:{}-{}", ID, JSONObject.toJSONString(vo));
// if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
// return Gb1400ResponseUtil.success("/VIID/Subscribes/" + ID);
// } else {
// return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes/" + ID);
// }
// }
/**
* 取消订阅
* @return
*/
@RequestMapping
(
value
=
"/Subscribes/{ID}"
,
method
=
RequestMethod
.
PUT
)
@ResponseBody
public
JSONObject
unSubscribes
(
@PathVariable
String
ID
,
@RequestBody
String
params
){
log
.
info
(
"收到请求[unSubscribes.request]:{}-{}"
,
ID
,
params
);
JsonMessage
vo
=
gb1400Service
.
unSubscribes
(
ID
,
params
);
public
void
unSubscribes
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
Map
attribute
=
(
Map
)
request
.
getAttribute
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
);
String
ID
=
""
;
if
(
attribute
!=
null
&&
attribute
.
containsKey
(
"ID"
))
{
ID
=
(
String
)
attribute
.
get
(
"ID"
);
}
BufferedReader
br
=
request
.
getReader
();
String
str
;
StringBuilder
params
=
new
StringBuilder
();
while
((
str
=
br
.
readLine
())
!=
null
){
params
.
append
(
str
);
}
log
.
info
(
"收到请求[unSubscribes.request]:{}-{}"
,
ID
,
params
.
toString
());
JsonMessage
vo
=
gb1400Service
.
unSubscribes
(
ID
,
params
.
toString
());
log
.
info
(
"响应[unSubscribes.request]:{}-{}"
,
ID
,
JSONObject
.
toJSONString
(
vo
));
JSONObject
result
=
null
;
response
.
setContentType
(
"application/VIID+JSON;charset=utf-8"
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
vo
.
getCode
())
{
re
turn
Gb1400ResponseUtil
.
success
(
"/VIID/Subscribes/"
+
ID
);
re
sult
=
Gb1400ResponseUtil
.
success
(
ID
,
"/VIID/Subscribes/"
+
ID
);
}
else
{
re
turn
Gb1400ResponseUtil
.
error
(
1
,
vo
.
getMsg
(),
"/VIID/Subscribes/"
+
ID
);
re
sult
=
Gb1400ResponseUtil
.
error
(
ID
,
1
,
vo
.
getMsg
(),
"/VIID/Subscribes/"
+
ID
);
}
response
.
getWriter
().
write
(
result
.
toJSONString
());
}
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/utils/Gb1400ResponseUtil.java
View file @
816bd57
...
...
@@ -85,4 +85,16 @@ public class Gb1400ResponseUtil {
result
.
put
(
"ResponseStatusObject"
,
response
);
return
result
;
}
public
static
JSONObject
error
(
String
id
,
Integer
errorNo
,
String
errorMsg
,
String
requestURL
)
{
JSONObject
response
=
new
JSONObject
();
response
.
put
(
"Id"
,
id
);
response
.
put
(
"LocalTime"
,
new
Date
());
response
.
put
(
"RequestURL"
,
requestURL
);
response
.
put
(
"StatusCode"
,
errorNo
);
response
.
put
(
"StatusString"
,
errorMsg
);
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"ResponseStatusObject"
,
response
);
return
result
;
}
}
\ No newline at end of file
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