[新增功能](main)

- 新增企业接口
 - 字段类型修改
 - 用户类型 企业类型枚举
main
huangyuxuan 2025-10-31 14:29:57 +08:00
parent 10d89e7126
commit df37fd4ea8
11 changed files with 101 additions and 43 deletions

View File

@ -22,19 +22,10 @@ public class CorpInfoAddExe {
private final CorpInfoGateway corpInfoGateway;
@Transactional(rollbackFor = Exception.class)
public boolean execute(CorpInfoAddCmd cmd) {
public Long execute(CorpInfoAddCmd cmd) {
CorpInfoE examTypeE = new CorpInfoE();
BeanUtils.copyProperties(cmd, examTypeE);
boolean res = false;
try {
res = corpInfoGateway.add(examTypeE);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (!res) {
throw new BizException("保存失败");
}
return true;
return corpInfoGateway.add(examTypeE);
}
}

View File

@ -0,0 +1,23 @@
package com.zcloud.basic.info.enums;
import lombok.Getter;
@Getter
public enum CorpTypeEnum {
OrdinaryEnterprises(0,"普通企业"),
groupUnits(1, "集团单位"),
share(2,"股份单位"),
serviceProvider(3, "相关方企业"),
cargoOwner(4, "货主单位"),
portUnit(5, "驻港单位");
private final Integer code;
private final String name;
CorpTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
}

View File

@ -0,0 +1,30 @@
package com.zcloud.basic.info.enums;
import lombok.Getter;
@Getter
public enum UserTypeEnum {
JG(1,"监管"),
QY(2,"企业"),
XGF(3,"相关方")
;
private final Integer code;
private final String name;
UserTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static Integer getUserType(Integer corpType){
if (corpType.equals(CorpTypeEnum.OrdinaryEnterprises.getCode()) ||
corpType.equals(CorpTypeEnum.groupUnits.getCode())){
return UserTypeEnum.QY.getCode();
}else if (corpType.equals(CorpTypeEnum.share.getCode())){
return UserTypeEnum.JG.getCode();
}else {
return UserTypeEnum.XGF.getCode();
}
}
}

View File

@ -2,17 +2,18 @@ package com.zcloud.basic.info.service;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.basic.info.api.CorpInfoServiceI;
import com.zcloud.basic.info.command.CorpInfoAddExe;
import com.zcloud.basic.info.command.CorpInfoRemoveExe;
import com.zcloud.basic.info.command.CorpInfoUpdateExe;
import com.zcloud.basic.info.command.SysUserAddExe;
import com.zcloud.basic.info.command.query.CorpInfoQueryExe;
import com.zcloud.basic.info.dto.CorpDepartmentQry;
import com.zcloud.basic.info.dto.CorpInfoAddCmd;
import com.zcloud.basic.info.dto.CorpInfoPageQry;
import com.zcloud.basic.info.dto.CorpInfoUpdateCmd;
import com.zcloud.basic.info.dto.*;
import com.zcloud.basic.info.dto.clientobject.CorpDepartmentCO;
import com.zcloud.basic.info.dto.clientobject.CorpInfoCO;
import com.zcloud.basic.info.enums.UserTypeEnum;
import com.zcloud.gbscommon.utils.Tools;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@ -31,6 +32,7 @@ public class CorpInfoServiceImpl implements CorpInfoServiceI {
private final CorpInfoUpdateExe corpInfoUpdateExe;
private final CorpInfoRemoveExe corpInfoRemoveExe;
private final CorpInfoQueryExe corpInfoQueryExe;
private final SysUserAddExe sysUserAddExe;
@Override
public PageResponse<CorpInfoCO> listPage(CorpInfoPageQry qry) {
@ -41,7 +43,15 @@ public class CorpInfoServiceImpl implements CorpInfoServiceI {
@Override
public SingleResponse add(CorpInfoAddCmd cmd) {
corpInfoAddExe.execute(cmd);
Long userId = AuthContext.getUserId();
Long id = corpInfoAddExe.execute(cmd);
//新增企业成功后新增企业主账号用户(企业主账号的gbsId与企业的gbsId一致) 2025-10-31 huangyuxuan
SysUserAddCmd user = new SysUserAddCmd();
user.setId(userId).setUserId(Tools.get32UUID()).setUsername(cmd.getCorpName()).setName(cmd.getCorpName())
.setCorpinfoId(id).setUserType(UserTypeEnum.getUserType(cmd.getType())).setStatus("0")
.setDepartmentId(id);
sysUserAddExe.execute(user);
return SingleResponse.buildSuccess();
}

View File

@ -6,8 +6,10 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
@ -20,10 +22,11 @@ import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class SysUserAddCmd extends Command {
@ApiModelProperty(value = "GBS用户id", name = "id", required = true)
@NotEmpty(message = "GBS用户id不能为空")
private Integer id;
@NotNull(message = "GBS用户id不能为空")
private Long id;
@ApiModelProperty(value = "用户id", name = "userId", required = true)
@NotEmpty(message = "用户id不能为空")
private String userId;
@ -37,17 +40,17 @@ public class SysUserAddCmd extends Command {
@NotEmpty(message = "姓名不能为空")
private String name;
@ApiModelProperty(value = "企业", name = "corpinfoId", required = true)
@NotEmpty(message = "企业不能为空")
private String corpinfoId;
@NotNull(message = "企业不能为空")
private Long corpinfoId;
@ApiModelProperty(value = "部门id", name = "departmentId", required = true)
@NotEmpty(message = "部门id不能为空")
private String departmentId;
@NotNull(message = "部门id不能为空")
private Long departmentId;
@ApiModelProperty(value = "角色id", name = "roleIds", required = true)
@NotEmpty(message = "角色id不能为空")
private String roleIds;
@ApiModelProperty(value = "1监管2企业3相关方", name = "userType", required = true)
@NotEmpty(message = "1监管2企业3相关方不能为空")
private String userType;
private Integer userType;
@ApiModelProperty(value = "状态0.正常 99.锁定 2密码错误次数超过当天限制", name = "status", required = true)
@NotEmpty(message = "状态0.正常 99.锁定 2密码错误次数超过当天限制不能为空")
private String status;

View File

@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
@ -22,8 +23,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
public class SysUserUpdateCmd extends Command {
@ApiModelProperty(value = "GBS用户id", name = "id", required = true)
@NotEmpty(message = "GBS用户id不能为空")
private Integer id;
@NotNull(message = "GBS用户id不能为空")
private Long id;
@ApiModelProperty(value = "用户id", name = "userId", required = true)
@NotEmpty(message = "用户id不能为空")
private String userId;
@ -37,17 +38,17 @@ public class SysUserUpdateCmd extends Command {
@NotEmpty(message = "姓名不能为空")
private String name;
@ApiModelProperty(value = "企业", name = "corpinfoId", required = true)
@NotEmpty(message = "企业不能为空")
private String corpinfoId;
@NotNull(message = "企业不能为空")
private Long corpinfoId;
@ApiModelProperty(value = "部门id", name = "departmentId", required = true)
@NotEmpty(message = "部门id不能为空")
private String departmentId;
@NotNull(message = "部门id不能为空")
private Long departmentId;
@ApiModelProperty(value = "角色id", name = "roleIds", required = true)
@NotEmpty(message = "角色id不能为空")
private String roleIds;
@ApiModelProperty(value = "1监管2企业3相关方", name = "userType", required = true)
@NotEmpty(message = "1监管2企业3相关方不能为空")
private String userType;
private Integer userType;
@ApiModelProperty(value = "状态0.正常 99.锁定 2密码错误次数超过当天限制", name = "status", required = true)
@NotEmpty(message = "状态0.正常 99.锁定 2密码错误次数超过当天限制不能为空")
private String status;

View File

@ -17,7 +17,7 @@ import java.util.Date;
public class SysUserCO extends ClientObject {
//GBS用户id
@ApiModelProperty(value = "GBS用户id")
private Integer id;
private Long id;
//用户id
@ApiModelProperty(value = "用户id")
private String userId;
@ -32,16 +32,16 @@ public class SysUserCO extends ClientObject {
private String name;
//企业
@ApiModelProperty(value = "企业")
private String corpinfoId;
private Long corpinfoId;
//部门id
@ApiModelProperty(value = "部门id")
private String departmentId;
private Long departmentId;
//角色id
@ApiModelProperty(value = "角色id")
private String roleIds;
//1监管2企业3相关方
@ApiModelProperty(value = "1监管2企业3相关方")
private String userType;
private Integer userType;
//状态0.正常 99.锁定 2密码错误次数超过当天限制
@ApiModelProperty(value = "状态0.正常 99.锁定 2密码错误次数超过当天限制")
private String status;

View File

@ -13,7 +13,7 @@ public interface CorpInfoGateway {
/**
*
*/
Boolean add(CorpInfoE corpInfoE);
Long add(CorpInfoE corpInfoE);
/**
*

View File

@ -28,13 +28,13 @@ public class SysUserE extends BaseE {
//姓名
private String name;
//企业
private String corpinfoId;
private Long corpinfoId;
//部门id
private String departmentId;
private Long departmentId;
//角色id
private String roleIds;
//1监管2企业3相关方
private String userType;
private Integer userType;
//状态0.正常 99.锁定 2密码错误次数超过当天限制
private String status;
//邮箱

View File

@ -22,11 +22,11 @@ public class CorpInfoGatewayImpl implements CorpInfoGateway {
private final CorpInfoRepository corpInfoRepository;
@Override
public Boolean add(CorpInfoE corpInfoE) {
public Long add(CorpInfoE corpInfoE) {
CorpInfoDO d = new CorpInfoDO();
BeanUtils.copyProperties(corpInfoE, d);
corpInfoRepository.save(d);
return true;
return d.getId();
}
@Override

View File

@ -37,16 +37,16 @@ public class SysUserDO extends BaseDO {
private String name;
//企业
@ApiModelProperty(value = "企业")
private String corpinfoId;
private Long corpinfoId;
//部门id
@ApiModelProperty(value = "部门id")
private String departmentId;
private Long departmentId;
//角色id
@ApiModelProperty(value = "角色id")
private String roleIds;
//1监管2企业3相关方
@ApiModelProperty(value = "1监管2企业3相关方")
private String userType;
private Integer userType;
//状态0.正常 99.锁定 2密码错误次数超过当天限制
@ApiModelProperty(value = "状态0.正常 99.锁定 2密码错误次数超过当天限制")
private String status;