企业入驻

master
niuniuniu 2023-11-19 22:31:37 +08:00
parent e50bf4158b
commit eebcdacbc3
9 changed files with 319 additions and 0 deletions

View File

@ -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>

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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>