chenzhengming 2 роки тому
батько
коміт
66d732925a

+ 10 - 0
ruoyi-admin/pom.xml

@@ -61,6 +61,16 @@
             <artifactId>ruoyi-generator</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>4.5.7</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -75,6 +75,7 @@ public class CommonController
     /**
      * 通用上传请求(单个)
      */
+
     @PostMapping("/upload")
     public AjaxResult uploadFile(MultipartFile file) throws Exception
     {

+ 52 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/FileController.java

@@ -0,0 +1,52 @@
+package com.ruoyi.web.controller.system;
+
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.framework.config.ServerConfig;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+@Api(tags = "FileController",description = "上传文件")
+@RestController
+@RequestMapping("/files")
+public class FileController {
+    @Autowired
+    private ServerConfig serverConfig;
+
+    /**
+     * 上传文件
+     */
+    /**
+     * 文件上传接口
+     */
+    @ApiOperation(value = "上传文件", notes = "上传文件接口")
+    @RequestMapping(value = "/send", method = RequestMethod.POST, headers = "content-type=multipart/form-data")
+    public AjaxResult uploadFile(@RequestPart("fire")MultipartFile file) throws Exception
+    {
+        try {
+            // 上传文件路径
+            String filePath = RuoYiConfig.getUploadPath();
+            if (filePath == null){
+                throw new RuntimeException("找不到文件路径");
+            }
+            //上传并返回文件名
+            String filename = FileUploadUtils.upload(filePath, file);
+            if (filename == null){
+                throw new RuntimeException("获取不到文件名称");
+            }
+            String url = serverConfig.getUrl()+filename;
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("fileName",filename);
+            ajax.put("url",url);
+            return ajax;
+        }catch (Exception e){
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+
+}

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java

@@ -59,7 +59,7 @@ public class SwaggerConfig
                 // 扫描所有有注解的api,用这种方式更灵活
                 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                 // 扫描指定包中的swagger注解
-                .apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller.system"))
+                .apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller"))
                 .apis(RequestHandlerSelectors.any())
                 .paths(PathSelectors.any())
                 .build()

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/domain/PostNotice.java

@@ -34,8 +34,8 @@ public class PostNotice extends BaseEntity
     @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date noticeTime;
 
-    /** 公告详情id */
-    @Excel(name = "公告详情id")
+    /** 公告详情 */
+    @Excel(name = "公告详情")
     private String noticeContent;
 
 

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LcdInfoServiceImpl.java

@@ -140,6 +140,11 @@ public class LcdInfoServiceImpl implements ILcdInfoService {
         if (title != null) {
             //标题不为空则判断时间
             if (lcdTimeLeft != null && lcdTimeRight != null) {
+                //时间不为空 ,且左时间在右时间之前
+                //确保查询到的公告为已发布的公告
+                if (DateUtils.getNowDate().before(lcdTimeRight)){
+                    lcdTimeRight = DateUtils.getNowDate();
+                }
                 //时间不为空 ,且左时间在右时间之前
                 if (lcdTimeLeft.before(lcdTimeRight)) {
                     return lcdInfoMapper.selectLcdListByTitleOrlcdTime(title, lcdTimeLeft, lcdTimeRight);

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/LcdInfoMapper.xml

@@ -43,6 +43,7 @@
             <if test="title != null  and title != ''"> and title = #{title}</if>
             <if test="sendTime != null "> and send_time = #{sendTime}</if>
             <if test="detail != null  and detail != ''"> and detail = #{detail}</if>
+            and send_time &lt; now()
         </where>
     </select>
 

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/PostNoticeMapper.xml

@@ -63,7 +63,7 @@
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="noticeTitle != null">#{noticeTitle},</if>
             <if test="noticeTime != null">#{noticeTime},</if>
-            <if test="noticeContent != null and noticeContent != '' ">#{notice_content},</if>
+            <if test="noticeContent != null and noticeContent != '' ">#{noticeContent},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>