diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/controller/RealNameController.java b/cloud-market2-server/src/main/java/com/muyu/market/server/controller/RealNameController.java new file mode 100644 index 0000000..b79f68b --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/controller/RealNameController.java @@ -0,0 +1,39 @@ +package com.muyu.market.server.controller; + +import com.muyu.market.admain.BasicApi; +import com.muyu.market.admain.request.RealNameRequest; +import com.muyu.market.admain.response.RealNameResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +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 javax.annotation.Resource; + + +@RestController +@RequestMapping("/juhe") +@Tag(name = "实名认证",description = "实名认证") +public class RealNameController { + + + @Resource + private BasicApi realNameService; + + + @PostMapping("/idcardSelect") + @Operation(summary = "查询身份证",description = "查询身份证") + public RealNameResponse realName(@RequestBody RealNameRequest realNameRequest){ + RealNameResponse realNameResponse = null; + try { + realNameResponse = realNameService.send(realNameRequest); + return realNameResponse; + } catch (Exception e) { + throw new RuntimeException("身份证错误"); + } + } +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/remote/AliRemoteService.java b/cloud-market2-server/src/main/java/com/muyu/market/server/remote/AliRemoteService.java new file mode 100644 index 0000000..6b3f508 --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/remote/AliRemoteService.java @@ -0,0 +1,16 @@ +package com.muyu.market.server.remote; + + +import com.muyu.market.admain.request.RealNameRequest; +import com.muyu.market.admain.response.RealNameResponse; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + + + +@FeignClient(value = "cloud-ali") +public interface AliRemoteService { + + @PostMapping("/ali/real/name") + RealNameResponse realName(RealNameRequest realNameReq); +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/remote/JuHeRemoteService.java b/cloud-market2-server/src/main/java/com/muyu/market/server/remote/JuHeRemoteService.java new file mode 100644 index 0000000..439a76e --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/remote/JuHeRemoteService.java @@ -0,0 +1,22 @@ +package com.muyu.market.server.remote; + + +import com.muyu.market.admain.request.RealNameRequest; +import com.muyu.market.admain.response.RealNameResponse; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + + +@FeignClient(value = "cloud-juhe") +public interface JuHeRemoteService { + + + + @PostMapping("/juhe/idcardSelect") + @Operation(summary = "查询身份证",description = "查询身份证") + public RealNameResponse realName(@RequestBody RealNameRequest realNameRequest); + + +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/RealNameServiceImpl.java b/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/RealNameServiceImpl.java new file mode 100644 index 0000000..a7bae5d --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/RealNameServiceImpl.java @@ -0,0 +1,61 @@ +package com.muyu.market.server.service.Impl; + + +import com.muyu.market.admain.BasicApi; +import com.muyu.market.admain.request.RealNameRequest; +import com.muyu.market.admain.response.RealNameResponse; +import com.muyu.market.server.remote.AliRemoteService; +import com.muyu.market.server.remote.JuHeRemoteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashSet; +import java.util.Set; + + +@Service +public class RealNameServiceImpl implements BasicApi { + @Autowired + private JuHeRemoteService juHeRemoteService; + @Autowired + private AliRemoteService aliRemoteService; +// @Autowired +// private UserMapper userMapper; + + + private static final Set realNameSet=new HashSet<>(){{ + add("张三-123456789123456712"); + add("李四-123456789123456713"); + add("王五-123456789123456714"); + add("赵六-123456789123456715"); + add("田七-123456789123456716"); + }}; + @Override + public RealNameResponse send(RealNameRequest realNameReq) { + + //改为去数据库查询 + String nameAndIdCard = realNameReq.getName() + "-" + realNameReq.getIdCard(); + if (realNameSet.contains(nameAndIdCard)) { + // 如果存在,则返回验证失败的消息 + return RealNameResponse.builder() + .code(0) + .msg("验证成功") + .build(); + } + + + //主从辅 + //假设聚合是主,阿里是从 + RealNameResponse realNameResp = juHeRemoteService.realName(realNameReq); + if (!realNameResp.getCode().equals(0) && !realNameResp.getMsg().equals("成功")){ + RealNameResponse realNameResp1 = aliRemoteService.realName(realNameReq); + if (!realNameResp1.getCode().equals(1) && !realNameResp1.getMsg().equals("认证成功")){ + throw new RuntimeException("线路正在抢修中!!!"); + } + return realNameResp1; + }else { + return realNameResp; + } + + } +} diff --git a/cloud-market2-server/src/main/resources/bootstrap.yml b/cloud-market2-server/src/main/resources/bootstrap.yml index 30207df..f477038 100644 --- a/cloud-market2-server/src/main/resources/bootstrap.yml +++ b/cloud-market2-server/src/main/resources/bootstrap.yml @@ -60,5 +60,6 @@ alipay: appPrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCWxZholdxU/C9Vh+4hjD4yWH5MUn3ZK7zkFKB09KY1Kz5k6t0fhcdMRbTaJulyQVL21wneb83f+5hhAzk9+j6RLrvIbE1YZyvt9uoUIpljMkEFyVL2L97/m/Bc+D+PMXMor0DxWMgdkGvmm/1Phjaoxr+HZn6WI1ZFXjKNdIUMNs8H5oLXkBpfTVDS8GLXfDxrUT2gx9g2AH8NJMLlWObHwG3ZPQenRg5szhjLHxuuNgcfJXyoW0agSnRqzn8QeYyq5H0XVElrtF+JbBsnvuUgJn/+h/oVoKeFekEYjfqogzx/1oROereXdEk3OxmzrlW0+EUYBEMViv7EGi0z8/jLAgMBAAECggEAYDm+OsmidK76+silZ83dCD7IZKelYEx04tBzVBGsXnS5/qiS9gJonzpB4ZVCGsSsUZQO3WNX7uLhbtEi4HZtJjXAbXsJpik6tUaIQM+QO+of67SA+VS2K0b4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QnG+mUg== alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvAodOIG6vaqMsl5DXjcRYPRro+C/SeTswVo5gqQdikK3qy118GWkVwL9gvEovq23EMCTmSV+KAFsHz8f0UxLEK9FZcfRuM5E7GfnP7sdY0ctjfmUhQ7fWVOTGLuH0h5DiQ+4voO/2Hi6SElvtLXAUBSqMKw6J0PsJ0uUY9CBZCQnZkFJWAAroUWw5ARUMy62KPZSAW2s8Qg4gacdhSk7SBACNGBFcJZHCS09xQJi5SxCHaTRLhhIckLBvuKEWhBsh+jU75BKYAC4ovoWhMAFnIWKwCmubhXqmYjuJ4egUQTQBbD1hasK99I1YzdXRH8OKwKD4Lufb42B9buZ/2hOywIDAQAB notifyUrl: http://12.2.1.1:8080/market2/alipay/notify + returnUrl: http://12.2.1.1:81/market2/apitype