feat(system): 新增外部系统推送配置功能
- 添加 BusinessTypeEnum 枚举定义采购、销售、生产三种业务类型 - 在 ErrorCodeConstants 中新增外部系统推送配置相关错误码 - 创建 ExternalPushConfigApi 定义推送配置的 RPC 接口 - 实现 ExternalPushConfigApiImpl 提供推送判断功能 - 设计 ExternalPushConfigDO 数据对象存储推送配置信息 - 开发 ExternalPushConfigMapper 提供数据库操作功能 - 实现 ExternalPushConfigService 业务逻辑处理 - 创建管理后台 Controller 提供 CRUD 和查询接口 - 定义请求响应 VO 对象规范接口参数和返回值 - 添加数据库表结构初始化脚本支持推送配置存储
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.zt.plat.module.system.api.push;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.system.service.push.ExternalPushConfigService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 外部系统推送配置 Feign API 实现类
|
||||
*
|
||||
* @author ZT Cloud
|
||||
*/
|
||||
@RestController
|
||||
@Validated
|
||||
public class ExternalPushConfigApiImpl implements ExternalPushConfigApi {
|
||||
|
||||
@Resource
|
||||
private ExternalPushConfigService externalPushConfigService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> isPushEnabled(Long companyId, Long deptId, String businessType, String externalSystem) {
|
||||
Boolean result = externalPushConfigService.isPushEnabled(companyId, deptId, businessType, externalSystem);
|
||||
return success(result);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
package com.zt.plat.module.system.controller.admin.push.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 业务类型 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BusinessTypeRespVO {
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "编码", example = "PURCHASE")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称", example = "采购")
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.system.controller.admin.push.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 外部系统推送配置基础信息")
|
||||
@Data
|
||||
public class ExternalPushConfigBaseVO {
|
||||
|
||||
@Schema(description = "公司编号(为空表示不限制公司)", example = "1024")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "部门编号(为空表示公司级配置)", example = "2048")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "业务类型(为空表示所有业务类型)", example = "PURCHASE")
|
||||
@Size(max = 32, message = "业务类型长度不能超过 32 个字符")
|
||||
private String businessType;
|
||||
|
||||
@Schema(description = "外部系统标识(为空表示所有外部系统)", example = "ERP")
|
||||
@Size(max = 64, message = "外部系统标识长度不能超过 64 个字符")
|
||||
private String externalSystem;
|
||||
|
||||
@Schema(description = "是否启用推送", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "推送开关不能为空")
|
||||
private Boolean enablePush;
|
||||
|
||||
@Schema(description = "备注", example = "ERP 采购单推送配置")
|
||||
@Size(max = 512, message = "备注长度不能超过 512 个字符")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zt.plat.module.system.controller.admin.push.vo;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - 外部系统推送配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ExternalPushConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "公司编号", example = "1024")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "部门编号", example = "2048")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "业务类型", example = "PURCHASE")
|
||||
private String businessType;
|
||||
|
||||
@Schema(description = "外部系统标识", example = "ERP")
|
||||
private String externalSystem;
|
||||
|
||||
@Schema(description = "是否启用推送", example = "true")
|
||||
private Boolean enablePush;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.zt.plat.module.system.controller.admin.push.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 外部系统推送配置 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ExternalPushConfigRespVO extends ExternalPushConfigBaseVO {
|
||||
|
||||
@Schema(description = "配置编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "公司名称", example = "浙江中天建设集团")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "部门名称", example = "采购部")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "最后更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zt.plat.module.system.controller.admin.push.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - 外部系统推送配置创建/修改 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ExternalPushConfigSaveReqVO extends ExternalPushConfigBaseVO {
|
||||
|
||||
@Schema(description = "配置编号", example = "1024")
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.zt.plat.module.system.dal.dataobject.push;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zt.plat.framework.tenant.core.db.TenantBaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 外部系统推送配置 DO
|
||||
*
|
||||
* 用于配置不同公司/部门/业务类型下的外部系统推送开关
|
||||
*
|
||||
* @author ZT Cloud
|
||||
*/
|
||||
@TableName("system_external_push_config")
|
||||
@KeySequence("system_external_push_config_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ExternalPushConfigDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 主键编号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司编号(可为空)
|
||||
*
|
||||
* 关联 system_dept 表,is_company = 1
|
||||
* 为空表示不限制公司
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 部门编号(可为空)
|
||||
*
|
||||
* 关联 system_dept 表,is_company = 0
|
||||
* 为空表示公司级配置
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 业务类型(可为空)
|
||||
*
|
||||
* 枚举值:PURCHASE, SALE, PRODUCTION
|
||||
* 为空表示所有业务类型
|
||||
* 枚举 {@link com.zt.plat.module.system.enums.push.BusinessTypeEnum}
|
||||
*/
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 外部系统标识(可为空)
|
||||
*
|
||||
* 如:ERP, IWORK
|
||||
* 为空表示所有外部系统
|
||||
* 枚举 {@link com.zt.plat.module.system.enums.dept.ExternalPlatformEnum}
|
||||
*/
|
||||
private String externalSystem;
|
||||
|
||||
/**
|
||||
* 是否启用推送
|
||||
*
|
||||
* true:启用推送
|
||||
* false:停用推送
|
||||
*/
|
||||
private Boolean enablePush;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.zt.plat.module.system.dal.mysql.push;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.system.controller.admin.push.vo.ExternalPushConfigPageReqVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.push.ExternalPushConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 外部系统推送配置 Mapper
|
||||
*
|
||||
* @author ZT Cloud
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExternalPushConfigMapper extends BaseMapperX<ExternalPushConfigDO> {
|
||||
|
||||
default PageResult<ExternalPushConfigDO> selectPage(ExternalPushConfigPageReqVO reqVO) {
|
||||
LambdaQueryWrapperX<ExternalPushConfigDO> wrapper = new LambdaQueryWrapperX<ExternalPushConfigDO>()
|
||||
.eqIfPresent(ExternalPushConfigDO::getCompanyId, reqVO.getCompanyId())
|
||||
.eqIfPresent(ExternalPushConfigDO::getBusinessType, reqVO.getBusinessType())
|
||||
.eqIfPresent(ExternalPushConfigDO::getExternalSystem, reqVO.getExternalSystem())
|
||||
.eqIfPresent(ExternalPushConfigDO::getEnablePush, reqVO.getEnablePush());
|
||||
|
||||
// 如果传了 companyId 但没传 deptId,则只查公司级配置(dept_id IS NULL)
|
||||
if (reqVO.getCompanyId() != null && reqVO.getDeptId() == null) {
|
||||
wrapper.isNull(ExternalPushConfigDO::getDeptId);
|
||||
} else if (reqVO.getDeptId() != null) {
|
||||
// 如果传了 deptId,则查指定部门的配置
|
||||
wrapper.eq(ExternalPushConfigDO::getDeptId, reqVO.getDeptId());
|
||||
}
|
||||
// 如果都没传,则查所有配置
|
||||
|
||||
wrapper.orderByDesc(ExternalPushConfigDO::getId);
|
||||
return selectPage(reqVO, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用查询配置方法
|
||||
*
|
||||
* @param companyId 公司ID(null 表示查询 company_id IS NULL 的记录)
|
||||
* @param deptId 部门ID(null 表示查询 dept_id IS NULL 的记录)
|
||||
* @param businessType 业务类型(null 表示查询 business_type IS NULL 的记录)
|
||||
* @param externalSystem 外部系统(null 表示查询 external_system IS NULL 的记录)
|
||||
* @return 配置对象
|
||||
*/
|
||||
default ExternalPushConfigDO selectByConfig(Long companyId, Long deptId, String businessType, String externalSystem) {
|
||||
LambdaQueryWrapperX<ExternalPushConfigDO> wrapper = new LambdaQueryWrapperX<>();
|
||||
|
||||
if (companyId == null) {
|
||||
wrapper.isNull(ExternalPushConfigDO::getCompanyId);
|
||||
} else {
|
||||
wrapper.eq(ExternalPushConfigDO::getCompanyId, companyId);
|
||||
}
|
||||
|
||||
if (deptId == null) {
|
||||
wrapper.isNull(ExternalPushConfigDO::getDeptId);
|
||||
} else {
|
||||
wrapper.eq(ExternalPushConfigDO::getDeptId, deptId);
|
||||
}
|
||||
|
||||
if (businessType == null) {
|
||||
wrapper.isNull(ExternalPushConfigDO::getBusinessType);
|
||||
} else {
|
||||
wrapper.eq(ExternalPushConfigDO::getBusinessType, businessType);
|
||||
}
|
||||
|
||||
if (externalSystem == null) {
|
||||
wrapper.isNull(ExternalPushConfigDO::getExternalSystem);
|
||||
} else {
|
||||
wrapper.eq(ExternalPushConfigDO::getExternalSystem, externalSystem);
|
||||
}
|
||||
|
||||
return selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询公司下所有配置
|
||||
*/
|
||||
default List<ExternalPushConfigDO> selectListByCompanyId(Long companyId) {
|
||||
return selectList(ExternalPushConfigDO::getCompanyId, companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门下所有配置
|
||||
*/
|
||||
default List<ExternalPushConfigDO> selectListByDeptId(Long deptId) {
|
||||
return selectList(ExternalPushConfigDO::getDeptId, deptId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zt.plat.module.system.service.push;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.system.controller.admin.push.vo.ExternalPushConfigPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.push.vo.ExternalPushConfigSaveReqVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.push.ExternalPushConfigDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 外部系统推送配置 Service 接口
|
||||
*
|
||||
* @author ZT Cloud
|
||||
*/
|
||||
public interface ExternalPushConfigService {
|
||||
|
||||
/**
|
||||
* 创建推送配置
|
||||
*/
|
||||
Long createExternalPushConfig(@Valid ExternalPushConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 修改推送配置
|
||||
*/
|
||||
void updateExternalPushConfig(@Valid ExternalPushConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除推送配置
|
||||
*/
|
||||
void deleteExternalPushConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获取推送配置详情
|
||||
*/
|
||||
ExternalPushConfigDO getExternalPushConfig(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询推送配置
|
||||
*/
|
||||
PageResult<ExternalPushConfigDO> getExternalPushConfigPage(ExternalPushConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 判断是否允许推送(核心业务逻辑)
|
||||
*
|
||||
* 优先级:部门配置 > 公司配置 > 默认允许
|
||||
*
|
||||
* @param companyId 公司编号(必填)
|
||||
* @param deptId 部门编号(可选)
|
||||
* @param businessType 业务类型(必填)
|
||||
* @param externalSystem 外部系统标识(必填)
|
||||
* @return 是否允许推送(true=允许,false=禁止,默认 true)
|
||||
*/
|
||||
Boolean isPushEnabled(Long companyId, Long deptId, String businessType, String externalSystem);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user