Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
tjmdp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
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
other-project
tjmdp
Commits
8f8fa6a9
Commit
8f8fa6a9
authored
Apr 23, 2019
by
liuchao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://fywlsoft.cn:50379/other-project/tjmdp
parents
a779a6f4
729db3d3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
214 additions
and
7 deletions
+214
-7
UserController.java
src/main/java/com/qiankun/controller/UserController.java
+2
-1
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+156
-0
User.java
src/main/java/com/qiankun/entity/User.java
+7
-2
DecryptedDataVo.java
src/main/java/com/qiankun/vo/DecryptedDataVo.java
+32
-0
PaperIdLoginVo.java
src/main/java/com/qiankun/vo/PaperIdLoginVo.java
+9
-0
UserVo.java
src/main/java/com/qiankun/vo/UserVo.java
+8
-4
No files found.
src/main/java/com/qiankun/controller/UserController.java
View file @
8f8fa6a9
...
...
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.UserUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -232,7 +233,7 @@ public class UserController extends BaseController<Object>{
user
.
getContacts
().
add
(
contacts2
);
User
u
=
userService
.
save
(
user
);
map
.
put
(
"user"
,
u
);
map
.
put
(
"user"
,
UserUtils
.
converToVo
(
u
)
);
map
.
put
(
"sKey"
,
tokenUtil
.
generateToken
(
u
.
getOpenid
()));
return
map
;
}
...
...
src/main/java/com/qiankun/controller/mdp/MdpController.java
View file @
8f8fa6a9
package
com
.
qiankun
.
controller
.
mdp
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.api.WxMaUserService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Maps
;
import
com.qiankun.annotation.Auth
;
import
com.qiankun.config.WxMaConfiguration
;
import
com.qiankun.config.WxMaProperties
;
import
com.qiankun.dao.UserDao
;
import
com.qiankun.entity.Contacts
;
import
com.qiankun.entity.User
;
import
com.qiankun.service.UserService
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.UserUtils
;
import
com.qiankun.vo.DecryptedDataVo
;
import
com.qiankun.vo.PaperIdLoginVo
;
import
com.qiankun.vo.UserVo
;
import
com.sun.mail.imap.ResyncData
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.ResourceBundle
;
import
java.util.Set
;
@RestController
@RequestMapping
(
"/wx/mdp"
)
...
...
@@ -37,6 +53,7 @@ public class MdpController {
private
String
getAppid
(){
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
}
private
String
uploadAvatarPath
=
File
.
separator
+
"mdp"
+
File
.
separator
+
"uploadAvatar"
;
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -76,12 +93,18 @@ public class MdpController {
User
user
=
userService
.
findByPaperId
(
vo
.
getPaperId
(),
vo
.
getPaperType
());
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
if
(
user
==
null
){
//新用户
result
.
put
(
"isExist"
,
false
);
}
else
{
//老用户
if
(!
user
.
getName
().
equals
(
vo
.
getName
())){
result
.
put
(
"errorMsg"
,
"姓名与库中信息不符,请核实后重新提交"
);
}
else
{
user
.
setOpenid
(
vo
.
getOpenid
());
if
(!
Strings
.
isNullOrEmpty
(
vo
.
getPhone
())){
//更新微信绑定的手机号
user
.
setMobile
(
vo
.
getPhone
());
}
userService
.
save
(
user
);
result
.
put
(
"sKey"
,
tokenUtil
.
generateToken
(
user
.
getOpenid
()));
result
.
put
(
"userInfo"
,
UserUtils
.
converToVo
(
user
));
...
...
@@ -101,5 +124,138 @@ public class MdpController {
User
user
=
userService
.
findByOpenid
(
openid
);
return
UserUtils
.
converToVo
(
user
);
}
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/decryptedData"
,
method
=
RequestMethod
.
POST
)
public
Map
<
String
,
Object
>
decryptedData
(
@RequestBody
DecryptedDataVo
dataVo
){
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
final
WxMaService
wxService
=
WxMaConfiguration
.
getMaService
(
getAppid
());
try
{
WxMaJscode2SessionResult
session
=
wxService
.
getUserService
().
getSessionInfo
(
dataVo
.
getCode
());
WxMaUserService
wxUserService
=
wxService
.
getUserService
();
WxMaPhoneNumberInfo
phoneInfo
=
wxUserService
.
getPhoneNoInfo
(
session
.
getSessionKey
(),
dataVo
.
getEncryptedData
(),
dataVo
.
getIv
());
result
.
put
(
"status"
,
"ok"
);
result
.
put
(
"phoneInfo"
,
phoneInfo
);
}
catch
(
WxErrorException
e
)
{
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"微信登陆失败"
);
}
return
result
;
}
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/uploadAvatar"
,
method
=
RequestMethod
.
POST
)
public
Map
<
String
,
String
>
uploadAvatar
(
MultipartFile
file
,
@RequestHeader
String
sKey
){
Map
<
String
,
String
>
result
=
Maps
.
newConcurrentMap
();
if
(
Strings
.
isNullOrEmpty
(
sKey
)){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"请求参数错误"
);
return
result
;
}
String
openid
=
tokenUtil
.
getUsernameFromToken
(
sKey
);
User
user
=
userService
.
findByOpenid
(
openid
);
if
(
user
==
null
){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"用户不存在"
);
return
result
;
}
try
{
if
(
file
!=
null
&&
!
file
.
isEmpty
()){
String
originalFileName
=
file
.
getOriginalFilename
();
String
rootPath
=
rb
.
getString
(
"file_path"
);
File
destFile
=
new
File
(
rootPath
+
uploadAvatarPath
,
originalFileName
);
FileUtils
.
writeByteArrayToFile
(
destFile
,
file
.
getBytes
());
user
.
setAvatarImage
(
uploadAvatarPath
+
File
.
separator
+
originalFileName
);
userService
.
save
(
user
);
result
.
put
(
"status"
,
"ok"
);
result
.
put
(
"avatarImage"
,
user
.
getAvatarImage
());
}
else
{
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"上传文件不存在"
);
return
result
;
}
}
catch
(
IOException
e
){
logger
.
error
(
e
.
getMessage
(),
e
);
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"上传文件失败"
);
}
return
result
;
}
/**
* 获取用户积分、参与的活动等相关信息
* @param sKey
* @return
*/
@Auth
(
verifyURL
=
false
,
verifyLogin
=
false
)
@RequestMapping
(
value
=
"/userActivityInfo"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
Object
>
getUserActivityInfo
(
@RequestHeader
String
sKey
){
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
if
(
Strings
.
isNullOrEmpty
(
sKey
)){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"请求参数错误"
);
return
result
;
}
String
openid
=
tokenUtil
.
getUsernameFromToken
(
sKey
);
User
user
=
userService
.
findByOpenid
(
openid
);
if
(
user
==
null
){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"用户不存在"
);
return
result
;
}
if
(
Strings
.
isNullOrEmpty
(
user
.
getName
())
||
Strings
.
isNullOrEmpty
(
user
.
getBirthday
())
||
Strings
.
isNullOrEmpty
(
user
.
getPaperType
())
||
Strings
.
isNullOrEmpty
(
user
.
getPaperId
())
||
Strings
.
isNullOrEmpty
(
user
.
getNation
())
||
Strings
.
isNullOrEmpty
(
user
.
getNationality
())
||
Strings
.
isNullOrEmpty
(
user
.
getNativePlace
())
||
Strings
.
isNullOrEmpty
(
user
.
getAddr
())
||
Strings
.
isNullOrEmpty
(
user
.
getMobile
())
||
Strings
.
isNullOrEmpty
(
user
.
getQq
())
||
!
validateContacts
(
user
)){
result
.
put
(
"userInfoStatus"
,
"unComplete"
);
}
else
{
result
.
put
(
"userInfoStatus"
,
"complete"
);
}
result
.
put
(
"points"
,
getUserPoints
(
user
));
result
.
put
(
"status"
,
"ok"
);
return
result
;
}
/**
* 获取用户积分
* @param user
* @return
*/
private
int
getUserPoints
(
User
user
){
return
0
;
}
private
boolean
validateContacts
(
User
user
){
boolean
flag
=
true
;
Set
<
Contacts
>
sets
=
user
.
getContacts
();
if
(
sets
==
null
){
flag
=
false
;
}
else
{
Iterator
<
Contacts
>
it
=
sets
.
iterator
();
while
(
it
.
hasNext
()){
Contacts
c
=
it
.
next
();
if
(
Strings
.
isNullOrEmpty
(
c
.
getName
())
||
Strings
.
isNullOrEmpty
(
c
.
getRelation
())
||
Strings
.
isNullOrEmpty
(
c
.
getMobile
())){
flag
=
false
;
break
;
}
}
}
return
flag
;
}
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/loadResource"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
byte
[]>
loadResource
(
@RequestParam
String
imageName
)
throws
IOException
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
File
file
=
new
File
(
rb
.
getString
(
"file_path"
),
imageName
);
return
new
ResponseEntity
<>(
FileUtils
.
readFileToByteArray
(
file
),
headers
,
HttpStatus
.
OK
);
}
}
src/main/java/com/qiankun/entity/User.java
View file @
8f8fa6a9
...
...
@@ -70,6 +70,7 @@ public class User {
private
String
role
;
//角色 1.管理员 2.志愿者
private
String
status
;
//状态 1.未采血 2.已采血 3退库 4 再次采血
private
boolean
login
=
false
;
//是否可以登后台;
private
String
avatarImage
;
//头像
private
Date
createTime
=
new
Date
();
private
Date
updateTime
=
new
Date
();
...
...
@@ -353,7 +354,11 @@ public class User {
this
.
login
=
login
;
}
public
String
getAvatarImage
()
{
return
avatarImage
;
}
public
void
setAvatarImage
(
String
avatarImage
)
{
this
.
avatarImage
=
avatarImage
;
}
}
src/main/java/com/qiankun/vo/DecryptedDataVo.java
0 → 100644
View file @
8f8fa6a9
package
com
.
qiankun
.
vo
;
public
class
DecryptedDataVo
{
private
String
encryptedData
;
private
String
iv
;
private
String
code
;
public
String
getEncryptedData
()
{
return
encryptedData
;
}
public
void
setEncryptedData
(
String
encryptedData
)
{
this
.
encryptedData
=
encryptedData
;
}
public
String
getIv
()
{
return
iv
;
}
public
void
setIv
(
String
iv
)
{
this
.
iv
=
iv
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
}
src/main/java/com/qiankun/vo/PaperIdLoginVo.java
View file @
8f8fa6a9
...
...
@@ -5,6 +5,7 @@ public class PaperIdLoginVo {
private
String
paperId
;
private
String
name
;
private
String
openid
;
private
String
phone
;
//微信绑定的手机号
public
String
getPaperType
()
{
return
paperType
;
...
...
@@ -37,4 +38,12 @@ public class PaperIdLoginVo {
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
}
src/main/java/com/qiankun/vo/UserVo.java
View file @
8f8fa6a9
...
...
@@ -60,6 +60,7 @@ public class UserVo {
private
String
searchStr
;
private
String
order
;
private
String
sort
;
private
String
avatarImage
;
//头像
public
String
getId
()
{
return
id
;
...
...
@@ -359,8 +360,11 @@ public class UserVo {
this
.
userCode
=
userCode
;
}
public
String
getAvatarImage
()
{
return
avatarImage
;
}
public
void
setAvatarImage
(
String
avatarImage
)
{
this
.
avatarImage
=
avatarImage
;
}
}
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