Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-miniappserver
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 a9c90d1c
authored
Mar 25, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
微信小程序后端服务
1 parent
aa553e14
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
90 additions
and
11 deletions
pom.xml
src/main/java/cn/com/glsx/app/config/WebConfig.java
src/main/java/cn/com/glsx/app/modules/ThirdLoginController.java
src/main/java/cn/com/glsx/app/modules/controller/VehicleMonitorController.java
src/main/java/cn/com/glsx/app/modules/model/LoginByAccountBO.java
src/main/java/cn/com/glsx/app/modules/model/VehicleLocationDTO.java
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
src/main/java/cn/com/glsx/app/modules/service/UserService.java
src/main/java/cn/com/glsx/app/modules/service/VehicleMonitorService.java
src/main/resources/mapper/UserWechatAccountMapper.xml
pom.xml
View file @
a9c90d1
...
@@ -44,6 +44,13 @@
...
@@ -44,6 +44,13 @@
<version>
1.1.0-SNAPSHOT
</version>
<version>
1.1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
<!-- devicemonitor-api -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
ne-shield-devicemonitor-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/cn/com/glsx/app/config/WebConfig.java
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
config
;
package
cn
.
com
.
glsx
.
app
.
config
;
import
cn.com.glsx.auth.interceptor.WebRequestAuthorizeInterceptor
;
import
cn.com.glsx.auth.interceptor.WebRequestAuthorizeInterceptor
;
import
com.google.common.collect.Lists
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
/**
/**
* @author payu
* @author payu
*/
*/
...
@@ -31,6 +34,10 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -31,6 +34,10 @@ public class WebConfig implements WebMvcConfigurer {
.
addPathPatterns
(
"/**"
)
.
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/"
)
.
excludePathPatterns
(
"/"
)
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/wechatAuth"
)
.
excludePathPatterns
(
"/wechatLogin"
)
.
excludePathPatterns
(
"/qqAuth"
)
.
excludePathPatterns
(
"/qqLogin"
)
.
excludePathPatterns
(
"/xactuator/**"
)
.
excludePathPatterns
(
"/xactuator/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
"/swagger-resources/**"
,
"/webjars/**"
,
"/v2/**"
,
"/swagger-ui.html/**"
);
.
excludePathPatterns
(
"/swagger-resources/**"
,
"/webjars/**"
,
"/v2/**"
,
"/swagger-ui.html/**"
);
...
...
src/main/java/cn/com/glsx/app/modules/ThirdLoginController.java
View file @
a9c90d1
...
@@ -41,11 +41,10 @@ public class ThirdLoginController {
...
@@ -41,11 +41,10 @@ public class ThirdLoginController {
private
WxMaService
wxMaService
;
private
WxMaService
wxMaService
;
@NoLogin
@NoLogin
@
Reques
tMapping
(
value
=
"/wechatAuth"
)
@
Ge
tMapping
(
value
=
"/wechatAuth"
)
public
R
wechatAuth
(
@RequestParam
String
code
)
throws
WxErrorException
{
public
R
wechatAuth
(
@RequestParam
String
code
)
throws
WxErrorException
{
//获取openId、unionid、session_key
//获取openId、unionid、session_key
WxMaJscode2SessionResult
sessionInfo
=
wxMaService
.
getUserService
().
getSessionInfo
(
code
);
WxMaJscode2SessionResult
sessionInfo
=
wxMaService
.
getUserService
().
getSessionInfo
(
code
);
log
.
info
(
"微信code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
sessionInfo
));
log
.
info
(
"微信code[{}]获取的Session信息为{}"
,
code
,
JSONUtil
.
toJsonStr
(
sessionInfo
));
UserAuthRel
authRel
=
loginService
.
wechatAuth
(
sessionInfo
);
UserAuthRel
authRel
=
loginService
.
wechatAuth
(
sessionInfo
);
...
@@ -66,7 +65,7 @@ public class ThirdLoginController {
...
@@ -66,7 +65,7 @@ public class ThirdLoginController {
}
}
@NoLogin
@NoLogin
@
Reques
tMapping
(
value
=
"/qqAuth"
)
@
Ge
tMapping
(
value
=
"/qqAuth"
)
public
R
qqAuth
(
@RequestParam
String
code
)
{
public
R
qqAuth
(
@RequestParam
String
code
)
{
QQOAuth2AccessToken
accessToken
=
new
QQOAuth2AccessToken
();
QQOAuth2AccessToken
accessToken
=
new
QQOAuth2AccessToken
();
...
@@ -79,7 +78,7 @@ public class ThirdLoginController {
...
@@ -79,7 +78,7 @@ public class ThirdLoginController {
}
}
@NoLogin
@NoLogin
@
Reque
stMapping
(
value
=
"/qqLogin"
)
@
Po
stMapping
(
value
=
"/qqLogin"
)
public
R
qqLogin
(
@RequestBody
QQLoginBO
loginBO
)
{
public
R
qqLogin
(
@RequestBody
QQLoginBO
loginBO
)
{
log
.
info
(
"QQ授权参数 {}"
,
loginBO
.
toString
());
log
.
info
(
"QQ授权参数 {}"
,
loginBO
.
toString
());
UserAuthRel
qqAuthRel
=
loginService
.
qqLogin
(
loginBO
);
UserAuthRel
qqAuthRel
=
loginService
.
qqLogin
(
loginBO
);
...
@@ -100,7 +99,7 @@ public class ThirdLoginController {
...
@@ -100,7 +99,7 @@ public class ThirdLoginController {
rtnMap
.
put
(
"token"
,
token
);
rtnMap
.
put
(
"token"
,
token
);
rtnMap
.
put
(
"user"
,
user
);
rtnMap
.
put
(
"user"
,
user
);
}
else
{
}
else
{
//没有绑定用户
//没有绑定用户
,跳转登录界面登录,回传此id
rtnMap
.
put
(
"authRelId"
,
authRel
.
getId
());
rtnMap
.
put
(
"authRelId"
,
authRel
.
getId
());
}
}
return
rtnMap
;
return
rtnMap
;
...
...
src/main/java/cn/com/glsx/app/modules/controller/VehicleMonitorController.java
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
import
cn.com.glsx.app.modules.model.VehicleDeviceDTO
;
import
cn.com.glsx.app.modules.model.VehicleDeviceDTO
;
import
cn.com.glsx.app.modules.model.VehicleLocationDTO
;
import
cn.com.glsx.app.modules.service.VehicleMonitorService
;
import
cn.com.glsx.app.modules.service.VehicleMonitorService
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -9,6 +10,7 @@ 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.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.List
;
...
@@ -28,9 +30,15 @@ public class VehicleMonitorController {
...
@@ -28,9 +30,15 @@ public class VehicleMonitorController {
*/
*/
@ApiOperation
(
value
=
"车辆树"
)
@ApiOperation
(
value
=
"车辆树"
)
@GetMapping
(
"/search"
)
@GetMapping
(
"/search"
)
public
R
<
List
>
search
(
String
term
)
{
public
R
<
List
<
VehicleDeviceDTO
>
>
search
(
String
term
)
{
List
<
VehicleDeviceDTO
>
list
=
vehicleMonitorService
.
search
(
term
);
List
<
VehicleDeviceDTO
>
list
=
vehicleMonitorService
.
search
(
term
);
return
R
.
ok
().
data
(
list
);
return
R
.
ok
().
data
(
list
);
}
}
@GetMapping
(
"/location"
)
public
R
location
(
@RequestParam
(
"sns"
)
String
sns
)
{
List
<
VehicleLocationDTO
>
vehicleLocations
=
vehicleMonitorService
.
getVehicleLocations
(
sns
);
return
R
.
ok
().
data
(
vehicleLocations
);
}
}
}
src/main/java/cn/com/glsx/app/modules/model/LoginByAccountBO.java
View file @
a9c90d1
...
@@ -20,6 +20,11 @@ public class LoginByAccountBO {
...
@@ -20,6 +20,11 @@ public class LoginByAccountBO {
@NotBlank
(
message
=
"验证码/密码不能为空"
)
@NotBlank
(
message
=
"验证码/密码不能为空"
)
private
String
code
;
private
String
code
;
/**
* 第三方授权关联id
*/
private
Long
authRelId
;
// @NotNull(message = "APP客户端ID不能为空")
// @NotNull(message = "APP客户端ID不能为空")
// private String clientId;
// private String clientId;
...
...
src/main/java/cn/com/glsx/app/modules/model/VehicleLocationDTO.java
0 → 100644
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
modules
.
model
;
import
lombok.Data
;
@Data
public
class
VehicleLocationDTO
{
}
src/main/java/cn/com/glsx/app/modules/service/LoginService.java
View file @
a9c90d1
...
@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
...
@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Objects
;
@Service
@Service
public
class
LoginService
{
public
class
LoginService
{
...
@@ -54,6 +56,17 @@ public class LoginService {
...
@@ -54,6 +56,17 @@ public class LoginService {
if
(
localAuth
==
null
)
{
if
(
localAuth
==
null
)
{
throw
new
AppServerException
(
"请先开通登录权限"
);
throw
new
AppServerException
(
"请先开通登录权限"
);
}
}
//2022/3/25 绑定第三方授权
if
(!
Objects
.
isNull
(
loginBO
.
getAuthRelId
()))
{
UserAuthRel
authRel
=
authRelMapper
.
selectById
(
loginBO
.
getAuthRelId
());
if
(
authRel
!=
null
)
{
authRel
.
setUserId
(
simpleUser
.
getId
());
authRel
.
setUpdatedDate
(
new
Date
());
authRelMapper
.
updateByPrimaryKeySelective
(
authRel
);
}
}
return
UserConverter
.
INSTANCE
.
su2au
(
simpleUser
);
return
UserConverter
.
INSTANCE
.
su2au
(
simpleUser
);
}
else
if
(
loginBO
.
getLoginType
()
==
2
)
{
}
else
if
(
loginBO
.
getLoginType
()
==
2
)
{
//验证码校验
//验证码校验
...
...
src/main/java/cn/com/glsx/app/modules/service/UserService.java
View file @
a9c90d1
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
import
cn.com.glsx.app.common.exception.AppServerException
;
import
cn.com.glsx.app.modules.converter.UserConverter
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.app.modules.model.AppUser
;
import
cn.com.glsx.auth.api.AuthFeignClient
;
import
cn.com.glsx.auth.model.SimpleUser
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.lang.UUID
;
import
com.glsx.plat.common.utils.ObjectUtils
;
import
com.glsx.plat.common.utils.ObjectUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.jwt.util.JwtUtils
;
import
com.glsx.plat.jwt.util.JwtUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
javax.annotation.Resource
;
import
java.util.Map
;
import
java.util.Map
;
@Service
@Service
public
class
UserService
{
public
class
UserService
{
@
Resource
@
Autowired
private
JwtUtils
<
ComJwtUser
>
jwtUtils
;
private
JwtUtils
<
ComJwtUser
>
jwtUtils
;
@Autowired
private
AuthFeignClient
authFeignClient
;
/**
/**
* 生成带用户信息的token
* 生成带用户信息的token
*
*
...
@@ -36,8 +44,13 @@ public class UserService {
...
@@ -36,8 +44,13 @@ public class UserService {
return
jwtUtils
.
createToken
(
userMap
);
return
jwtUtils
.
createToken
(
userMap
);
}
}
public
AppUser
getAppUserByUserId
(
Long
aLong
)
{
public
AppUser
getAppUserByUserId
(
Long
userId
)
{
return
null
;
R
<
SimpleUser
>
userR
=
authFeignClient
.
getSimpleUserById
(
userId
);
SimpleUser
simpleUser
=
userR
.
getData
(
SimpleUser
.
class
);
if
(!
userR
.
isSuccess
()
||
simpleUser
==
null
)
{
throw
new
AppServerException
(
userR
.
getMessage
());
}
return
UserConverter
.
INSTANCE
.
su2au
(
simpleUser
);
}
}
}
}
src/main/java/cn/com/glsx/app/modules/service/VehicleMonitorService.java
View file @
a9c90d1
...
@@ -2,9 +2,16 @@ package cn.com.glsx.app.modules.service;
...
@@ -2,9 +2,16 @@ package cn.com.glsx.app.modules.service;
import
cn.com.glsx.app.modules.mapper.VehicleMapper
;
import
cn.com.glsx.app.modules.mapper.VehicleMapper
;
import
cn.com.glsx.app.modules.model.VehicleDeviceDTO
;
import
cn.com.glsx.app.modules.model.VehicleDeviceDTO
;
import
cn.com.glsx.app.modules.model.VehicleLocationDTO
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO
;
import
cn.com.glsx.devicemonitor.api.feign.GpsBsFeignService
;
import
com.glsx.plat.core.web.R
;
import
com.google.gson.reflect.TypeToken
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
...
@@ -13,8 +20,21 @@ public class VehicleMonitorService {
...
@@ -13,8 +20,21 @@ public class VehicleMonitorService {
@Resource
@Resource
private
VehicleMapper
vehicleMapper
;
private
VehicleMapper
vehicleMapper
;
@Autowired
private
GpsBsFeignService
gpsBsFeignService
;
public
List
<
VehicleDeviceDTO
>
search
(
String
term
)
{
public
List
<
VehicleDeviceDTO
>
search
(
String
term
)
{
return
vehicleMapper
.
search
(
term
);
return
vehicleMapper
.
search
(
term
);
}
}
public
List
<
VehicleLocationDTO
>
getVehicleLocations
(
String
sns
)
{
R
<
List
<
DeviceLocationDTO
>>
listR
=
gpsBsFeignService
.
listDeviceMonitorInfo
(
sns
,
null
);
List
<
DeviceLocationDTO
>
dataList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
DeviceLocationDTO
>>()
{
}.
getType
());
List
<
VehicleLocationDTO
>
retVehicleBoList
=
new
ArrayList
<>();
// TODO: 2022/3/25 转换
return
retVehicleBoList
;
}
}
}
src/main/resources/mapper/UserWechatAccountMapper.xml
View file @
a9c90d1
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"auth_id"
jdbcType=
"INTEGER"
property=
"authId"
/>
<result
column=
"auth_id"
jdbcType=
"INTEGER"
property=
"authId"
/>
<result
column=
"union_id"
jdbcType=
"VARCHAR"
property=
"unionId"
/>
<result
column=
"union_id"
jdbcType=
"VARCHAR"
property=
"unionId"
/>
<result
column=
"wechat_avatar"
jdbcType=
"VARCHAR"
property=
"
wechatA
vatar"
/>
<result
column=
"wechat_avatar"
jdbcType=
"VARCHAR"
property=
"
a
vatar"
/>
<result
column=
"wechat_name"
jdbcType=
"VARCHAR"
property=
"wechatName"
/>
<result
column=
"wechat_name"
jdbcType=
"VARCHAR"
property=
"wechatName"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
...
...
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