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
ad9edf08
Commit
ad9edf08
authored
Apr 23, 2019
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成个人信息传改和上传头像功能
parent
7c603f42
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
6 deletions
+66
-6
UserController.java
src/main/java/com/qiankun/controller/UserController.java
+2
-1
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+57
-2
UserVo.java
src/main/java/com/qiankun/vo/UserVo.java
+7
-3
No files found.
src/main/java/com/qiankun/controller/UserController.java
View file @
ad9edf08
...
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.UserUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -232,7 +233,7 @@ public class UserController extends BaseController<Object>{
...
@@ -232,7 +233,7 @@ public class UserController extends BaseController<Object>{
user
.
getContacts
().
add
(
contacts2
);
user
.
getContacts
().
add
(
contacts2
);
User
u
=
userService
.
save
(
user
);
User
u
=
userService
.
save
(
user
);
map
.
put
(
"user"
,
u
);
map
.
put
(
"user"
,
UserUtils
.
converToVo
(
u
)
);
map
.
put
(
"sKey"
,
tokenUtil
.
generateToken
(
u
.
getOpenid
()));
map
.
put
(
"sKey"
,
tokenUtil
.
generateToken
(
u
.
getOpenid
()));
return
map
;
return
map
;
}
}
...
...
src/main/java/com/qiankun/controller/mdp/MdpController.java
View file @
ad9edf08
...
@@ -9,6 +9,7 @@ import com.google.common.collect.Maps;
...
@@ -9,6 +9,7 @@ import com.google.common.collect.Maps;
import
com.qiankun.annotation.Auth
;
import
com.qiankun.annotation.Auth
;
import
com.qiankun.config.WxMaConfiguration
;
import
com.qiankun.config.WxMaConfiguration
;
import
com.qiankun.config.WxMaProperties
;
import
com.qiankun.config.WxMaProperties
;
import
com.qiankun.dao.UserDao
;
import
com.qiankun.entity.User
;
import
com.qiankun.entity.User
;
import
com.qiankun.service.UserService
;
import
com.qiankun.service.UserService
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.JwtTokenUtil
;
...
@@ -16,13 +17,22 @@ import com.qiankun.utils.UserUtils;
...
@@ -16,13 +17,22 @@ import com.qiankun.utils.UserUtils;
import
com.qiankun.vo.DecryptedDataVo
;
import
com.qiankun.vo.DecryptedDataVo
;
import
com.qiankun.vo.PaperIdLoginVo
;
import
com.qiankun.vo.PaperIdLoginVo
;
import
com.qiankun.vo.UserVo
;
import
com.qiankun.vo.UserVo
;
import
com.sun.mail.imap.ResyncData
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.ResourceBundle
;
import
java.util.ResourceBundle
;
...
@@ -40,7 +50,7 @@ public class MdpController {
...
@@ -40,7 +50,7 @@ public class MdpController {
private
String
getAppid
(){
private
String
getAppid
(){
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
}
}
private
Map
<
String
,
String
>
wxSessionKeyCache
=
Maps
.
newConcurrentMap
()
;
private
String
uploadAvatarPath
=
File
.
separator
+
"mdp"
+
File
.
separator
+
"uploadAvatar"
;
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
...
@@ -55,7 +65,6 @@ public class MdpController {
...
@@ -55,7 +65,6 @@ public class MdpController {
WxMaJscode2SessionResult
session
=
wxService
.
getUserService
().
getSessionInfo
(
code
);
WxMaJscode2SessionResult
session
=
wxService
.
getUserService
().
getSessionInfo
(
code
);
this
.
logger
.
info
(
session
.
getSessionKey
());
this
.
logger
.
info
(
session
.
getSessionKey
());
this
.
logger
.
info
(
session
.
getOpenid
());
this
.
logger
.
info
(
session
.
getOpenid
());
wxSessionKeyCache
.
put
(
session
.
getOpenid
(),
session
.
getSessionKey
());
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
User
userInfo
=
userService
.
findByOpenid
(
session
.
getOpenid
());
User
userInfo
=
userService
.
findByOpenid
(
session
.
getOpenid
());
...
@@ -129,5 +138,51 @@ public class MdpController {
...
@@ -129,5 +138,51 @@ public class MdpController {
}
}
return
result
;
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
;
}
@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/vo/UserVo.java
View file @
ad9edf08
...
@@ -60,6 +60,7 @@ public class UserVo {
...
@@ -60,6 +60,7 @@ public class UserVo {
private
String
searchStr
;
private
String
searchStr
;
private
String
order
;
private
String
order
;
private
String
sort
;
private
String
sort
;
private
String
avatarImage
;
//头像
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
...
@@ -359,8 +360,11 @@ public class UserVo {
...
@@ -359,8 +360,11 @@ public class UserVo {
this
.
userCode
=
userCode
;
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