mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-20 07:16:00 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -3,10 +3,14 @@ package com.jsowell.api.uniapp;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.jsowell.common.annotation.Anonymous;
|
import com.jsowell.common.annotation.Anonymous;
|
||||||
import com.jsowell.common.core.controller.BaseController;
|
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.common.response.RestApiResponse;
|
||||||
|
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
import com.jsowell.pile.service.IPileAuthCardService;
|
import com.jsowell.pile.service.IPileAuthCardService;
|
||||||
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
|
import com.jsowell.service.MemberService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -27,8 +31,12 @@ public class AuthCardController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IPileAuthCardService pileAuthCardService;
|
private IPileAuthCardService pileAuthCardService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询鉴权卡列表
|
* 查询鉴权卡列表
|
||||||
|
* http://localhost:8080/uniapp/authCard/getAuthCardList
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -51,23 +59,37 @@ public class AuthCardController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户绑定鉴权卡
|
* 用户绑定鉴权卡
|
||||||
|
* http://localhost:8080/uniapp/authCard/bindAuthCard
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/bindAuthCard")
|
@PostMapping("/bindAuthCard")
|
||||||
public RestApiResponse<?> bindAuthCard(HttpServletRequest request, @RequestBody PileAuthCardDTO dto) {
|
public RestApiResponse<?> bindAuthCard(HttpServletRequest request, @RequestBody PileAuthCardDTO dto) {
|
||||||
logger.info("用户绑定鉴权卡 params: {}", JSONObject.toJSONString(dto));
|
logger.info("用户绑定鉴权卡 params: {}", JSONObject.toJSONString(dto));
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
try {
|
try {
|
||||||
String memberId = getMemberIdByAuthorization(request);
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
if (memberId != null) {
|
if (memberId == null) {
|
||||||
dto.setMemberId(memberId);
|
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) {
|
} catch (Exception e) {
|
||||||
|
logger.error("用户绑定鉴权卡 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
}
|
}
|
||||||
return null;
|
logger.info("用户绑定鉴权卡 result:{}", response);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ public enum ReturnCodeEnum {
|
|||||||
|
|
||||||
CODE_SECRET_KEY_NOT_SAME("00600004", "密钥错误,请检查!"),
|
CODE_SECRET_KEY_NOT_SAME("00600004", "密钥错误,请检查!"),
|
||||||
|
|
||||||
|
CODE_THIS_CARD_STATUS_ANOMALY("00600005", "卡状态异常!"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ public class PileAuthCardDTO {
|
|||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private String secretKey;
|
||||||
|
|
||||||
private String memberId;
|
private String memberId;
|
||||||
|
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
private String VerificationCode;
|
private String verificationCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,4 +119,10 @@ public interface IPileAuthCardService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AuthCardVO> getAuthCardListByMemberId(String memberId);
|
List<AuthCardVO> getAuthCardListByMemberId(String memberId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定鉴权卡 (小程序用)
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
int bindAuthCard(PileAuthCardDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import java.util.Locale;
|
|||||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||||
|
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||||
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
@@ -217,4 +219,31 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定鉴权卡
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int bindAuthCard(PileAuthCardDTO dto) {
|
||||||
|
String phoneNumber = dto.getPhoneNumber();
|
||||||
|
// 判断此用户是否已注册小程序账号
|
||||||
|
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(phoneNumber);
|
||||||
|
if (memberBasicInfo == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||||
|
}
|
||||||
|
// 判断此卡是否已被绑定
|
||||||
|
PileAuthCard pileAuthCard = selectCardInfoByLogicCard(dto.getLogicCard());
|
||||||
|
if (!StringUtils.equals(pileAuthCard.getStatus(), "0")) { // 0-待激活
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_STATUS_ANOMALY);
|
||||||
|
}
|
||||||
|
// 验证密钥
|
||||||
|
if (!StringUtils.equals(dto.getSecretKey(), pileAuthCard.getSecretKey())) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_SECRET_KEY_NOT_SAME);
|
||||||
|
}
|
||||||
|
// 绑定操作
|
||||||
|
pileAuthCard.setMemberId(dto.getMemberId());
|
||||||
|
pileAuthCard.setStatus("1");
|
||||||
|
return updatePileAuthCard(pileAuthCard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user