Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
ca00070b
Commit
ca00070b
authored
Jun 13, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口调整,跨域问题真正解决
parent
1115ec57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
89 deletions
+17
-89
CorsConfig.java
.../src/main/java/iot/sixiang/license/config/CorsConfig.java
+3
-7
MonitorController.java
...ava/iot/sixiang/license/controller/MonitorController.java
+0
-41
OperateController.java
...ava/iot/sixiang/license/controller/OperateController.java
+11
-37
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+3
-4
No files found.
license/src/main/java/iot/sixiang/license/config/CorsConfig.java
View file @
ca00070b
...
@@ -12,16 +12,12 @@ public class CorsConfig implements WebMvcConfigurer {
...
@@ -12,16 +12,12 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
// 设置允许跨域的路径
registry
.
addMapping
(
"/**"
)
registry
.
addMapping
(
"/**"
)
// 设置允许跨域请求的域名
.
allowedOriginPatterns
(
"*"
)
.
allowedOriginPatterns
(
"*"
)
// 是否允许证书 不再默认开启
.
allowCredentials
(
true
)
// 设置允许的方法
.
allowedMethods
(
"*"
)
.
allowedMethods
(
"*"
)
// 跨域允许时间
.
allowCredentials
(
true
)
.
maxAge
(
3600
);
.
maxAge
(
3600
)
.
allowedHeaders
(
"*"
);
}
}
@Override
@Override
...
...
license/src/main/java/iot/sixiang/license/controller/MonitorController.java
deleted
100644 → 0
View file @
1115ec57
package
iot
.
sixiang
.
license
.
controller
;
import
iot.sixiang.license.entity.Monitor
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.service.MonitorService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDate
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping
(
"/iot_license/monitor"
)
public
class
MonitorController
{
@Autowired
private
MonitorService
monitorService
;
@PostMapping
(
"add"
)
public
boolean
addMonitor
(){
return
monitorService
.
addMonitor
(
20
);
}
@GetMapping
(
"list"
)
public
ResResult
getMonitorList
(
@RequestParam
(
"type"
)
int
type
)
{
HashMap
<
String
,
List
<
Integer
>>
monitorList
=
monitorService
.
getMonitorList
(
type
);
return
ResResult
.
success
().
record
(
monitorList
);
}
}
license/src/main/java/iot/sixiang/license/controller/OperateController.java
View file @
ca00070b
package
iot
.
sixiang
.
license
.
controller
;
package
iot
.
sixiang
.
license
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.model.SamMonitor
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.service.
Alarm
Service
;
import
iot.sixiang.license.service.
Monitor
Service
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.
ArrayList
;
import
java.util.
HashMap
;
import
java.util.List
;
import
java.util.List
;
@Slf4j
@Slf4j
...
@@ -22,49 +18,27 @@ public class OperateController {
...
@@ -22,49 +18,27 @@ public class OperateController {
@Autowired
@Autowired
private
OperateManager
operateManager
;
private
OperateManager
operateManager
;
@Autowired
@Autowired
private
AlarmService
alarm
Service
;
private
MonitorService
monitor
Service
;
@GetMapping
(
"monitor/server"
)
@GetMapping
(
"monitor/server"
)
public
ResResult
getDeviceTypes
()
{
public
ResResult
getDeviceTypes
()
{
// List<JSONObject> list = new ArrayList<>();
// JSONObject obj = new JSONObject();
// obj.put("serverIp", "192.168.1.11");
// obj.put("samCount", 100);
// obj.put("onlineCount",55);
// list.add(obj);
// JSONObject obj2 = new JSONObject();
// obj2.put("serverIp", "192.168.1.12");
// obj2.put("samCount", 100);
// obj2.put("onlineCount",55);
// list.add(obj2);
List
<
SamMonitor
>
records
=
operateManager
.
getSamMonitorList
();
List
<
SamMonitor
>
records
=
operateManager
.
getSamMonitorList
();
return
ResResult
.
success
().
record
(
records
);
return
ResResult
.
success
().
record
(
records
);
}
}
@PostMapping
(
"monitor/add"
)
public
boolean
addMonitor
()
{
return
monitorService
.
addMonitor
(
20
);
}
@GetMapping
(
"monitor/qps"
)
@GetMapping
(
"monitor/qps"
)
public
ResResult
getQps
(
@RequestParam
(
"type"
)
int
type
)
{
public
ResResult
getQps
(
@RequestParam
(
"type"
)
int
type
)
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
HashMap
<
String
,
List
<
Integer
>>
monitorList
=
monitorService
.
getMonitorList
(
type
);
JSONObject
obj
=
new
JSONObject
();
return
ResResult
.
success
().
record
(
monitorList
);
obj
.
put
(
"x"
,
1
);
obj
.
put
(
"y"
,
2
);
list
.
add
(
obj
);
JSONObject
obj2
=
new
JSONObject
();
obj2
.
put
(
"x"
,
2
);
obj2
.
put
(
"y"
,
2
);
list
.
add
(
obj2
);
JSONObject
obj3
=
new
JSONObject
();
obj2
.
put
(
"x"
,
3
);
obj2
.
put
(
"y"
,
3
);
list
.
add
(
obj3
);
return
ResResult
.
success
().
record
(
list
);
}
}
}
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
ca00070b
...
@@ -5,6 +5,7 @@ import com.auth0.jwt.interfaces.Claim;
...
@@ -5,6 +5,7 @@ import com.auth0.jwt.interfaces.Claim;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.ResResult
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.annotation.WebFilter
;
...
@@ -30,12 +31,10 @@ public class JwtFilter implements Filter {
...
@@ -30,12 +31,10 @@ public class JwtFilter implements Filter {
final
HttpServletRequest
request
=
(
HttpServletRequest
)
servletRequest
;
final
HttpServletRequest
request
=
(
HttpServletRequest
)
servletRequest
;
final
HttpServletResponse
response
=
(
HttpServletResponse
)
servletResponse
;
final
HttpServletResponse
response
=
(
HttpServletResponse
)
servletResponse
;
response
.
setContentType
(
"text/html; charset=utf-8"
);
response
.
setContentType
(
"text/html; charset=utf-8"
);
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
addHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
response
.
addHeader
(
"Access-Control-Allow-Methods"
,
"GET, HEAD, POST, PUT, DELETE, OPTIONS, PATCH"
);
if
(
"OPTIONS"
.
equals
(
request
.
getMethod
()))
{
if
(
"OPTIONS"
.
equals
(
request
.
getMethod
()))
{
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
filterChain
.
doFilter
(
request
,
response
);
return
;
}
}
String
token
=
request
.
getHeader
(
"authorization"
);
String
token
=
request
.
getHeader
(
"authorization"
);
...
...
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