...
|
...
|
@@ -2,6 +2,7 @@ package com.xkl.controller; |
|
|
|
|
|
import com.wordnik.swagger.annotations.ApiOperation;
|
|
|
import com.xkl.authorization.manager.ITokenManager;
|
|
|
import com.xkl.authorization.model.TokenModel;
|
|
|
import com.xkl.config.ResultStatus;
|
|
|
import com.xkl.domain.User;
|
|
|
import com.xkl.domain.XklMemberOpenidEntity;
|
...
|
...
|
@@ -47,10 +48,11 @@ public class OpenIdController { |
|
|
if (user == null) {//用户,密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
|
|
} else {
|
|
|
XklMemberOpenidEntity xklMemberOpenid=xklMemberOpenidRespository.findByMemberIdAndType(user.getMemberId(),openIdtype);
|
|
|
XklMemberOpenidEntity xklMemberOpenid=xklMemberOpenidRespository.findByAccountIdAndType(user.getId(),openIdtype);
|
|
|
if(xklMemberOpenid == null ){
|
|
|
xklMemberOpenid = new XklMemberOpenidEntity();
|
|
|
xklMemberOpenid.setType(openIdtype);
|
|
|
xklMemberOpenid.setAccountId(user.getId());
|
|
|
xklMemberOpenid.setMemberId(user.getMemberId());
|
|
|
xklMemberOpenid.setOpenid(openId);
|
|
|
}else{//已经存在
|
...
|
...
|
@@ -76,7 +78,7 @@ public class OpenIdController { |
|
|
if (user == null) {//用户,密码错误
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
|
|
|
} else {
|
|
|
XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByMemberIdAndTypeAndOpenid(user.getMemberId(), openIdtype,openId);
|
|
|
XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByAccountIdAndTypeAndOpenid(user.getId(), openIdtype,openId);
|
|
|
if(xklMemberOpenid!=null) {
|
|
|
xklMemberOpenidRespository.delete(xklMemberOpenid);
|
|
|
}else{
|
...
|
...
|
@@ -86,4 +88,24 @@ public class OpenIdController { |
|
|
return new ResponseEntity<>(ResultModel.ok(ResultStatus.OPENID_UNBIND_SUCESS), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@AntiXSS
|
|
|
//@Sign
|
|
|
@RequestMapping(value="/login",method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "OpenId登录接口")
|
|
|
public ResponseEntity<ResultModel> openIdLogin(HttpServletRequest request,@RequestParam String openId, @RequestParam int openIdtype,
|
|
|
@RequestParam String sign,@RequestParam long t,@RequestParam int type) {
|
|
|
XklMemberOpenidEntity xklMemberOpenid = xklMemberOpenidRespository.findByOpenidAndType(openId, openIdtype);
|
|
|
|
|
|
if(xklMemberOpenid == null){
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.OPENID_ERROR), HttpStatus.NOT_FOUND);
|
|
|
}
|
|
|
long accountId = xklMemberOpenid.getId();
|
|
|
TokenModel model = tokenManager.createToken(String.valueOf(accountId));
|
|
|
|
|
|
return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|