parent
9fcc42adc1
commit
53e55f5d14
39 changed files with 2507 additions and 16 deletions
@ -0,0 +1,50 @@ |
||||
package com.huoran.nakadai.config; |
||||
|
||||
import org.apache.commons.codec.binary.Base64; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
|
||||
public class AliRealNameAuthenticationConfig { |
||||
public static final String ALI_API_HOST = "https://cardnumber.market.alicloudapi.com"; |
||||
|
||||
|
||||
|
||||
//营业执照
|
||||
public static final String ALI_API_BUSINESS_LICENSE_HOST = "https://bizlicense.market.alicloudapi.com"; |
||||
|
||||
public static final String ALI_API_BUSINESS_LICENSE_PATH = "/rest/160601/ocr/ocr_business_license.json"; |
||||
|
||||
|
||||
|
||||
|
||||
public static final String ALI_API_PATH = "/rest/160601/ocr/ocr_idcard.json"; |
||||
public static final String ALI_API_APPCODE = "4c22c2b34b2d4b5aaa57186a49aa3a4c"; |
||||
// public static final String ALI_API_APPCODE = "62512c9aa7714735a182bb08a0173f22";
|
||||
|
||||
public static final String ALI_IDCHECK_HOST = "https://sxidcheck.market.alicloudapi.com"; |
||||
public static final String ALI_IDCHECK_PATH = "/idcard/check"; |
||||
|
||||
public static final String GET_APP_CODE_LINK = "https://idenauthen.market.alicloudapi.com/idenAuthentication"; |
||||
|
||||
public static Map<String, String> buildHeaders() { |
||||
Map<String, String> headers = new HashMap<>(); |
||||
headers.put("Authorization", "APPCODE " + ALI_API_APPCODE); |
||||
headers.put("Content-Type", "application/json; charset=UTF-8"); |
||||
return headers; |
||||
} |
||||
|
||||
public static String imgBase64(MultipartFile file) { |
||||
String imgBase64 = ""; |
||||
try { |
||||
byte[] content = file.getBytes(); |
||||
imgBase64 = new String(Base64.encodeBase64(content)); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return imgBase64; |
||||
} |
||||
} |
@ -0,0 +1,367 @@ |
||||
package com.huoran.nakadai.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
||||
import com.google.gson.Gson; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.common.utils.TokenUtils; |
||||
import com.huoran.nakadai.config.AliRealNameAuthenticationConfig; |
||||
import com.huoran.nakadai.entity.EnterpriseCertification; |
||||
import com.huoran.nakadai.entity.UserInfo; |
||||
import com.huoran.nakadai.entity.UserAccount; |
||||
import com.huoran.nakadai.entity.UserAuthenticationInformation; |
||||
import com.huoran.nakadai.entity.res.BusinessLicenseOCRResp; |
||||
import com.huoran.nakadai.entity.res.CreditCodeResp; |
||||
import com.huoran.nakadai.entity.res.IdCardOCRResp; |
||||
import com.huoran.nakadai.entity.res.RealNameAuthenticationResp; |
||||
import com.huoran.nakadai.service.EnterpriseCertificationService; |
||||
import com.huoran.nakadai.service.UserAuthenticationInformationService; |
||||
import com.huoran.nakadai.utils.ali.FaceRecognitionAidUtil; |
||||
import com.huoran.nakadai.utils.ali.HttpUtils; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import org.apache.http.HttpResponse; |
||||
import org.apache.http.util.EntityUtils; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.util.ObjectUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Api(value = "小程序-实名认证", tags = "小程序-实名认证") |
||||
@RestController |
||||
@RequestMapping("/users/autonym") |
||||
public class AliRealNameAuthenticationController { |
||||
|
||||
//实名认证实现类
|
||||
@Autowired |
||||
public UserAuthenticationInformationService service; |
||||
|
||||
|
||||
//企业认证信息存储
|
||||
@Autowired |
||||
public EnterpriseCertificationService enterpriseCertificationService; |
||||
|
||||
@ApiOperation(value = "删除平台全部认证信息") |
||||
@PostMapping("/deletePlatformAuthenticationInformation") |
||||
public R deletePlatformAuthenticationInformation(@ApiParam(name = "openIds", value = "微信openId", required = true) @RequestBody List<String> openIds) { |
||||
|
||||
openIds.forEach(openId -> { |
||||
QueryWrapper<UserAuthenticationInformation> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("open_id", openId); |
||||
service.remove(queryWrapper); |
||||
|
||||
|
||||
QueryWrapper<EnterpriseCertification> queryWrapper1 = new QueryWrapper<>(); |
||||
queryWrapper1.eq("open_id", openId); |
||||
enterpriseCertificationService.remove(queryWrapper1); |
||||
}); |
||||
|
||||
return R.ok(); |
||||
} |
||||
|
||||
|
||||
@ApiOperation(value = "身份证图片验证") |
||||
@PostMapping("/faceAuthentication") |
||||
public R faceAuthentication(@RequestParam(name = "imgFile", required = true) @ApiParam(value = "图片url") String imgFile, @RequestParam(name = "side", required = true) @ApiParam(value = "身份证正反面类型:face/back") String side) throws IOException { |
||||
//身份证信息返回
|
||||
String idCardInformationReturn = FaceRecognitionAidUtil.IdCardOCRRecognition(imgFile, side); |
||||
if (ObjectUtils.isEmpty(idCardInformationReturn)) { |
||||
return R.error("身份证图片验证失败,请重新再试!"); |
||||
} |
||||
IdCardOCRResp resp = new Gson().fromJson(idCardInformationReturn, IdCardOCRResp.class); |
||||
if (resp.getSuccess()) { |
||||
return R.ok().put("data", resp); |
||||
} else { |
||||
return R.error("身份证图片验证失败,请重新再试!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
@PostMapping("/realNameAuthentication") |
||||
@ApiOperation(value = "输入身份证号码、姓名进行实名认证且添加认证信息", response = UserAuthenticationInformation.class) |
||||
public R realNameAuthentication(@RequestBody @ApiParam(name = "用户实名认证信息记录对象", value = "传入json格式", required = true) UserAuthenticationInformation userAuthenticationInformation, HttpServletRequest request) throws IOException { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
userAuthenticationInformation.setAccountId(Integer.valueOf(accountId)); |
||||
|
||||
String json = FaceRecognitionAidUtil.postData(AliRealNameAuthenticationConfig.ALI_API_APPCODE, AliRealNameAuthenticationConfig.GET_APP_CODE_LINK, userAuthenticationInformation.getRealName(), userAuthenticationInformation.getIdCardNo()); |
||||
RealNameAuthenticationResp info = new Gson().fromJson(json, RealNameAuthenticationResp.class); |
||||
|
||||
if (!info.getRespCode().equals("0000")) { |
||||
return R.error(info.getRespMessage()); |
||||
} |
||||
|
||||
QueryWrapper<UserAuthenticationInformation> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("open_id", userAuthenticationInformation.getOpenId()); |
||||
UserAuthenticationInformation information = service.getOne(queryWrapper); |
||||
|
||||
if (!ObjectUtils.isEmpty(information)) { |
||||
//为二次认证,删除上一次的认证信息
|
||||
service.removeById(information.getId()); |
||||
} |
||||
|
||||
|
||||
//设置用户当前认证时间
|
||||
userAuthenticationInformation.setRealNameAuthenticationTime(new Date()); |
||||
userAuthenticationInformation.setProvince(info.getProvince()); |
||||
userAuthenticationInformation.setCity(info.getCity()); |
||||
userAuthenticationInformation.setCounty(info.getCounty()); |
||||
|
||||
/*QueryWrapper<HrUserAccount> accountQueryWrapper = new QueryWrapper<>(); |
||||
accountQueryWrapper.eq("app_open_id", userAuthenticationInformation.getOpenId()); |
||||
accountQueryWrapper.eq("platform_id", 7);*/ |
||||
|
||||
UserAccount userAccount = enterpriseCertificationService.queryAccountInformation(userAuthenticationInformation.getOpenId(), 7); |
||||
|
||||
userAccount.setAccount(userAuthenticationInformation.getRealName()); |
||||
/*userAccountService.updateById(userAccount);*/ |
||||
enterpriseCertificationService.updateAccountInfo(userAccount); |
||||
|
||||
|
||||
/* UpdateWrapper<HrUserInfo> userInfoUpdateWrapper = new UpdateWrapper<>(); |
||||
userInfoUpdateWrapper.set("user_name", userAuthenticationInformation.getRealName()); |
||||
userInfoUpdateWrapper.eq("user_id", userAccount.getUserId()); |
||||
|
||||
userInfoService.update(new HrUserInfo(), userInfoUpdateWrapper);*/ |
||||
|
||||
UserInfo userInfo = new UserInfo(); |
||||
userInfo.setUserName(userAuthenticationInformation.getRealName()); |
||||
userInfo.setUserId(userAccount.getUserId()); |
||||
enterpriseCertificationService.updateUserInfo(userInfo); |
||||
|
||||
boolean addState = service.save(userAuthenticationInformation); |
||||
return addState ? R.ok() : R.error("认证失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/authenticationOrNot") |
||||
@ApiOperation(value = "个人是否认证", response = UserAuthenticationInformation.class) |
||||
public R authenticationOrNot(HttpServletRequest request) { |
||||
|
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
QueryWrapper<UserAuthenticationInformation> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("account_id", accountId); |
||||
UserAuthenticationInformation userAuthenticationInformation = service.getOne(queryWrapper); |
||||
if (ObjectUtils.isEmpty(userAuthenticationInformation)) { |
||||
return R.ok().put("data", false).put("msg", "未认证"); |
||||
} |
||||
return R.ok().put("data", true).put("authenticationInformation", userAuthenticationInformation); |
||||
} |
||||
|
||||
|
||||
@ApiOperation(value = "营业执照图片验证") |
||||
@PostMapping("/businessLicensePictureVerification") |
||||
public R businessLicensePictureVerification(@RequestParam(name = "imgFile", required = true) @ApiParam(value = "图片url") String imgFile) throws IOException { |
||||
String method = "POST"; |
||||
Map<String, String> headers = new HashMap<String, String>(); |
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); |
||||
//根据API的要求,定义相对应的Content-Type
|
||||
headers.put("Content-Type", "application/json; charset=UTF-8"); |
||||
Map<String, String> querys = new HashMap<String, String>(); |
||||
String bodys = "{\"image\":\"" + imgFile + "\"}"; |
||||
try { |
||||
HttpResponse response = HttpUtils.doPost(AliRealNameAuthenticationConfig.ALI_API_BUSINESS_LICENSE_HOST, AliRealNameAuthenticationConfig.ALI_API_BUSINESS_LICENSE_PATH, method, headers, querys, bodys); |
||||
BusinessLicenseOCRResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), BusinessLicenseOCRResp.class); |
||||
if (info.getSuccess()) { |
||||
return R.ok().put("data", info); |
||||
} else { |
||||
//("营业执照图片验证失败,请重新再试!");
|
||||
return R.error("营业执照图片验证失败,请重新再试!"); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
// ("营业执照图片验证失败,请重新再试!");
|
||||
return R.error("营业执照图片验证失败,请重新再试!"); |
||||
} |
||||
} |
||||
|
||||
|
||||
@ApiOperation(value = "统一社会信用代码认证(更改审核状态未提交为待审核)", response = CreditCodeResp.class) |
||||
@PostMapping("/creditCodeAuthentication") |
||||
public R creditCodeAuthentication(@RequestBody EnterpriseCertification enterpriseCertification, HttpServletRequest request) throws IOException { |
||||
|
||||
|
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
enterpriseCertification.setAccountId(Integer.valueOf(accountId)); |
||||
enterpriseCertification.setSubmitTime(new Date()); |
||||
String host = "https://sys.81api.com"; |
||||
String path = "/verifyCompany/"; |
||||
String method = "GET"; |
||||
Map<String, String> headers = new HashMap<String, String>(); |
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + "5a7f623d06724a4da5806c1fb0544e47"); |
||||
Map<String, String> querys = new HashMap<String, String>(); |
||||
querys.put("ComapnyName", enterpriseCertification.getCompanyName()); |
||||
querys.put("CreditCode", enterpriseCertification.getCreditCode()); |
||||
querys.put("LegalPersonName", enterpriseCertification.getLegalPerson()); |
||||
|
||||
String errorMsg = ""; |
||||
//查询认证id
|
||||
QueryWrapper<EnterpriseCertification> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("open_id", enterpriseCertification.getOpenId()); |
||||
EnterpriseCertification certification = enterpriseCertificationService.getOne(queryWrapper); |
||||
enterpriseCertification.setId(certification.getId()); |
||||
try { |
||||
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys); |
||||
CreditCodeResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), CreditCodeResp.class); |
||||
if (info.getStatus()) { |
||||
if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), certification.getId(), enterpriseCertification.getOpenId()))) { |
||||
errorMsg = "企业名称已存在"; |
||||
// (errorMsg);
|
||||
|
||||
return R.error(errorMsg); |
||||
} |
||||
|
||||
//删除上团队信息
|
||||
// enterpriseCertificationService.deleteTeamInformation(enterpriseCertification.getAccountId());
|
||||
enterpriseCertificationService.updateById(enterpriseCertification); |
||||
|
||||
//更改二次验证的组织信息
|
||||
return changeTeamInformation(enterpriseCertification); |
||||
} else { |
||||
errorMsg = info.getReason(); |
||||
return R.error().put("message", info.getReason()); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
// (errorMsg);
|
||||
return R.error(errorMsg); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
@NotNull |
||||
private R changeTeamInformation(@RequestBody EnterpriseCertification enterpriseCertification) { |
||||
enterpriseCertification.setSubmitTime(new Date()); |
||||
/*QueryWrapper<HrUserAccount> accountQueryWrapper1 = new QueryWrapper<>(); |
||||
accountQueryWrapper1.eq("app_open_id", enterpriseCertification.getOpenId()); |
||||
accountQueryWrapper1.eq("platform_id", enterpriseCertification.getPlatformSource());*/ |
||||
UserAccount userAccount1 = enterpriseCertificationService.queryAccountInformation(enterpriseCertification.getOpenId(), |
||||
Integer.valueOf(enterpriseCertification.getPlatformSource())); |
||||
|
||||
// userAccountService.updateById(userAccount1);
|
||||
userAccount1.setAccount(enterpriseCertification.getCompanyName()); |
||||
enterpriseCertificationService.updateAccountInfo(userAccount1); |
||||
|
||||
/* UpdateWrapper<HrUserInfo> userInfoUpdateWrapper = new UpdateWrapper<>(); |
||||
userInfoUpdateWrapper.set("user_name", enterpriseCertification.getCompanyName()); |
||||
userInfoUpdateWrapper.eq("user_id", userAccount1.getUserId()); |
||||
userInfoService.update(new HrUserInfo(), userInfoUpdateWrapper);*/ |
||||
|
||||
UserInfo userInfo = new UserInfo(); |
||||
userInfo.setUserName(enterpriseCertification.getCompanyName()); |
||||
userInfo.setUserId(userAccount1.getUserId()); |
||||
enterpriseCertificationService.updateUserInfo(userInfo); |
||||
|
||||
//删除团队信息
|
||||
// enterpriseCertificationService.deleteTeamInformation(enterpriseCertification.getAccountId());
|
||||
return R.ok("提交成功,请等待审核!"); |
||||
} |
||||
|
||||
@ApiOperation(value = "统一社会信用代码认证(auditStatus给1,新增认证状态为待审核,用于个人认证幼儿园或供应商情况下)", response = CreditCodeResp.class) |
||||
@PostMapping("/organizationCertification") |
||||
public R organizationCertification(@RequestBody EnterpriseCertification enterpriseCertification, HttpServletRequest request) throws IOException { |
||||
|
||||
/* |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
enterpriseCertification.setAccountId(Integer.valueOf(accountId));*/ |
||||
enterpriseCertification.setSubmitTime(new Date()); |
||||
String host = "https://sys.81api.com"; |
||||
String path = "/verifyCompany/"; |
||||
String method = "GET"; |
||||
Map<String, String> headers = new HashMap<String, String>(); |
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " +"5a7f623d06724a4da5806c1fb0544e47"); |
||||
Map<String, String> querys = new HashMap<String, String>(); |
||||
querys.put("ComapnyName", enterpriseCertification.getCompanyName()); |
||||
querys.put("CreditCode", enterpriseCertification.getCreditCode()); |
||||
querys.put("LegalPersonName", enterpriseCertification.getLegalPerson()); |
||||
|
||||
String errorMsg = ""; |
||||
|
||||
try { |
||||
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys); |
||||
CreditCodeResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), CreditCodeResp.class); |
||||
if (info.getStatus()) { |
||||
if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { |
||||
errorMsg = "企业名称已存在"; |
||||
return R.error(errorMsg); |
||||
} |
||||
enterpriseCertificationService.save(enterpriseCertification); |
||||
|
||||
//更改二次验证的组织信息
|
||||
return changeTeamInformation(enterpriseCertification); |
||||
} else { |
||||
errorMsg = info.getReason(); |
||||
|
||||
//失败后删除本次生成的企业团队信息
|
||||
/*QueryWrapper<HrUserAccount> accountQueryWrapper = new QueryWrapper<>(); |
||||
accountQueryWrapper.eq("app_open_id", enterpriseCertification.getOpenId()); |
||||
accountQueryWrapper.eq("platform_id", enterpriseCertification.getPlatformSource()); |
||||
|
||||
HrUserAccount userAccount = userAccountService.getOne(accountQueryWrapper);*/ |
||||
|
||||
UserAccount userAccount = enterpriseCertificationService.queryAccountInformation(enterpriseCertification.getOpenId(), |
||||
Integer.valueOf(enterpriseCertification.getPlatformSource())); |
||||
|
||||
enterpriseCertificationService.deleteUserInformation(userAccount.getUserId()); |
||||
enterpriseCertificationService.deleteAccountInformation(userAccount.getId()); |
||||
/*userInfoService.removeById(userAccount.getUserId()); |
||||
userAccountService.removeById(userAccount);*/ |
||||
return R.error().put("message", info.getReason()); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return R.error().put("message", errorMsg); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
String host = "https://sys.81api.com"; |
||||
String path = "/verifyCompany/"; |
||||
String method = "GET"; |
||||
Map<String, String> headers = new HashMap<String, String>(); |
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); |
||||
Map<String, String> querys = new HashMap<String, String>(); |
||||
querys.put("ComapnyName", "荆州国瑞网络科技有限公司"); |
||||
querys.put("CreditCode", "91421000MA494BGL8W"); |
||||
querys.put("LegalPersonName", "余承文"); |
||||
|
||||
String errorMsg = ""; |
||||
|
||||
try { |
||||
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys); |
||||
CreditCodeResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), CreditCodeResp.class); |
||||
if (info.getStatus()) { |
||||
/*if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { |
||||
errorMsg = "企业名称已存在"; |
||||
(errorMsg); |
||||
} |
||||
enterpriseCertificationService.save(enterpriseCertification);*/ |
||||
|
||||
} else { |
||||
errorMsg = info.getReason(); |
||||
|
||||
System.err.println("错误信息:" + errorMsg); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
errorMsg = "系统错误"; |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,214 @@ |
||||
package com.huoran.nakadai.controller; |
||||
|
||||
import cn.hutool.json.JSONObject; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.common.utils.TokenUtils; |
||||
import com.huoran.nakadai.entity.EnterpriseCertification; |
||||
import com.huoran.nakadai.entity.HrUserAccount; |
||||
import com.huoran.nakadai.entity.PartnerAccount; |
||||
import com.huoran.nakadai.entity.UserAccount; |
||||
import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; |
||||
import com.huoran.nakadai.entity.vo.WxMssVo; |
||||
import com.huoran.nakadai.service.EnterpriseCertificationService; |
||||
|
||||
import com.huoran.nakadai.utils.WeChatUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.util.ObjectUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
|
||||
@Api(value = "后台-企业实名认证相关", tags = "后台-企业实名认证相关") |
||||
@RestController |
||||
@RequestMapping("/enterprise/certification") |
||||
public class EnterpriseCertificationController { |
||||
|
||||
|
||||
@Autowired |
||||
public EnterpriseCertificationService service; |
||||
|
||||
/* @Autowired |
||||
public IHrUserAccountService userAccountService; |
||||
|
||||
@Autowired |
||||
public IHrUserInfoService userInfoService;*/ |
||||
|
||||
|
||||
/** |
||||
* 由前台申请认证后才有后台认证记录,认证状态有 待审核、已通过、未驳回三种状态,没有未提交这种状态 |
||||
* |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
@PostMapping("/selectEnterpriseCertificationList") |
||||
@ApiOperation(value = "企业认证列表", response = EnterpriseCertification.class) |
||||
public R selectEnterpriseCertificationList(@RequestBody EnterpriseCertificationLIstReq req) { |
||||
return service.selectEnterpriseCertificationList(req); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/enterpriseCertificationDetails") |
||||
@ApiOperation(value = "企业认证详情", response = EnterpriseCertification.class) |
||||
public R enterpriseCertificationDetails(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
return service.enterpriseCertificationDetails(id); |
||||
} |
||||
|
||||
@PostMapping("/findById") |
||||
@ApiOperation(value = "查询详情", response = EnterpriseCertification.class) |
||||
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
EnterpriseCertification enterpriseCertification = service.getById(id); |
||||
return R.ok().put("data", enterpriseCertification); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/enterpriseCertificationStatus") |
||||
@ApiOperation(value = "查询企业当前认证状态", response = EnterpriseCertification.class) |
||||
public R enterpriseCertificationStatus(@ApiParam(name = "openId", value = "微信openId", required = true) @RequestParam String openId) { |
||||
/*String accountId = TokenUtils.getIdByJwtToken(request);*/ |
||||
QueryWrapper<EnterpriseCertification> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("open_id", openId); |
||||
EnterpriseCertification enterpriseCertification = service.getOne(queryWrapper); |
||||
return R.ok().put("data", enterpriseCertification); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增(注册后调用此接口,传值状态0默认未提交)", response = EnterpriseCertification.class) |
||||
public R save(@RequestBody @ApiParam(name = "企业实名认证信息记录对象", value = "传入json格式", required = true) EnterpriseCertification enterpriseCertification, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
enterpriseCertification.setAccountId(Integer.valueOf(accountId)); |
||||
if (!ObjectUtils.isEmpty(service.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, null))) { |
||||
throw new RuntimeException("企业名称已存在"); |
||||
} |
||||
boolean addState = service.save(enterpriseCertification); |
||||
return addState ? R.ok() : R.error("新增失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改", response = EnterpriseCertification.class) |
||||
public R update(@RequestBody @ApiParam(name = "企业实名认证信息记录对象", value = "传入json格式", required = true) EnterpriseCertification enterpriseCertification, HttpServletRequest request) { |
||||
/* String accountId = TokenUtils.getIdByJwtToken(request); |
||||
enterpriseCertification.setAccountId(Integer.valueOf(accountId));*/ |
||||
boolean updateState = service.updateById(enterpriseCertification); |
||||
return updateState ? R.ok() : R.error("编辑失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/informationAudit") |
||||
@ApiOperation(value = "信息审核", response = EnterpriseCertification.class) |
||||
public R informationAudit(@ApiParam(name = "auditStatus", value = "审核状态(2.通过,3.不通过)", required = true) @RequestParam(required = false) Integer auditStatus, |
||||
@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, |
||||
@ApiParam(name = "openId", value = "openid", required = true) @RequestParam(required = true) String openId, |
||||
@ApiParam(name = "remark", value = "备注", required = false) @RequestParam(required = false) String remark) { |
||||
|
||||
EnterpriseCertification details = service.getById(id); |
||||
|
||||
EnterpriseCertification enterpriseCertification = new EnterpriseCertification(); |
||||
enterpriseCertification.setAuditStatus(auditStatus); |
||||
enterpriseCertification.setId(id); |
||||
|
||||
String authenticationStatus = ""; |
||||
|
||||
WxMssVo wxMssVo = new WxMssVo(); |
||||
//设置模板id
|
||||
wxMssVo.setTemplate_id("8pDVfWYqh9c-nn3CeA1NXJtBxdd1FYiCtrl5BeLvbgU"); |
||||
//跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
wxMssVo.setMiniprogram_state("trial"); |
||||
wxMssVo.setLang("zh_CN"); |
||||
String accessToken = null; |
||||
try { |
||||
//设置openId
|
||||
wxMssVo.setTouser(openId); |
||||
//设置accessToken
|
||||
accessToken = WeChatUtil.getAccessToken(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//设置小程序 跳转页面
|
||||
wxMssVo.setPage("/pages/person/person"); |
||||
|
||||
wxMssVo.setRequest_url("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken); |
||||
//将模板中的值一一赋值 发送到小程序的数据要转化为json格式 可以使用下面的方法直接拼接成JSONObject
|
||||
//使用map结合模板 后续再加遍历拼接成JSONObject
|
||||
HashMap<String, Object> map = new HashMap<>(3); |
||||
map.put("thing1", details.getCompanyName());//公司名称
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
String format = sdf.format(new Date()); |
||||
map.put("time5", format);//申请时间
|
||||
|
||||
switch (auditStatus) { |
||||
case 2: |
||||
//通过:更改认证状态 认证状态(0默认未认证 1.认证中2.已认证)
|
||||
enterpriseCertification.setAuthenticationStatus(2); |
||||
authenticationStatus = "通过"; |
||||
break; |
||||
case 3: |
||||
//不通过
|
||||
authenticationStatus = "不通过"; |
||||
map.put("thing3", remark);//备注
|
||||
enterpriseCertification.setAuthenticationStatus(0); |
||||
break; |
||||
} |
||||
|
||||
map.put("phrase2", authenticationStatus);//认证状态
|
||||
wxMssVo.setMap(map); |
||||
WeChatUtil.sendTemplateMessage(wxMssVo); |
||||
//更新状态
|
||||
boolean updateState = service.updateById(enterpriseCertification); |
||||
return updateState ? R.ok() : R.error("编辑失败"); |
||||
} |
||||
|
||||
@PostMapping("/batchDeletion") |
||||
@ApiOperation(value = "批量删除", response = EnterpriseCertification.class) |
||||
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List<Integer> ids) { |
||||
|
||||
for (Integer id : ids) { |
||||
//
|
||||
|
||||
EnterpriseCertification enterpriseCertification = service.getById(id); |
||||
|
||||
//删除企业认证后同步删除团队、用户、账户信息
|
||||
|
||||
|
||||
//删除账号表
|
||||
/*QueryWrapper<HrUserAccount> accountQueryWrapper1 = new QueryWrapper<>(); |
||||
accountQueryWrapper1.eq("app_open_id", enterpriseCertification.getOpenId()); |
||||
accountQueryWrapper1.eq("platform_id",enterpriseCertification.getPlatformSource()); |
||||
HrUserAccount userAccount = userAccountService.getOne(accountQueryWrapper1);*/ |
||||
|
||||
UserAccount userAccount = service.queryAccountInformation(enterpriseCertification.getOpenId(), Integer.valueOf(enterpriseCertification.getPlatformSource())); |
||||
service.deleteAccountInformation(userAccount.getId()); |
||||
|
||||
//删除用户表
|
||||
service.deleteUserInformation(userAccount.getUserId()); |
||||
|
||||
//删除团队信息表
|
||||
service.deleteTeamInformation(userAccount.getId()); |
||||
} |
||||
|
||||
boolean delState = service.removeByIds(ids); |
||||
return delState ? R.ok() : R.error("删除失败"); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,77 @@ |
||||
package com.huoran.nakadai.controller; |
||||
|
||||
import com.huoran.api.UserClient; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.common.utils.TokenUtils; |
||||
import com.huoran.nakadai.entity.SupplierClassificationConfig; |
||||
import com.huoran.nakadai.service.SupplierClassificationConfigService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @描述:供应商分类配置表控制类 |
||||
* @作者: Rong |
||||
* @日期: 2023-12-27 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/supplierClassificationConfig") |
||||
@Api(value = "供应商分类配置表:SupplierClassificationConfigController", tags = "供应商分类配置表") |
||||
public class SupplierClassificationConfigController { |
||||
|
||||
@Autowired |
||||
public SupplierClassificationConfigService service; |
||||
|
||||
@Autowired |
||||
private UserClient userClient; |
||||
|
||||
/*@PostMapping("/listByEntity") |
||||
@ApiOperation(value = "分页查询", response = SupplierClassificationConfig.class) |
||||
public R listByEntity(@RequestBody SupplierClassificationConfig supplierClassificationConfig) { |
||||
|
||||
return null; |
||||
} |
||||
*/ |
||||
|
||||
@PostMapping("/findById") |
||||
@ApiOperation(value = "查询详情", response = SupplierClassificationConfig.class) |
||||
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
SupplierClassificationConfig supplierClassificationConfig = service.getById(id); |
||||
return R.ok().put("data", supplierClassificationConfig); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增分类", response = SupplierClassificationConfig.class) |
||||
public R save(@RequestBody @ApiParam(name = "供应商分类配置表对象", value = "传入json格式", required = true) SupplierClassificationConfig supplierClassificationConfig, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
supplierClassificationConfig.setAccountId(Integer.valueOf(accountId)); |
||||
boolean addState = service.save(supplierClassificationConfig); |
||||
return addState ? R.ok() : R.error("新增失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改", response = SupplierClassificationConfig.class) |
||||
public R update(@RequestBody @ApiParam(name = "供应商分类配置表对象", value = "传入json格式", required = true) SupplierClassificationConfig supplierClassificationConfig, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
Integer schoolId = userClient.getSchoolIdByAccountId(accountId); |
||||
supplierClassificationConfig.setAccountId(Integer.valueOf(accountId)); |
||||
boolean updateState = service.updateById(supplierClassificationConfig); |
||||
return updateState ? R.ok() : R.error("编辑失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/batchDeletion") |
||||
@ApiOperation(value = "批量删除", response = SupplierClassificationConfig.class) |
||||
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List<Integer> ids) { |
||||
boolean delState = service.removeByIds(ids); |
||||
return delState ? R.ok() : R.error("删除失败"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,106 @@ |
||||
package com.huoran.nakadai.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.huoran.api.UserClient; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.common.utils.TokenUtils; |
||||
import com.huoran.nakadai.entity.SupplierClassification; |
||||
import com.huoran.nakadai.entity.req.SupplierClassificationReq; |
||||
import com.huoran.nakadai.service.SupplierClassificationService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.util.ObjectUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @描述:供应商分类信息控制类 |
||||
* @作者: Rong |
||||
* @日期: 2023-12-27 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/supplierClassification") |
||||
@Api(value = "供应商分类信息:SupplierClassificationController", tags = "供应商分类信息") |
||||
public class SupplierClassificationController { |
||||
|
||||
@Autowired |
||||
public SupplierClassificationService service; |
||||
|
||||
@Autowired |
||||
private UserClient userClient; |
||||
|
||||
|
||||
@PostMapping("/treeStructureList") |
||||
@ApiOperation(value = "树结构列表", response = SupplierClassification.class) |
||||
public R treeStructureList(@RequestBody SupplierClassificationReq supplierClassification) { |
||||
/*QueryWrapper<SupplierClassification> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("parent_id", supplierClassification.getParentId());*/ |
||||
List<SupplierClassification> list = service.list(null); |
||||
|
||||
|
||||
return R.ok().put("list", buildTree(list)); |
||||
} |
||||
|
||||
public List<SupplierClassification> buildTree(List<SupplierClassification> list) { |
||||
List<SupplierClassification> treeList = new ArrayList<SupplierClassification>(); |
||||
List<SupplierClassification> children; |
||||
|
||||
for (SupplierClassification address : list) { |
||||
if (address.getParentId() == 0) { |
||||
treeList.add(address); |
||||
} |
||||
children = new ArrayList<SupplierClassification>(); |
||||
for (SupplierClassification node : list) { |
||||
if (node.getParentId() == address.getId()) { |
||||
children.add(node); |
||||
} |
||||
} |
||||
address.setChildren(children); |
||||
} |
||||
|
||||
return treeList; |
||||
} |
||||
|
||||
|
||||
@PostMapping("/findById") |
||||
@ApiOperation(value = "查询详情", response = SupplierClassification.class) |
||||
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
SupplierClassification supplierClassification = service.getById(id); |
||||
return R.ok().put("data", supplierClassification); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增", response = SupplierClassification.class) |
||||
public R save(@RequestBody @ApiParam(name = "供应商分类信息对象", value = "传入json格式", required = true) SupplierClassification supplierClassification, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
Integer schoolId = userClient.getSchoolIdByAccountId(accountId); |
||||
supplierClassification.setAccountId(Integer.valueOf(accountId)); |
||||
boolean addState = service.save(supplierClassification); |
||||
return addState ? R.ok() : R.error("新增失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改", response = SupplierClassification.class) |
||||
public R update(@RequestBody @ApiParam(name = "供应商分类信息对象", value = "传入json格式", required = true) SupplierClassification supplierClassification, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
Integer schoolId = userClient.getSchoolIdByAccountId(accountId); |
||||
supplierClassification.setAccountId(Integer.valueOf(accountId)); |
||||
boolean updateState = service.updateById(supplierClassification); |
||||
return updateState ? R.ok() : R.error("编辑失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/batchDeletion") |
||||
@ApiOperation(value = "批量删除", response = SupplierClassification.class) |
||||
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List<Integer> ids) { |
||||
boolean delState = service.removeByIds(ids); |
||||
return delState ? R.ok() : R.error("删除失败"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,132 @@ |
||||
package com.huoran.nakadai.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("hr_enterprise_certification") |
||||
@ApiModel(value = "EnterpriseCertification对象", description = "企业认证审核") |
||||
public class EnterpriseCertification implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "申请认证人账号id") |
||||
private Integer accountId; |
||||
|
||||
@ApiModelProperty(value = "企业名称") |
||||
private String companyName; |
||||
|
||||
@ApiModelProperty(value = "统一社会信用代码") |
||||
private String creditCode; |
||||
|
||||
@ApiModelProperty(value = "法人") |
||||
private String legalPerson; |
||||
|
||||
@ApiModelProperty(value = "公司类型") |
||||
private String type; |
||||
|
||||
@ApiModelProperty(value = "公司注册日期") |
||||
private String establishDate; |
||||
|
||||
@ApiModelProperty(value = "公司营业期限终止日期") |
||||
private String validPeriod; |
||||
|
||||
@ApiModelProperty(value = "公司地址") |
||||
private String address; |
||||
|
||||
@ApiModelProperty(value = "注册资本") |
||||
private String capital; |
||||
|
||||
@ApiModelProperty(value = "经营范围") |
||||
private String business; |
||||
|
||||
@ApiModelProperty(value = "营业执照照片") |
||||
private String businessLicensePicture; |
||||
|
||||
@ApiModelProperty(value = "办学许可证") |
||||
private String licenseForRunningSchool; |
||||
|
||||
|
||||
@ApiModelProperty(value = "提交时间") |
||||
private Date submitTime; |
||||
|
||||
@ApiModelProperty(value = "审核状态(0默认未提交 1.待审核,2.已通过,3.已驳回)") |
||||
private Integer auditStatus; |
||||
|
||||
@ApiModelProperty(value = "来源区分(5:幼儿园,6:供应商)") |
||||
private String platformSource; |
||||
|
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
|
||||
@ApiModelProperty(value = "账号") |
||||
@TableField(exist = false) |
||||
private String account; |
||||
|
||||
@ApiModelProperty(value = "申请人") |
||||
@TableField(exist = false) |
||||
private String proposer; |
||||
|
||||
@ApiModelProperty(value = "联系方式") |
||||
@TableField(exist = false) |
||||
private String contactInformation; |
||||
|
||||
@ApiModelProperty(value = "省") |
||||
@TableField(exist = false) |
||||
private String province; |
||||
|
||||
@ApiModelProperty(value = "市") |
||||
@TableField(exist = false) |
||||
private String city; |
||||
|
||||
@ApiModelProperty(value = "团队id") |
||||
@TableField(exist = false) |
||||
private Integer teamId; |
||||
|
||||
@ApiModelProperty(value = "logo地址") |
||||
@TableField(exist = false) |
||||
private String logoUrl; |
||||
|
||||
@ApiModelProperty(value = "组织创建时间") |
||||
@TableField(exist = false) |
||||
private String organizationCreationTime; |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
@TableField(exist = false) |
||||
private String briefIntroduction; |
||||
|
||||
|
||||
@ApiModelProperty(value = "认证状态(0默认未认证 1.认证中2.已认证)") |
||||
private Integer authenticationStatus; |
||||
|
||||
|
||||
@ApiModelProperty(value = "微信唯一标识") |
||||
private String openId; |
||||
} |
@ -0,0 +1,70 @@ |
||||
package com.huoran.nakadai.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类信息 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@ApiModel(value = "SupplierSupplierClassification对象", description = "供应商分类信息") |
||||
public class SupplierClassification implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "分类主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "分类名称") |
||||
private String classificationName; |
||||
|
||||
@ApiModelProperty(value = "父id") |
||||
private Integer parentId; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "创建人Id") |
||||
private Integer accountId; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "是否删除(0未删除 1已删除 默认0)") |
||||
private Integer isDel; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "创建时间") |
||||
private Date createTime; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "修改时间") |
||||
private Date updateTime; |
||||
|
||||
@ApiModelProperty(value = "子分类集合") |
||||
@TableField(exist = false) |
||||
private List<SupplierClassification> children; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
package com.huoran.nakadai.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import java.io.Serializable; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类配置表 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@ApiModel(value="SupplierClassificationConfig对象", description="供应商分类配置表") |
||||
public class SupplierClassificationConfig implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "分类id") |
||||
private Integer classificationId; |
||||
|
||||
@ApiModelProperty(value = "账号id") |
||||
private Integer accountId; |
||||
|
||||
|
||||
} |
@ -0,0 +1,89 @@ |
||||
package com.huoran.nakadai.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户实名认证信息记录 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-14 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("hr_user_authentication_information") |
||||
@ApiModel(value="UserAuthenticationInformation对象", description="用户实名认证信息记录") |
||||
public class UserAuthenticationInformation implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "账号id") |
||||
private Integer accountId; |
||||
|
||||
@ApiModelProperty(value = "姓名") |
||||
private String realName; |
||||
|
||||
@ApiModelProperty(value = "身份证号码") |
||||
private String idCardNo; |
||||
|
||||
@ApiModelProperty(value = "生日") |
||||
private String birthday; |
||||
|
||||
/*@ApiModelProperty(value = "年龄") |
||||
private Integer age;*/ |
||||
|
||||
@ApiModelProperty(value = "性别") |
||||
private String sex; |
||||
|
||||
@ApiModelProperty(value = "省") |
||||
private String province; |
||||
|
||||
@ApiModelProperty(value = "市") |
||||
private String city; |
||||
|
||||
@ApiModelProperty(value = "县") |
||||
private String county; |
||||
|
||||
@ApiModelProperty(value = "地址信息") |
||||
private String address; |
||||
|
||||
@ApiModelProperty(value = "民族") |
||||
private String nationality; |
||||
|
||||
@ApiModelProperty(value = "身份证有效期起始时间") |
||||
private String startDate; |
||||
|
||||
@ApiModelProperty(value = "身份证有效期结束时间") |
||||
private String endDate; |
||||
|
||||
@ApiModelProperty(value = "签发机关") |
||||
private String issue; |
||||
|
||||
@ApiModelProperty(value = "身份证正面图片地址") |
||||
private String frontOfIdCard; |
||||
|
||||
@ApiModelProperty(value = "身份证反面图片地址") |
||||
private String reverseOfIdCard; |
||||
|
||||
@ApiModelProperty(value = "实名认证的时间") |
||||
private Date realNameAuthenticationTime; |
||||
|
||||
@ApiModelProperty(value = "微信唯一标识") |
||||
private String openId; |
||||
} |
@ -0,0 +1,55 @@ |
||||
package com.huoran.nakadai.entity.req; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "EnterpriseCertification对象", description = "企业认证审核列表请求参数") |
||||
public class EnterpriseCertificationLIstReq { |
||||
|
||||
|
||||
@ApiModelProperty(value = "关键字") |
||||
private String keyWord; |
||||
|
||||
@ApiModelProperty(value = "开始提交时间") |
||||
private String startCommitTime; |
||||
|
||||
@ApiModelProperty(value = "结束提交时间") |
||||
private String endCommitTime; |
||||
|
||||
@ApiModelProperty(value = "审核状态(0默认待审核,1通过,2驳回)") |
||||
private Integer auditStatus; |
||||
|
||||
|
||||
@ApiModelProperty(value = "认证状态(0默认未认证 1.认证中2.已认证)") |
||||
private Integer authenticationStatus; |
||||
|
||||
@ApiModelProperty(value = "来源区分(5:幼儿园,6:供应商)") |
||||
private String platformSource; |
||||
|
||||
|
||||
@ApiModelProperty(value = "账号") |
||||
private String account; |
||||
|
||||
|
||||
@ApiModelProperty(value = "省") |
||||
private String province; |
||||
|
||||
@ApiModelProperty(value = "市") |
||||
private String city; |
||||
|
||||
@ApiModelProperty(value = "当前页数", name = "pageNum", example = "1", required = true) |
||||
private Integer pageNum; |
||||
@ApiModelProperty(value = "当前页需要显示的数量", name = "pageSize", example = "10", required = true) |
||||
private Integer pageSize; |
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
package com.huoran.nakadai.entity.req; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
@ApiModel(value = "企业认证请求参数") |
||||
public class EnterpriseCertificationReq { |
||||
@ApiModelProperty(value = "公司的名字") |
||||
private String comapnyName; |
||||
|
||||
@ApiModelProperty(value = "法人") |
||||
private String legalPerson; |
||||
|
||||
|
||||
@ApiModelProperty(value = "统一社会信用代码") |
||||
private String creditCode; |
||||
|
||||
@ApiModelProperty(value = "公司类型") |
||||
private String type; |
||||
|
||||
@ApiModelProperty(value = "公司注册日期(例:证件上为2014年04月16日,算法返回20140416") |
||||
private String establishDate; |
||||
|
||||
@ApiModelProperty(value = "公司营业期限终止日期(例:证件上为2014年04月16日至2034年04月15日,算法返回20340415)") |
||||
private String validPeriod; |
||||
|
||||
@ApiModelProperty(value = "公司地址,没有识别出来时返回FailInRecognition") |
||||
private String address; |
||||
|
||||
@ApiModelProperty(value = "注册资本,没有识别出来时返回FailInRecognition") |
||||
private String capital; |
||||
|
||||
|
||||
@ApiModelProperty(value = "经营范围,没有识别出来时返回FailInRecognition") |
||||
private String business; |
||||
|
||||
|
||||
@ApiModelProperty(value = "营业执照图片") |
||||
private String businessLicensePicture; |
||||
|
||||
@ApiModelProperty(value = "办学许可证件") |
||||
private String licenseForRunningSchool; |
||||
|
||||
@ApiModelProperty(value = "申请人") |
||||
private String proposer; |
||||
|
||||
@ApiModelProperty(value = "联系方式") |
||||
private String contactInformation; |
||||
|
||||
@ApiModelProperty(value = "提交时间") |
||||
private Date submitTime; |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,40 @@ |
||||
package com.huoran.nakadai.entity.req; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类信息 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@ApiModel(value = "SupplierSupplierClassification对象", description = "供应商分类信息") |
||||
public class SupplierClassificationReq { |
||||
|
||||
@ApiModelProperty(value = "分类主键") |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "分类名称") |
||||
private String classificationName; |
||||
|
||||
@ApiModelProperty(value = "父id") |
||||
private Integer parentId; |
||||
|
||||
|
||||
} |
@ -0,0 +1,64 @@ |
||||
package com.huoran.nakadai.entity.res; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@ApiModel(value = "营业执照OCR文件识别") |
||||
public class BusinessLicenseOCRResp { |
||||
|
||||
/*@ApiModelProperty(value = "配置字符串信息") |
||||
private String config_str;*/ |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "#统一社会信用代码或注册号,没有识别出来时返回FailInRecognition") |
||||
private String reg_num; |
||||
|
||||
@ApiModelProperty(value = "公司名称,没有识别出来时返回FailInRecognition") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "公司类型,没有识别出来时返回FailInRecognition") |
||||
private String type; |
||||
|
||||
|
||||
@ApiModelProperty(value = "公司法人,没有识别出来时返回FailInRecognition") |
||||
private String person; |
||||
|
||||
|
||||
@ApiModelProperty(value = "公司注册日期(例:证件上为2014年04月16日,算法返回20140416") |
||||
private String establish_date; |
||||
|
||||
@ApiModelProperty(value = "公司营业期限终止日期(例:证件上为2014年04月16日至2034年04月15日,算法返回20340415)") |
||||
private String valid_period; |
||||
|
||||
@ApiModelProperty(value = "公司地址,没有识别出来时返回FailInRecognition") |
||||
private String address; |
||||
|
||||
|
||||
@ApiModelProperty(value = "注册资本,没有识别出来时返回FailInRecognition") |
||||
private String capital; |
||||
|
||||
|
||||
@ApiModelProperty(value = "经营范围,没有识别出来时返回FailInRecognition") |
||||
private String business; |
||||
|
||||
|
||||
/* @ApiModelProperty(value = "国徽位置[top,left,height,width],没有识别出来时返回FailInDetection") |
||||
private String emblem;*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "识别结果,true表示成功,false表示失败") |
||||
private Boolean success; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,40 @@ |
||||
package com.huoran.nakadai.entity.res; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@ApiModel(value = "营业执照OCR文件识别") |
||||
public class CreditCodeResp { |
||||
|
||||
|
||||
|
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "识别结果,true表示成功,false表示失败") |
||||
private Boolean status; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "正确返回返回信息") |
||||
private String msg; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "查询结果") |
||||
private String result; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "失败返回信息") |
||||
private String reason; |
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "返回码") |
||||
private Integer code; |
||||
|
||||
} |
@ -0,0 +1,70 @@ |
||||
package com.huoran.nakadai.entity.res; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@ApiModel(value = "身份证OCR文件识别") |
||||
public class IdCardOCRResp { |
||||
@ApiModelProperty(value = "地址信息") |
||||
private String address; |
||||
|
||||
@ApiModelProperty(value = "用户姓名") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "身份证号码") |
||||
private String num; |
||||
|
||||
@ApiModelProperty(value = "民族") |
||||
private String nationality; |
||||
|
||||
@ApiModelProperty(value = "配置信息,同输入configure") |
||||
private String config_str; |
||||
|
||||
@ApiModelProperty(value = "返回信息") |
||||
private String respMessage; |
||||
|
||||
@ApiModelProperty(value = "返回错误码") |
||||
private String respCode; |
||||
|
||||
@ApiModelProperty(value = "省") |
||||
private String province; |
||||
|
||||
@ApiModelProperty(value = "市") |
||||
private String city; |
||||
|
||||
@ApiModelProperty(value = "县/区") |
||||
private String county; |
||||
|
||||
@ApiModelProperty(value = "生日") |
||||
private String birth; |
||||
|
||||
@ApiModelProperty(value = "性别") |
||||
private String sex; |
||||
|
||||
@ApiModelProperty(value = "年龄") |
||||
private String age; |
||||
|
||||
@ApiModelProperty(value = "是否是复印件") |
||||
private String is_fake; |
||||
|
||||
@ApiModelProperty(value = "有效期起始时间") |
||||
private String start_date; |
||||
|
||||
@ApiModelProperty(value = "有效期结束时间") |
||||
private String end_date; |
||||
|
||||
@ApiModelProperty(value = "签发机关") |
||||
private String issue; |
||||
|
||||
|
||||
//使用@JsonIgnore注解,忽略此属性,前端不会拿到该属性
|
||||
@JsonIgnore |
||||
@ApiModelProperty(value = "识别结果,true表示成功,false表示失败") |
||||
private Boolean success; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,42 @@ |
||||
package com.huoran.nakadai.entity.res; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@ApiModel(value = "实名认证返回的信息") |
||||
public class RealNameAuthenticationResp { |
||||
@ApiModelProperty(value = "用户姓名") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "身份证号码") |
||||
private String idNo; |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "返回信息") |
||||
private String respMessage; |
||||
|
||||
@ApiModelProperty(value = "返回错误码") |
||||
private String respCode; |
||||
|
||||
@ApiModelProperty(value = "省") |
||||
private String province; |
||||
|
||||
@ApiModelProperty(value = "市") |
||||
private String city; |
||||
|
||||
@ApiModelProperty(value = "县/区") |
||||
private String county; |
||||
|
||||
@ApiModelProperty(value = "生日") |
||||
private String birthday; |
||||
|
||||
@ApiModelProperty(value = "性别") |
||||
private String sex; |
||||
|
||||
@ApiModelProperty(value = "年龄") |
||||
private String age; |
||||
|
||||
} |
@ -0,0 +1,44 @@ |
||||
package com.huoran.nakadai.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.huoran.nakadai.entity.EnterpriseCertification; |
||||
import com.huoran.nakadai.entity.UserAccount; |
||||
import com.huoran.nakadai.entity.UserInfo; |
||||
import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
@Mapper |
||||
public interface EnterpriseCertificationMapper extends BaseMapper<EnterpriseCertification> { |
||||
|
||||
IPage<EnterpriseCertification> selectEnterpriseCertificationList(IPage<EnterpriseCertification> page, @Param("req")EnterpriseCertificationLIstReq req); |
||||
|
||||
EnterpriseCertification enterpriseCertificationDetails(@Param("id")Integer id); |
||||
|
||||
|
||||
Integer deleteTeamInformation(@Param("accountId")Integer accountId); |
||||
|
||||
|
||||
UserAccount queryAccountInformation(@Param("openId")String openId, @Param("platformId")Integer platformId); |
||||
|
||||
//逻辑删除用户信息
|
||||
Integer updateUserInformation(@Param("userId")Integer userId); |
||||
|
||||
//逻辑删除账户信息
|
||||
Integer updateAccountInformation(@Param("accountId")Integer accountId); |
||||
|
||||
Integer updateAccountInfo(@Param("userAccount")UserAccount userAccount); |
||||
|
||||
Integer updateUserInfo(@Param("userInfo") UserInfo userInfo); |
||||
|
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.huoran.nakadai.mapper; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassificationConfig; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类配置表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
public interface SupplierClassificationConfigMapper extends BaseMapper<SupplierClassificationConfig> { |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.huoran.nakadai.mapper; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassification; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类信息 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
public interface SupplierClassificationMapper extends BaseMapper<SupplierClassification> { |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.huoran.nakadai.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.huoran.nakadai.entity.UserAuthenticationInformation; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户实名认证信息记录 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-14 |
||||
*/ |
||||
@Mapper |
||||
public interface UserAuthenticationInformationMapper extends BaseMapper<UserAuthenticationInformation> { |
||||
|
||||
} |
@ -0,0 +1,159 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.nakadai.mapper.EnterpriseCertificationMapper"> |
||||
|
||||
<delete id="deleteTeamInformation"> |
||||
DELETE |
||||
a, |
||||
t, |
||||
c |
||||
FROM |
||||
k_platform_team_account a |
||||
INNER JOIN k_platform_team t ON t.manage_id = a.manage_id |
||||
INNER JOIN k_platform_team_classification c ON c.id = t.classification_id |
||||
WHERE |
||||
a.account_id = #{accountId} |
||||
</delete> |
||||
|
||||
|
||||
<select id="selectEnterpriseCertificationList" |
||||
resultType="com.huoran.nakadai.entity.EnterpriseCertification"> |
||||
SELECT |
||||
t.* |
||||
FROM |
||||
( |
||||
SELECT |
||||
IFNULL( |
||||
info.real_name, |
||||
( |
||||
SELECT |
||||
u.user_name |
||||
FROM |
||||
hr_user_account ua |
||||
INNER JOIN hr_user_info u ON u.user_id = ua.user_id |
||||
AND u.is_del = 0 |
||||
WHERE |
||||
ua.is_del = 0 |
||||
AND ua.app_open_id = c.open_id |
||||
AND ua.platform_id = 7 |
||||
) |
||||
) AS proposer, |
||||
a.phone AS contactInformation, |
||||
a.account, |
||||
c.*, |
||||
IFNULL( cla.province, '未完善' ) AS province, |
||||
IFNULL( cla.city, '未完善' ) AS city, |
||||
cla.id AS teamId, |
||||
logo_url, |
||||
brief_introduction, |
||||
cla.create_time as organizationCreationTime |
||||
FROM |
||||
hr_enterprise_certification c |
||||
INNER JOIN hr_user_account a ON a.id = c.account_id |
||||
INNER JOIN hr_user_info u ON u.user_id = a.user_id |
||||
LEFT JOIN hr_user_authentication_information info ON info.account_id = a.id |
||||
LEFT JOIN k_platform_team_account ta ON ta.account_id = a.id |
||||
LEFT JOIN k_platform_team t ON ta.manage_id = t.manage_id |
||||
LEFT JOIN k_platform_team_classification cla ON cla.id = t.classification_id |
||||
AND is_team = 1 |
||||
AND cla.is_del = 0 |
||||
WHERE |
||||
a.is_del = 0 |
||||
AND u.is_del = 0 |
||||
) t |
||||
WHERE |
||||
t.platform_source = #{req.platformSource} |
||||
|
||||
|
||||
<if test=" req.auditStatus!= null and req.auditStatus!= '' or req.auditStatus ==0"> |
||||
and t.audit_status =#{req.auditStatus,jdbcType=INTEGER} |
||||
</if> |
||||
|
||||
|
||||
<if test=" req.authenticationStatus!= null and req.authenticationStatus!= '' or req.authenticationStatus ==0"> |
||||
and t.authentication_status =#{req.authenticationStatus,jdbcType=INTEGER} |
||||
</if> |
||||
|
||||
<if test="req.startCommitTime != '' and req.startCommitTime!= null |
||||
and req.endCommitTime != '' and req.endCommitTime!= null"> |
||||
AND date_format( t.submit_time, '%Y-%m-%d' ) |
||||
BETWEEN #{req.startCommitTime} AND #{req.endCommitTime} |
||||
</if> |
||||
|
||||
<if test="req.keyWord!=null and req.keyWord!='' "> |
||||
and ( |
||||
proposer like concat('%' #{req.keyWord} '%') |
||||
or account like concat('%' #{req.keyWord} '%') |
||||
or contactInformation like concat('%' #{req.keyWord} '%') |
||||
or company_name like concat('%' #{req.keyWord} '%')) |
||||
</if> |
||||
|
||||
|
||||
<if test="req.province!=null and req.province!='' "> |
||||
and t.province=#{req.province,jdbcType=VARCHAR} |
||||
</if> |
||||
|
||||
<if test="req.city!=null and req.city!='' "> |
||||
and t.city=#{req.province,jdbcType=VARCHAR} |
||||
</if> |
||||
</select> |
||||
<select id="enterpriseCertificationDetails" resultType="com.huoran.nakadai.entity.EnterpriseCertification"> |
||||
SELECT |
||||
t.* |
||||
FROM |
||||
( |
||||
SELECT |
||||
IFNULL( info.real_name, u.user_name ) AS proposer, |
||||
a.phone AS contactInformation, |
||||
a.account, |
||||
c.*, |
||||
IFNULL( cla.province, '未完善' ) AS province, |
||||
IFNULL( cla.city, '未完善' ) AS city, |
||||
cla.id AS teamId, |
||||
logo_url, |
||||
brief_introduction |
||||
FROM |
||||
hr_enterprise_certification c |
||||
INNER JOIN hr_user_account a ON a.id = c.account_id |
||||
INNER JOIN hr_user_info u ON u.user_id = a.user_id |
||||
LEFT JOIN hr_user_authentication_information info ON info.account_id = a.id |
||||
LEFT JOIN k_platform_team_account ta ON ta.account_id = a.id |
||||
LEFT JOIN k_platform_team t ON ta.manage_id = t.manage_id |
||||
LEFT JOIN k_platform_team_classification cla ON cla.id = t.classification_id |
||||
AND is_team = 1 |
||||
AND cla.is_del = 0 |
||||
WHERE |
||||
a.is_del = 0 |
||||
AND u.is_del = 0 |
||||
) t |
||||
WHERE |
||||
t.id = #{id} |
||||
</select> |
||||
<select id="queryAccountInformation" resultType="com.huoran.nakadai.entity.UserAccount"> |
||||
SELECT |
||||
* |
||||
FROM |
||||
hr_user_account |
||||
WHERE |
||||
is_del = 0 |
||||
AND app_open_id = #{openId} |
||||
AND platform_id = #{platformId} |
||||
</select> |
||||
|
||||
|
||||
<update id="updateUserInformation"> |
||||
update hr_user_info set is_del = 1 WHERE user_id = #{userId} |
||||
|
||||
</update> |
||||
<update id="updateAccountInformation"> |
||||
update hr_user_account set is_del = 1 WHERE id =#{accountId} |
||||
|
||||
</update> |
||||
<update id="updateAccountInfo"> |
||||
update hr_user_account set account = #{userAccount.account} WHERE is_del = 0 and id = #{userAccount.id} |
||||
</update> |
||||
|
||||
<update id="updateUserInfo"> |
||||
update hr_user_info set user_name = #{userInfo.userName} WHERE is_del = 0 and user_id = #{userInfo.userId} |
||||
</update> |
||||
</mapper> |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.nakadai.mapper.SupplierClassificationConfigMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.nakadai.mapper.SupplierClassificationMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.nakadai.mapper.UserAuthenticationInformationMapper"> |
||||
</mapper> |
@ -0,0 +1,40 @@ |
||||
package com.huoran.nakadai.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.nakadai.entity.EnterpriseCertification; |
||||
import com.huoran.nakadai.entity.UserAccount; |
||||
import com.huoran.nakadai.entity.UserInfo; |
||||
import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 服务类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
public interface EnterpriseCertificationService extends IService<EnterpriseCertification> { |
||||
EnterpriseCertification checkWhetherItExists(String comapnyName, Integer id,String opnenId); |
||||
|
||||
R selectEnterpriseCertificationList(EnterpriseCertificationLIstReq req); |
||||
|
||||
R enterpriseCertificationDetails(Integer id); |
||||
|
||||
boolean deleteTeamInformation(Integer accountId); |
||||
|
||||
UserAccount queryAccountInformation(String openId,Integer platformId); |
||||
|
||||
//逻辑删除用户信息
|
||||
boolean deleteUserInformation(Integer userId); |
||||
|
||||
//逻辑删除账户信息
|
||||
boolean deleteAccountInformation(Integer accountId); |
||||
|
||||
boolean updateAccountInfo(UserAccount userAccount); |
||||
|
||||
boolean updateUserInfo( UserInfo userInfo); |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.huoran.nakadai.service; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassificationConfig; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类配置表 服务类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
public interface SupplierClassificationConfigService extends IService<SupplierClassificationConfig> { |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.huoran.nakadai.service; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassification; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类信息 服务类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
public interface SupplierClassificationService extends IService<SupplierClassification> { |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.huoran.nakadai.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.huoran.nakadai.entity.UserAuthenticationInformation; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户实名认证信息记录 服务类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-14 |
||||
*/ |
||||
public interface UserAuthenticationInformationService extends IService<UserAuthenticationInformation> { |
||||
} |
@ -0,0 +1,83 @@ |
||||
package com.huoran.nakadai.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.nakadai.entity.EnterpriseCertification; |
||||
import com.huoran.nakadai.entity.UserAccount; |
||||
import com.huoran.nakadai.entity.UserInfo; |
||||
import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; |
||||
import com.huoran.nakadai.mapper.EnterpriseCertificationMapper; |
||||
import com.huoran.nakadai.service.EnterpriseCertificationService; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.ObjectUtils; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业认证审核 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-18 |
||||
*/ |
||||
@Service |
||||
public class EnterpriseCertificationServiceImpl extends ServiceImpl<EnterpriseCertificationMapper, EnterpriseCertification> implements EnterpriseCertificationService { |
||||
|
||||
@Override |
||||
public EnterpriseCertification checkWhetherItExists(String company_name, Integer id, String opnenId) { |
||||
QueryWrapper<EnterpriseCertification> wrapper = new QueryWrapper<>(); |
||||
wrapper.eq("company_name", company_name); |
||||
|
||||
|
||||
if (!ObjectUtils.isEmpty(id)) { |
||||
wrapper.last(" and id <> " + id); |
||||
} |
||||
return getOne(wrapper); |
||||
} |
||||
|
||||
@Override |
||||
public R selectEnterpriseCertificationList(EnterpriseCertificationLIstReq req) { |
||||
Page<EnterpriseCertification> page = new Page<EnterpriseCertification>(req.getPageNum(), req.getPageSize()); |
||||
IPage<EnterpriseCertification> pageList = baseMapper.selectEnterpriseCertificationList(page, req); |
||||
|
||||
|
||||
return R.ok().put("data", pageList); |
||||
} |
||||
|
||||
@Override |
||||
public R enterpriseCertificationDetails(Integer id) { |
||||
return R.ok().put("data", baseMapper.enterpriseCertificationDetails(id)); |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteTeamInformation(Integer accountId) { |
||||
return baseMapper.deleteTeamInformation(accountId) > 0; |
||||
} |
||||
|
||||
@Override |
||||
public UserAccount queryAccountInformation(String openId, Integer platformId) { |
||||
return baseMapper.queryAccountInformation(openId, platformId); |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteUserInformation(Integer userId) { |
||||
return baseMapper.updateUserInformation(userId) > 0; |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteAccountInformation(Integer accountId) { |
||||
return baseMapper.deleteTeamInformation(accountId) > 0; |
||||
} |
||||
|
||||
@Override |
||||
public boolean updateAccountInfo(UserAccount userAccount) { |
||||
return baseMapper.updateAccountInfo(userAccount)>0; |
||||
} |
||||
|
||||
@Override |
||||
public boolean updateUserInfo(UserInfo userInfo) { |
||||
return baseMapper.updateUserInfo(userInfo)>0; |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.huoran.nakadai.service.impl; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassificationConfig; |
||||
import com.huoran.nakadai.mapper.SupplierClassificationConfigMapper; |
||||
import com.huoran.nakadai.service.SupplierClassificationConfigService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类配置表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
@Service |
||||
public class SupplierClassificationConfigServiceImpl extends ServiceImpl<SupplierClassificationConfigMapper, SupplierClassificationConfig> implements SupplierClassificationConfigService { |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.huoran.nakadai.service.impl; |
||||
|
||||
import com.huoran.nakadai.entity.SupplierClassification; |
||||
import com.huoran.nakadai.mapper.SupplierClassificationMapper; |
||||
import com.huoran.nakadai.service.SupplierClassificationService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 供应商分类信息 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-27 |
||||
*/ |
||||
@Service |
||||
public class SupplierClassificationServiceImpl extends ServiceImpl<SupplierClassificationMapper, SupplierClassification> implements SupplierClassificationService { |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.huoran.nakadai.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.huoran.nakadai.entity.UserAuthenticationInformation; |
||||
import com.huoran.nakadai.mapper.UserAuthenticationInformationMapper; |
||||
import com.huoran.nakadai.service.UserAuthenticationInformationService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户实名认证信息记录 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-14 |
||||
*/ |
||||
@Service |
||||
public class UserAuthenticationInformationServiceImpl extends ServiceImpl<UserAuthenticationInformationMapper, UserAuthenticationInformation> implements UserAuthenticationInformationService { |
||||
|
||||
} |
@ -0,0 +1,148 @@ |
||||
package com.huoran.nakadai.utils.ali; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.alibaba.nacos.client.identify.Base64; |
||||
import com.huoran.nakadai.config.AliRealNameAuthenticationConfig; |
||||
import okhttp3.*; |
||||
import org.apache.http.HttpResponse; |
||||
import org.apache.http.util.EntityUtils; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class FaceRecognitionAidUtil { |
||||
public static String postData(String appCode, String url, String name, String idNo) throws IOException { |
||||
String result = ""; |
||||
RequestBody formBody = new FormBody.Builder().add("name", name).add("idNo", idNo).build(); |
||||
Request request = new Request.Builder().url(url).addHeader("Authorization", "APPCODE " + appCode).post(formBody).build(); |
||||
|
||||
Call call = new OkHttpClient().newCall(request); |
||||
Response response = null; |
||||
try { |
||||
response = call.execute(); |
||||
} catch (IOException e) { |
||||
System.out.println("execute failed, message:" + e.getMessage()); |
||||
} |
||||
|
||||
assert response != null; |
||||
if (!response.isSuccessful()) { |
||||
// 状态码为403时一般是套餐包用尽,需续购;注意:续购不会改变秘钥(appCode),仅增加次数
|
||||
// 续购链接:https://market.aliyun.com/products/57000002/cmapi025518.html
|
||||
System.out.println("request failed----" + "返回状态码" + response.code() + ",message:" + response.message()); |
||||
} |
||||
result = response.body().string(); //此处不可以使用toString()方法,该方法已过期
|
||||
|
||||
return result; |
||||
} |
||||
|
||||
public static JSONObject checkIdcard(Object idcard, Object name) { |
||||
JSONObject result = new JSONObject(); |
||||
|
||||
Map<String, String> querys = new HashMap<>(); |
||||
querys.put("idCard", idcard.toString()); |
||||
querys.put("name", name.toString()); |
||||
|
||||
try { |
||||
HttpResponse response = HttpUtils.doPost(AliRealNameAuthenticationConfig.ALI_IDCHECK_HOST, AliRealNameAuthenticationConfig.ALI_IDCHECK_PATH, "POST", AliRealNameAuthenticationConfig.buildHeaders(), querys, new HashMap<>() // No need to pass an empty map for bodys
|
||||
); |
||||
|
||||
int stat = response.getStatusLine().getStatusCode(); |
||||
if (stat == 200) { |
||||
String res = EntityUtils.toString(response.getEntity()); |
||||
result = JSON.parseObject(res); |
||||
} else { |
||||
result.put("error", "Http code: " + stat); |
||||
result.put("message", EntityUtils.toString(response.getEntity())); |
||||
} |
||||
} catch (Exception e) { |
||||
result.put("error", "实名认证检测失败"); |
||||
result.put("message", e.getMessage()); |
||||
// 记录错误而不仅仅打印堆栈跟踪
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
System.out.println(result); |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
public static String img_base64(String path) { |
||||
/** |
||||
* 对path进行判断,如果是本地文件就二进制读取并base64编码,如果是url,则返回 |
||||
*/ |
||||
String imgBase64=""; |
||||
if (path.startsWith("http")){ |
||||
imgBase64 = path; |
||||
}else { |
||||
try { |
||||
File file = new File(path); |
||||
byte[] content = new byte[(int) file.length()]; |
||||
FileInputStream finputstream = new FileInputStream(file); |
||||
finputstream.read(content); |
||||
finputstream.close(); |
||||
imgBase64 = new String(Base64.encodeBase64(content)); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
return imgBase64; |
||||
} |
||||
} |
||||
|
||||
return imgBase64; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
public static String IdCardOCRRecognition(String imgFile,String side){ |
||||
String method = "POST"; |
||||
Map<String, String> headers = new HashMap<String, String>(); |
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); |
||||
//根据API的要求,定义相对应的Content-Type
|
||||
headers.put("Content-Type", "application/json; charset=UTF-8"); |
||||
|
||||
Map<String, String> querys = new HashMap<String, String>(); |
||||
// 对图像进行base64编码
|
||||
String imgBase64 = FaceRecognitionAidUtil.img_base64(imgFile); |
||||
|
||||
//configure配置
|
||||
JSONObject configObj = new JSONObject(); |
||||
// configObj.put("side", "face");
|
||||
configObj.put("side", side); |
||||
|
||||
String config_str = configObj.toString(); |
||||
|
||||
// 拼装请求body的json字符串
|
||||
JSONObject requestObj = new JSONObject(); |
||||
requestObj.put("image", imgBase64); |
||||
if (configObj.size() > 0) { |
||||
requestObj.put("configure", config_str); |
||||
} |
||||
String bodys = requestObj.toString(); |
||||
|
||||
try { |
||||
HttpResponse response = HttpUtils.doPost(AliRealNameAuthenticationConfig.ALI_API_HOST, AliRealNameAuthenticationConfig.ALI_API_PATH, method, headers, querys, bodys); |
||||
int stat = response.getStatusLine().getStatusCode(); |
||||
if (stat != 200) { |
||||
System.out.println("Http code: " + stat); |
||||
System.out.println("http header error msg: " + response.getFirstHeader("X-Ca-Error-Message")); |
||||
System.out.println("Http body error msg:" + EntityUtils.toString(response.getEntity())); |
||||
} |
||||
|
||||
String res = EntityUtils.toString(response.getEntity()); |
||||
/* JSONObject res_obj = JSON.parseObject(res); |
||||
|
||||
System.out.println(res_obj.toJSONString());*/ |
||||
return res; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,312 @@ |
||||
package com.huoran.nakadai.utils.ali; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.apache.http.HttpResponse; |
||||
import org.apache.http.NameValuePair; |
||||
import org.apache.http.client.HttpClient; |
||||
import org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
import org.apache.http.client.methods.HttpDelete; |
||||
import org.apache.http.client.methods.HttpGet; |
||||
import org.apache.http.client.methods.HttpPost; |
||||
import org.apache.http.client.methods.HttpPut; |
||||
import org.apache.http.conn.ClientConnectionManager; |
||||
import org.apache.http.conn.scheme.Scheme; |
||||
import org.apache.http.conn.scheme.SchemeRegistry; |
||||
import org.apache.http.conn.ssl.SSLSocketFactory; |
||||
import org.apache.http.entity.ByteArrayEntity; |
||||
import org.apache.http.entity.StringEntity; |
||||
import org.apache.http.impl.client.DefaultHttpClient; |
||||
import org.apache.http.message.BasicNameValuePair; |
||||
|
||||
import javax.net.ssl.SSLContext; |
||||
import javax.net.ssl.TrustManager; |
||||
import javax.net.ssl.X509TrustManager; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URLEncoder; |
||||
import java.security.KeyManagementException; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.security.cert.X509Certificate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@SuppressWarnings("deprecation") |
||||
public class HttpUtils { |
||||
|
||||
/** |
||||
* get |
||||
* |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doGet(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpGet request = new HttpGet(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* post form |
||||
* |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @param bodys |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doPost(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys, |
||||
Map<String, String> bodys) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
if (bodys != null) { |
||||
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>(); |
||||
|
||||
for (String key : bodys.keySet()) { |
||||
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); |
||||
} |
||||
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); |
||||
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); |
||||
request.setEntity(formEntity); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* Post String |
||||
* |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @param body |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doPost(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys, |
||||
String body) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(body)) { |
||||
request.setEntity(new StringEntity(body, "utf-8")); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* Post stream |
||||
* |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @param body |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doPost(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys, |
||||
byte[] body) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
if (body != null) { |
||||
request.setEntity(new ByteArrayEntity(body)); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* Put String |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @param body |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doPut(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys, |
||||
String body) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(body)) { |
||||
request.setEntity(new StringEntity(body, "utf-8")); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* Put stream |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @param body |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doPut(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys, |
||||
byte[] body) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
if (body != null) { |
||||
request.setEntity(new ByteArrayEntity(body)); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
/** |
||||
* Delete |
||||
* |
||||
* @param host |
||||
* @param path |
||||
* @param method |
||||
* @param headers |
||||
* @param querys |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static HttpResponse doDelete(String host, String path, String method, |
||||
Map<String, String> headers, |
||||
Map<String, String> querys) |
||||
throws Exception { |
||||
HttpClient httpClient = wrapClient(host); |
||||
|
||||
HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); |
||||
for (Map.Entry<String, String> e : headers.entrySet()) { |
||||
request.addHeader(e.getKey(), e.getValue()); |
||||
} |
||||
|
||||
return httpClient.execute(request); |
||||
} |
||||
|
||||
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException { |
||||
StringBuilder sbUrl = new StringBuilder(); |
||||
sbUrl.append(host); |
||||
if (!StringUtils.isBlank(path)) { |
||||
sbUrl.append(path); |
||||
} |
||||
if (null != querys) { |
||||
StringBuilder sbQuery = new StringBuilder(); |
||||
for (Map.Entry<String, String> query : querys.entrySet()) { |
||||
if (0 < sbQuery.length()) { |
||||
sbQuery.append("&"); |
||||
} |
||||
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { |
||||
sbQuery.append(query.getValue()); |
||||
} |
||||
if (!StringUtils.isBlank(query.getKey())) { |
||||
sbQuery.append(query.getKey()); |
||||
if (!StringUtils.isBlank(query.getValue())) { |
||||
sbQuery.append("="); |
||||
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); |
||||
} |
||||
} |
||||
} |
||||
if (0 < sbQuery.length()) { |
||||
sbUrl.append("?").append(sbQuery); |
||||
} |
||||
} |
||||
|
||||
return sbUrl.toString(); |
||||
} |
||||
|
||||
private static HttpClient wrapClient(String host) { |
||||
HttpClient httpClient = new DefaultHttpClient(); |
||||
if (host.startsWith("https://")) { |
||||
sslClient(httpClient); |
||||
} |
||||
|
||||
return httpClient; |
||||
} |
||||
|
||||
private static void sslClient(HttpClient httpClient) { |
||||
try { |
||||
SSLContext ctx = SSLContext.getInstance("TLS"); |
||||
X509TrustManager tm = new X509TrustManager() { |
||||
public X509Certificate[] getAcceptedIssuers() { |
||||
return null; |
||||
} |
||||
public void checkClientTrusted(X509Certificate[] xcs, String str) { |
||||
|
||||
} |
||||
public void checkServerTrusted(X509Certificate[] xcs, String str) { |
||||
|
||||
} |
||||
}; |
||||
ctx.init(null, new TrustManager[] { tm }, null); |
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx); |
||||
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
||||
ClientConnectionManager ccm = httpClient.getConnectionManager(); |
||||
SchemeRegistry registry = ccm.getSchemeRegistry(); |
||||
registry.register(new Scheme("https", 443, ssf)); |
||||
} catch (KeyManagementException ex) { |
||||
throw new RuntimeException(ex); |
||||
} catch (NoSuchAlgorithmException ex) { |
||||
throw new RuntimeException(ex); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue