李雨欣 9.4测试接口 20:19
parent
79220dd3be
commit
3b0439063f
|
@ -1,52 +0,0 @@
|
|||
package com.muyu.market.admain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "dashuju",autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DaShuJu extends BaseEntity {
|
||||
|
||||
|
||||
private String ManName;
|
||||
private String CardNo;
|
||||
private String Descriot;
|
||||
private String CtfTp;
|
||||
private String CtfId;
|
||||
private String Gender;
|
||||
private String Birthday;
|
||||
private String Address;
|
||||
private String Zip;
|
||||
private String Dirty;
|
||||
private String District1;
|
||||
private String District2;
|
||||
private String District3;
|
||||
private String District4;
|
||||
private String District5;
|
||||
private String District6;
|
||||
private String FirstNm;
|
||||
private String LastNm;
|
||||
private String Duty;
|
||||
private String Mobile;
|
||||
private String Tel;
|
||||
private String Fax;
|
||||
private String EMail;
|
||||
private String Nation;
|
||||
private String Taste;
|
||||
private String Education;
|
||||
private String Company;
|
||||
private String CTel;
|
||||
private String CAddress;
|
||||
private String CZip;
|
||||
private String Family;
|
||||
private String Version;
|
||||
private String id;
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.market.admain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SelectIDCard {
|
||||
|
||||
//身份证号码
|
||||
private String idcard;
|
||||
//姓名
|
||||
private String realname;
|
||||
//传1时返回单号,默认不返回单号(建议传入)
|
||||
private Integer orderid;
|
||||
//在个人中心->我的数据,接口名称上方查看
|
||||
private String key;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.muyu.market.server.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.market.server.util.SelectIDCardUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/idcard")
|
||||
@Tag(name = "第三方身份证接口",description = "接口")
|
||||
@RequiredArgsConstructor
|
||||
public class SelectIDCardController {
|
||||
/**第三方身份证接口
|
||||
*
|
||||
* @param name 姓名
|
||||
* @param idcard 身份证
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/idcardSelect")
|
||||
@Operation(summary = "查询身份证",description = "查询身份证")
|
||||
public Result selparty(@RequestParam("phoneNumber") String name,@RequestParam("idcard") String idcard ){
|
||||
try {
|
||||
Result main = SelectIDCardUtil.main(name, idcard);
|
||||
return Result.success(main);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.muyu.market.server.util;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SelectIDCardUtil {
|
||||
public static Result main(String name, String idcard) throws Exception {
|
||||
String apiKey = "cdd821cebf9cb018406845ca9b37bd62";
|
||||
String apiUrl = "http://op.juhe.cn/idcard/query";
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("key", apiKey);
|
||||
map.put("idcard", idcard);
|
||||
map.put("realname", name);
|
||||
|
||||
URL url = new URL(apiUrl + "?" + params(map));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
System.out.println(response);
|
||||
return Result.success(response);
|
||||
}
|
||||
|
||||
public static String params(Map<String, String> map) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> {
|
||||
try {
|
||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue