Browse Source

信息文件

zhangyang 2 years ago
parent
commit
090c55f753

+ 102 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoNewsFileController.java

@@ -0,0 +1,102 @@
+package com.ruoyi.web.controller.system;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.PoNewsFile;
+import com.ruoyi.system.service.IPoNewsFileService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 信息文件Controller
+ * @date 2023-01-25
+ */
+@RestController
+@RequestMapping("/system/file")
+public class PoNewsFileController extends BaseController
+{
+    @Autowired
+    private IPoNewsFileService poNewsFileService;
+
+    /**
+     * 查询信息文件列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(PoNewsFile poNewsFile)
+    {
+        startPage();
+        List<PoNewsFile> list = poNewsFileService.selectPoNewsFileList(poNewsFile);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出信息文件列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:export')")
+    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, PoNewsFile poNewsFile)
+    {
+        List<PoNewsFile> list = poNewsFileService.selectPoNewsFileList(poNewsFile);
+        ExcelUtil<PoNewsFile> util = new ExcelUtil<PoNewsFile>(PoNewsFile.class);
+        util.exportExcel(response, list, "信息文件数据");
+    }
+
+    /**
+     * 获取信息文件详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:query')")
+    @GetMapping(value = "/{fileId}")
+    public AjaxResult getInfo(@PathVariable("fileId") Long fileId)
+    {
+        return success(poNewsFileService.selectPoNewsFileByFileId(fileId));
+    }
+
+    /**
+     * 新增信息文件
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:add')")
+    @Log(title = "信息文件", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody PoNewsFile poNewsFile)
+    {
+        return toAjax(poNewsFileService.insertPoNewsFile(poNewsFile));
+    }
+
+    /**
+     * 修改信息文件
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:edit')")
+    @Log(title = "信息文件", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody PoNewsFile poNewsFile)
+    {
+        return toAjax(poNewsFileService.updatePoNewsFile(poNewsFile));
+    }
+
+    /**
+     * 删除信息文件
+     */
+    @PreAuthorize("@ss.hasPermi('system:file:remove')")
+    @Log(title = "信息文件", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{fileIds}")
+    public AjaxResult remove(@PathVariable Long[] fileIds)
+    {
+        return toAjax(poNewsFileService.deletePoNewsFileByFileIds(fileIds));
+    }
+}

+ 79 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/PoNewsFile.java

@@ -0,0 +1,79 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 信息文件对象 po_news_file
+ *
+ * @author ruoyi
+ * @date 2023-01-25
+ */
+public class PoNewsFile extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 文件Id */
+    private Long fileId;
+
+    /** 文件名 */
+    @Excel(name = "文件名")
+    private String fileName;
+
+    /** 文件图片 */
+    @Excel(name = "文件图片")
+    private String image;
+
+    /** 文件路径 */
+    @Excel(name = "文件路径")
+    private String filePath;
+
+    public void setFileId(Long fileId)
+    {
+        this.fileId = fileId;
+    }
+
+    public Long getFileId()
+    {
+        return fileId;
+    }
+    public void setFileName(String fileName)
+    {
+        this.fileName = fileName;
+    }
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+    public void setImage(String image)
+    {
+        this.image = image;
+    }
+
+    public String getImage()
+    {
+        return image;
+    }
+    public void setFilePath(String filePath)
+    {
+        this.filePath = filePath;
+    }
+
+    public String getFilePath()
+    {
+        return filePath;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+                .append("fileId", getFileId())
+                .append("fileName", getFileName())
+                .append("image", getImage())
+                .append("filePath", getFilePath())
+                .toString();
+    }
+}

+ 40 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoNewsFileMapper.java

@@ -0,0 +1,40 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.PoNewsFile;
+
+/**
+ * 信息文件Mapper接口
+ */
+public interface PoNewsFileMapper
+{
+    /**
+     * 查询信息文件
+     */
+    public PoNewsFile selectPoNewsFileByFileId(Long fileId);
+
+    /**
+     * 查询信息文件列表
+     */
+    public List<PoNewsFile> selectPoNewsFileList(PoNewsFile poNewsFile);
+
+    /**
+     * 新增信息文件
+     */
+    public int insertPoNewsFile(PoNewsFile poNewsFile);
+
+    /**
+     * 修改信息文件
+     */
+    public int updatePoNewsFile(PoNewsFile poNewsFile);
+
+    /**
+     * 删除信息文件
+     */
+    public int deletePoNewsFileByFileId(Long fileId);
+
+    /**
+     * 批量删除信息文件
+     */
+    public int deletePoNewsFileByFileIds(Long[] fileIds);
+}

+ 45 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoNewsFileService.java

@@ -0,0 +1,45 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+import com.ruoyi.system.domain.PoNewsFile;
+
+/**
+ * 信息文件Service接口
+ *
+ * @author ruoyi
+ * @date 2023-01-25
+ */
+public interface IPoNewsFileService
+{
+    /**
+     * 查询信息文件
+     *
+     * @param fileId 主键
+     */
+    public PoNewsFile selectPoNewsFileByFileId(Long fileId);
+
+    /**
+     * 查询信息文件列表
+     */
+    public List<PoNewsFile> selectPoNewsFileList(PoNewsFile poNewsFile);
+
+    /**
+     * 新增信息文件
+     */
+    public int insertPoNewsFile(PoNewsFile poNewsFile);
+
+    /**
+     * 修改信息文件
+     */
+    public int updatePoNewsFile(PoNewsFile poNewsFile);
+
+    /**
+     * 批量删除信息文件
+     */
+    public int deletePoNewsFileByFileIds(Long[] fileIds);
+
+    /**
+     * 删除信息文件信息
+     */
+    public int deletePoNewsFileByFileId(Long fileId);
+}

+ 75 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoNewsFileServiceImpl.java

@@ -0,0 +1,75 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.PoNewsFileMapper;
+import com.ruoyi.system.domain.PoNewsFile;
+import com.ruoyi.system.service.IPoNewsFileService;
+
+/**
+ * 信息文件Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-01-25
+ */
+@Service
+public class PoNewsFileServiceImpl implements IPoNewsFileService
+{
+    @Autowired
+    private PoNewsFileMapper poNewsFileMapper;
+
+    /**
+     * 查询信息文件
+     */
+    @Override
+    public PoNewsFile selectPoNewsFileByFileId(Long fileId)
+    {
+        return poNewsFileMapper.selectPoNewsFileByFileId(fileId);
+    }
+
+    /**
+     * 查询信息文件列表
+     */
+    @Override
+    public List<PoNewsFile> selectPoNewsFileList(PoNewsFile poNewsFile)
+    {
+        return poNewsFileMapper.selectPoNewsFileList(poNewsFile);
+    }
+
+    /**
+     * 新增信息文件
+     */
+    @Override
+    public int insertPoNewsFile(PoNewsFile poNewsFile)
+    {
+        return poNewsFileMapper.insertPoNewsFile(poNewsFile);
+    }
+
+    /**
+     * 修改信息文件
+     */
+    @Override
+    public int updatePoNewsFile(PoNewsFile poNewsFile)
+    {
+        return poNewsFileMapper.updatePoNewsFile(poNewsFile);
+    }
+
+    /**
+     * 批量删除信息文件
+     */
+    @Override
+    public int deletePoNewsFileByFileIds(Long[] fileIds)
+    {
+        return poNewsFileMapper.deletePoNewsFileByFileIds(fileIds);
+    }
+
+    /**
+     * 删除信息文件信息
+     */
+    @Override
+    public int deletePoNewsFileByFileId(Long fileId)
+    {
+        return poNewsFileMapper.deletePoNewsFileByFileId(fileId);
+    }
+}

+ 68 - 0
ruoyi-system/src/main/resources/mapper/system/PoNewsFileMapper.xml

@@ -0,0 +1,68 @@
+<?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="com.ruoyi.system.mapper.PoNewsFileMapper">
+
+    <resultMap type="PoNewsFile" id="PoNewsFileResult">
+        <result property="fileId"    column="file_id"    />
+        <result property="fileName"    column="file_name"    />
+        <result property="image"    column="image"    />
+        <result property="filePath"    column="file_path"    />
+    </resultMap>
+
+    <sql id="selectPoNewsFileVo">
+        select file_id, file_name, image, file_path from po_news_file
+    </sql>
+
+    <select id="selectPoNewsFileList" parameterType="PoNewsFile" resultMap="PoNewsFileResult">
+        <include refid="selectPoNewsFileVo"/>
+        <where>
+            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
+            <if test="image != null  and image != ''"> and image = #{image}</if>
+            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
+        </where>
+    </select>
+
+    <select id="selectPoNewsFileByFileId" parameterType="Long" resultMap="PoNewsFileResult">
+        <include refid="selectPoNewsFileVo"/>
+        where file_id = #{fileId}
+    </select>
+
+    <insert id="insertPoNewsFile" parameterType="PoNewsFile">
+        insert into po_news_file
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fileId != null">file_id,</if>
+            <if test="fileName != null and fileName != ''">file_name,</if>
+            <if test="image != null and image != ''">image,</if>
+            <if test="filePath != null">file_path,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fileId != null">#{fileId},</if>
+            <if test="fileName != null and fileName != ''">#{fileName},</if>
+            <if test="image != null and image != ''">#{image},</if>
+            <if test="filePath != null">#{filePath},</if>
+        </trim>
+    </insert>
+
+    <update id="updatePoNewsFile" parameterType="PoNewsFile">
+        update po_news_file
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
+            <if test="image != null and image != ''">image = #{image},</if>
+            <if test="filePath != null">file_path = #{filePath},</if>
+        </trim>
+        where file_id = #{fileId}
+    </update>
+
+    <delete id="deletePoNewsFileByFileId" parameterType="Long">
+        delete from po_news_file where file_id = #{fileId}
+    </delete>
+
+    <delete id="deletePoNewsFileByFileIds" parameterType="String">
+        delete from po_news_file where file_id in
+        <foreach item="fileId" collection="array" open="(" separator="," close=")">
+            #{fileId}
+        </foreach>
+    </delete>
+</mapper>