From 1e82fe25e49afe2587be410d14ec5bf43dac831d Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Mon, 18 Dec 2023 18:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E8=AE=A4=E8=AF=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AliRealNameAuthenticationController.java | 45 +++++---- .../EnterpriseCertificationController.java | 80 +++++++++++++++ .../users/entity/EnterpriseCertification.java | 97 +++++++++++++++++++ .../req/EnterpriseCertificationLIstReq.java | 44 +++++++++ .../req/EnterpriseCertificationReq.java | 60 ++++++++++++ .../mapper/EnterpriseCertificationMapper.java | 20 ++++ .../UserAuthenticationInformationMapper.java | 1 + .../xml/EnterpriseCertificationMapper.xml | 46 +++++++++ .../UserAuthenticationInformationMapper.xml | 1 - .../EnterpriseCertificationService.java | 20 ++++ .../UserAuthenticationInformationService.java | 1 - .../EnterpriseCertificationServiceImpl.java | 38 ++++++++ 12 files changed, 430 insertions(+), 23 deletions(-) create mode 100644 users/src/main/java/com/huoran/users/controller/EnterpriseCertificationController.java create mode 100644 users/src/main/java/com/huoran/users/entity/EnterpriseCertification.java create mode 100644 users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationLIstReq.java create mode 100644 users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationReq.java create mode 100644 users/src/main/java/com/huoran/users/mapper/EnterpriseCertificationMapper.java create mode 100644 users/src/main/java/com/huoran/users/mapper/xml/EnterpriseCertificationMapper.xml create mode 100644 users/src/main/java/com/huoran/users/service/EnterpriseCertificationService.java create mode 100644 users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java diff --git a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java index f7ceccf..b7281d6 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -8,11 +8,14 @@ import com.google.gson.Gson; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; import com.huoran.users.config.AliRealNameAuthenticationConfig; +import com.huoran.users.entity.EnterpriseCertification; import com.huoran.users.entity.UserAuthenticationInformation; +import com.huoran.users.entity.req.EnterpriseCertificationReq; import com.huoran.users.entity.res.BusinessLicenseOCRResp; import com.huoran.users.entity.res.CreditCodeResp; import com.huoran.users.entity.res.IdCardOCRResp; import com.huoran.users.entity.res.RealNameAuthenticationResp; +import com.huoran.users.service.EnterpriseCertificationService; import com.huoran.users.service.UserAuthenticationInformationService; import com.huoran.users.utils.ali.FaceRecognitionAidUtil; import com.huoran.users.utils.ali.HttpUtils; @@ -40,6 +43,11 @@ public class AliRealNameAuthenticationController { @Autowired public UserAuthenticationInformationService service; + + //企业认证信息存储 + @Autowired + public EnterpriseCertificationService enterpriseCertificationService; + /* @ApiOperation(value = "身份证图片验证(对象)") @PostMapping("/faceAuthenticationByObject") public R faceAuthenticationByObject(HttpServletRequest request, @RequestBody IdCardOCRReq req) throws IOException { @@ -160,11 +168,14 @@ public class AliRealNameAuthenticationController { } - @ApiOperation(value = "统一社会信用代码认证") + @ApiOperation(value = "统一社会信用代码认证",response = CreditCodeResp.class) @PostMapping("/creditCodeAuthentication") - public R creditCodeAuthentication(@RequestParam(name = "comapnyName", required = true) @ApiParam(value = "公司的名字") String comapnyName, - @RequestParam(name = "legalPerson", required = true) @ApiParam(value = "法人") String legalPerson, - @RequestParam(name = "creditCode", required = true) @ApiParam(value = "统一社会信用代码") String creditCode, HttpServletRequest request) throws IOException { + 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"; @@ -172,21 +183,22 @@ public class AliRealNameAuthenticationController { //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); Map querys = new HashMap(); - querys.put("ComapnyName", comapnyName); - querys.put("CreditCode", creditCode); - querys.put("LegalPersonName", legalPerson); + 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); -// System.out.println(response.toString()); - //获取response的body - //System.out.println(EntityUtils.toString(response.getEntity())); - CreditCodeResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), CreditCodeResp.class); if (info.getStatus()) { - return R.ok().put("message", "认证通过!"); + if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName()))){ + errorMsg = "企业名称已存在"; + throw new RuntimeException(errorMsg); + } + enterpriseCertificationService.save(enterpriseCertification); + return R.ok("提交成功,请等待审核!"); } else { errorMsg = info.getReason(); return R.ok().put("message", info.getReason()); @@ -199,15 +211,6 @@ public class AliRealNameAuthenticationController { } - public static T jsonToObject(String json) { - try { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(json, new TypeReference() {}); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } diff --git a/users/src/main/java/com/huoran/users/controller/EnterpriseCertificationController.java b/users/src/main/java/com/huoran/users/controller/EnterpriseCertificationController.java new file mode 100644 index 0000000..a5b3217 --- /dev/null +++ b/users/src/main/java/com/huoran/users/controller/EnterpriseCertificationController.java @@ -0,0 +1,80 @@ +package com.huoran.users.controller; + +import com.huoran.common.response.R; +import com.huoran.common.utils.TokenUtils; +import com.huoran.users.entity.EnterpriseCertification; +import com.huoran.users.entity.EnterpriseCertification; +import com.huoran.users.entity.req.EnterpriseCertificationLIstReq; +import com.huoran.users.service.EnterpriseCertificationService; +import com.huoran.users.service.EnterpriseCertificationService; +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; + +/** + *

+ * 企业认证审核 前端控制器 + *

+ * + * @author chen + * @since 2023-12-18 + */ + +@Api(value = "后台-企业实名认证相关", tags = "后台-企业实名认证相关") +@RestController +@RequestMapping("/enterprise/certification") +public class EnterpriseCertificationController { + + + @Autowired + public EnterpriseCertificationService service; + + @PostMapping("/selectEnterpriseCertificationList") + @ApiOperation(value = "企业认证列表", response = EnterpriseCertification.class) + public R selectEnterpriseCertificationList(@RequestBody EnterpriseCertificationLIstReq req) { + return service.selectEnterpriseCertificationList(req); + } + + + @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("/save") + @ApiOperation(value = "新增", 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)); + 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("/batchDeletion") + @ApiOperation(value = "批量删除", response = EnterpriseCertification.class) + public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List ids) { + boolean delState = service.removeByIds(ids); + return delState ? R.ok() : R.error("删除失败"); + } + +} + diff --git a/users/src/main/java/com/huoran/users/entity/EnterpriseCertification.java b/users/src/main/java/com/huoran/users/entity/EnterpriseCertification.java new file mode 100644 index 0000000..dcc26fc --- /dev/null +++ b/users/src/main/java/com/huoran/users/entity/EnterpriseCertification.java @@ -0,0 +1,97 @@ +package com.huoran.users.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +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; + +/** + *

+ * 企业认证审核 + *

+ * + * @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驳回)") + private Integer auditStatus; + + @ApiModelProperty(value = "来源区分(5:幼儿园,6:供应商)") + private String platformsOurce; + + + @ApiModelProperty(value = "账号") + @TableField(exist = false) + private String account; + + @ApiModelProperty(value = "申请人") + @TableField(exist = false) + private String proposer; + + @ApiModelProperty(value = "联系方式") + @TableField(exist = false) + private String contactInformation; + + +} diff --git a/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationLIstReq.java b/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationLIstReq.java new file mode 100644 index 0000000..ced38ec --- /dev/null +++ b/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationLIstReq.java @@ -0,0 +1,44 @@ +package com.huoran.users.entity.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 企业认证审核 + *

+ * + * @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 = "来源区分(5:幼儿园,6:供应商)") + private String platformsOurce; + + + @ApiModelProperty(value = "账号") + private String account; + + @ApiModelProperty(value = "当前页数", name = "pageNum", example = "1", required = true) + private Integer pageNum; + @ApiModelProperty(value = "当前页需要显示的数量", name = "pageSize", example = "10", required = true) + private Integer pageSize; + +} diff --git a/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationReq.java b/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationReq.java new file mode 100644 index 0000000..439d920 --- /dev/null +++ b/users/src/main/java/com/huoran/users/entity/req/EnterpriseCertificationReq.java @@ -0,0 +1,60 @@ +package com.huoran.users.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; + + + + +} diff --git a/users/src/main/java/com/huoran/users/mapper/EnterpriseCertificationMapper.java b/users/src/main/java/com/huoran/users/mapper/EnterpriseCertificationMapper.java new file mode 100644 index 0000000..ff1b418 --- /dev/null +++ b/users/src/main/java/com/huoran/users/mapper/EnterpriseCertificationMapper.java @@ -0,0 +1,20 @@ +package com.huoran.users.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.huoran.users.entity.EnterpriseCertification; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.huoran.users.entity.req.EnterpriseCertificationLIstReq; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * 企业认证审核 Mapper 接口 + *

+ * + * @author chen + * @since 2023-12-18 + */ +public interface EnterpriseCertificationMapper extends BaseMapper { + + IPage selectEnterpriseCertificationList(IPage page, @Param("req")EnterpriseCertificationLIstReq req); +} diff --git a/users/src/main/java/com/huoran/users/mapper/UserAuthenticationInformationMapper.java b/users/src/main/java/com/huoran/users/mapper/UserAuthenticationInformationMapper.java index a6f4402..a34d730 100644 --- a/users/src/main/java/com/huoran/users/mapper/UserAuthenticationInformationMapper.java +++ b/users/src/main/java/com/huoran/users/mapper/UserAuthenticationInformationMapper.java @@ -1,5 +1,6 @@ package com.huoran.users.mapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.huoran.users.entity.UserAuthenticationInformation; import com.baomidou.mybatisplus.core.mapper.BaseMapper; diff --git a/users/src/main/java/com/huoran/users/mapper/xml/EnterpriseCertificationMapper.xml b/users/src/main/java/com/huoran/users/mapper/xml/EnterpriseCertificationMapper.xml new file mode 100644 index 0000000..d01c529 --- /dev/null +++ b/users/src/main/java/com/huoran/users/mapper/xml/EnterpriseCertificationMapper.xml @@ -0,0 +1,46 @@ + + + + + + diff --git a/users/src/main/java/com/huoran/users/mapper/xml/UserAuthenticationInformationMapper.xml b/users/src/main/java/com/huoran/users/mapper/xml/UserAuthenticationInformationMapper.xml index 31be555..57eb2c8 100644 --- a/users/src/main/java/com/huoran/users/mapper/xml/UserAuthenticationInformationMapper.xml +++ b/users/src/main/java/com/huoran/users/mapper/xml/UserAuthenticationInformationMapper.xml @@ -1,5 +1,4 @@ - diff --git a/users/src/main/java/com/huoran/users/service/EnterpriseCertificationService.java b/users/src/main/java/com/huoran/users/service/EnterpriseCertificationService.java new file mode 100644 index 0000000..ff1b565 --- /dev/null +++ b/users/src/main/java/com/huoran/users/service/EnterpriseCertificationService.java @@ -0,0 +1,20 @@ +package com.huoran.users.service; + +import com.huoran.common.response.R; +import com.huoran.users.entity.EnterpriseCertification; +import com.baomidou.mybatisplus.extension.service.IService; +import com.huoran.users.entity.req.EnterpriseCertificationLIstReq; + +/** + *

+ * 企业认证审核 服务类 + *

+ * + * @author chen + * @since 2023-12-18 + */ +public interface EnterpriseCertificationService extends IService { + EnterpriseCertification checkWhetherItExists(String comapnyName); + + R selectEnterpriseCertificationList(EnterpriseCertificationLIstReq req); +} diff --git a/users/src/main/java/com/huoran/users/service/UserAuthenticationInformationService.java b/users/src/main/java/com/huoran/users/service/UserAuthenticationInformationService.java index b975fdc..bad24f9 100644 --- a/users/src/main/java/com/huoran/users/service/UserAuthenticationInformationService.java +++ b/users/src/main/java/com/huoran/users/service/UserAuthenticationInformationService.java @@ -12,5 +12,4 @@ import com.baomidou.mybatisplus.extension.service.IService; * @since 2023-12-14 */ public interface UserAuthenticationInformationService extends IService { - } diff --git a/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java b/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java new file mode 100644 index 0000000..370e92c --- /dev/null +++ b/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java @@ -0,0 +1,38 @@ +package com.huoran.users.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.huoran.common.response.R; +import com.huoran.users.entity.EnterpriseCertification; +import com.huoran.users.entity.req.EnterpriseCertificationLIstReq; +import com.huoran.users.mapper.EnterpriseCertificationMapper; +import com.huoran.users.service.EnterpriseCertificationService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 企业认证审核 服务实现类 + *

+ * + * @author chen + * @since 2023-12-18 + */ +@Service +public class EnterpriseCertificationServiceImpl extends ServiceImpl implements EnterpriseCertificationService { + + @Override + public EnterpriseCertification checkWhetherItExists(String company_name) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("company_name", company_name); + return getOne(wrapper); + } + + @Override + public R selectEnterpriseCertificationList(EnterpriseCertificationLIstReq req) { + Page page = new Page(req.getPageNum(), req.getPageSize()); + IPage pageList = baseMapper.selectEnterpriseCertificationList(page, req); + return R.ok().put("data", pageList); + } +}