26 changed files with 1924 additions and 2 deletions
@ -0,0 +1,79 @@ |
|||||
|
package org.dromara.system.config; |
||||
|
|
||||
|
import io.minio.MinioClient; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
/** |
||||
|
* Minio 配置信息 |
||||
|
* |
||||
|
* @author ruoyi |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@ConfigurationProperties(prefix = "osstianyi") |
||||
|
public class OssTianyiConfig |
||||
|
{ |
||||
|
|
||||
|
private String endPoint; |
||||
|
private String accessKey; |
||||
|
private String secretKey; |
||||
|
private String bucketName; |
||||
|
|
||||
|
public String getEndPoint() { |
||||
|
return endPoint; |
||||
|
} |
||||
|
|
||||
|
public void setEndPoint(String endPoint) { |
||||
|
this.endPoint = endPoint; |
||||
|
} |
||||
|
|
||||
|
public String getAccessKey() |
||||
|
{ |
||||
|
return accessKey; |
||||
|
} |
||||
|
|
||||
|
public void setAccessKey(String accessKey) |
||||
|
{ |
||||
|
this.accessKey = accessKey; |
||||
|
} |
||||
|
|
||||
|
public String getSecretKey() |
||||
|
{ |
||||
|
return secretKey; |
||||
|
} |
||||
|
|
||||
|
public void setSecretKey(String secretKey) |
||||
|
{ |
||||
|
this.secretKey = secretKey; |
||||
|
} |
||||
|
|
||||
|
public String getBucketName() |
||||
|
{ |
||||
|
return bucketName; |
||||
|
} |
||||
|
|
||||
|
public void setBucketName(String bucketName) |
||||
|
{ |
||||
|
this.bucketName = bucketName; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "OssTianyiConfig{" + |
||||
|
"endPoint='" + endPoint + '\'' + |
||||
|
", accessKey='" + accessKey + '\'' + |
||||
|
", secretKey='" + secretKey + '\'' + |
||||
|
", bucketName='" + bucketName + '\'' + |
||||
|
'}'; |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public MinioClient getMinioClient() |
||||
|
{ |
||||
|
// System.out.println("OssTianyiConfig");
|
||||
|
// System.out.println("OssTianyiConfig" + endPoint);
|
||||
|
System.out.println(toString()); |
||||
|
return MinioClient.builder().endpoint(endPoint).credentials(accessKey, secretKey).build(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
package org.dromara.system.controller.ossTianyi; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.dromara.system.domain.SysUploadFile; |
||||
|
import org.dromara.system.utils.OssTianyiClientUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
|
||||
|
/** |
||||
|
* 系统上传文件Controller |
||||
|
* |
||||
|
* @author tom |
||||
|
* @date 2024-12-21 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/ossTianyi") |
||||
|
public class OssTianyiController extends BaseController |
||||
|
{ |
||||
|
|
||||
|
@Autowired |
||||
|
private OssTianyiClientUtils ossTianyiClientUtils; |
||||
|
|
||||
|
/** |
||||
|
* 查询系统上传文件列表 (实际是上传接口) |
||||
|
*/ |
||||
|
@SaCheckPermission("file:sysUploadFile:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo list(SysUploadFile sysUploadFile) |
||||
|
{ |
||||
|
String localFilePath = "D:\\123pan\\page.html"; |
||||
|
try{ |
||||
|
ossTianyiClientUtils.uploadFileTest("page.html","dev/temp",localFilePath); |
||||
|
}catch (Exception e){ |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/upload") |
||||
|
public R<HashMap<String, Object>> upload(@RequestPart("file") MultipartFile file) { |
||||
|
try { |
||||
|
ossTianyiClientUtils.uploadFile( "dev/temp/"+file.getName(), file); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,125 @@ |
|||||
|
package org.dromara.system.controller.site; |
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.apache.dubbo.config.annotation.DubboReference; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.core.service.DictService; |
||||
|
import org.dromara.common.log.annotation.Log; |
||||
|
import org.dromara.common.log.enums.BusinessType; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.dromara.resource.api.RemoteMessageService; |
||||
|
import org.dromara.system.domain.bo.SysNoticeBo; |
||||
|
import org.dromara.system.domain.vo.SysNoticeVo; |
||||
|
import org.dromara.system.service.ISysNoticeService; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* 公告 信息操作处理 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/site") |
||||
|
public class SiteController extends BaseController { |
||||
|
|
||||
|
private final ISysNoticeService noticeService; |
||||
|
private final DictService dictService; |
||||
|
|
||||
|
@DubboReference |
||||
|
private final RemoteMessageService remoteMessageService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
//每周提供一次二维场地全貌图及工地视频。 以周为单位处理数据
|
||||
|
//site/img/2005/xxxxxxx.png
|
||||
|
//site/video/2025/
|
||||
|
|
||||
|
//todo 二维瓦片上传
|
||||
|
|
||||
|
|
||||
|
//todo 二维瓦片批量上传 (按照周)
|
||||
|
|
||||
|
|
||||
|
//todo 二维瓦片批量下载 (按照周)
|
||||
|
|
||||
|
//todo 二维瓦片访问 #按照 http://localhost:3308/tile/{z}/{x}/{y}.png 模式访问
|
||||
|
|
||||
|
|
||||
|
//todo 工地视频上传
|
||||
|
|
||||
|
//todo 工地视频下载
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取通知公告列表 |
||||
|
*/ |
||||
|
// @SaCheckPermission("system:notice:list")
|
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<SysNoticeVo> list(SysNoticeBo notice, PageQuery pageQuery) { |
||||
|
return noticeService.selectPageNoticeList(notice, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据通知公告编号获取详细信息 |
||||
|
* |
||||
|
* @param noticeId 公告ID |
||||
|
*/ |
||||
|
// @SaCheckPermission("system:notice:query")
|
||||
|
@GetMapping(value = "/{noticeId}") |
||||
|
public R<SysNoticeVo> getInfo(@PathVariable Long noticeId) { |
||||
|
return R.ok(noticeService.selectNoticeById(noticeId)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增通知公告 |
||||
|
*/ |
||||
|
// @SaCheckPermission("system:notice:add")
|
||||
|
@Log(title = "通知公告", businessType = BusinessType.INSERT) |
||||
|
@PostMapping |
||||
|
public R<Void> add(@Validated @RequestBody SysNoticeBo notice) { |
||||
|
int rows = noticeService.insertNotice(notice); |
||||
|
if (rows <= 0) { |
||||
|
return R.fail(); |
||||
|
} |
||||
|
String type = dictService.getDictLabel("sys_notice_type", notice.getNoticeType()); |
||||
|
remoteMessageService.publishAll("[" + type + "] " + notice.getNoticeTitle()); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改通知公告 |
||||
|
*/ |
||||
|
// @SaCheckPermission("system:notice:edit")
|
||||
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE) |
||||
|
@PutMapping |
||||
|
public R<Void> edit(@Validated @RequestBody SysNoticeBo notice) { |
||||
|
return toAjax(noticeService.updateNotice(notice)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除通知公告 |
||||
|
* |
||||
|
* @param noticeIds 公告ID串 |
||||
|
*/ |
||||
|
// @SaCheckPermission("system:notice:remove")
|
||||
|
@Log(title = "通知公告", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{noticeIds}") |
||||
|
public R<Void> remove(@PathVariable Long[] noticeIds) { |
||||
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,239 @@ |
|||||
|
package org.dromara.system.controller.site; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.dromara.common.core.service.DictService; |
||||
|
import org.dromara.common.dict.utils.DictUtils; |
||||
|
import org.dromara.system.api.RemoteDictService; |
||||
|
import org.dromara.system.api.domain.vo.RemoteDictDataVo; |
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
import org.dromara.system.domain.bo.SiteWeekOssBo; |
||||
|
import org.dromara.system.domain.vo.SiteWeekOssVo; |
||||
|
import org.dromara.system.domain.vo.SysDictDataVo; |
||||
|
import org.dromara.system.service.ISiteWeekOssService; |
||||
|
import org.dromara.system.service.ISysDictDataService; |
||||
|
import org.dromara.system.utils.OssTianyiClientUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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.system.domain.vo.SiteWeekVo; |
||||
|
import org.dromara.system.domain.bo.SiteWeekBo; |
||||
|
import org.dromara.system.service.ISiteWeekService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.system.utils.WeekNoUtil; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 工地日期周 |
||||
|
* 前端访问路由地址为:/system/siteWeek |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/siteWeek") |
||||
|
public class SiteWeekController extends BaseController { |
||||
|
|
||||
|
private final ISiteWeekService siteWeekService; |
||||
|
|
||||
|
// @Autowired
|
||||
|
// private ISysDictDataService sysDictDataService;
|
||||
|
// RemoteDictService
|
||||
|
|
||||
|
private final DictService dictService; |
||||
|
|
||||
|
@Autowired |
||||
|
private ISiteWeekOssService siteWeekOssService; |
||||
|
|
||||
|
@Autowired |
||||
|
private OssTianyiClientUtils ossTianyiClientUtils; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询工地日期周列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<SiteWeekVo> list(SiteWeekBo bo, PageQuery pageQuery) { |
||||
|
return siteWeekService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出工地日期周列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:export") |
||||
|
@Log(title = "工地日期周", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(SiteWeekBo bo, HttpServletResponse response) { |
||||
|
List<SiteWeekVo> list = siteWeekService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "工地日期周", SiteWeekVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取工地日期周详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<SiteWeekVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable Long id) { |
||||
|
return R.ok(siteWeekService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增工地日期周 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:add") |
||||
|
@Log(title = "工地日期周", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SiteWeekBo bo) { |
||||
|
return toAjax(siteWeekService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
@SaCheckPermission("system:siteWeek:add") |
||||
|
@Log(title = "工地日期周", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping("/autoAdd") |
||||
|
public R<SiteWeekVo> autoAdd(@Validated(AddGroup.class) @RequestBody SiteWeekBo bo) { |
||||
|
R<SiteWeekVo> siteWeekVo = autoAddSiteWeek(); |
||||
|
return siteWeekVo; |
||||
|
} |
||||
|
|
||||
|
private R<SiteWeekVo> autoAddSiteWeek() { |
||||
|
//新增时基于最新日期处理weekNo
|
||||
|
//先查找当前周是否已存在数据库, 有》返回已有数据, 无》新建数据再返回
|
||||
|
Date currentDate = new Date(); |
||||
|
|
||||
|
int weekNoByDate = WeekNoUtil.getWeekNoByDate(currentDate); |
||||
|
|
||||
|
SiteWeekBo siteWeekBo = new SiteWeekBo(); |
||||
|
siteWeekBo.setWeekNo((long) weekNoByDate); |
||||
|
|
||||
|
|
||||
|
List<SiteWeekVo> siteWeekVoList = siteWeekService.queryList(siteWeekBo); |
||||
|
SiteWeekVo siteWeekVo = null; |
||||
|
if (siteWeekVoList.size() > 0) { |
||||
|
return R.fail("当前周已存在,无法新增"); |
||||
|
|
||||
|
}else{ |
||||
|
String dateStr = WeekNoUtil.generateDateStr(currentDate); |
||||
|
String dateFormatStr = DateUtil.format(currentDate, "yyyy-MM-dd"); |
||||
|
siteWeekBo.setName(dateStr); |
||||
|
siteWeekBo.setNameTime(dateFormatStr); |
||||
|
|
||||
|
|
||||
|
//扩展默认字典配置 默认(tile/tileZip/img/video)
|
||||
|
// List<SysDictDataVo> siteOssDirList = DictUtils.getDictCache("site_oss_dir");
|
||||
|
/** |
||||
|
* 这里用dictService直接查,是因为 RemoteDictDataVo 转 SysDictDataVo 报错,折中做法,(简单说就是 RemoteDictDataVo vo = siteOssDirList.get(0)就报错) |
||||
|
* 报错如下 |
||||
|
* class org.dromara.system.domain.vo.SysDictDataVo cannot be cast to class org.dromara.system.api.domain.vo.RemoteDictDataVo |
||||
|
* (org.dromara.system.domain.vo.SysDictDataVo and org.dromara.system.api.domain.vo.RemoteDictDataVo are in unnamed module of |
||||
|
* loader 'app') |
||||
|
*/ |
||||
|
Map<String, String> siteOssDirMap = dictService.getAllDictMapByDictType("site_oss_dir"); |
||||
|
|
||||
|
siteWeekBo.setDirTile(siteOssDirMap.getOrDefault("二维地图","tile")); |
||||
|
siteWeekBo.setDirTileZip(siteOssDirMap.getOrDefault("二维地图压缩包","tileZip")); |
||||
|
siteWeekBo.setDirImg(siteOssDirMap.getOrDefault("图片","img")); |
||||
|
siteWeekBo.setDirVideo(siteOssDirMap.getOrDefault("视频","video")); |
||||
|
|
||||
|
/* |
||||
|
for (int i = 0; i < siteOssDirList.size(); i++) { |
||||
|
switch (siteOssDirList.get(i).getDictLabel()){ |
||||
|
case "二维地图": |
||||
|
siteWeekBo.setDirTile(siteOssDirList.get(i).getDictValue()); |
||||
|
break; |
||||
|
case "二维地图压缩包": |
||||
|
siteWeekBo.setDirTileZip(siteOssDirList.get(i).getDictValue()); |
||||
|
break; |
||||
|
case "图片": |
||||
|
siteWeekBo.setDirImg(siteOssDirList.get(i).getDictValue()); |
||||
|
break; |
||||
|
case "视频": |
||||
|
siteWeekBo.setDirVideo(siteOssDirList.get(i).getDictValue()); |
||||
|
break; |
||||
|
} |
||||
|
}*/ |
||||
|
|
||||
|
siteWeekService.insertByBo(siteWeekBo); |
||||
|
siteWeekVo = BeanUtil.copyProperties(siteWeekBo, SiteWeekVo.class); |
||||
|
} |
||||
|
return R.ok(siteWeekVo); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 修改工地日期周 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:edit") |
||||
|
@Log(title = "工地日期周", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SiteWeekBo bo) { |
||||
|
return toAjax(siteWeekService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
@SaCheckPermission("system:siteWeek:edit") |
||||
|
@Log(title = "更新工地日期周", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping("changeKeepFlag") |
||||
|
public R<Void> changeKeepFlag(@Validated(EditGroup.class) @RequestBody SiteWeekBo bo) { |
||||
|
return toAjax(siteWeekService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除工地日期周 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeek:remove") |
||||
|
@Log(title = "工地日期周", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable Long[] ids) { |
||||
|
// Boolean result = siteWeekService.deleteWithValidByIds(List.of(ids), true);
|
||||
|
|
||||
|
Boolean result = true; |
||||
|
for (Long id : ids) { |
||||
|
SiteWeekOssBo siteWeekOssBo = new SiteWeekOssBo(); |
||||
|
siteWeekOssBo.setSiteWeekId(id); |
||||
|
List<SiteWeekOssVo> siteWeekOssVoList = siteWeekOssService.queryList(siteWeekOssBo); |
||||
|
for (SiteWeekOssVo siteWeekOssVo : siteWeekOssVoList) { |
||||
|
try{ |
||||
|
ossTianyiClientUtils.deleteFile(siteWeekOssVo.getUrl()); //minio删除文件
|
||||
|
siteWeekOssService.deleteWithValidByIds(List.of(siteWeekOssVo.getId()),true); //工地周数据删除
|
||||
|
}catch (Exception e){ |
||||
|
result = false; |
||||
|
System.err.println("天翼oss文件删除失败"+ siteWeekOssVo.getUrl()); |
||||
|
} |
||||
|
} |
||||
|
siteWeekService.deleteWithValidByIds(List.of(id),true); |
||||
|
} |
||||
|
|
||||
|
return toAjax(result); |
||||
|
} |
||||
|
} |
@ -0,0 +1,227 @@ |
|||||
|
package org.dromara.system.controller.site; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import cn.hutool.core.io.FileUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import jakarta.servlet.ServletOutputStream; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.apache.poi.util.IOUtils; |
||||
|
import org.dromara.system.config.OssTianyiConfig; |
||||
|
import org.dromara.system.domain.bo.SiteWeekBo; |
||||
|
import org.dromara.system.domain.vo.SiteWeekVo; |
||||
|
import org.dromara.system.service.ISiteWeekService; |
||||
|
import org.dromara.system.utils.OssTianyiClientUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
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.system.domain.vo.SiteWeekOssVo; |
||||
|
import org.dromara.system.domain.bo.SiteWeekOssBo; |
||||
|
import org.dromara.system.service.ISiteWeekOssService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储 |
||||
|
* 前端访问路由地址为:/system/siteWeekOss |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/siteWeekOss") |
||||
|
public class SiteWeekOssController extends BaseController { |
||||
|
|
||||
|
private final ISiteWeekOssService siteWeekOssService; |
||||
|
|
||||
|
@Autowired |
||||
|
private ISiteWeekService siteWeekService; |
||||
|
|
||||
|
@Autowired |
||||
|
private OssTianyiClientUtils ossTianyiClientUtils; |
||||
|
|
||||
|
/** |
||||
|
* 查询工地周OSS对象存储列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<SiteWeekOssVo> list(SiteWeekOssBo bo, PageQuery pageQuery) { |
||||
|
return siteWeekOssService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出工地周OSS对象存储列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:export") |
||||
|
@Log(title = "工地周OSS对象存储", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(SiteWeekOssBo bo, HttpServletResponse response) { |
||||
|
List<SiteWeekOssVo> list = siteWeekOssService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "工地周OSS对象存储", SiteWeekOssVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取工地周OSS对象存储详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<SiteWeekOssVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable Long id) { |
||||
|
return R.ok(siteWeekOssService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增工地周OSS对象存储 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:add") |
||||
|
@Log(title = "工地周OSS对象存储", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SiteWeekOssBo bo) { |
||||
|
return toAjax(siteWeekOssService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改工地周OSS对象存储 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:edit") |
||||
|
@Log(title = "工地周OSS对象存储", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SiteWeekOssBo bo) { |
||||
|
return toAjax(siteWeekOssService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
// @Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
|
@Operation(summary = "上传OSS对象存储",description = "上传OSS对象存储") |
||||
|
public R<SiteWeekOssBo> upload(@RequestPart("file") MultipartFile file, @RequestParam("siteWeekId") Long siteWeekId) { |
||||
|
if (ObjectUtil.isNull(file)) { |
||||
|
return R.fail("上传文件不能为空"); |
||||
|
} |
||||
|
|
||||
|
SiteWeekVo siteWeekVo = siteWeekService.queryById(siteWeekId); |
||||
|
//工地日期周默认上传路径
|
||||
|
String baseUrl = siteWeekVo.getNameTime() + "/" + siteWeekVo.getDirTile() + "/"; |
||||
|
|
||||
|
//上传到minio
|
||||
|
String fileUrl = baseUrl + file.getOriginalFilename(); |
||||
|
ossTianyiClientUtils.uploadFile(fileUrl, file); |
||||
|
|
||||
|
|
||||
|
//记录到本地
|
||||
|
SiteWeekOssBo siteWeekOssBo = new SiteWeekOssBo(); |
||||
|
siteWeekOssBo.setSiteWeekId(siteWeekVo.getId()); |
||||
|
siteWeekOssBo.setWeekNo(siteWeekVo.getWeekNo()); |
||||
|
siteWeekOssBo.setFileName(file.getOriginalFilename()); |
||||
|
siteWeekOssBo.setOriginalName(file.getOriginalFilename()); |
||||
|
siteWeekOssBo.setFileSuffix(FileUtil.extName(file.getOriginalFilename())); |
||||
|
siteWeekOssBo.setUrl(fileUrl); |
||||
|
siteWeekOssBo.setService("tianyiOss"); |
||||
|
|
||||
|
Boolean uploadBo = siteWeekOssService.insertByBo(siteWeekOssBo); |
||||
|
|
||||
|
|
||||
|
// SysOssVo oss = iSysOssService.upload(file);
|
||||
|
// SiteWeekOssBo uploadVo = new SiteWeekOssBo();
|
||||
|
// uploadVo.setUrl(oss.getUrl());
|
||||
|
// uploadVo.setFileName(oss.getOriginalName());
|
||||
|
// uploadVo.setOssId(oss.getOssId().toString());
|
||||
|
// return R.ok(uploadVo);
|
||||
|
return R.ok(siteWeekOssBo); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 下载OSS对象存储 |
||||
|
* |
||||
|
* @param id OSS对象ID |
||||
|
*/ |
||||
|
@GetMapping("/download/{id}") |
||||
|
@Operation(summary = "下载OSS对象存储",description = "下载OSS对象存储") |
||||
|
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException { |
||||
|
SiteWeekOssVo siteWeekOssVo = siteWeekOssService.queryById(id); |
||||
|
// InputStream inputStream = ossTianyiClientUtils.downloadFile(siteWeekOssVo.getUrl());
|
||||
|
|
||||
|
// String encodedFileName = URLEncoder.encode(siteWeekOssVo.getFileName(), "UTF-8").replaceAll("\\+", "%20");
|
||||
|
// response.setContentType("application/octet-stream");
|
||||
|
// response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName);
|
||||
|
// response.setHeader("download-filename", encodedFileName);
|
||||
|
// // 文件流复制
|
||||
|
// try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
|
// IOUtils.copy(inputStream, outputStream);
|
||||
|
// outputStream.flush();
|
||||
|
// } finally {
|
||||
|
// inputStream.close(); // 关闭流
|
||||
|
// }
|
||||
|
|
||||
|
try (InputStream inputStream = ossTianyiClientUtils.downloadFile(siteWeekOssVo.getUrl())) { |
||||
|
|
||||
|
// 文件名进行编码
|
||||
|
String encodedFileName = URLEncoder.encode(siteWeekOssVo.getFileName(), "UTF-8").replaceAll("\\+", "%20"); |
||||
|
response.setContentType("application/octet-stream");// 设置响应内容类型
|
||||
|
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
||||
|
|
||||
|
// 获取响应输出流
|
||||
|
ServletOutputStream outputStream = response.getOutputStream(); |
||||
|
// 文件内容写入响应输出流
|
||||
|
byte[] buffer = new byte[1024]; |
||||
|
|
||||
|
int bytesRead; |
||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) { |
||||
|
outputStream.write(buffer, 0, bytesRead); |
||||
|
} |
||||
|
outputStream.flush(); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException("下载有误"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 删除工地周OSS对象存储 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:siteWeekOss:remove") |
||||
|
@Log(title = "工地周OSS对象存储", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable Long[] ids) { |
||||
|
// Boolean result = siteWeekOssService.deleteWithValidByIds(List.of(ids), true);
|
||||
|
Boolean result = true; |
||||
|
for (Long id : ids) { |
||||
|
SiteWeekOssVo siteWeekOssVo = siteWeekOssService.queryById(id); |
||||
|
try{ |
||||
|
ossTianyiClientUtils.deleteFile(siteWeekOssVo.getUrl()); //minio删除文件
|
||||
|
siteWeekOssService.deleteWithValidByIds(List.of(id),true); //工地周数据删除
|
||||
|
}catch (Exception e){ |
||||
|
result = false; |
||||
|
System.err.println("天翼oss文件删除失败"+ siteWeekOssVo.getUrl()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
return toAjax(result); |
||||
|
} |
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
package org.dromara.system.domain; |
||||
|
|
||||
|
import org.dromara.common.tenant.core.TenantEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 工地日期周对象 site_week |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("site_week") |
||||
|
public class SiteWeek extends TenantEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 年月日名称 |
||||
|
*/ |
||||
|
private String nameTime; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 周描述 |
||||
|
*/ |
||||
|
private String weekNoDescr; |
||||
|
|
||||
|
/** |
||||
|
* 分组编号(备用) |
||||
|
*/ |
||||
|
private Long groupNo; |
||||
|
|
||||
|
private String dirTile; |
||||
|
private String dirTileZip; |
||||
|
private String dirImg; |
||||
|
private String dirVideo; |
||||
|
private String isKeepFlag; //是否保存(0正常 1停用)
|
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
package org.dromara.system.domain; |
||||
|
|
||||
|
import org.dromara.common.tenant.core.TenantEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储对象 site_week_oss |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("site_week_oss") |
||||
|
public class SiteWeekOss extends TenantEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 工地周id |
||||
|
*/ |
||||
|
private Long siteWeekId; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 文件名 |
||||
|
*/ |
||||
|
private String fileName; |
||||
|
|
||||
|
/** |
||||
|
* 原名 |
||||
|
*/ |
||||
|
private String originalName; |
||||
|
|
||||
|
/** |
||||
|
* 文件后缀名 |
||||
|
*/ |
||||
|
private String fileSuffix; |
||||
|
|
||||
|
/** |
||||
|
* URL地址 |
||||
|
*/ |
||||
|
private String url; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 服务商 |
||||
|
*/ |
||||
|
private String service; |
||||
|
|
||||
|
|
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package org.dromara.sample.storage.domain; |
package org.dromara.system.domain; |
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
import com.baomidou.mybatisplus.annotation.TableField; |
@ -0,0 +1,73 @@ |
|||||
|
package org.dromara.system.domain.bo; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
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.*; |
||||
|
|
||||
|
/** |
||||
|
* 工地日期周业务对象 site_week |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = SiteWeek.class, reverseConvertGenerate = false) |
||||
|
public class SiteWeekBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@NotNull(message = "ID不能为空", groups = { EditGroup.class }) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
// @NotBlank(message = "名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 年月日名称 |
||||
|
*/ |
||||
|
// @NotBlank(message = "年月日名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private String nameTime; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
// @NotNull(message = "周编号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 周描述 |
||||
|
*/ |
||||
|
// @NotBlank(message = "周描述不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private String weekNoDescr; |
||||
|
|
||||
|
/** |
||||
|
* 分组编号(备用) |
||||
|
*/ |
||||
|
// @NotNull(message = "分组编号(备用)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private Long groupNo; |
||||
|
|
||||
|
private String dirTile;//瓦片路径
|
||||
|
private String dirTileZip;//瓦片压缩包
|
||||
|
private String dirImg;//图片路径
|
||||
|
private String dirVideo;//视频路径
|
||||
|
private String isKeepFlag; //是否保存(0正常 1停用)
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
// @NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,78 @@ |
|||||
|
package org.dromara.system.domain.bo; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeekOss; |
||||
|
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.*; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储业务对象 site_week_oss |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = SiteWeekOss.class, reverseConvertGenerate = false) |
||||
|
public class SiteWeekOssBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@NotNull(message = "ID不能为空", groups = { EditGroup.class }) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 工地周id |
||||
|
*/ |
||||
|
@NotNull(message = "工地周id不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long siteWeekId; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
@NotNull(message = "周编号不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 文件名 |
||||
|
*/ |
||||
|
@NotBlank(message = "文件名不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String fileName; |
||||
|
|
||||
|
/** |
||||
|
* 原名 |
||||
|
*/ |
||||
|
@NotBlank(message = "原名不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String originalName; |
||||
|
|
||||
|
/** |
||||
|
* 文件后缀名 |
||||
|
*/ |
||||
|
@NotBlank(message = "文件后缀名不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String fileSuffix; |
||||
|
|
||||
|
/** |
||||
|
* URL地址 |
||||
|
*/ |
||||
|
@NotBlank(message = "URL地址不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String url; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 服务商 |
||||
|
*/ |
||||
|
@NotBlank(message = "服务商不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String service; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package org.dromara.system.domain.vo; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeekOss; |
||||
|
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; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储视图对象 site_week_oss |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = SiteWeekOss.class) |
||||
|
public class SiteWeekOssVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@ExcelProperty(value = "ID") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 工地周id |
||||
|
*/ |
||||
|
@ExcelProperty(value = "工地周id") |
||||
|
private Long siteWeekId; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "周编号") |
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 文件名 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "文件名") |
||||
|
private String fileName; |
||||
|
|
||||
|
/** |
||||
|
* 原名 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "原名") |
||||
|
private String originalName; |
||||
|
|
||||
|
/** |
||||
|
* 文件后缀名 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "文件后缀名") |
||||
|
private String fileSuffix; |
||||
|
|
||||
|
/** |
||||
|
* URL地址 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "URL地址") |
||||
|
private String url; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 服务商 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "服务商") |
||||
|
private String service; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package org.dromara.system.domain.vo; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
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; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 工地日期周视图对象 site_week |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = SiteWeek.class) |
||||
|
public class SiteWeekVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* ID |
||||
|
*/ |
||||
|
@ExcelProperty(value = "ID") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "名称") |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 年月日名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "年月日名称") |
||||
|
private String nameTime; |
||||
|
|
||||
|
/** |
||||
|
* 周编号 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "周编号") |
||||
|
private Long weekNo; |
||||
|
|
||||
|
/** |
||||
|
* 周描述 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "周描述") |
||||
|
private String weekNoDescr; |
||||
|
|
||||
|
/** |
||||
|
* 分组编号(备用) |
||||
|
*/ |
||||
|
@ExcelProperty(value = "分组编号", converter = ExcelDictConvert.class) |
||||
|
@ExcelDictFormat(readConverterExp = "备=用") |
||||
|
private Long groupNo; |
||||
|
|
||||
|
@ExcelProperty(value = "瓦片路径") |
||||
|
private String dirTile; |
||||
|
@ExcelProperty(value = "瓦片压缩包") |
||||
|
private String dirTileZip; |
||||
|
@ExcelProperty(value = "图片路径") |
||||
|
private String dirImg; |
||||
|
@ExcelProperty(value = "视频路径") |
||||
|
private String dirVideo; |
||||
|
@ExcelProperty(value = "是否保存") |
||||
|
private String isKeepFlag; //是否保存(0正常 1停用)
|
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.system.mapper; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
import org.dromara.system.domain.vo.SiteWeekVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 工地日期周Mapper接口 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
public interface SiteWeekMapper extends BaseMapperPlus<SiteWeek, SiteWeekVo> { |
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.system.mapper; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeekOss; |
||||
|
import org.dromara.system.domain.vo.SiteWeekOssVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储Mapper接口 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
public interface SiteWeekOssMapper extends BaseMapperPlus<SiteWeekOss, SiteWeekOssVo> { |
||||
|
|
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package org.dromara.system.service; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeekOss; |
||||
|
import org.dromara.system.domain.vo.SiteWeekOssVo; |
||||
|
import org.dromara.system.domain.bo.SiteWeekOssBo; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储Service接口 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
public interface ISiteWeekOssService { |
||||
|
|
||||
|
/** |
||||
|
* 查询工地周OSS对象存储 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 工地周OSS对象存储 |
||||
|
*/ |
||||
|
SiteWeekOssVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询工地周OSS对象存储列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 工地周OSS对象存储分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<SiteWeekOssVo> queryPageList(SiteWeekOssBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的工地周OSS对象存储列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 工地周OSS对象存储列表 |
||||
|
*/ |
||||
|
List<SiteWeekOssVo> queryList(SiteWeekOssBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增工地周OSS对象存储 |
||||
|
* |
||||
|
* @param bo 工地周OSS对象存储 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(SiteWeekOssBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改工地周OSS对象存储 |
||||
|
* |
||||
|
* @param bo 工地周OSS对象存储 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(SiteWeekOssBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除工地周OSS对象存储信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package org.dromara.system.service; |
||||
|
|
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
import org.dromara.system.domain.vo.SiteWeekVo; |
||||
|
import org.dromara.system.domain.bo.SiteWeekBo; |
||||
|
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-10 |
||||
|
*/ |
||||
|
public interface ISiteWeekService { |
||||
|
|
||||
|
/** |
||||
|
* 查询工地日期周 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 工地日期周 |
||||
|
*/ |
||||
|
SiteWeekVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询工地日期周列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 工地日期周分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<SiteWeekVo> queryPageList(SiteWeekBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的工地日期周列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 工地日期周列表 |
||||
|
*/ |
||||
|
List<SiteWeekVo> queryList(SiteWeekBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增工地日期周 |
||||
|
* |
||||
|
* @param bo 工地日期周 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(SiteWeekBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改工地日期周 |
||||
|
* |
||||
|
* @param bo 工地日期周 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(SiteWeekBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除工地日期周信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
} |
@ -0,0 +1,135 @@ |
|||||
|
package org.dromara.system.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.system.domain.bo.SiteWeekOssBo; |
||||
|
import org.dromara.system.domain.vo.SiteWeekOssVo; |
||||
|
import org.dromara.system.domain.SiteWeekOss; |
||||
|
import org.dromara.system.mapper.SiteWeekOssMapper; |
||||
|
import org.dromara.system.service.ISiteWeekOssService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
/** |
||||
|
* 工地周OSS对象存储Service业务层处理 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class SiteWeekOssServiceImpl implements ISiteWeekOssService { |
||||
|
|
||||
|
private final SiteWeekOssMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询工地周OSS对象存储 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 工地周OSS对象存储 |
||||
|
*/ |
||||
|
@Override |
||||
|
public SiteWeekOssVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询工地周OSS对象存储列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 工地周OSS对象存储分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<SiteWeekOssVo> queryPageList(SiteWeekOssBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<SiteWeekOss> lqw = buildQueryWrapper(bo); |
||||
|
Page<SiteWeekOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的工地周OSS对象存储列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 工地周OSS对象存储列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<SiteWeekOssVo> queryList(SiteWeekOssBo bo) { |
||||
|
LambdaQueryWrapper<SiteWeekOss> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<SiteWeekOss> buildQueryWrapper(SiteWeekOssBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<SiteWeekOss> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(bo.getSiteWeekId() != null, SiteWeekOss::getSiteWeekId, bo.getSiteWeekId()); |
||||
|
lqw.eq(bo.getWeekNo() != null, SiteWeekOss::getWeekNo, bo.getWeekNo()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getFileName()), SiteWeekOss::getFileName, bo.getFileName()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SiteWeekOss::getOriginalName, bo.getOriginalName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SiteWeekOss::getFileSuffix, bo.getFileSuffix()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SiteWeekOss::getUrl, bo.getUrl()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getService()), SiteWeekOss::getService, bo.getService()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增工地周OSS对象存储 |
||||
|
* |
||||
|
* @param bo 工地周OSS对象存储 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(SiteWeekOssBo bo) { |
||||
|
SiteWeekOss add = MapstructUtils.convert(bo, SiteWeekOss.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改工地周OSS对象存储 |
||||
|
* |
||||
|
* @param bo 工地周OSS对象存储 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(SiteWeekOssBo bo) { |
||||
|
SiteWeekOss update = MapstructUtils.convert(bo, SiteWeekOss.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(SiteWeekOss entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除工地周OSS对象存储信息 |
||||
|
* |
||||
|
* @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,135 @@ |
|||||
|
package org.dromara.system.service.impl; |
||||
|
|
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
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.system.domain.bo.SiteWeekBo; |
||||
|
import org.dromara.system.domain.vo.SiteWeekVo; |
||||
|
import org.dromara.system.domain.SiteWeek; |
||||
|
import org.dromara.system.mapper.SiteWeekMapper; |
||||
|
import org.dromara.system.service.ISiteWeekService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
/** |
||||
|
* 工地日期周Service业务层处理 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-10 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class SiteWeekServiceImpl implements ISiteWeekService { |
||||
|
|
||||
|
private final SiteWeekMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询工地日期周 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 工地日期周 |
||||
|
*/ |
||||
|
@Override |
||||
|
public SiteWeekVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询工地日期周列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 工地日期周分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<SiteWeekVo> queryPageList(SiteWeekBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<SiteWeek> lqw = buildQueryWrapper(bo); |
||||
|
Page<SiteWeekVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的工地日期周列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 工地日期周列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<SiteWeekVo> queryList(SiteWeekBo bo) { |
||||
|
LambdaQueryWrapper<SiteWeek> lqw = buildQueryWrapper(bo); |
||||
|
lqw.orderByDesc(BaseEntity::getCreateTime); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<SiteWeek> buildQueryWrapper(SiteWeekBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<SiteWeek> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getName()), SiteWeek::getName, bo.getName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getNameTime()), SiteWeek::getNameTime, bo.getNameTime()); |
||||
|
lqw.eq(bo.getWeekNo() != null, SiteWeek::getWeekNo, bo.getWeekNo()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getWeekNoDescr()), SiteWeek::getWeekNoDescr, bo.getWeekNoDescr()); |
||||
|
lqw.eq(bo.getGroupNo() != null, SiteWeek::getGroupNo, bo.getGroupNo()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增工地日期周 |
||||
|
* |
||||
|
* @param bo 工地日期周 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(SiteWeekBo bo) { |
||||
|
SiteWeek add = MapstructUtils.convert(bo, SiteWeek.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改工地日期周 |
||||
|
* |
||||
|
* @param bo 工地日期周 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(SiteWeekBo bo) { |
||||
|
SiteWeek update = MapstructUtils.convert(bo, SiteWeek.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(SiteWeek 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,179 @@ |
|||||
|
package org.dromara.system.utils; |
||||
|
|
||||
|
import cn.hutool.core.io.FileUtil; |
||||
|
import io.minio.*; |
||||
|
import io.minio.errors.*; |
||||
|
import io.minio.messages.Item; |
||||
|
import org.dromara.system.config.OssTianyiConfig; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.io.BufferedInputStream; |
||||
|
import java.io.File; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.nio.file.Files; |
||||
|
import java.security.InvalidKeyException; |
||||
|
import java.security.NoSuchAlgorithmException; |
||||
|
|
||||
|
@Component |
||||
|
public class OssTianyiClientUtils { |
||||
|
|
||||
|
private static MinioClient minioClient; |
||||
|
|
||||
|
// private static String endPoint = "https://jiangsu-10.zos.ctyun.cn"; //地域节点,可访问
|
||||
|
// // private static String endPoint = "https://dk-ty-oss-bucket.jiangsu-10.zos.ctyun.cn"; //说是桶的域名地址,支持公网访问ZOS,实测报错
|
||||
|
// private static String minioAccessKey = "22e3f37368a242b38f4f25d98c9baf1f";
|
||||
|
// private static String minioSecretKey = "0d858850666248e59830d9a596847062";
|
||||
|
|
||||
|
// private static String bucketName = "dk-ty-oss-bucket";
|
||||
|
// private String bucketName = "dkossbucket";
|
||||
|
private String objectName = "page.html"; |
||||
|
//注意,天翼云里默认路径就是文件名,不需要在前面加根路径/
|
||||
|
private String filePath = "dev/temp/"; |
||||
|
private String fileDir = "dev"; |
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
OssTianyiConfig ossTianyiConfig; |
||||
|
|
||||
|
@Autowired |
||||
|
public OssTianyiClientUtils(OssTianyiConfig ossTianyiConfig) { |
||||
|
this.ossTianyiConfig = ossTianyiConfig; |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
private void init() { |
||||
|
this.minioClient = MinioClient.builder() |
||||
|
.endpoint(ossTianyiConfig.getEndPoint()) |
||||
|
.credentials(ossTianyiConfig.getAccessKey(), ossTianyiConfig.getSecretKey()) |
||||
|
.build(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 天翼云OSS初始化(采用S3 Compatible Storage) |
||||
|
*/ |
||||
|
// public void tianyiOssInit() {
|
||||
|
// minioClient = MinioClient.builder()
|
||||
|
// .endpoint(ossTianyiConfig.getEndPoint())
|
||||
|
// .credentials(ossTianyiConfig.getAccessKey(), ossTianyiConfig.getSecretKey())
|
||||
|
// .build();
|
||||
|
// }
|
||||
|
|
||||
|
/** |
||||
|
* 文件上传 (固定) |
||||
|
*/ |
||||
|
public void uploadFileTest(String objectName, String filePath, String localFilePath) throws Exception { |
||||
|
File file = new File(localFilePath); |
||||
|
BufferedInputStream inputStream = FileUtil.getInputStream(file); |
||||
|
String contentType = Files.probeContentType(file.toPath()); |
||||
|
if (contentType == null) { |
||||
|
contentType = "application/octet-stream"; |
||||
|
} |
||||
|
PutObjectArgs args = PutObjectArgs.builder() |
||||
|
.bucket(ossTianyiConfig.getBucketName()) |
||||
|
.object(filePath + objectName) |
||||
|
.stream(inputStream, FileUtil.size(file), -1) |
||||
|
.contentType(contentType) |
||||
|
.build(); |
||||
|
minioClient.putObject(args); |
||||
|
} |
||||
|
|
||||
|
public void uploadFile(String fileUrl, MultipartFile file) { |
||||
|
try { |
||||
|
PutObjectArgs args = PutObjectArgs.builder() |
||||
|
.bucket(ossTianyiConfig.getBucketName()) |
||||
|
.object( fileUrl) //路径 /dev/temp/page.png
|
||||
|
.stream(file.getInputStream(), file.getSize(), -1) |
||||
|
.contentType(file.getContentType()) |
||||
|
.build(); |
||||
|
minioClient.putObject(args); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 文件删除 |
||||
|
*/ |
||||
|
public void deleteFile( String objectName) throws Exception { |
||||
|
minioClient.removeObject( |
||||
|
RemoveObjectArgs.builder() |
||||
|
.bucket(ossTianyiConfig.getBucketName()) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 文件下载 |
||||
|
*/ |
||||
|
public InputStream downloadFile( String objectUrl) { |
||||
|
InputStream inputStream = null; |
||||
|
try { |
||||
|
inputStream = minioClient.getObject( |
||||
|
GetObjectArgs.builder() |
||||
|
.bucket(ossTianyiConfig.getBucketName()) |
||||
|
.object(objectUrl) |
||||
|
.build() |
||||
|
); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
// FileUtil.writeFromStream(inputStream, new File(downloadPath));
|
||||
|
return inputStream; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 文件列表 |
||||
|
* @param prefix |
||||
|
*/ |
||||
|
public void listFiles( String prefix) { |
||||
|
Iterable<Result<Item>> results = minioClient.listObjects( |
||||
|
ListObjectsArgs.builder() |
||||
|
.bucket(ossTianyiConfig.getBucketName()) |
||||
|
.prefix(prefix) |
||||
|
.recursive(true) |
||||
|
.build() |
||||
|
); |
||||
|
|
||||
|
try { |
||||
|
for (Result<Item> result : results) { |
||||
|
try { |
||||
|
// System.out.println("文件名:" + result.get().objectName()); // 获取对象名称(文件路径)
|
||||
|
System.out.println(result.get().objectName()); // 获取对象名称(文件路径)
|
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
System.err.println("文件读取异常: " + e.getMessage()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// public void updateFile(String bucketName, String objectName, String filePath, String localFilePath) throws Exception {
|
||||
|
// uploadFile(bucketName, objectName, filePath, localFilePath);
|
||||
|
// }
|
||||
|
|
||||
|
|
||||
|
// public static void main(String[] args) throws Exception {
|
||||
|
// String localFilePath = "D:\\123pan\\page.html";
|
||||
|
//
|
||||
|
// tianyiOssInit("", "", "");
|
||||
|
// uploadFile(bucketName, objectName, filePath, localFilePath);//正常
|
||||
|
//// deleteFile(bucketName, filePath + objectName);//正常
|
||||
|
//// listFiles(bucketName, fileDir + "/"); // 正常
|
||||
|
//
|
||||
|
//// downloadFile(bucketName, filePath + objectName, "D:\\123pan\\downloaded_page.html"); //正常
|
||||
|
//
|
||||
|
// }
|
||||
|
|
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
package org.dromara.system.utils; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.date.DateTime; |
||||
|
import cn.hutool.core.date.DateUnit; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* WeekNo生成工具,基于固定日期计算(1970年1月1日) |
||||
|
* 测试结果:2025-05-10号距离固定日期为2889周 |
||||
|
*/ |
||||
|
public class WeekNoUtil { |
||||
|
|
||||
|
// 设置参考点(ISO周:2023年第1周开始的周一)
|
||||
|
// private static final String REFERENCE_DATE_STR = "2023-01-02 00:00:00";
|
||||
|
private static final String REFERENCE_DATE_STR = "1970-01-01 00:00:00"; |
||||
|
|
||||
|
public static int getWeekNoByDate(Date date) { |
||||
|
DateTime inputDate = DateUtil.date(date); |
||||
|
DateTime referenceDate = DateUtil.parse(REFERENCE_DATE_STR, "yyyy-MM-dd HH:mm:ss"); |
||||
|
|
||||
|
// 获取参考日所在的周一
|
||||
|
DateTime refMonday = DateUtil.beginOfWeek(referenceDate); |
||||
|
DateTime inputMonday = DateUtil.beginOfWeek(inputDate); |
||||
|
|
||||
|
// 计算两个周一之间的周数差值
|
||||
|
long weeks = DateUtil.between(inputMonday, refMonday, DateUnit.WEEK); |
||||
|
|
||||
|
// 周差 + 1,得到 weekNo
|
||||
|
return (int) weeks + 1; |
||||
|
} |
||||
|
|
||||
|
public static int getWeekNoByStr(String dateStr) { |
||||
|
DateTime inputDate = DateUtil.parse(dateStr, "yyyy-MM-dd HH:mm:ss"); |
||||
|
DateTime referenceDate = DateUtil.parse(REFERENCE_DATE_STR, "yyyy-MM-dd HH:mm:ss"); |
||||
|
|
||||
|
// 获取参考日所在的周一
|
||||
|
DateTime refMonday = DateUtil.beginOfWeek(referenceDate); |
||||
|
DateTime inputMonday = DateUtil.beginOfWeek(inputDate); |
||||
|
|
||||
|
// 计算两个周一之间的周数差值
|
||||
|
long weeks = DateUtil.between(inputMonday, refMonday, DateUnit.WEEK); |
||||
|
|
||||
|
// 周差 + 1,得到 weekNo
|
||||
|
return (int) weeks + 1; |
||||
|
} |
||||
|
|
||||
|
public static String generateDateStr(Date currentDate) { |
||||
|
int year = DateUtil.year(currentDate); |
||||
|
int month = DateUtil.month(currentDate); |
||||
|
int weekofMonth = DateUtil.weekOfMonth(currentDate); |
||||
|
String name = year + "年" + month + "月" + weekofMonth + "周"; |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
/* public static void main(String[] args) { |
||||
|
String now = DateUtil.now(); // 当前时间
|
||||
|
int weekNo = getWeekNoByStr(now); |
||||
|
System.out.println("当前周No:" + weekNo); |
||||
|
|
||||
|
int weekNoD = getWeekNoByDate(new Date()); |
||||
|
System.out.println("当前周No:" + weekNoD); |
||||
|
}*/ |
||||
|
} |
@ -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.system.mapper.SiteWeekMapper"> |
||||
|
|
||||
|
</mapper> |
@ -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.system.mapper.SiteWeekOssMapper"> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue