企业入驻
parent
e50bf4158b
commit
eebcdacbc3
|
@ -17,6 +17,19 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baidu.aip</groupId>
|
||||
<artifactId>java-sdk</artifactId>
|
||||
<version>4.12.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dragon</groupId>
|
||||
<artifactId>dragon-common-core</artifactId>
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.dragon.vehicle.company.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 企业信息
|
||||
*/
|
||||
@Data
|
||||
public class FirmInfo {
|
||||
|
||||
/**
|
||||
* 企业编号
|
||||
*/
|
||||
private Integer firmId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
/**
|
||||
* 企业电话
|
||||
*/
|
||||
private String firmTel;
|
||||
/**
|
||||
* 企业详细地址
|
||||
*/
|
||||
private String firmAddress;
|
||||
/**
|
||||
* 企业法定代表人
|
||||
*/
|
||||
private String firmRepresentative;
|
||||
/**
|
||||
* 法定代表人电话
|
||||
*/
|
||||
private String firmRepresentativePhone;
|
||||
/**
|
||||
* 法定代表人身份证号
|
||||
*/
|
||||
private String firmRepresentativeId;
|
||||
/**
|
||||
* 开户行名称
|
||||
*/
|
||||
private String firmBank;
|
||||
/**
|
||||
* 开户行支行
|
||||
*/
|
||||
private String firmBankBranch;
|
||||
/**
|
||||
* 银行账号
|
||||
*/
|
||||
private String firmBankAccount;
|
||||
/**
|
||||
* 营业执照号
|
||||
*/
|
||||
private String firmBusinessLicense;
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
*/
|
||||
private String unifiedSocialCredit;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.dragon.vehicle.company.common.utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* 百度检查
|
||||
*/
|
||||
public class BaiDuAiCheck {
|
||||
|
||||
|
||||
/**
|
||||
* 文本审核
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject checkText(String text){
|
||||
JSONObject reponse = BaiDuAiConfig.client.textCensorUserDefined(text);
|
||||
return reponse;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.dragon.vehicle.company.common.utils;
|
||||
|
||||
|
||||
import com.baidu.aip.contentcensor.AipContentCensor;
|
||||
|
||||
|
||||
/**
|
||||
* 百度敏感信息配置
|
||||
*/
|
||||
public class BaiDuAiConfig {
|
||||
|
||||
//设置APPID/AK/SK
|
||||
private static final String APP_ID="41793871";
|
||||
private static final String API_KEY="kmuqlfvH0QSAzsHGuNQRpICB";
|
||||
public static final String SECRET_KEY="cF3KyORcop0x0PUiz3KUu1CcYFyBwzwp";
|
||||
|
||||
|
||||
/**
|
||||
* 初始化客户端
|
||||
*/
|
||||
public static final AipContentCensor client = new AipContentCensor(APP_ID, API_KEY, SECRET_KEY);
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.dragon.vehicle.company.common.utils;
|
||||
|
||||
|
||||
import com.dragon.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 企业认真工具类
|
||||
*/
|
||||
public class ValidatorUtils {
|
||||
|
||||
public static boolean isPhone(String phone){
|
||||
if (StringUtils.isEmpty(phone)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//手机号校验规则
|
||||
String regex="^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[1|8|9]))\\d{8}$";
|
||||
if (phone.length()!= 11){
|
||||
return false;
|
||||
}else{
|
||||
Pattern p = Pattern.compile(regex);
|
||||
Matcher matcher = p.matcher(phone);
|
||||
boolean isMatch = matcher.matches();
|
||||
return isMatch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 座机号码校验
|
||||
* @param tel
|
||||
* @return
|
||||
*/
|
||||
public static boolean isTel(String tel){
|
||||
if (tel !=null && !tel.isEmpty()){
|
||||
boolean matches = Pattern.matches(
|
||||
"^\\d{3}-\\d{8}$|^\\d{4}-\\d{7}$",tel
|
||||
);
|
||||
return matches;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证校验
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean validator(String id){
|
||||
//
|
||||
String str="^[1-9]\\d{5}(?:18|19|20)\\d{2}(?:0\\d|10|11|12)(?:0[1-9]|[1-2]\\d|30|31)\\d{3}[\\dXx]$";
|
||||
Pattern pattern = Pattern.compile(str);
|
||||
return pattern.matcher(id).matches();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统一社会信用代码校验
|
||||
* @param license
|
||||
* @return
|
||||
*/
|
||||
public static boolean isLicense18(String license){
|
||||
if (StringUtils.isEmpty(license)){
|
||||
return false;
|
||||
}
|
||||
if (license.length() != 18){
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
String regex="^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$";
|
||||
|
||||
String str = "0123456789ABCDEFGHJKLMNPQRTUWXY";
|
||||
int[] ws = { 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28 };
|
||||
String[] codes = new String[2];
|
||||
codes[0] = license.substring(0, license.length() - 1);
|
||||
codes[1] = license.substring(license.length() - 1, license.length());
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 17; i++) {
|
||||
sum += str.indexOf(codes[0].charAt(i)) * ws[i];
|
||||
}
|
||||
int c18 = 31 - (sum % 31);
|
||||
if (c18 == 31) {
|
||||
c18 = 'Y';
|
||||
} else if (c18 == 30) {
|
||||
c18 = '0';
|
||||
}
|
||||
if (str.charAt(c18) != codes[1].charAt(0)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.dragon.vehicle.company.server.controller;
|
||||
|
||||
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.company.common.domain.FirmInfo;
|
||||
import com.dragon.vehicle.company.common.utils.BaiDuAiCheck;
|
||||
import com.dragon.vehicle.company.server.service.FirmService;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/firm")
|
||||
public class FirmController {
|
||||
|
||||
@Autowired
|
||||
private FirmService firmService;
|
||||
|
||||
|
||||
@PostMapping("/firmEnter")
|
||||
public Object addFirm(@RequestBody FirmInfo firmInfo){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject text = BaiDuAiCheck.checkText(firmInfo.getFirmName());
|
||||
System.out.println(text);
|
||||
if (text.get("conclusion")==null){
|
||||
jsonObject.put("code",2);
|
||||
}else if (text.get("conclusion").equals("合规")){
|
||||
jsonObject.put("code",1);
|
||||
Result result=firmService.addFirm(firmInfo);
|
||||
return result;
|
||||
}else {
|
||||
jsonObject.put("code",3);
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.dragon.vehicle.company.server.mapper;
|
||||
|
||||
import com.dragon.vehicle.company.common.domain.FirmInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FirmMapper {
|
||||
void addFirm(FirmInfo firmInfo);
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.dragon.vehicle.company.server.service.impl;
|
||||
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.company.common.domain.FirmInfo;
|
||||
import com.dragon.vehicle.company.common.utils.ValidatorUtils;
|
||||
import com.dragon.vehicle.company.server.mapper.FirmMapper;
|
||||
import com.dragon.vehicle.company.server.service.FirmService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FirmServiceImpl implements FirmService {
|
||||
|
||||
@Autowired
|
||||
private FirmMapper firmMapper;
|
||||
|
||||
@Override
|
||||
public Result addFirm(FirmInfo firmInfo) {
|
||||
if (!ValidatorUtils.isPhone(firmInfo.getFirmRepresentativePhone())){
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
if (!ValidatorUtils.validator(firmInfo.getFirmRepresentativeId())){
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
if (!ValidatorUtils.isLicense18(firmInfo.getUnifiedSocialCredit())){
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
if (!ValidatorUtils.isTel(firmInfo.getFirmTel())){
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
firmMapper.addFirm(firmInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?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.dragon.vehicle.company.server.mapper.FirmMapper">
|
||||
|
||||
|
||||
<insert id="addFirm">
|
||||
insert into firm_info(firm_name,firm_tel,firm_address,firm_representative,firm_representative_phone,firm_representative_id,firm_bank,firm_bank_branch,
|
||||
firm_bank_account,firm_business_license,unified_social_credit)
|
||||
values (#{firmName},#{firmTel},#{firmAddress},#{firmRepresentative},#{firmRepresentativePhone},#{firmRepresentativeId},#{firmBank},
|
||||
#{firmBankAccount},#{firmBusinessLicense},#{unifiedSocialCredit})
|
||||
</insert>
|
||||
</mapper>
|
Loading…
Reference in New Issue