Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
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 933cfc22
authored
May 11, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
接口请求方式修改
1 parent
20bcfd35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
68 deletions
src/main/java/cn/com/glsx/smart/common/filter/ChejiaCorsFilter.java
src/main/java/cn/com/glsx/smart/modules/controller/ProductController.java
src/main/java/cn/com/glsx/smart/modules/controller/ProductTypeController.java
src/main/java/cn/com/glsx/smart/modules/controller/RemoteProductController.java
src/main/java/cn/com/glsx/smart/common/filter/ChejiaCorsFilter.java
deleted
100644 → 0
View file @
20bcfd3
package
cn
.
com
.
glsx
.
smart
.
common
.
filter
;
import
com.glsx.plat.common.utils.StringUtils
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Enumeration
;
/**
* <p>Description: 跨域配置
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-18
*/
//@Component
public
class
ChejiaCorsFilter
implements
Filter
{
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
HttpServletRequest
httpRequest
=
(
HttpServletRequest
)
request
;
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
StringBuffer
headersSb
=
new
StringBuffer
();
Enumeration
<
String
>
headerNames
=
httpRequest
.
getHeaderNames
();
while
(
headerNames
.
hasMoreElements
())
{
headersSb
.
append
(
headerNames
.
nextElement
()).
append
(
", "
);
}
if
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
CONTENT_TYPE
))
{
headersSb
.
append
(
HttpHeaders
.
CONTENT_TYPE
).
append
(
", "
);
}
if
(!
StringUtils
.
containsIgnoreCase
(
headersSb
,
HttpHeaders
.
AUTHORIZATION
))
{
headersSb
.
append
(
HttpHeaders
.
AUTHORIZATION
).
append
(
", "
);
}
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
headersSb
.
toString
().
replaceAll
(
", +$"
,
""
));
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
httpRequest
.
getHeader
(
HttpHeaders
.
ORIGIN
));
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
httpRequest
.
getMethod
());
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_EXPOSE_HEADERS
,
"*"
);
httpResponse
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"18000L"
);
// 放行预检请求(preflight requests)
if
(
httpRequest
.
getMethod
().
equalsIgnoreCase
(
HttpMethod
.
OPTIONS
.
toString
()))
{
httpResponse
.
setStatus
(
HttpServletResponse
.
SC_OK
);
httpResponse
.
getWriter
().
println
(
"OK"
);
return
;
}
chain
.
doFilter
(
request
,
response
);
}
}
src/main/java/cn/com/glsx/smart/modules/controller/ProductController.java
View file @
933cfc2
...
@@ -66,7 +66,7 @@ public class ProductController {
...
@@ -66,7 +66,7 @@ public class ProductController {
* @param req 请求体
* @param req 请求体
* @return 结果
* @return 结果
*/
*/
@
Ge
tMapping
(
"/getListByCondition"
)
@
Pos
tMapping
(
"/getListByCondition"
)
public
R
getListByCondition
(
@RequestBody
ProductReq
req
)
{
public
R
getListByCondition
(
@RequestBody
ProductReq
req
)
{
log
.
info
(
"/product/getListByCondition param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"/product/getListByCondition param: {}"
,
JSON
.
toJSONString
(
req
));
List
<
SmartProduct
>
productList
=
productService
.
getListByCondition
(
req
);
List
<
SmartProduct
>
productList
=
productService
.
getListByCondition
(
req
);
...
...
src/main/java/cn/com/glsx/smart/modules/controller/ProductTypeController.java
View file @
933cfc2
...
@@ -91,7 +91,7 @@ public class ProductTypeController {
...
@@ -91,7 +91,7 @@ public class ProductTypeController {
*
*
* @return 结果
* @return 结果
*/
*/
@
Ge
tMapping
(
"/getListAndContent"
)
@
Pos
tMapping
(
"/getListAndContent"
)
public
R
getListAndContent
(
@RequestBody
List
<
Long
>
list
)
{
public
R
getListAndContent
(
@RequestBody
List
<
Long
>
list
)
{
List
<
SmartProductType
>
contentList
=
productTypeService
.
getListAndContent
(
list
);
List
<
SmartProductType
>
contentList
=
productTypeService
.
getListAndContent
(
list
);
List
<
ProductTypeResponse
>
responseList
=
new
ArrayList
<>();
List
<
ProductTypeResponse
>
responseList
=
new
ArrayList
<>();
...
@@ -104,7 +104,7 @@ public class ProductTypeController {
...
@@ -104,7 +104,7 @@ public class ProductTypeController {
*
*
* @return 结果
* @return 结果
*/
*/
@
Ge
tMapping
(
"/getListAndCondition"
)
@
Pos
tMapping
(
"/getListAndCondition"
)
public
R
getListAndCondition
(
@RequestBody
List
<
Long
>
list
)
{
public
R
getListAndCondition
(
@RequestBody
List
<
Long
>
list
)
{
List
<
SmartProductType
>
conditionList
=
productTypeService
.
getListAndCondition
(
list
);
List
<
SmartProductType
>
conditionList
=
productTypeService
.
getListAndCondition
(
list
);
List
<
ProductTypeResponse
>
responseList
=
new
ArrayList
<>();
List
<
ProductTypeResponse
>
responseList
=
new
ArrayList
<>();
...
...
src/main/java/cn/com/glsx/smart/modules/controller/RemoteProductController.java
View file @
933cfc2
...
@@ -23,11 +23,11 @@ import org.apache.commons.collections.CollectionUtils;
...
@@ -23,11 +23,11 @@ import org.apache.commons.collections.CollectionUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
...
@@ -57,8 +57,7 @@ public class RemoteProductController {
...
@@ -57,8 +57,7 @@ public class RemoteProductController {
*
*
* @return 结果
* @return 结果
*/
*/
@ResponseBody
@PostMapping
(
value
=
"/getList"
)
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getList
(
@RequestBody
UserRelationRequest
relationRequest
)
{
public
R
getList
(
@RequestBody
UserRelationRequest
relationRequest
)
{
log
.
info
(
"用户参数:{}"
,
JSON
.
toJSONString
(
relationRequest
));
log
.
info
(
"用户参数:{}"
,
JSON
.
toJSONString
(
relationRequest
));
SmartUserRelation
request
=
new
SmartUserRelation
();
SmartUserRelation
request
=
new
SmartUserRelation
();
...
@@ -120,8 +119,7 @@ public class RemoteProductController {
...
@@ -120,8 +119,7 @@ public class RemoteProductController {
*
*
* @return 结果
* @return 结果
*/
*/
@ResponseBody
@GetMapping
(
value
=
"/findRemotes"
)
@RequestMapping
(
value
=
"/findRemotes"
,
method
=
{
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"查询红外设备下的遥控器"
)
@ApiOperation
(
value
=
"查询红外设备下的遥控器"
)
public
String
findRemotes
(
@RequestParam
String
infrared_id
)
{
public
String
findRemotes
(
@RequestParam
String
infrared_id
)
{
return
productTypeService
.
findRemotesById
(
infrared_id
);
return
productTypeService
.
findRemotesById
(
infrared_id
);
...
...
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