diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index 78104e7..dc67b4f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -284,30 +284,30 @@ public class CommonController try { /** oss --------------- */ -// // 检查文件是否为空 -// if (file.isEmpty()) { -// return AjaxResult.error("上传文件不能为空"); -// } -// -// // 检查文件类型(可选) -// String contentType = file.getContentType(); -// if (contentType == null || !contentType.startsWith("image/")) { -// return AjaxResult.error("只允许上传图片文件"); -// } -// -// // 上传到 OSS -// String url = ossService.uploadImage(file); -// // 返回文件访问 URL -// String[] str = url.split("/"); -// String fileName = str[str.length - 1]; + // 检查文件是否为空 + if (file.isEmpty()) { + return AjaxResult.error("上传文件不能为空"); + } + + // 检查文件类型(可选) + String contentType = file.getContentType(); + if (contentType == null || !contentType.startsWith("image/")) { + return AjaxResult.error("只允许上传图片文件"); + } + + // 上传到 OSS + String url = ossService.uploadImage(file); + // 返回文件访问 URL + String[] str = url.split("/"); + String fileName = str[str.length - 1]; /** 原文件上传 --------------- */ - // 上传文件路径 - String filePath = RuoYiConfig.getUploadPath(); - // 上传并返回新文件名称 - String fileName = FileUploadUtils.upload(filePath, fileType, file); - - String url = serverConfig.getUrl() + fileName; +// // 上传文件路径 +// String filePath = RuoYiConfig.getUploadPath(); +// // 上传并返回新文件名称 +// String fileName = FileUploadUtils.upload(filePath, fileType, file); +// +// String url = serverConfig.getUrl() + fileName; /** -------------------------- */ String uuid = UUID.randomUUID().toString(); CommonAttachment insert = new CommonAttachment(); diff --git a/ruoyi-admin/src/main/resources/mapper/operation/ZcCarBrandMapper.xml b/ruoyi-admin/src/main/resources/mapper/operation/ZcCarBrandMapper.xml index a980756..e8cdcf0 100644 --- a/ruoyi-admin/src/main/resources/mapper/operation/ZcCarBrandMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/operation/ZcCarBrandMapper.xml @@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and extend2 = #{extend2} and extend3 = #{extend3} + order by update_time desc