|
@@ -1,14 +1,5 @@
|
|
package com.qmth.exam.reserve.controller.student;
|
|
package com.qmth.exam.reserve.controller.student;
|
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
-
|
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
@@ -20,10 +11,13 @@ import com.qmth.exam.reserve.controller.BaseController;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
import com.qmth.exam.reserve.weixin.OauthAccessTokenRequest;
|
|
import com.qmth.exam.reserve.weixin.OauthAccessTokenRequest;
|
|
import com.qmth.exam.reserve.weixin.response.OauthAccessTokenResponseJson;
|
|
import com.qmth.exam.reserve.weixin.response.OauthAccessTokenResponseJson;
|
|
-
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@Api(tags = "【考生端】考生相关接口")
|
|
@Api(tags = "【考生端】考生相关接口")
|
|
@@ -59,17 +53,16 @@ public class StudentController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
@Aac(strict = false, auth = false)
|
|
@Aac(strict = false, auth = false)
|
|
- @ApiOperation(value = "获取用户的openid")
|
|
|
|
|
|
+ @ApiOperation(value = "获取微信用户的openid")
|
|
@PostMapping(value = "/wechat/get/openid")
|
|
@PostMapping(value = "/wechat/get/openid")
|
|
- public String getOpenid(@ApiParam("微信平台返回的用户code") @RequestParam String code) {
|
|
|
|
- OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, wxProperty.getAppId(),
|
|
|
|
- wxProperty.getAppSecret());
|
|
|
|
- OauthAccessTokenResponseJson responseJson = tokenRequest.request();
|
|
|
|
- if (responseJson.getErrcode() != 0) {
|
|
|
|
- log.warn("openId获取失败:用户code:" + code);
|
|
|
|
- throw new StatusException(Constants.SYSTEM_BUSY);
|
|
|
|
|
|
+ public String getOpenid(@ApiParam("微信用户code") @RequestParam String code) {
|
|
|
|
+ OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, wxProperty.getAppId(), wxProperty.getAppSecret());
|
|
|
|
+ OauthAccessTokenResponseJson response = tokenRequest.request();
|
|
|
|
+ if (response.getErrcode() != 0) {
|
|
|
|
+ log.warn("获取微信用户的openid失败!code:{}", code);
|
|
|
|
+ throw new StatusException(Constants.REQUEST_API_BUSY);
|
|
}
|
|
}
|
|
- return responseJson.getOpenid();
|
|
|
|
|
|
+ return response.getOpenid();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|