Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pension
Project
Project
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
mengmeng
pension
Commits
24a54ae4
Commit
24a54ae4
authored
Mar 17, 2021
by
mlchun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.添加微信登录,返回token
parent
447b86e6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
132 additions
and
20 deletions
+132
-20
SwaggerConfig.java
hmit-api/src/main/java/io/hmit/config/SwaggerConfig.java
+1
-1
ApiLoginController.java
.../src/main/java/io/hmit/controller/ApiLoginController.java
+14
-0
WeChatController.java
...pi/src/main/java/io/hmit/controller/WeChatController.java
+53
-0
UserDao.java
hmit-api/src/main/java/io/hmit/dao/UserDao.java
+2
-0
PensionOrderController.java
...dules/serviceOrder/controller/PensionOrderController.java
+3
-2
PensionOrderEvaluationController.java
...iceOrder/controller/PensionOrderEvaluationController.java
+1
-1
PensionOrderServiceImpl.java
...es/serviceOrder/service/impl/PensionOrderServiceImpl.java
+1
-1
UserService.java
hmit-api/src/main/java/io/hmit/service/UserService.java
+10
-0
PushMessageImpl.java
...i/src/main/java/io/hmit/service/impl/PushMessageImpl.java
+8
-5
UserServiceImpl.java
...i/src/main/java/io/hmit/service/impl/UserServiceImpl.java
+26
-1
application.yml
hmit-api/src/main/resources/application.yml
+9
-9
UserDao.xml
hmit-api/src/main/resources/mapper/UserDao.xml
+4
-0
No files found.
hmit-api/src/main/java/io/hmit/config/SwaggerConfig.java
View file @
24a54ae4
...
...
@@ -27,7 +27,7 @@ public class SwaggerConfig {
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
host
(
"byyl.zjhmit.com"
)
//
.host("byyl.zjhmit.com")
.
apiInfo
(
apiInfo
())
.
select
()
//加了ApiOperation注解的类,才生成接口文档
...
...
hmit-api/src/main/java/io/hmit/controller/ApiLoginController.java
View file @
24a54ae4
...
...
@@ -13,6 +13,7 @@ import io.hmit.service.UserService;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
springfox.documentation.annotations.ApiIgnore
;
...
...
@@ -24,6 +25,8 @@ import java.util.Map;
*
* @author zsh 408538940@qq.com
*/
@Slf4j
@RestController
@RequestMapping
(
"/api"
)
@Api
(
tags
=
"登录接口"
)
...
...
@@ -48,6 +51,17 @@ public class ApiLoginController {
return
new
Result
().
ok
(
map
);
}
@RequestMapping
(
"login"
)
@ApiOperation
(
"登录"
)
public
Result
<
Map
<
String
,
Object
>>
login
(
@RequestParam
(
"openid"
)
String
openid
)
{
log
.
info
(
"【微信网页授权】openId={}"
,
openid
);
//用户登录
Map
<
String
,
Object
>
map
=
userService
.
login
(
openid
);
return
new
Result
().
ok
(
map
);
}
@Login
@PostMapping
(
"logout"
)
@ApiOperation
(
"退出"
)
...
...
hmit-api/src/main/java/io/hmit/controller/WeChatController.java
0 → 100644
View file @
24a54ae4
package
io
.
hmit
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.api.WxConsts
;
import
me.chanjar.weixin.common.exception.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.net.URLEncoder
;
/**
* @Description :
* @Author : Shen Yuanfeng
* @Date: 2021/3/17 15:32
*/
@Slf4j
@Controller
@RequestMapping
(
"/wechat"
)
public
class
WeChatController
{
@Autowired
private
WxMpService
wxMpService
;
@GetMapping
(
"/authorize"
)
public
String
authorize
(
/*@RequestParam("returnUrl") String returnUrl*/
)
{
String
returnUrl
=
"http://byyl.zjhmit.com/hmit-api/api/login"
;
String
url
=
"http://byyl.zjhmit.com/hmit-api/wechat/authcode"
;
String
redirectUrl
=
wxMpService
.
oauth2buildAuthorizationUrl
(
url
,
WxConsts
.
OAUTH2_SCOPE_BASE
,
URLEncoder
.
encode
(
returnUrl
));
log
.
info
(
"【微信网页授权】获取code,redirectUrl={}"
,
redirectUrl
);
return
"redirect:"
+
redirectUrl
;
}
@GetMapping
(
"/authcode"
)
public
String
userInfo
(
@RequestParam
(
"code"
)
String
code
,
@RequestParam
(
"state"
)
String
returnUrl
)
{
log
.
info
(
"【微信网页授权】code={}, returnUrl={}"
,
code
,
returnUrl
);
WxMpOAuth2AccessToken
wxMpOAuth2AccessToken
=
new
WxMpOAuth2AccessToken
();
try
{
wxMpOAuth2AccessToken
=
wxMpService
.
oauth2getAccessToken
(
code
);
}
catch
(
WxErrorException
e
){
log
.
error
(
"【微信网页授权】错误{}"
,
e
.
getMessage
());
}
String
openid
=
wxMpOAuth2AccessToken
.
getOpenId
();
return
"redirect:"
+
returnUrl
+
"?openid="
+
openid
;
}
}
hmit-api/src/main/java/io/hmit/dao/UserDao.java
View file @
24a54ae4
...
...
@@ -18,6 +18,8 @@ public interface UserDao extends BaseDao<UserEntity> {
UserEntity
getUserByUserId
(
Long
userId
);
UserEntity
getUserByOpenId
(
String
openId
);
List
<
Long
>
getAllOrganizationStaff
(
Long
userId
);
}
hmit-api/src/main/java/io/hmit/modules/serviceOrder/controller/PensionOrderController.java
View file @
24a54ae4
...
...
@@ -226,7 +226,8 @@ public class PensionOrderController {
try
{
todto
=
URLDecoder
.
decode
(
dto
,
"UTF-8"
);
}
catch
(
Exception
ignored
){}
StaffFinishDTO
staffFinishDTO
=
JSON
.
parseObject
(
todto
.
substring
(
4
),
StaffFinishDTO
.
class
);
// StaffFinishDTO staffFinishDTO = JSON.parseObject(todto.substring(4), StaffFinishDTO.class);
StaffFinishDTO
staffFinishDTO
=
JSON
.
parseObject
(
todto
,
StaffFinishDTO
.
class
);
pensionOrderService
.
staffFinishedOrder
(
staffFinishDTO
);
return
new
Result
();
}
...
...
@@ -317,7 +318,7 @@ public class PensionOrderController {
try
{
todto
=
URLDecoder
.
decode
(
dto
,
"UTF-8"
);
}
catch
(
Exception
ignored
){}
ReservationDTO
reservationDTO
=
JSON
.
parseObject
(
todto
.
substring
(
4
)
,
ReservationDTO
.
class
);
ReservationDTO
reservationDTO
=
JSON
.
parseObject
(
todto
,
ReservationDTO
.
class
);
PensionOrderDTO
data
=
new
PensionOrderDTO
().
assemblePensionOrder
(
reservationDTO
,
user
);
data
.
setCommunityId
(
user
.
getCommunityId
());
...
...
hmit-api/src/main/java/io/hmit/modules/serviceOrder/controller/PensionOrderEvaluationController.java
View file @
24a54ae4
...
...
@@ -74,7 +74,7 @@ public class PensionOrderEvaluationController {
try
{
todto
=
URLDecoder
.
decode
(
dto
,
"UTF-8"
);
}
catch
(
Exception
ignored
){}
PensionOrderEvaluationDTO
pensionOrderEvaluationDTO
=
JSON
.
parseObject
(
todto
.
substring
(
4
)
,
PensionOrderEvaluationDTO
.
class
);
PensionOrderEvaluationDTO
pensionOrderEvaluationDTO
=
JSON
.
parseObject
(
todto
,
PensionOrderEvaluationDTO
.
class
);
pensionOrderEvaluationDTO
.
setFile
(
StringUtils
.
join
(
pensionOrderEvaluationDTO
.
getFiles
(),
","
));
pensionOrderEvaluationService
.
save
(
pensionOrderEvaluationDTO
);
...
...
hmit-api/src/main/java/io/hmit/modules/serviceOrder/service/impl/PensionOrderServiceImpl.java
View file @
24a54ae4
...
...
@@ -89,7 +89,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
save
(
pensionOrderDTO
);
PensionOrderServiceDTO
orderServiceDTO
=
new
PensionOrderServiceDTO
().
assemblePensionOrderService
(
pensionOrderDTO
);
pensionOrderServiceService
.
save
(
orderServiceDTO
);
//
pushMessage.sendWeChatMsg(pensionOrderDTO, userService.getUserByUserId(pensionOrderDTO.getCreator()).getOpenid());
pushMessage
.
sendWeChatMsg
(
pensionOrderDTO
,
userService
.
getUserByUserId
(
pensionOrderDTO
.
getCreator
()).
getOpenid
());
// pushMessage.sendSMSMsg(pensionOrderDTO, userService.getUserByUserId(pensionOrderDTO.getCreator()).getOpenid());
}
...
...
hmit-api/src/main/java/io/hmit/service/UserService.java
View file @
24a54ae4
...
...
@@ -17,6 +17,8 @@ public interface UserService extends BaseService<UserEntity> {
UserEntity
getByMobile
(
String
mobile
);
UserEntity
getByOpenId
(
String
mobile
);
UserEntity
getUserByUserId
(
Long
userId
);
/**
...
...
@@ -27,6 +29,14 @@ public interface UserService extends BaseService<UserEntity> {
*/
Map
<
String
,
Object
>
login
(
LoginDTO
dto
);
/**
* 用户登录
*
* @param openid 免登
* @return 返回登录信息
*/
Map
<
String
,
Object
>
login
(
String
openid
);
PageData
<
UserEntity
>
getOrganizationAllUsers
(
Map
<
String
,
Object
>
params
,
Long
userId
);
}
hmit-api/src/main/java/io/hmit/service/impl/PushMessageImpl.java
View file @
24a54ae4
...
...
@@ -45,11 +45,16 @@ public class PushMessageImpl implements PushMessage {
templateMessage
.
setTemplateId
(
wechatAccountConfig
.
getTemplateId
());
templateMessage
.
setToUser
(
openId
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm"
);
String
appointmentTime
=
sdf
.
format
(
pensionOrderDTO
.
getAppointmentTime
());
List
<
WxMpTemplateData
>
data
=
Arrays
.
asList
(
new
WxMpTemplateData
(
"first"
,
"
订单预约成功!
"
),
new
WxMpTemplateData
(
"first"
,
"
【智慧养老】您的订单提醒
"
),
new
WxMpTemplateData
(
"keyword1"
,
pensionOrderDTO
.
getServiceName
()),
new
WxMpTemplateData
(
"keyword2"
,
pensionOrderDTO
.
getAppointmentTime
().
toString
()),
new
WxMpTemplateData
(
"keyword3"
,
pensionOrderDTO
.
getStatusName
())
new
WxMpTemplateData
(
"keyword2"
,
pensionOrderDTO
.
getId
().
toString
()),
new
WxMpTemplateData
(
"keyword3"
,
pensionOrderDTO
.
getServiceName
()),
new
WxMpTemplateData
(
"keyword4"
,
appointmentTime
),
new
WxMpTemplateData
(
"remark"
,
"备注:"
+
pensionOrderDTO
.
getRemark
())
);
templateMessage
.
setData
(
data
);
try
{
...
...
@@ -62,8 +67,6 @@ public class PushMessageImpl implements PushMessage {
@Override
public
void
sendSMSMsg
(
PensionOrderDTO
pensionOrderDTO
,
String
receiver
)
{
try
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdfYMD
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdfHms
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
String
ymd
=
sdfYMD
.
format
(
pensionOrderDTO
.
getAppointmentTime
());
...
...
hmit-api/src/main/java/io/hmit/service/impl/UserServiceImpl.java
View file @
24a54ae4
...
...
@@ -36,6 +36,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return
baseDao
.
getUserByMobile
(
mobile
);
}
@Override
public
UserEntity
getByOpenId
(
String
openId
)
{
return
baseDao
.
getUserByOpenId
(
openId
);
}
@Override
public
UserEntity
getUserByUserId
(
Long
userId
)
{
return
baseDao
.
getUserByUserId
(
userId
);
...
...
@@ -43,7 +48,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Override
public
Map
<
String
,
Object
>
login
(
LoginDTO
dto
)
{
UserEntity
user
=
getByMobile
(
dto
.
getMobile
());
AssertUtils
.
isNull
(
user
,
ErrorCode
.
ACCOUNT_PASSWORD_ERROR
);
...
...
@@ -62,6 +66,27 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return
map
;
}
/**
* 用户登录
*
* @param openId 免登
* @return 返回登录信息
*/
@Override
public
Map
<
String
,
Object
>
login
(
String
openId
)
{
UserEntity
user
=
getByOpenId
(
openId
);
AssertUtils
.
isNull
(
user
,
ErrorCode
.
ACCOUNT_PASSWORD_ERROR
);
//获取登录token
TokenEntity
tokenEntity
=
tokenService
.
createToken
(
user
.
getId
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
map
.
put
(
"token"
,
tokenEntity
.
getToken
());
map
.
put
(
"expire"
,
tokenEntity
.
getExpireDate
().
getTime
()
-
System
.
currentTimeMillis
());
return
map
;
}
@Override
public
PageData
<
UserEntity
>
getOrganizationAllUsers
(
Map
<
String
,
Object
>
params
,
Long
userId
)
{
IPage
<
UserEntity
>
page
=
getPage
(
params
,
Constant
.
CREATE_DATE
,
false
);
...
...
hmit-api/src/main/resources/application.yml
View file @
24a54ae4
...
...
@@ -38,11 +38,11 @@ spring:
max-wait
:
-1ms
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle
:
10
# 连接池中的最大空闲连接
min-idle
:
5
# 连接池中的最小空闲连接
mvc
:
static-path-pattern
:
/static/**
resources
:
static-locations
:
file:${QR.download-path},classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/
#静态资源对外暴露的访问路径
#
mvc:
#
static-path-pattern: /static/**
#
resources:
#
static-locations: file:${QR.download-path},classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/
#
#静态资源对外暴露的访问路径
hmit
:
redis
:
...
...
@@ -72,9 +72,9 @@ mybatis-plus:
jdbc-type-for-null
:
'
null'
QR
:
# download-path: D:/123/ /home/websoft/java_jar/pension_service/myfile/
download-path
:
/home/websoft/java_jar/pension_service/myfile
/
download-path
:
D:/123
/
wechat
:
mpAppId
:
wxfa2386639794d998
mpAppSecret
:
8f624f83c9585baa9d1697e24fdffd81
templateId
:
GsGydVGl-vzOv5aA0LaIdA-FcMM88TEpe37U-lZ6HJ8
\ No newline at end of file
mpAppId
:
wx6e3288074243a47f
mpAppSecret
:
603d6ebf4db906bdb24eb9a1c0cbb444
templateId
:
_7PQQku6jHU4yE42NZIbX9cyvRWeeMSAGKhhs0uzWYM
\ No newline at end of file
hmit-api/src/main/resources/mapper/UserDao.xml
View file @
24a54ae4
...
...
@@ -11,6 +11,10 @@
select * from tb_user where id = #{value}
</select>
<select
id=
"getUserByOpenId"
resultType=
"io.hmit.entity.UserEntity"
>
select * from tb_user where openid = #{value}
</select>
<select
id=
"getAllOrganizationStaff"
resultType=
"Long"
>
SELECT user_id FROM pension_organization_user
WHERE organization_id = (SELECT organization_id FROM pension_organization_user
...
...
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