入节点注册账号功能

添加上传营业执照
生成公私密钥对
master
wanghb 1 year ago
parent ce376e4f31
commit d678e74e4c

@ -22,6 +22,11 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>

@ -5,6 +5,7 @@ import com.sztzjy.block_finance.util.ResultEntity;
import com.sztzjy.block_finance.util.ThrowableUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.validation.FieldError;
@ -87,16 +88,12 @@ public class GlobalExceptionHandler {
return new ResultEntity<>(HttpStatus.SEE_OTHER, e.getMessage());
}
@ExceptionHandler(InvoceException.class)
public ResultEntity<String> serviceExceptionHandler(InvoceException e) {
log.error("异常信息", e);
return new ResultEntity<>(HttpStatus.ACCEPTED, e.getMessage());
}
@ExceptionHandler(InvoceTException.class)
public ResultEntity<String> serviceExceptionHandler(InvoceTException e) {
public ResultEntity<String> invoceExceptionHandler(InvoceTException e) {
log.error("异常信息", e);
return new ResultEntity<>(HttpStatus.CREATED, e.getMessage());
return new ResultEntity<>(HttpStatus.BAD_REQUEST, e.getMessage());
}
}

@ -0,0 +1,78 @@
package com.sztzjy.block_finance.controller;
/**
* @author 17803
* @date 2024-03-06 13:54
*/
import com.sztzjy.block_finance.annotation.AnonymousAccess;
import com.sztzjy.block_finance.entity.dto.StuAddNodesDto;
import com.sztzjy.block_finance.entity.stuJoinNode;
import com.sztzjy.block_finance.service.StuBusinessSupplyService;
import com.sztzjy.block_finance.util.ResultEntity;
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.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.List;
@RestController
@RequestMapping("api/stu/businessSupply")
@Api(tags = "供应链接口")
public class StuSupplyBusinessController {
@Autowired
private StuBusinessSupplyService stuBusinessSupplyService;
@GetMapping("/getNodesInfo")
@ApiOperation(value = "获取首页节点信息")
@AnonymousAccess
public ResultEntity<List<stuJoinNode>> getNodesInfo(@ApiParam("用户ID") String userId){
List<stuJoinNode> nodeList = stuBusinessSupplyService.getNodesInfo(userId);
return new ResultEntity<>(HttpStatus.OK,"获取成功",nodeList);
}
@PostMapping("/addNodes")
@ApiOperation(value = "加入节点")
@AnonymousAccess
public ResultEntity addNodes(@Valid @RequestBody StuAddNodesDto stuAddNodesDto) throws NoSuchAlgorithmException {
stuBusinessSupplyService.addNodes(stuAddNodesDto);
return new ResultEntity<>(HttpStatus.OK);
}
@PostMapping("/uploadBussinessImg")
@ApiOperation(value = "上传营业执照")
@AnonymousAccess
public ResultEntity<String> uploadBussinessImg(@RequestPart MultipartFile file,
@ApiParam("用户ID") String userId,
@ApiParam("用户名")String userName){
String path = stuBusinessSupplyService.uploadBussinessImg(file,userId,userName);
return new ResultEntity<>(HttpStatus.OK);
}
}

@ -0,0 +1,77 @@
package com.sztzjy.block_finance.entity.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
/**
* @author 17803
* @date 2024-03-06 14:07
*/
@ApiModel(description = "加入节点,注册账号")
public class StuAddNodesDto {
@ApiModelProperty(required = true,value = "注册用户((传参:昆明闻泰通讯有限公司 ,信丰世嘉科技有限公司 ,银邦科技有限公司 ,深圳拓朴商业保理有限公司))")
@NotBlank(message = "注册用户不能为空")
private String regName;
@ApiModelProperty(required = true,value = "纳税识别号")
@NotBlank(message = "纳税识别号不能为空")
private String taxAccount;
@ApiModelProperty(required = true,value = "营业执照地址")
@NotBlank(message = "营业执照上传地址不能为空")
private String imgAddress;
@ApiModelProperty(required = true,value = "用户ID")
@NotBlank(message = "用户ID不能为空")
private String userId;
public StuAddNodesDto() {
}
public StuAddNodesDto(String regName, String taxAccount, String imgAddress, String userId) {
this.regName = regName;
this.taxAccount = taxAccount;
this.imgAddress = imgAddress;
this.userId = userId;
}
public String getRegName() {
return regName;
}
public void setRegName(String regName) {
this.regName = regName;
}
public String getTaxAccount() {
return taxAccount;
}
public void setTaxAccount(String taxAccount) {
this.taxAccount = taxAccount;
}
public String getImgAddress() {
return imgAddress;
}
public void setImgAddress(String imgAddress) {
this.imgAddress = imgAddress;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}

@ -5,7 +5,7 @@ import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @author whb
* @author
* stu_join_node
*/
public class stuJoinNode {
@ -57,6 +57,9 @@ public class stuJoinNode {
@ApiModelProperty("保理融资额")
private String factorFinanceAmount;
@ApiModelProperty("上传执照路径")
private String imgPath;
@ApiModelProperty("保理利息收入")
private String factorInterestIncome;
@ -197,6 +200,14 @@ public class stuJoinNode {
this.factorFinanceAmount = factorFinanceAmount == null ? null : factorFinanceAmount.trim();
}
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath == null ? null : imgPath.trim();
}
public String getFactorInterestIncome() {
return factorInterestIncome;
}

@ -1205,6 +1205,76 @@ public class stuJoinNodeExample {
return (Criteria) this;
}
public Criteria andImgPathIsNull() {
addCriterion("img_path is null");
return (Criteria) this;
}
public Criteria andImgPathIsNotNull() {
addCriterion("img_path is not null");
return (Criteria) this;
}
public Criteria andImgPathEqualTo(String value) {
addCriterion("img_path =", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathNotEqualTo(String value) {
addCriterion("img_path <>", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathGreaterThan(String value) {
addCriterion("img_path >", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathGreaterThanOrEqualTo(String value) {
addCriterion("img_path >=", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathLessThan(String value) {
addCriterion("img_path <", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathLessThanOrEqualTo(String value) {
addCriterion("img_path <=", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathLike(String value) {
addCriterion("img_path like", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathNotLike(String value) {
addCriterion("img_path not like", value, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathIn(List<String> values) {
addCriterion("img_path in", values, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathNotIn(List<String> values) {
addCriterion("img_path not in", values, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathBetween(String value1, String value2) {
addCriterion("img_path between", value1, value2, "imgPath");
return (Criteria) this;
}
public Criteria andImgPathNotBetween(String value1, String value2) {
addCriterion("img_path not between", value1, value2, "imgPath");
return (Criteria) this;
}
public Criteria andFactorInterestIncomeIsNull() {
addCriterion("factor_interest_income is null");
return (Criteria) this;

@ -3,8 +3,10 @@ package com.sztzjy.block_finance.mappers;
import com.sztzjy.block_finance.entity.stuJoinNode;
import com.sztzjy.block_finance.entity.stuJoinNodeExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface stuJoinNodeMapper {
long countByExample(stuJoinNodeExample example);

@ -0,0 +1,26 @@
package com.sztzjy.block_finance.service;
import com.sztzjy.block_finance.entity.dto.StuAddNodesDto;
import com.sztzjy.block_finance.entity.stuJoinNode;
import io.swagger.annotations.ApiParam;
import org.springframework.web.multipart.MultipartFile;
import java.security.NoSuchAlgorithmException;
import java.util.List;
/**
* @author 17803
* @date 2024-03-06 14:23
*/
public interface StuBusinessSupplyService {
//获取首页节点信息
List<stuJoinNode> getNodesInfo(String userId);
//加入节点
void addNodes(StuAddNodesDto stuAddNodesDto) throws NoSuchAlgorithmException;
//上传营业执照
String uploadBussinessImg(MultipartFile file,
String userId,
String userName);
}

@ -0,0 +1,205 @@
package com.sztzjy.block_finance.service.impl;/**
* @author 17803
* @date 2024-03-06 14:23
*/
import cn.hutool.core.util.IdUtil;
import com.sztzjy.block_finance.config.exception.handler.InvoceTException;
import com.sztzjy.block_finance.config.exception.handler.NoContentException;
import com.sztzjy.block_finance.entity.dto.StuAddNodesDto;
import com.sztzjy.block_finance.entity.stuJoinNode;
import com.sztzjy.block_finance.entity.stuJoinNodeExample;
import com.sztzjy.block_finance.mappers.stuJoinNodeMapper;
import com.sztzjy.block_finance.service.StuBusinessSupplyService;
import com.sztzjy.block_finance.util.ResultEntity;
import com.sztzjy.block_finance.util.RsaUtil;
import com.sztzjy.block_finance.util.file.LocalFileUtil;
import io.jsonwebtoken.lang.Strings;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.security.NoSuchAlgorithmException;
import java.util.*;
@Service
public class StuBusinessSupplyServiceImpl implements StuBusinessSupplyService {
@Autowired
private stuJoinNodeMapper stuJoinNodeMapper;
@Value("${file.path}")
String path;
//获取首页节点信息
@Override
public List<stuJoinNode> getNodesInfo(String userId) {
stuJoinNodeExample stuJoinNodeExample = new stuJoinNodeExample();
stuJoinNodeExample.createCriteria().andUserIdEqualTo(userId);
List<stuJoinNode> nodeList = stuJoinNodeMapper.selectByExample(stuJoinNodeExample);
if (nodeList != null && nodeList.size() > 0)
{
return nodeList;
}else {
ArrayList<stuJoinNode> arr = new ArrayList<>();
//添加信息
stuJoinNode stuJoinNode = new stuJoinNode();
int i = UUID.randomUUID().hashCode();
int id = i > 0 ? i : -i;
stuJoinNode.setId(id);
//核心企业
stuJoinNode.setModule(1);
stuJoinNode.setUserName("昆明闻泰通讯有限公司");
stuJoinNode.setTaxIdentifyNumber("91530100MA6NRB2A0E");
stuJoinNode.setTelNumber("15999857868");
stuJoinNode.setBaseAccount("9550880214383700108");
stuJoinNode.setBankOfDeposit("广发银行昆明分行");
stuJoinNode.setRegAddress("昆明市市场监督管理局");
stuJoinNode.setRegAddress("云南省昆明市高新区海源北路6号招商大厦");
stuJoinNode.setUserId(userId);
stuJoinNode.setCreateTime(new Date());
stuJoinNodeMapper.insertSelective(stuJoinNode);
arr.add(stuJoinNode);
stuJoinNode stuJoinNodeInfoTwo = new stuJoinNode();
int j = UUID.randomUUID().hashCode();
int idTwo = j > 0 ? j : -j;
stuJoinNodeInfoTwo.setId(idTwo);
//核心企业
stuJoinNodeInfoTwo.setModule(2);
stuJoinNodeInfoTwo.setUserName("信丰世嘉科技有限公司");
stuJoinNodeInfoTwo.setTaxIdentifyNumber("91360722MA35LME192");
stuJoinNodeInfoTwo.setTelNumber("15999857848");
stuJoinNodeInfoTwo.setBaseAccount("1917402008217");
stuJoinNodeInfoTwo.setBankOfDeposit("中国银行赣州市信丰县支行");
stuJoinNodeInfoTwo.setRegAddress("信丰县市场监督管理局");
stuJoinNodeInfoTwo.setRegAddress("江西省赣州市信丰县高新区深圳大道5G智能机器人产业园众恒科技园B区8号");
stuJoinNodeInfoTwo.setUserId(userId);
stuJoinNodeInfoTwo.setCreateTime(new Date());
stuJoinNodeMapper.insertSelective(stuJoinNodeInfoTwo);
arr.add(stuJoinNodeInfoTwo);
stuJoinNode stuJoinNodeInfoThree = new stuJoinNode();
int k = UUID.randomUUID().hashCode();
int idThree = k > 0 ? k : -k;
stuJoinNodeInfoThree.setId(idThree);
//核心企业
stuJoinNodeInfoThree.setModule(3);
stuJoinNodeInfoThree.setUserName("银邦科技有限公司");
stuJoinNodeInfoThree.setTaxIdentifyNumber("91420900MA49JL521M");
stuJoinNodeInfoThree.setTelNumber("15999857858");
stuJoinNodeInfoThree.setBaseAccount("6222000000000000011");
stuJoinNodeInfoThree.setBankOfDeposit("工商银行孝感市支行");
stuJoinNodeInfoThree.setRegAddress("孝感市市场监督管理局");
stuJoinNodeInfoThree.setRegAddress("孝感市航空南路特1号");
stuJoinNodeInfoThree.setUserId(userId);
stuJoinNodeInfoThree.setCreateTime(new Date());
stuJoinNodeMapper.insertSelective(stuJoinNodeInfoThree);
arr.add(stuJoinNodeInfoThree);
stuJoinNode stuJoinNodeInfoFour = new stuJoinNode();
int z = UUID.randomUUID().hashCode();
int idz = z > 0 ? z : -z;
stuJoinNodeInfoFour.setId(idz);
//核心企业
stuJoinNodeInfoFour.setModule(4);
stuJoinNodeInfoFour.setUserName("深圳拓朴商业保理有限公司");
stuJoinNodeInfoFour.setTaxIdentifyNumber("914403003265877025");
stuJoinNodeInfoFour.setTelNumber("15999855878");
stuJoinNodeInfoFour.setBaseAccount("7441210182600135845");
stuJoinNodeInfoFour.setBankOfDeposit("中信银行红树湾支行");
stuJoinNodeInfoFour.setRegAddress("深圳市市场监督管理局");
stuJoinNodeInfoFour.setRegAddress("深圳市福田区沙头街道沙嘴社区沙嘴路8号红树华府A、B、C、D栋A栋12层1211-03");
stuJoinNodeInfoFour.setUserId(userId);
stuJoinNodeInfoFour.setCreateTime(new Date());
stuJoinNodeMapper.insertSelective(stuJoinNodeInfoFour);
arr.add(stuJoinNodeInfoFour);
return arr;
}
}
//加入节点
@Override
public void addNodes(StuAddNodesDto stuAddNodesDto) throws NoSuchAlgorithmException {
// module校验
//纳税识别号 校验 上传成功生成公钥私钥
stuJoinNodeExample example = new stuJoinNodeExample();
example.createCriteria().andUserIdEqualTo(stuAddNodesDto.getUserId()).andUserNameEqualTo(stuAddNodesDto.getRegName());
List<stuJoinNode> stuJoinNodes = stuJoinNodeMapper.selectByExample(example);
if (StringUtils.hasLength(stuJoinNodes.get(0).getPublicKey()))
{
throw new InvoceTException(HttpStatus.BAD_REQUEST,"请勿重复注册!");
}
RsaUtil.RsaKeyPair rsaKeyPair = RsaUtil.generateKeyPair();
stuJoinNodes.get(0).setPublicKey( rsaKeyPair.getPublicKey());
stuJoinNodes.get(0).setPrivateKey( rsaKeyPair.getPrivateKey());
stuJoinNodes.get(0).setUpdateTime(new Date());
stuJoinNodeMapper.updateByPrimaryKeySelective(stuJoinNodes.get(0));
}
//上传营业执照
@Override
public String uploadBussinessImg(MultipartFile file,
String userId,
String userName) {
if (file.isEmpty())
{
throw new InvoceTException(HttpStatus.BAD_REQUEST,"上传的文件为空!");
}
LocalFileUtil localFileUtil = new LocalFileUtil(path);
String upload = localFileUtil.upload(file);
stuJoinNodeExample example = new stuJoinNodeExample();
example.createCriteria().andUserIdEqualTo(userId).andUserNameEqualTo(userName);
List<stuJoinNode> stuJoinNodes = stuJoinNodeMapper.selectByExample(example);
if (!CollectionUtils.isEmpty(stuJoinNodes)){
stuJoinNode stuJoinNode = stuJoinNodes.get(0);
stuJoinNode.setImgPath(upload);
stuJoinNodeMapper.updateByPrimaryKeySelective(stuJoinNode);
return upload;
}else {
throw new InvoceTException(HttpStatus.BAD_REQUEST,"异常!");
}
}
}

@ -19,6 +19,7 @@
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://118.31.7.2:3306/tz_finance_supply" userId="root"
password="sztzjy2017">
<property name="nullCatalogMeansCurrent" value="true"/>
<property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 -->
</jdbcConnection>
<!-- 配置实体类的位置 -->
@ -40,7 +41,7 @@
</javaClientGenerator>
<!-- 需要生成的表 -->
<table tableName="stu_join_node" domainObjectName="stuJoinNode" />
<table tableName="stu_join_node" domainObjectName="StuJoinNode" />
</context>

@ -18,6 +18,7 @@
<result column="account_pay" jdbcType="VARCHAR" property="accountPay" />
<result column="token_asset" jdbcType="VARCHAR" property="tokenAsset" />
<result column="factor_finance_amount" jdbcType="VARCHAR" property="factorFinanceAmount" />
<result column="img_path" jdbcType="VARCHAR" property="imgPath" />
<result column="factor_interest_income" jdbcType="VARCHAR" property="factorInterestIncome" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
@ -84,7 +85,7 @@
<sql id="Base_Column_List">
id, module, user_name, tax_identify_number, tel_number, base_account, bank_of_deposit,
reg_auth, reg_address, node_address, public_key, private_key, account_receive, account_pay,
token_asset, factor_finance_amount, factor_interest_income, user_id, create_time,
token_asset, factor_finance_amount, img_path, factor_interest_income, user_id, create_time,
update_time
</sql>
<select id="selectByExample" parameterType="com.sztzjy.block_finance.entity.stuJoinNodeExample" resultMap="BaseResultMap">
@ -123,7 +124,7 @@
bank_of_deposit, reg_auth, reg_address,
node_address, public_key, private_key,
account_receive, account_pay, token_asset,
factor_finance_amount, factor_interest_income,
factor_finance_amount, img_path, factor_interest_income,
user_id, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{module,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
@ -131,7 +132,7 @@
#{bankOfDeposit,jdbcType=VARCHAR}, #{regAuth,jdbcType=VARCHAR}, #{regAddress,jdbcType=VARCHAR},
#{nodeAddress,jdbcType=VARCHAR}, #{publicKey,jdbcType=VARCHAR}, #{privateKey,jdbcType=VARCHAR},
#{accountReceive,jdbcType=VARCHAR}, #{accountPay,jdbcType=VARCHAR}, #{tokenAsset,jdbcType=VARCHAR},
#{factorFinanceAmount,jdbcType=VARCHAR}, #{factorInterestIncome,jdbcType=VARCHAR},
#{factorFinanceAmount,jdbcType=VARCHAR}, #{imgPath,jdbcType=VARCHAR}, #{factorInterestIncome,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
@ -186,6 +187,9 @@
<if test="factorFinanceAmount != null">
factor_finance_amount,
</if>
<if test="imgPath != null">
img_path,
</if>
<if test="factorInterestIncome != null">
factor_interest_income,
</if>
@ -248,6 +252,9 @@
<if test="factorFinanceAmount != null">
#{factorFinanceAmount,jdbcType=VARCHAR},
</if>
<if test="imgPath != null">
#{imgPath,jdbcType=VARCHAR},
</if>
<if test="factorInterestIncome != null">
#{factorInterestIncome,jdbcType=VARCHAR},
</if>
@ -319,6 +326,9 @@
<if test="record.factorFinanceAmount != null">
factor_finance_amount = #{record.factorFinanceAmount,jdbcType=VARCHAR},
</if>
<if test="record.imgPath != null">
img_path = #{record.imgPath,jdbcType=VARCHAR},
</if>
<if test="record.factorInterestIncome != null">
factor_interest_income = #{record.factorInterestIncome,jdbcType=VARCHAR},
</if>
@ -354,6 +364,7 @@
account_pay = #{record.accountPay,jdbcType=VARCHAR},
token_asset = #{record.tokenAsset,jdbcType=VARCHAR},
factor_finance_amount = #{record.factorFinanceAmount,jdbcType=VARCHAR},
img_path = #{record.imgPath,jdbcType=VARCHAR},
factor_interest_income = #{record.factorInterestIncome,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
@ -410,6 +421,9 @@
<if test="factorFinanceAmount != null">
factor_finance_amount = #{factorFinanceAmount,jdbcType=VARCHAR},
</if>
<if test="imgPath != null">
img_path = #{imgPath,jdbcType=VARCHAR},
</if>
<if test="factorInterestIncome != null">
factor_interest_income = #{factorInterestIncome,jdbcType=VARCHAR},
</if>
@ -442,6 +456,7 @@
account_pay = #{accountPay,jdbcType=VARCHAR},
token_asset = #{tokenAsset,jdbcType=VARCHAR},
factor_finance_amount = #{factorFinanceAmount,jdbcType=VARCHAR},
img_path = #{imgPath,jdbcType=VARCHAR},
factor_interest_income = #{factorInterestIncome,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},

Loading…
Cancel
Save