add remote firmInfo

master
冯凯 2023-11-22 14:25:10 +08:00
parent dbe69abb5e
commit 7a960076ce
5 changed files with 159 additions and 23 deletions

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.dragon.common.core.annotation.Excel; import com.dragon.common.core.annotation.Excel;
import com.dragon.vehicle.firm.domain.req.FirmRegisterReq;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -22,69 +23,83 @@ import lombok.NoArgsConstructor;
@TableName("firm_info") @TableName("firm_info")
public class FirmInfo { public class FirmInfo {
/** /**
* *
*/ */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
@Excel(name = "编号") @Excel(name = "编号")
private String firmId; private String firmId;
/** /**
* *
*/ */
@Excel(name = "企业名称") @Excel(name = "企业名称")
private String firmName; private String firmName;
/** /**
* *
*/ */
@Excel(name = "企业联系方式") @Excel(name = "企业联系方式")
private String firmTel; private String firmTel;
/** /**
* *
*/ */
@Excel(name = "企业联系地址") @Excel(name = "企业联系地址")
private String firmAddress; private String firmAddress;
/** /**
* *
*/ */
@Excel(name = "法定代表人") @Excel(name = "法定代表人")
private String firmRepresentative; private String firmRepresentative;
/** /**
* *
*/ */
@Excel(name = "法人联系方式") @Excel(name = "法人联系方式")
private String firmRepresentativePhone; private String firmRepresentativePhone;
/** /**
* *
*/ */
@Excel(name = "法人身份证号") @Excel(name = "法人身份证号")
private String firmRepresentativeId; private String firmRepresentativeId;
/** /**
* *
*/ */
@Excel(name = "公司开户银行") @Excel(name = "公司开户银行")
private String firmBank; private String firmBank;
/** /**
* *
*/ */
@Excel(name = "开户行支行") @Excel(name = "开户行支行")
private String firmBankBranch; private String firmBankBranch;
/** /**
* *
*/ */
@Excel(name = "银行账户") @Excel(name = "银行账户")
private String firmBankAccount; private String firmBankAccount;
/** /**
* *
*/ */
@Excel(name = "企业营业执照号") @Excel(name = "企业营业执照号")
private String firmBusinessLicense; private String firmBusinessLicense;
/** /**
* *
*/ */
@Excel(name = "统一社会信用代码") @Excel(name = "统一社会信用代码")
private String firmSocialCredit; private String firmSocialCredit;
/** /**
*id * id
*/ */
private Long createBy; private Long createBy;
public static FirmInfo registry(FirmRegisterReq firmRegisterReq) {
return FirmInfo.builder()
.firmName(firmRegisterReq.getFirmName())
.firmTel(firmRegisterReq.getFirmTel())
.firmAddress(firmRegisterReq.getFirmAddress())
.firmBank(firmRegisterReq.getFirmBank())
.firmBankAccount(firmRegisterReq.getFirmBankAccount())
.firmBusinessLicense(firmRegisterReq.getFirmBusinessLicense())
.firmRepresentative(firmRegisterReq.getFirmRepresentative())
.firmRepresentativeId(firmRegisterReq.getFirmRepresentativeId()).
build();
}
} }

View File

@ -0,0 +1,91 @@
package com.dragon.vehicle.firm.domain.req;
import com.dragon.common.core.annotation.Excel;
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
import com.dragon.vehicle.firm.domain.common.FirmInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.UniqueElements;
import javax.validation.constraints.NotNull;
/**
* @author
* @version 1.0
* @description:
* @date 2023/11/22 14:05
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FirmRegisterReq {
/**
*
*/
private String firmId;
/**
*
*/
@NotNull(message = "企业名称不能为空")
private String firmName;
/**
*
*/
@NotNull(message = "企业联系方式不能为空")
private String firmTel;
/**
*
*/
@NotNull(message = "企业地址不能为空")
private String firmAddress;
/**
*
*/
@NotNull(message = "法定代表人不能为空")
private String firmRepresentative;
/**
*
*/
@NotNull(message = "法定代表人联系方式不能为空")
private String firmRepresentativePhone;
/**
*
*/
@NotNull(message = "法人身份证不能为空")
private String firmRepresentativeId;
/**
*
*/
@NotNull(message = "开户银行不能为空")
private String firmBank;
/**
*
*/
private String firmBankBranch;
/**
*
*/
@NotNull(message = "银行账户不能为空")
private String firmBankAccount;
/**
*
*/
@NotNull(message = "企业营业执照号不能为空")
private String firmBusinessLicense;
/**
*
*/
@NotNull(message = "统一社会信用代码不能为空")
private String firmSocialCredit;
/**
* id
*/
private Long createBy;
}

View File

@ -1,16 +1,17 @@
package com.dragon.vehicle.firm.server.controller; package com.dragon.vehicle.firm.server.controller;
import com.dragon.common.core.domain.Result; import com.dragon.common.core.domain.Result;
import com.dragon.common.core.utils.StringUtils;
import com.dragon.common.redis.service.RedisService; import com.dragon.common.redis.service.RedisService;
import com.dragon.common.security.utils.SecurityUtils; import com.dragon.common.security.utils.SecurityUtils;
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache; import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
import com.dragon.vehicle.firm.domain.common.FirmInfo;
import com.dragon.vehicle.firm.domain.req.FirmRegisterReq;
import com.dragon.vehicle.firm.server.service.FirmInfoService; import com.dragon.vehicle.firm.server.service.FirmInfoService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author * @author
@ -26,7 +27,7 @@ public class FirmInfoController {
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
/** /**
*service * service
*/ */
@Autowired @Autowired
private FirmInfoService firmService; private FirmInfoService firmService;
@ -39,12 +40,22 @@ public class FirmInfoController {
* @date: 2023/11/21 13:55 * @date: 2023/11/21 13:55
*/ */
@GetMapping("/by/userId") @GetMapping("/by/userId")
public Result<FirmInfoCache> getFirmInfoByUserId(){ public Result<FirmInfoCache> getFirmInfoByUserId() {
Long userId = SecurityUtils.getUserId();//获取当前登录人的userId Long userId = SecurityUtils.getUserId();//获取当前登录人的userId
log.info("当前登录人是:"+userId); log.info("当前登录人是:" + userId);
FirmInfoCache firmInfoCache = firmService.getFirmInfoByUserId(1L);
FirmInfoCache firmInfoCache=firmService.getFirmInfoByUserId(1L);
return Result.success(firmInfoCache); return Result.success(firmInfoCache);
} }
@PostMapping("/register/company")
public Result registerCompany(@RequestBody @Validated FirmRegisterReq firmRegisterReq) {
if (firmService.checkFirmNameUnique(firmRegisterReq.getFirmName())) {
//返回true证明已经有同名企业入驻了
return Result.error(StringUtils.format("入驻失败,企业 【{}】已经存在", firmRegisterReq.getFirmName()));
}
//企业入驻
firmService.save(FirmInfo.registry(firmRegisterReq));
return Result.success("", "入驻成功!!!");
}
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.dragon.vehicle.firm.domain.cache.FirmInfoCache; import com.dragon.vehicle.firm.domain.cache.FirmInfoCache;
import com.dragon.vehicle.firm.domain.common.FirmInfo; import com.dragon.vehicle.firm.domain.common.FirmInfo;
import javax.validation.constraints.NotNull;
/** /**
* @author * @author
* @version 1.0 * @version 1.0
@ -21,4 +23,11 @@ public interface FirmInfoService extends IService<FirmInfo>{
* @date: 2023/11/21 13:55 * @date: 2023/11/21 13:55
*/ */
FirmInfoCache getFirmInfoByUserId(Long userId); FirmInfoCache getFirmInfoByUserId(Long userId);
/**
*
*/
boolean checkFirmNameUnique(@NotNull String firmName);
} }

View File

@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
/** /**
* @author * @author
* @version 1.0 * @version 1.0
@ -51,4 +53,12 @@ public class FirmInfoServiceImpl extends ServiceImpl<FirmInfoMapper,FirmInfo> i
log.info(firmInfoCache); log.info(firmInfoCache);
return firmInfoCache; return firmInfoCache;
} }
@Override
public boolean checkFirmNameUnique(@NotNull String firmName) {
LambdaQueryWrapper<FirmInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FirmInfo::getFirmName,firmName);
return firmInfoMapper.selectCount(queryWrapper)>0;
}
} }