19 changed files with 1236 additions and 24 deletions
@ -0,0 +1,85 @@ |
|||
package org.dromara.business.api.domain.vo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 预警任务-施工信息对象 business_alert_construct_info |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@Data |
|||
public class RemoteBusinessAlertConstructInfo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long id; |
|||
|
|||
private String tenantId; |
|||
|
|||
|
|||
/** |
|||
* 1:图片比对预警 2:AI实时预警 |
|||
*/ |
|||
private Long businessType; |
|||
|
|||
/** |
|||
* job任务id |
|||
*/ |
|||
private String jobId; |
|||
|
|||
/** |
|||
* 预警名称 |
|||
*/ |
|||
private String jobName; |
|||
|
|||
/** |
|||
* 预警任务id |
|||
*/ |
|||
private Long businessAlertId; |
|||
|
|||
/** |
|||
* 施工名称 |
|||
*/ |
|||
private String constructName; |
|||
|
|||
/** |
|||
* 施工单位 |
|||
*/ |
|||
private String constructDept; |
|||
|
|||
/** |
|||
* 施工单位负责人 |
|||
*/ |
|||
private String constructLeader; |
|||
|
|||
/** |
|||
* 联系电话 |
|||
*/ |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 施工地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 所属管道 |
|||
*/ |
|||
private String pipeline; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
package org.dromara.business.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
|||
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
|||
import org.dromara.business.service.IBusinessAlertConstructInfoService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 预警任务-施工信息 |
|||
* 前端访问路由地址为:/business/alertConstructInfo |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/alertConstructInfo") |
|||
public class BusinessAlertConstructInfoController extends BaseController { |
|||
|
|||
private final IBusinessAlertConstructInfoService businessAlertConstructInfoService; |
|||
|
|||
/** |
|||
* 查询预警任务-施工信息列表 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<BusinessAlertConstructInfoVo> list(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) { |
|||
return businessAlertConstructInfoService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出预警任务-施工信息列表 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:export") |
|||
@Log(title = "预警任务-施工信息", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(BusinessAlertConstructInfoBo bo, HttpServletResponse response) { |
|||
List<BusinessAlertConstructInfoVo> list = businessAlertConstructInfoService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "预警任务-施工信息", BusinessAlertConstructInfoVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取预警任务-施工信息详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:query") |
|||
@GetMapping("/{id}") |
|||
public R<BusinessAlertConstructInfoVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(businessAlertConstructInfoService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增预警任务-施工信息 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:add") |
|||
@Log(title = "预警任务-施工信息", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) { |
|||
return toAjax(businessAlertConstructInfoService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改预警任务-施工信息 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:edit") |
|||
@Log(title = "预警任务-施工信息", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) { |
|||
return toAjax(businessAlertConstructInfoService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除预警任务-施工信息 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("business:businessAlertConstructInfo:remove") |
|||
@Log(title = "预警任务-施工信息", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(businessAlertConstructInfoService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
@ -0,0 +1,86 @@ |
|||
package org.dromara.business.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 预警任务-施工信息对象 business_alert_construct_info |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("business_alert_construct_info") |
|||
public class BusinessAlertConstructInfo extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 1:图片比对预警 2:AI实时预警 |
|||
*/ |
|||
private Long businessType; |
|||
|
|||
/** |
|||
* job任务id |
|||
*/ |
|||
private String jobId; |
|||
|
|||
/** |
|||
* 预警名称 |
|||
*/ |
|||
private String jobName; |
|||
|
|||
/** |
|||
* 预警任务id |
|||
*/ |
|||
private Long businessAlertId; |
|||
|
|||
/** |
|||
* 施工名称 |
|||
*/ |
|||
private String constructName; |
|||
|
|||
/** |
|||
* 施工单位 |
|||
*/ |
|||
private String constructDept; |
|||
|
|||
/** |
|||
* 施工单位负责人 |
|||
*/ |
|||
private String constructLeader; |
|||
|
|||
/** |
|||
* 联系电话 |
|||
*/ |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 施工地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 所属管道 |
|||
*/ |
|||
private String pipeline; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,87 @@ |
|||
package org.dromara.business.domain.bo; |
|||
|
|||
import org.dromara.business.domain.BusinessAlertConstructInfo; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
/** |
|||
* 预警任务-施工信息业务对象 business_alert_construct_info |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = BusinessAlertConstructInfo.class, reverseConvertGenerate = false) |
|||
public class BusinessAlertConstructInfoBo extends BaseEntity { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
@NotNull(message = "不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 1:图片比对预警 2:AI实时预警 |
|||
*/ |
|||
private Long businessType; |
|||
|
|||
/** |
|||
* job任务id |
|||
*/ |
|||
private String jobId; |
|||
|
|||
/** |
|||
* 预警名称 |
|||
*/ |
|||
private String jobName; |
|||
|
|||
/** |
|||
* 预警任务id |
|||
*/ |
|||
@NotNull(message = "预警任务id不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long businessAlertId; |
|||
|
|||
/** |
|||
* 施工名称 |
|||
*/ |
|||
@NotBlank(message = "施工名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String constructName; |
|||
|
|||
/** |
|||
* 施工单位 |
|||
*/ |
|||
private String constructDept; |
|||
|
|||
/** |
|||
* 施工单位负责人 |
|||
*/ |
|||
private String constructLeader; |
|||
|
|||
/** |
|||
* 联系电话 |
|||
*/ |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 施工地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 所属管道 |
|||
*/ |
|||
private String pipeline; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,104 @@ |
|||
package org.dromara.business.domain.vo; |
|||
|
|||
import org.dromara.business.domain.BusinessAlertConstructInfo; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 预警任务-施工信息视图对象 business_alert_construct_info |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = BusinessAlertConstructInfo.class) |
|||
public class BusinessAlertConstructInfoVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
@ExcelProperty(value = "") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 1:图片比对预警 2:AI实时预警 |
|||
*/ |
|||
@ExcelProperty(value = "1:图片比对预警 2:AI实时预警") |
|||
private Long businessType; |
|||
|
|||
/** |
|||
* job任务id |
|||
*/ |
|||
@ExcelProperty(value = "job任务id") |
|||
private String jobId; |
|||
|
|||
/** |
|||
* 预警名称 |
|||
*/ |
|||
@ExcelProperty(value = "预警名称") |
|||
private String jobName; |
|||
|
|||
/** |
|||
* 预警任务id |
|||
*/ |
|||
@ExcelProperty(value = "预警任务id") |
|||
private Long businessAlertId; |
|||
|
|||
/** |
|||
* 施工名称 |
|||
*/ |
|||
@ExcelProperty(value = "施工名称") |
|||
private String constructName; |
|||
|
|||
/** |
|||
* 施工单位 |
|||
*/ |
|||
@ExcelProperty(value = "施工单位") |
|||
private String constructDept; |
|||
|
|||
/** |
|||
* 施工单位负责人 |
|||
*/ |
|||
@ExcelProperty(value = "施工单位负责人") |
|||
private String constructLeader; |
|||
|
|||
/** |
|||
* 联系电话 |
|||
*/ |
|||
@ExcelProperty(value = "联系电话") |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 施工地址 |
|||
*/ |
|||
@ExcelProperty(value = "施工地址") |
|||
private String address; |
|||
|
|||
/** |
|||
* 所属管道 |
|||
*/ |
|||
@ExcelProperty(value = "所属管道") |
|||
private String pipeline; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.business.mapper; |
|||
|
|||
import org.dromara.business.domain.BusinessAlertConstructInfo; |
|||
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 预警任务-施工信息Mapper接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
public interface BusinessAlertConstructInfoMapper extends BaseMapperPlus<BusinessAlertConstructInfo, BusinessAlertConstructInfoVo> { |
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
package org.dromara.business.service; |
|||
|
|||
import org.dromara.business.domain.BusinessAlertConstructInfo; |
|||
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
|||
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 预警任务-施工信息Service接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
public interface IBusinessAlertConstructInfoService { |
|||
|
|||
/** |
|||
* 查询预警任务-施工信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 预警任务-施工信息 |
|||
*/ |
|||
BusinessAlertConstructInfoVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询预警任务-施工信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 预警任务-施工信息分页列表 |
|||
*/ |
|||
TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的预警任务-施工信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 预警任务-施工信息列表 |
|||
*/ |
|||
List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo); |
|||
|
|||
/** |
|||
* 新增预警任务-施工信息 |
|||
* |
|||
* @param bo 预警任务-施工信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(BusinessAlertConstructInfoBo bo); |
|||
|
|||
/** |
|||
* 修改预警任务-施工信息 |
|||
* |
|||
* @param bo 预警任务-施工信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(BusinessAlertConstructInfoBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除预警任务-施工信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
} |
@ -0,0 +1,138 @@ |
|||
package org.dromara.business.service.impl; |
|||
|
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
|||
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
|||
import org.dromara.business.domain.BusinessAlertConstructInfo; |
|||
import org.dromara.business.mapper.BusinessAlertConstructInfoMapper; |
|||
import org.dromara.business.service.IBusinessAlertConstructInfoService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 预警任务-施工信息Service业务层处理 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-21 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class BusinessAlertConstructInfoServiceImpl implements IBusinessAlertConstructInfoService { |
|||
|
|||
private final BusinessAlertConstructInfoMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询预警任务-施工信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 预警任务-施工信息 |
|||
*/ |
|||
@Override |
|||
public BusinessAlertConstructInfoVo queryById(Long id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询预警任务-施工信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 预警任务-施工信息分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo); |
|||
Page<BusinessAlertConstructInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的预警任务-施工信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 预警任务-施工信息列表 |
|||
*/ |
|||
@Override |
|||
public List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo) { |
|||
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<BusinessAlertConstructInfo> buildQueryWrapper(BusinessAlertConstructInfoBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(bo.getBusinessType() != null, BusinessAlertConstructInfo::getBusinessType, bo.getBusinessType()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getJobId()), BusinessAlertConstructInfo::getJobId, bo.getJobId()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getJobName()), BusinessAlertConstructInfo::getJobName, bo.getJobName()); |
|||
lqw.eq(bo.getBusinessAlertId() != null, BusinessAlertConstructInfo::getBusinessAlertId, bo.getBusinessAlertId()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getConstructName()), BusinessAlertConstructInfo::getConstructName, bo.getConstructName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getConstructDept()), BusinessAlertConstructInfo::getConstructDept, bo.getConstructDept()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getConstructLeader()), BusinessAlertConstructInfo::getConstructLeader, bo.getConstructLeader()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), BusinessAlertConstructInfo::getPhonenumber, bo.getPhonenumber()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), BusinessAlertConstructInfo::getAddress, bo.getAddress()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getPipeline()), BusinessAlertConstructInfo::getPipeline, bo.getPipeline()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增预警任务-施工信息 |
|||
* |
|||
* @param bo 预警任务-施工信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(BusinessAlertConstructInfoBo bo) { |
|||
BusinessAlertConstructInfo add = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改预警任务-施工信息 |
|||
* |
|||
* @param bo 预警任务-施工信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(BusinessAlertConstructInfoBo bo) { |
|||
BusinessAlertConstructInfo update = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(BusinessAlertConstructInfo entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除预警任务-施工信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
} |
@ -0,0 +1,183 @@ |
|||
package org.dromara.business.utils; |
|||
|
|||
import cn.hutool.core.io.IoUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import io.minio.*; |
|||
import io.minio.http.Method; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.InputStream; |
|||
import java.util.HashMap; |
|||
|
|||
@Component |
|||
public class MinioUtil { |
|||
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
|
|||
private static String endpoint; |
|||
// MinIO的访问密钥(Access Key),用于身份验证
|
|||
private static String accessKey; |
|||
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
|
|||
private static String secretKey; |
|||
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
|
|||
private static String bucket; |
|||
|
|||
@Value("${minio.endpoint:http://114.235.183.147:9090}") |
|||
public void setEndpoint(String endpoint) { |
|||
MinioUtil.endpoint = endpoint; |
|||
} |
|||
|
|||
@Value("${minio.accessKey:wuyuan@yf}") |
|||
public void setAccessKey(String accessKey) { |
|||
MinioUtil.accessKey = accessKey; |
|||
} |
|||
|
|||
@Value("${minio.secretKey:wuyuan@yf}") |
|||
public void setSecretKey(String secretKey) { |
|||
MinioUtil.secretKey = secretKey; |
|||
} |
|||
|
|||
@Value("${minio.bucket:dkcy}") |
|||
public void setBucket(String bucket) { |
|||
MinioUtil.bucket = bucket; |
|||
} |
|||
|
|||
/** |
|||
* 创建并返回一个配置好的MinioClient实例 |
|||
* 用于与MinIO服务器交互,上传文件、下载文件、删除文件 |
|||
* |
|||
* @return 配置 |
|||
*/ |
|||
public static MinioClient getMinioClient() { |
|||
return MinioClient.builder() |
|||
.endpoint(endpoint) |
|||
.credentials(accessKey, secretKey) |
|||
.build(); |
|||
} |
|||
|
|||
/** |
|||
* 上传:将一个输入流中的文件上传到MinIO服务器上指定的存储桶(bucket)里 |
|||
* |
|||
* @param objectName .object(objectName)指定了上传后对象的名称。 |
|||
* @param inputStream 转换为 流 |
|||
* @param size 文件大小 |
|||
* @param contentType 内容类型 |
|||
* @throws Exception 异常 |
|||
*/ |
|||
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
minioClient.putObject( |
|||
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
|
|||
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1) |
|||
// .contentType(contentType)指定了上传文件的内容类型。
|
|||
.contentType(contentType) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 下载:从MinIO服务器下载指定存储桶(bucket)中的文件 |
|||
* |
|||
* @param objectName 指定要从MinIO下载的文件对象名称(即文件路径和文件名)。 |
|||
* @return 流 对象 |
|||
* @throws Exception 异常 |
|||
*/ |
|||
public static InputStream downloadFile(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
return minioClient.getObject( |
|||
GetObjectArgs.builder() |
|||
// .bucket(bucket)指定了文件所在的存储桶名称。
|
|||
.bucket(bucketName) |
|||
// .object(objectName)指定了要下载的对象名称。
|
|||
.object(objectName) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 预览:生成一个预签名的URL,允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象(文件)的临时链接 |
|||
* |
|||
* @param objectName 指定需要获取预览链接的文件对象名称(包括路径)。 |
|||
* @return 对象 |
|||
* @throws Exception .method(Method.GET)指定了请求的方法为GET,这是预览文件时的标准HTTP方法。 |
|||
* .bucket(bucket)指定了存储桶的名称。 |
|||
* .object(objectName)指定了对象(文件)的名称。 |
|||
*/ |
|||
public static String getPreviewUrl(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
return minioClient.getPresignedObjectUrl( |
|||
GetPresignedObjectUrlArgs.builder() |
|||
.method(Method.GET) |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
} |
|||
|
|||
/** |
|||
* 删除:从MinIO服务器上的指定存储桶中删除一个文件 |
|||
* |
|||
* @param objectName 指定要删除的文件对象名称(包括路径和文件名) |
|||
* @throws Exception |
|||
*/ |
|||
public static void deleteFile(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
minioClient.removeObject( |
|||
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); |
|||
} |
|||
|
|||
//查询文件信息
|
|||
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
MinioClient client = getMinioClient(); |
|||
|
|||
// 获取对象
|
|||
InputStream is = client.getObject(GetObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
|
|||
// 获取文件元信息(如 contentType)
|
|||
StatObjectResponse stat = client.statObject(StatObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
|
|||
String contentType = stat.contentType(); |
|||
|
|||
// 将流读为 byte[] 以生成 MockMultipartFile
|
|||
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
|
|||
HashMap<String, Object> map = new HashMap<>(); |
|||
map.put("objectName",objectName); |
|||
map.put("contentType",contentType); |
|||
map.put("bytes",bytes); |
|||
|
|||
return map; |
|||
} |
|||
|
|||
|
|||
//文件复制
|
|||
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception { |
|||
MinioClient client = getMinioClient(); |
|||
|
|||
// 使用服务器端复制,无需下载上传
|
|||
client.copyObject(CopyObjectArgs.builder() |
|||
.bucket(targetBucket) // 目标桶
|
|||
.object(targetObjectName) // 目标对象
|
|||
.source(CopySource.builder() |
|||
.bucket(sourceBucket) |
|||
.object(sourceObjectName) |
|||
.build()) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -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="org.dromara.business.mapper.BusinessAlertConstructInfoMapper"> |
|||
|
|||
</mapper> |
@ -0,0 +1,183 @@ |
|||
package org.dromara.sample.utils; |
|||
|
|||
import cn.hutool.core.io.IoUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import io.minio.*; |
|||
import io.minio.http.Method; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.InputStream; |
|||
import java.util.HashMap; |
|||
|
|||
@Component |
|||
public class MinioUtil { |
|||
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
|
|||
private static String endpoint; |
|||
// MinIO的访问密钥(Access Key),用于身份验证
|
|||
private static String accessKey; |
|||
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
|
|||
private static String secretKey; |
|||
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
|
|||
private static String bucket; |
|||
|
|||
@Value("${minio.endpoint:http://114.235.183.147:9090}") |
|||
public void setEndpoint(String endpoint) { |
|||
MinioUtil.endpoint = endpoint; |
|||
} |
|||
|
|||
@Value("${minio.accessKey:wuyuan@yf}") |
|||
public void setAccessKey(String accessKey) { |
|||
MinioUtil.accessKey = accessKey; |
|||
} |
|||
|
|||
@Value("${minio.secretKey:wuyuan@yf}") |
|||
public void setSecretKey(String secretKey) { |
|||
MinioUtil.secretKey = secretKey; |
|||
} |
|||
|
|||
@Value("${minio.bucket:dkcy}") |
|||
public void setBucket(String bucket) { |
|||
MinioUtil.bucket = bucket; |
|||
} |
|||
|
|||
/** |
|||
* 创建并返回一个配置好的MinioClient实例 |
|||
* 用于与MinIO服务器交互,上传文件、下载文件、删除文件 |
|||
* |
|||
* @return 配置 |
|||
*/ |
|||
public static MinioClient getMinioClient() { |
|||
return MinioClient.builder() |
|||
.endpoint(endpoint) |
|||
.credentials(accessKey, secretKey) |
|||
.build(); |
|||
} |
|||
|
|||
/** |
|||
* 上传:将一个输入流中的文件上传到MinIO服务器上指定的存储桶(bucket)里 |
|||
* |
|||
* @param objectName .object(objectName)指定了上传后对象的名称。 |
|||
* @param inputStream 转换为 流 |
|||
* @param size 文件大小 |
|||
* @param contentType 内容类型 |
|||
* @throws Exception 异常 |
|||
*/ |
|||
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
minioClient.putObject( |
|||
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
|
|||
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1) |
|||
// .contentType(contentType)指定了上传文件的内容类型。
|
|||
.contentType(contentType) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 下载:从MinIO服务器下载指定存储桶(bucket)中的文件 |
|||
* |
|||
* @param objectName 指定要从MinIO下载的文件对象名称(即文件路径和文件名)。 |
|||
* @return 流 对象 |
|||
* @throws Exception 异常 |
|||
*/ |
|||
public static InputStream downloadFile(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
return minioClient.getObject( |
|||
GetObjectArgs.builder() |
|||
// .bucket(bucket)指定了文件所在的存储桶名称。
|
|||
.bucket(bucketName) |
|||
// .object(objectName)指定了要下载的对象名称。
|
|||
.object(objectName) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 预览:生成一个预签名的URL,允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象(文件)的临时链接 |
|||
* |
|||
* @param objectName 指定需要获取预览链接的文件对象名称(包括路径)。 |
|||
* @return 对象 |
|||
* @throws Exception .method(Method.GET)指定了请求的方法为GET,这是预览文件时的标准HTTP方法。 |
|||
* .bucket(bucket)指定了存储桶的名称。 |
|||
* .object(objectName)指定了对象(文件)的名称。 |
|||
*/ |
|||
public static String getPreviewUrl(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
return minioClient.getPresignedObjectUrl( |
|||
GetPresignedObjectUrlArgs.builder() |
|||
.method(Method.GET) |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
} |
|||
|
|||
/** |
|||
* 删除:从MinIO服务器上的指定存储桶中删除一个文件 |
|||
* |
|||
* @param objectName 指定要删除的文件对象名称(包括路径和文件名) |
|||
* @throws Exception |
|||
*/ |
|||
public static void deleteFile(String objectName,String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
|
|||
MinioClient minioClient = getMinioClient(); |
|||
minioClient.removeObject( |
|||
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); |
|||
} |
|||
|
|||
//查询文件信息
|
|||
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception { |
|||
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
|||
MinioClient client = getMinioClient(); |
|||
|
|||
// 获取对象
|
|||
InputStream is = client.getObject(GetObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
|
|||
// 获取文件元信息(如 contentType)
|
|||
StatObjectResponse stat = client.statObject(StatObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
|
|||
String contentType = stat.contentType(); |
|||
|
|||
// 将流读为 byte[] 以生成 MockMultipartFile
|
|||
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
|
|||
HashMap<String, Object> map = new HashMap<>(); |
|||
map.put("objectName",objectName); |
|||
map.put("contentType",contentType); |
|||
map.put("bytes",bytes); |
|||
|
|||
return map; |
|||
} |
|||
|
|||
|
|||
//文件复制
|
|||
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception { |
|||
MinioClient client = getMinioClient(); |
|||
|
|||
// 使用服务器端复制,无需下载上传
|
|||
client.copyObject(CopyObjectArgs.builder() |
|||
.bucket(targetBucket) // 目标桶
|
|||
.object(targetObjectName) // 目标对象
|
|||
.source(CopySource.builder() |
|||
.bucket(sourceBucket) |
|||
.object(sourceObjectName) |
|||
.build()) |
|||
.build()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
Loading…
Reference in new issue