|
@@ -2,6 +2,7 @@ package com.xkl.controller; |
|
@@ -2,6 +2,7 @@ package com.xkl.controller; |
2
|
|
2
|
|
3
|
import com.wordnik.swagger.annotations.ApiOperation;
|
3
|
import com.wordnik.swagger.annotations.ApiOperation;
|
4
|
import com.xkl.authorization.manager.ITokenManager;
|
4
|
import com.xkl.authorization.manager.ITokenManager;
|
|
|
5
|
+import com.xkl.authorization.model.TokenModel;
|
5
|
import com.xkl.config.ResultStatus;
|
6
|
import com.xkl.config.ResultStatus;
|
6
|
import com.xkl.domain.User;
|
7
|
import com.xkl.domain.User;
|
7
|
import com.xkl.domain.XklMemberOpenidEntity;
|
8
|
import com.xkl.domain.XklMemberOpenidEntity;
|
|
@@ -47,10 +48,11 @@ public class OpenIdController { |
|
@@ -47,10 +48,11 @@ public class OpenIdController { |
47
|
if (user == null) {//用户,密码错误
|
48
|
if (user == null) {//用户,密码错误
|
48
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
49
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
49
|
} else {
|
50
|
} else {
|
50
|
- XklMemberOpenidEntity xklMemberOpenid=xklMemberOpenidRespository.findByMemberIdAndType(user.getMemberId(),openIdtype);
|
51
|
+ XklMemberOpenidEntity xklMemberOpenid=xklMemberOpenidRespository.findByAccountIdAndType(user.getId(),openIdtype);
|
51
|
if(xklMemberOpenid == null ){
|
52
|
if(xklMemberOpenid == null ){
|
52
|
xklMemberOpenid = new XklMemberOpenidEntity();
|
53
|
xklMemberOpenid = new XklMemberOpenidEntity();
|
53
|
xklMemberOpenid.setType(openIdtype);
|
54
|
xklMemberOpenid.setType(openIdtype);
|
|
|
55
|
+ xklMemberOpenid.setAccountId(user.getId());
|
54
|
xklMemberOpenid.setMemberId(user.getMemberId());
|
56
|
xklMemberOpenid.setMemberId(user.getMemberId());
|
55
|
xklMemberOpenid.setOpenid(openId);
|
57
|
xklMemberOpenid.setOpenid(openId);
|
56
|
}else{//已经存在
|
58
|
}else{//已经存在
|
|
@@ -76,7 +78,7 @@ public class OpenIdController { |
|
@@ -76,7 +78,7 @@ public class OpenIdController { |
76
|
if (user == null) {//用户,密码错误
|
78
|
if (user == null) {//用户,密码错误
|
77
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
79
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
78
|
} else {
|
80
|
} else {
|
79
|
- XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByMemberIdAndTypeAndOpenid(user.getMemberId(), openIdtype,openId);
|
81
|
+ XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByAccountIdAndTypeAndOpenid(user.getId(), openIdtype,openId);
|
80
|
if(xklMemberOpenid!=null) {
|
82
|
if(xklMemberOpenid!=null) {
|
81
|
xklMemberOpenidRespository.delete(xklMemberOpenid);
|
83
|
xklMemberOpenidRespository.delete(xklMemberOpenid);
|
82
|
}else{
|
84
|
}else{
|
|
@@ -86,4 +88,24 @@ public class OpenIdController { |
|
@@ -86,4 +88,24 @@ public class OpenIdController { |
86
|
return new ResponseEntity<>(ResultModel.ok(ResultStatus.OPENID_UNBIND_SUCESS), HttpStatus.OK);
|
88
|
return new ResponseEntity<>(ResultModel.ok(ResultStatus.OPENID_UNBIND_SUCESS), HttpStatus.OK);
|
87
|
}
|
89
|
}
|
88
|
|
90
|
|
|
|
91
|
+ @AntiXSS
|
|
|
92
|
+ //@Sign
|
|
|
93
|
+ @RequestMapping(value="/login",method = RequestMethod.POST)
|
|
|
94
|
+ @ApiOperation(value = "OpenId登录接口")
|
|
|
95
|
+ public ResponseEntity<ResultModel> openIdLogin(HttpServletRequest request,@RequestParam String openId, @RequestParam int openIdtype,
|
|
|
96
|
+ @RequestParam String sign,@RequestParam long t,@RequestParam int type) {
|
|
|
97
|
+ XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByOpenidAndType(openId, openIdtype);
|
|
|
98
|
+
|
|
|
99
|
+ if(xklMemberOpenid == null){
|
|
|
100
|
+ return new ResponseEntity<>(ResultModel.error(ResultStatus.OPENID_ERROR), HttpStatus.NOT_FOUND);
|
|
|
101
|
+ }
|
|
|
102
|
+ long accountId = xklMemberOpenid.getId();
|
|
|
103
|
+ TokenModel model = tokenManager.createToken(String.valueOf(accountId));
|
|
|
104
|
+
|
|
|
105
|
+ return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK);
|
|
|
106
|
+ }
|
|
|
107
|
+
|
|
|
108
|
+
|
|
|
109
|
+
|
|
|
110
|
+
|
89
|
} |
111
|
} |