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
81cf6e4e
Commit
81cf6e4e
authored
Apr 11, 2019
by
liuchao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://fywlsoft.cn:50379/other-project/tjmdp
parents
8c715f46
038e3099
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
10 deletions
+124
-10
WxMaProperties.java
src/main/java/com/qiankun/config/WxMaProperties.java
+7
-0
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+72
-0
RainbowPlanController.java
...qiankun/controller/rainbowplan/RainbowPlanController.java
+16
-0
UserDao.java
src/main/java/com/qiankun/dao/UserDao.java
+1
-0
UserDaoImpl.java
src/main/java/com/qiankun/dao/UserDaoImpl.java
+6
-0
User.java
src/main/java/com/qiankun/entity/User.java
+11
-8
UserService.java
src/main/java/com/qiankun/service/UserService.java
+4
-0
system.properties
src/main/resources/system.properties
+7
-2
No files found.
src/main/java/com/qiankun/config/WxMaProperties.java
View file @
81cf6e4e
...
...
@@ -29,6 +29,13 @@ public class WxMaProperties {
config
.
setSecret
(
rb
.
getString
(
"rainbowplan.secret"
));
configs
=
Lists
.
newArrayList
();
configs
.
add
(
config
);
Config
mdpConfig
=
new
Config
();
mdpConfig
.
setAppid
(
rb
.
getString
(
"tjmdp.appid"
));
mdpConfig
.
setSecret
(
rb
.
getString
(
"tjmdp.secret"
));
configs
.
add
(
mdpConfig
);
}
public
static
class
Config
{
...
...
src/main/java/com/qiankun/controller/mdp/MdpController.java
0 → 100644
View file @
81cf6e4e
package
com
.
qiankun
.
controller
.
mdp
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
com.google.common.collect.Maps
;
import
com.qiankun.annotation.Auth
;
import
com.qiankun.config.WxMaConfiguration
;
import
com.qiankun.config.WxMaProperties
;
import
com.qiankun.entity.User
;
import
com.qiankun.service.UserService
;
import
com.qiankun.utils.JwtTokenUtil
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Map
;
import
java.util.ResourceBundle
;
@RestController
@RequestMapping
(
"/wx/mdp"
)
public
class
MdpController
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MdpController
.
class
);
@Autowired
private
JwtTokenUtil
tokenUtil
;
@Autowired
private
WxMaProperties
propertis
;
@Autowired
private
UserService
userService
;
private
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"system"
);
private
String
getAppid
(){
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
}
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
Object
>
login
(
@RequestParam
String
code
){
if
(
StringUtils
.
isBlank
(
code
))
{
return
null
;
}
final
WxMaService
wxService
=
WxMaConfiguration
.
getMaService
(
getAppid
());
try
{
WxMaJscode2SessionResult
session
=
wxService
.
getUserService
().
getSessionInfo
(
code
);
this
.
logger
.
info
(
session
.
getSessionKey
());
this
.
logger
.
info
(
session
.
getOpenid
());
Map
<
String
,
Object
>
result
=
Maps
.
newConcurrentMap
();
User
userInfo
=
userService
.
findByOpenid
(
session
.
getOpenid
());
if
(
userInfo
!=
null
){
String
sKey
=
tokenUtil
.
generateToken
(
userInfo
.
getOpenid
());
result
.
put
(
"sKey"
,
sKey
);
result
.
put
(
"userInfo"
,
userInfo
);
}
else
{
result
.
put
(
"sKey"
,
""
);
result
.
put
(
"userInfo"
,
""
);
result
.
put
(
"openid"
,
session
.
getOpenid
());
}
return
result
;
}
catch
(
WxErrorException
e
)
{
this
.
logger
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
}
src/main/java/com/qiankun/controller/rainbowplan/RainbowPlanController.java
View file @
81cf6e4e
package
com
.
qiankun
.
controller
.
rainbowplan
;
import
cn.binarywang.wx.miniapp.api.WxMaQrcodeService
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
com.google.common.base.Strings
;
...
...
@@ -296,6 +297,21 @@ public class RainbowPlanController {
}
}
@Auth
(
verifyURL
=
false
,
verifyLogin
=
false
)
@RequestMapping
(
value
=
"/qrcode"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
byte
[]>
getQrcode
(
@RequestHeader
String
sKey
)
throws
WxErrorException
{
if
(
Strings
.
isNullOrEmpty
(
sKey
)){
throw
new
IllegalArgumentException
(
"请求参数错误"
);
}
String
openid
=
tokenUtil
.
getUsernameFromToken
(
sKey
);
WxMaService
wxMaService
=
WxMaConfiguration
.
getMaService
(
getAppid
());
WxMaQrcodeService
qrcodeService
=
wxMaService
.
getQrcodeService
();
byte
[]
codeBytes
=
qrcodeService
.
createWxaCodeUnlimitBytes
(
"inviter="
+
openid
,
"pages/register"
,
360
,
true
,
null
,
false
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
return
new
ResponseEntity
<
byte
[]>(
codeBytes
,
headers
,
HttpStatus
.
OK
);
}
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
@RequestMapping
(
value
=
"/loadResource"
,
method
=
RequestMethod
.
GET
)
...
...
src/main/java/com/qiankun/dao/UserDao.java
View file @
81cf6e4e
...
...
@@ -17,4 +17,5 @@ public interface UserDao extends IDao<User, String> {
Boolean
validateUserExistByUserName
(
String
userName
);
User
findByOpenid
(
String
openid
);
}
src/main/java/com/qiankun/dao/UserDaoImpl.java
View file @
81cf6e4e
...
...
@@ -26,6 +26,7 @@ public class UserDaoImpl extends AbsDao<User, String> implements UserDao {
private
static
final
String
VALIDATE_USERNAME
=
" from User where userName = ?"
;
private
static
final
String
VALIDATE_PWD
=
" from User where id = ? and pwd = ? and isRemove=false"
;
private
static
final
String
FIND_BY_OPENID
=
"from User where openid = ?"
;
@Override
public
Boolean
validateUserExistByPaperId
(
String
paperId
)
{
...
...
@@ -106,4 +107,9 @@ public class UserDaoImpl extends AbsDao<User, String> implements UserDao {
return
false
;
}
@Override
public
User
findByOpenid
(
String
openid
)
{
return
findUnique
(
FIND_BY_OPENID
,
new
Hints
(),
openid
);
}
}
src/main/java/com/qiankun/entity/User.java
View file @
81cf6e4e
...
...
@@ -51,7 +51,7 @@ public class User {
private
String
email
;
//邮箱
private
String
tel
;
//固定电话
private
String
qq
;
private
String
weixin
;
//微信号
private
String
openid
;
//微信openid
private
Integer
donateBloodCount
;
//无偿献血次数
private
String
bloodType
;
//血型
private
Integer
height
;
//身高
...
...
@@ -246,13 +246,16 @@ public class User {
public
void
setQq
(
String
qq
)
{
this
.
qq
=
qq
;
}
public
String
getWeixin
()
{
return
weixin
;
}
public
void
setWeixin
(
String
weixin
)
{
this
.
weixin
=
weixin
;
}
public
Integer
getDonateBloodCount
()
{
public
String
getOpenid
()
{
return
openid
;
}
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
public
Integer
getDonateBloodCount
()
{
return
donateBloodCount
;
}
public
void
setDonateBloodCount
(
Integer
donateBloodCount
)
{
...
...
src/main/java/com/qiankun/service/UserService.java
View file @
81cf6e4e
package
com
.
qiankun
.
service
;
import
org.dom4j.util.UserDataDocumentFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -54,4 +55,7 @@ public class UserService {
public
Boolean
validatePwd
(
String
id
,
String
password
)
{
return
userDao
.
validatePwd
(
id
,
MD5
.
digest
(
password
));
}
public
User
findByOpenid
(
String
openid
){
return
userDao
.
findByOpenid
(
openid
);
}
}
src/main/resources/system.properties
View file @
81cf6e4e
...
...
@@ -10,4 +10,9 @@ rainbowplan.appid=wxd097672957e48ba8
rainbowplan.secret
=
6500d648cc5715f8829dab993de746f3
rainbowplan.token
=
rainbowplan.aesKey
=
rainbowplan.msgDataFormat
:
JSON
\ No newline at end of file
rainbowplan.msgDataFormat
=
JSON
tjmdp.appid
=
wx77f58984e50cbc08
tjmdp.secret
=
6e6e00e5c01216c2464a8771cb9bdfca
tjmdp.token
=
tjmdp.aesKey
=
tjmdp.msgDataFormat
=
JSON
\ No newline at end of file
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