mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 用户绑定鉴权卡
This commit is contained in:
@@ -3,10 +3,14 @@ package com.jsowell.api.uniapp;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||
import com.jsowell.pile.service.IPileAuthCardService;
|
||||
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -27,8 +31,12 @@ public class AuthCardController extends BaseController {
|
||||
@Autowired
|
||||
private IPileAuthCardService pileAuthCardService;
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
/**
|
||||
* 查询鉴权卡列表
|
||||
* http://localhost:8080/uniapp/authCard/getAuthCardList
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@@ -51,23 +59,37 @@ public class AuthCardController extends BaseController {
|
||||
|
||||
/**
|
||||
* 用户绑定鉴权卡
|
||||
* http://localhost:8080/uniapp/authCard/bindAuthCard
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/bindAuthCard")
|
||||
public RestApiResponse<?> bindAuthCard(HttpServletRequest request, @RequestBody PileAuthCardDTO dto) {
|
||||
logger.info("用户绑定鉴权卡 params: {}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (memberId != null) {
|
||||
dto.setMemberId(memberId);
|
||||
|
||||
if (memberId == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
||||
}
|
||||
|
||||
dto.setMemberId(memberId);
|
||||
// 校验短信验证码
|
||||
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
||||
.mobileNumber(dto.getPhoneNumber())
|
||||
.verificationCode(dto.getVerificationCode())
|
||||
.build();
|
||||
memberService.checkVerificationCode(registerAndLoginDTO);
|
||||
int i = pileAuthCardService.bindAuthCard(dto);
|
||||
response = new RestApiResponse<>(i);
|
||||
}catch (BusinessException e){
|
||||
logger.warn("用户绑定鉴权卡 warn:", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.error("用户绑定鉴权卡 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
return null;
|
||||
logger.info("用户绑定鉴权卡 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user