mirror of https://gitee.com/stylefeng/roses
【7.3.4】初始化文件业务的绑定
parent
fbb09a170c
commit
e2b582bbc8
|
@ -0,0 +1,58 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 业务关联的文件实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
@TableName("sys_file_business")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysFileBusiness extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "file_business_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键id")
|
||||
private Long fileBusinessId;
|
||||
|
||||
/**
|
||||
* 业务主键id
|
||||
*/
|
||||
@TableField("business_id")
|
||||
@ChineseDescription("业务主键id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 关联文件表的id
|
||||
*/
|
||||
@TableField("file_id")
|
||||
@ChineseDescription("关联文件表的id")
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 下载次数
|
||||
*/
|
||||
@TableField("download_count")
|
||||
@ChineseDescription("下载次数")
|
||||
private Integer downloadCount;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务关联的文件异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
@Getter
|
||||
public enum SysFileBusinessExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
SYS_FILE_BUSINESS_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
SysFileBusinessExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.file.modular.entity.SysFileBusiness;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 业务关联的文件 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
public interface SysFileBusinessMapper extends BaseMapper<SysFileBusiness> {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.file.modular.mapper.SysFileBusinessMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 业务关联的文件封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysFileBusinessRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键id")
|
||||
private Long fileBusinessId;
|
||||
|
||||
/**
|
||||
* 业务主键id
|
||||
*/
|
||||
@ChineseDescription("业务主键id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 关联文件表的id
|
||||
*/
|
||||
@ChineseDescription("关联文件表的id")
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 下载次数
|
||||
*/
|
||||
@ChineseDescription("下载次数")
|
||||
private Integer downloadCount;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.file.modular.entity.SysFileBusiness;
|
||||
import cn.stylefeng.roses.kernel.file.modular.pojo.request.SysFileBusinessRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务关联的文件 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
public interface SysFileBusinessService extends IService<SysFileBusiness> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
void add(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
void del(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
void edit(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
SysFileBusiness detail(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @return List<SysFileBusiness> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
List<SysFileBusiness> findList(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param sysFileBusinessRequest 请求参数
|
||||
* @return PageResult<SysFileBusiness> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
PageResult<SysFileBusiness> findPage(SysFileBusinessRequest sysFileBusinessRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package cn.stylefeng.roses.kernel.file.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.file.modular.entity.SysFileBusiness;
|
||||
import cn.stylefeng.roses.kernel.file.modular.enums.SysFileBusinessExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.file.modular.mapper.SysFileBusinessMapper;
|
||||
import cn.stylefeng.roses.kernel.file.modular.pojo.request.SysFileBusinessRequest;
|
||||
import cn.stylefeng.roses.kernel.file.modular.service.SysFileBusinessService;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务关联的文件业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
@Service
|
||||
public class SysFileBusinessServiceImpl extends ServiceImpl<SysFileBusinessMapper, SysFileBusiness> implements SysFileBusinessService {
|
||||
|
||||
@Override
|
||||
public void add(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
SysFileBusiness sysFileBusiness = new SysFileBusiness();
|
||||
BeanUtil.copyProperties(sysFileBusinessRequest, sysFileBusiness);
|
||||
this.save(sysFileBusiness);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
SysFileBusiness sysFileBusiness = this.querySysFileBusiness(sysFileBusinessRequest);
|
||||
this.removeById(sysFileBusiness.getFileBusinessId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
SysFileBusiness sysFileBusiness = this.querySysFileBusiness(sysFileBusinessRequest);
|
||||
BeanUtil.copyProperties(sysFileBusinessRequest, sysFileBusiness);
|
||||
this.updateById(sysFileBusiness);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysFileBusiness detail(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
return this.querySysFileBusiness(sysFileBusinessRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysFileBusiness> findPage(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
LambdaQueryWrapper<SysFileBusiness> wrapper = createWrapper(sysFileBusinessRequest);
|
||||
Page<SysFileBusiness> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysFileBusiness> findList(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
LambdaQueryWrapper<SysFileBusiness> wrapper = this.createWrapper(sysFileBusinessRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
private SysFileBusiness querySysFileBusiness(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
SysFileBusiness sysFileBusiness = this.getById(sysFileBusinessRequest.getFileBusinessId());
|
||||
if (ObjectUtil.isEmpty(sysFileBusiness)) {
|
||||
throw new ServiceException(SysFileBusinessExceptionEnum.SYS_FILE_BUSINESS_NOT_EXISTED);
|
||||
}
|
||||
return sysFileBusiness;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/03/31 13:30
|
||||
*/
|
||||
private LambdaQueryWrapper<SysFileBusiness> createWrapper(SysFileBusinessRequest sysFileBusinessRequest) {
|
||||
LambdaQueryWrapper<SysFileBusiness> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long fileBusinessId = sysFileBusinessRequest.getFileBusinessId();
|
||||
Long businessId = sysFileBusinessRequest.getBusinessId();
|
||||
Long fileId = sysFileBusinessRequest.getFileId();
|
||||
Integer downloadCount = sysFileBusinessRequest.getDownloadCount();
|
||||
Long tenantId = sysFileBusinessRequest.getTenantId();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(fileBusinessId), SysFileBusiness::getFileBusinessId, fileBusinessId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(businessId), SysFileBusiness::getBusinessId, businessId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(fileId), SysFileBusiness::getFileId, fileId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(downloadCount), SysFileBusiness::getDownloadCount, downloadCount);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), SysFileBusiness::getTenantId, tenantId);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue