Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cneeds-server
Overview
Overview
Details
Activity
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
zhangzr
cneeds-server
Commits
f1fdc4b3
Commit
f1fdc4b3
authored
Mar 05, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.渠道号
2.跨域等 3.认证问题
parent
bde8517c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
213 additions
and
5 deletions
+213
-5
workspace.xml
.idea/workspace.xml
+0
-0
JwtToken.java
...pojo/src/main/java/com/mx/cneeds/common/dto/JwtToken.java
+2
-0
R.java
...mon-pojo/src/main/java/com/mx/cneeds/common/result/R.java
+0
-0
DeviceChannelVo.java
...rc/main/java/com/mx/cneeds/common/vo/DeviceChannelVo.java
+37
-0
UserInfoVo.java
...ojo/src/main/java/com/mx/cneeds/common/vo/UserInfoVo.java
+21
-0
pom.xml
cneeds-common-utils/pom.xml
+6
-0
FeignInterceptor.java
...om/mx/cneeds/server/datashow/config/FeignInterceptor.java
+1
-1
OAuth2ResourceServer.java
...x/cneeds/server/datashow/config/OAuth2ResourceServer.java
+3
-1
WebConfig.java
.../java/com/mx/cneeds/server/datashow/config/WebConfig.java
+40
-0
CrossFilter.java
...ava/com/mx/cneeds/server/datashow/filter/CrossFilter.java
+48
-0
DeviceController.java
...x/cneeds/server/datashow/web/device/DeviceController.java
+30
-0
UserController.java
...om/mx/cneeds/server/datashow/web/user/UserController.java
+25
-3
No files found.
.idea/workspace.xml
View file @
f1fdc4b3
This diff is collapsed.
Click to expand it.
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/dto/JwtToken.java
View file @
f1fdc4b3
...
...
@@ -24,4 +24,6 @@ public class JwtToken implements Serializable {
private
String
scope
;
private
String
jti
;
private
String
token
;
}
cneeds-common-
utils
/src/main/java/com/mx/cneeds/common/result/R.java
→
cneeds-common-
pojo
/src/main/java/com/mx/cneeds/common/result/R.java
View file @
f1fdc4b3
File moved
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/vo/DeviceChannelVo.java
0 → 100644
View file @
f1fdc4b3
package
com
.
mx
.
cneeds
.
common
.
vo
;
import
lombok.Data
;
/**
* @ClassName DeviceChannelVo
* @Author zzrdark
* @Date 2020-03-05 14:46
* @Description TODO
**/
@Data
public
class
DeviceChannelVo
{
/**
* 渠道号
*/
private
String
channelNums
;
/**
* 提示信息
*/
private
String
channelNumsMessage
;
/**
* 名单规则
*/
private
Integer
channelRules
;
public
DeviceChannelVo
(
String
channelNums
,
String
channelNumsMessage
,
Integer
channelRules
)
{
this
.
channelNums
=
channelNums
;
this
.
channelNumsMessage
=
channelNumsMessage
;
this
.
channelRules
=
channelRules
;
}
public
DeviceChannelVo
()
{
}
}
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/vo/UserInfoVo.java
0 → 100644
View file @
f1fdc4b3
package
com
.
mx
.
cneeds
.
common
.
vo
;
import
lombok.Data
;
/**
* @ClassName UserInfoVo
* @Author zzrdark
* @Date 2020-01-19 17:07
* @Description TODO
**/
@Data
public
class
UserInfoVo
{
private
String
roles
;
private
String
name
;
private
String
avatar
;
private
String
introduction
;
}
cneeds-common-utils/pom.xml
View file @
f1fdc4b3
...
...
@@ -43,5 +43,10 @@
<version>
${commons.io.version}
</version>
</dependency>
<dependency>
<groupId>
com.mx.cneeds
</groupId>
<artifactId>
cneeds-common-pojo
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/Feign
Config
.java
→
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/Feign
Interceptor
.java
View file @
f1fdc4b3
...
...
@@ -19,7 +19,7 @@ import javax.servlet.http.HttpServletRequest;
**/
@Configuration
@Slf4j
public
class
Feign
Config
implements
RequestInterceptor
{
public
class
Feign
Interceptor
implements
RequestInterceptor
{
@Override
public
void
apply
(
RequestTemplate
requestTemplate
)
{
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/OAuth2ResourceServer.java
View file @
f1fdc4b3
...
...
@@ -18,7 +18,9 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
@Override
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
antMatchers
(
"/user/login"
)
.
antMatchers
(
"/user/login"
,
"/device/getChannel_nums"
,
"/statics/**"
)
.
permitAll
()
// 开启认证
.
anyRequest
()
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/WebConfig.java
0 → 100644
View file @
f1fdc4b3
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
mx
.
cneeds
.
server
.
datashow
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* WebMvc配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"/statics/**"
).
addResourceLocations
(
"classpath:/statics/"
);
}
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedOrigins
(
"*"
)
.
allowedMethods
(
"GET"
,
"HEAD"
,
"POST"
,
"PUT"
,
"DELETE"
,
"OPTIONS"
)
.
allowCredentials
(
true
)
.
maxAge
(
3600
)
.
allowedHeaders
(
"*"
);
}
}
\ No newline at end of file
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/filter/CrossFilter.java
0 → 100644
View file @
f1fdc4b3
package
com
.
mx
.
cneeds
.
server
.
datashow
.
filter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Configuration
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* @ClassName CrossFilter
* @Author zzrdark
* @Date 2020-01-17 19:22
* @Description TODO
**/
@WebFilter
(
filterName
=
"CorsFilter"
)
@Configuration
@Slf4j
public
class
CrossFilter
implements
Filter
{
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
}
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
filterChain
)
throws
IOException
,
ServletException
{
HttpServletRequest
httpServletRequest
=
(
HttpServletRequest
)
request
;
log
.
info
(
httpServletRequest
.
getRequestURL
().
toString
());
// log.info(httpServletRequest.getHeader("Access-Control-Allow-Origin"));
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
httpResponse
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Methods"
,
"*"
);
httpResponse
.
setHeader
(
"Access-Control-Max-Age"
,
"3600"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Headers"
,
"Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie, Authorization"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
// httpResponse.setHeader("Content-type", "application/json");
httpResponse
.
setHeader
(
"Cache-Control"
,
"no-cache, must-revalidate"
);
filterChain
.
doFilter
(
request
,
httpResponse
);
}
@Override
public
void
destroy
()
{
}
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/device/DeviceController.java
0 → 100644
View file @
f1fdc4b3
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
device
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.vo.DeviceChannelVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @ClassName DeviceController
* @Author zzrdark
* @Date 2020-03-05 14:42
* @Description TODO
**/
@RestController
@Slf4j
@RequestMapping
(
"/device"
)
public
class
DeviceController
{
@GetMapping
(
"/getChannel_nums"
)
public
R
getChannel_nums
(
String
imei
){
DeviceChannelVo
channelVo
=
new
DeviceChannelVo
(
"123456,112233,654321"
,
"提示的信息"
,
0
);
return
new
R
().
put
(
"data"
,
channelVo
);
}
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/user/UserController.java
View file @
f1fdc4b3
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
user
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.vo.UserInfoVo
;
import
com.mx.cneeds.server.datashow.client.AuthorizationClient
;
import
com.mx.cneeds.common.dto.JwtToken
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -24,11 +26,31 @@ public class UserController {
@Autowired
private
AuthorizationClient
authenticatorClient
;
@GetMapping
(
"/login"
)
public
JwtToken
login
(
String
username
,
String
password
){
/**
* 登陆接口
* @param username
* @param password
* @return
*/
@RequestMapping
(
"/login"
)
public
R
login
(
String
username
,
String
password
){
JwtToken
token
=
authenticatorClient
.
getToken
(
"password"
,
username
,
password
,
"all"
);
token
.
setToken
(
token
.
getTokenType
()+
" "
+
token
.
getAccessToken
());
log
.
info
(
token
.
toString
());
return
token
;
return
new
R
().
put
(
"data"
,
token
)
;
}
@RequestMapping
(
"/info"
)
public
UserInfoVo
getInfo
(){
UserInfoVo
userInfoVo
=
new
UserInfoVo
();
log
.
info
(
"getInfo"
);
userInfoVo
.
setName
(
"admin"
);
userInfoVo
.
setIntroduction
(
"manager"
);
userInfoVo
.
setRoles
(
"admin"
);
userInfoVo
.
setAvatar
(
"avatar"
);
return
userInfoVo
;
}
}
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