add remote firmInfo
parent
dbe69abb5e
commit
7a960076ce
|
@ -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;
|
||||||
|
@ -87,4 +88,18 @@ public class FirmInfo {
|
||||||
* 创建人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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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 冯凯
|
||||||
|
@ -43,8 +44,18 @@ public class FirmInfoController {
|
||||||
|
|
||||||
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("", "入驻成功!!!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue