|
@@ -1,20 +1,29 @@
|
|
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.exam.reserve.bean.Constants;
|
|
import com.qmth.exam.reserve.bean.student.StudentInfo;
|
|
import com.qmth.exam.reserve.bean.student.StudentInfo;
|
|
import com.qmth.exam.reserve.bean.student.WechatBindReq;
|
|
import com.qmth.exam.reserve.bean.student.WechatBindReq;
|
|
|
|
+import com.qmth.exam.reserve.config.WxProperty;
|
|
import com.qmth.exam.reserve.controller.BaseController;
|
|
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.response.OauthAccessTokenResponseJson;
|
|
|
|
+
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
-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.RestController;
|
|
|
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@Api(tags = "【考生端】考生相关接口")
|
|
@Api(tags = "【考生端】考生相关接口")
|
|
@@ -27,6 +36,9 @@ public class StudentController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private StudentService studentService;
|
|
private StudentService studentService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private WxProperty wxProperty;
|
|
|
|
+
|
|
@ApiOperation(value = "考生账号与微信号绑定")
|
|
@ApiOperation(value = "考生账号与微信号绑定")
|
|
@PostMapping(value = "/wechat/binding")
|
|
@PostMapping(value = "/wechat/binding")
|
|
public void binding(@RequestBody WechatBindReq req) {
|
|
public void binding(@RequestBody WechatBindReq req) {
|
|
@@ -46,4 +58,18 @@ public class StudentController extends BaseController {
|
|
return studentService.findInfoByStudentId(curLoginStudent().getId());
|
|
return studentService.findInfoByStudentId(curLoginStudent().getId());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Aac(strict = false, auth = false)
|
|
|
|
+ @ApiOperation(value = "获取用户的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);
|
|
|
|
+ }
|
|
|
|
+ return responseJson.getOpenid();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|