Browse Source

feat:myself file page

lihao16 7 months ago
parent
commit
efa275489c

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iit/IitFileInfoController.java

@@ -38,6 +38,17 @@ public class IitFileInfoController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 查询文件管理列表 - 我的文件
+     */
+    @PreAuthorize("@ss.hasPermi('iit:file:list')")
+    @GetMapping("/myself/list")
+    public TableDataInfo myselfList(IitFileInfo iitFileInfo) {
+        startPage();
+        List<IitFileInfo> list = iitFileInfoService.selectMyselfList(iitFileInfo);
+        return getDataTable(list);
+    }
+
     /**
      * 导出文件管理列表
      */

+ 64 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/domain/IitMyselfFile.java

@@ -0,0 +1,64 @@
+package com.ruoyi.iit.domain;
+
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 我的文件对象 iit_myself_file
+ *
+ * @author Hao Li
+ * @date 2025-04-12
+ */
+public class IitMyselfFile extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 文件ID
+     */
+    private Long fileId;
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setFileId(Long fileId) {
+        this.fileId = fileId;
+    }
+
+    public Long getFileId() {
+        return fileId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("fileId", getFileId())
+                .append("userId", getUserId())
+                .append("createTime", getCreateTime())
+                .toString();
+    }
+}

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/domain/IitPushUserRel.java

@@ -62,6 +62,8 @@ public class IitPushUserRel extends BaseEntity {
 
     private String pushName;
 
+    private Long fileId;
+
     private String fileName;
 
     private String fileType;
@@ -70,6 +72,14 @@ public class IitPushUserRel extends BaseEntity {
 
     private String fileUrl;
 
+    public Long getFileId() {
+        return fileId;
+    }
+
+    public void setFileId(Long fileId) {
+        this.fileId = fileId;
+    }
+
     public String getPushName() {
         return pushName;
     }

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/mapper/IitFileInfoMapper.java

@@ -67,4 +67,11 @@ public interface IitFileInfoMapper
      */
     public int updatePushTimes(Long fileId);
 
+    /**
+     * 查询我的文件列表
+     *
+     * @param iitFileInfo 文件管理
+     * @return 文件管理集合
+     */
+    public List<IitFileInfo> selectMyselfList(IitFileInfo iitFileInfo);
 }

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/mapper/IitMyselfFileMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.iit.mapper;
+
+import com.ruoyi.iit.domain.IitMyselfFile;
+
+import java.util.List;
+
+/**
+ * 我的文件Mapper接口
+ *
+ * @author Hao Li
+ * @date 2025-04-12
+ */
+public interface IitMyselfFileMapper {
+    /**
+     * 查询我的文件
+     *
+     * @param id 我的文件主键
+     * @return 我的文件
+     */
+    public IitMyselfFile selectIitMyselfFileById(Long id);
+
+    /**
+     * 查询我的文件列表
+     *
+     * @param iitMyselfFile 我的文件
+     * @return 我的文件集合
+     */
+    public List<IitMyselfFile> selectIitMyselfFileList(IitMyselfFile iitMyselfFile);
+
+    /**
+     * 新增我的文件
+     *
+     * @param iitMyselfFile 我的文件
+     * @return 结果
+     */
+    public int insertIitMyselfFile(IitMyselfFile iitMyselfFile);
+
+    /**
+     * 修改我的文件
+     *
+     * @param iitMyselfFile 我的文件
+     * @return 结果
+     */
+    public int updateIitMyselfFile(IitMyselfFile iitMyselfFile);
+
+    /**
+     * 删除我的文件
+     *
+     * @param id 我的文件主键
+     * @return 结果
+     */
+    public int deleteIitMyselfFileById(Long id);
+
+    /**
+     * 批量删除我的文件
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteIitMyselfFileByIds(Long[] ids);
+}

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/service/IIitFileInfoService.java

@@ -58,4 +58,11 @@ public interface IIitFileInfoService
      * @return 结果
      */
     public int deleteIitFileInfoById(Long id);
+
+    /**
+     * 查询我的文件列表
+     * @param iitFileInfo
+     * @return
+     */
+    public List<IitFileInfo> selectMyselfList(IitFileInfo iitFileInfo);
 }

+ 22 - 1
ruoyi-system/src/main/java/com/ruoyi/iit/service/impl/IitFileInfoServiceImpl.java

@@ -6,6 +6,8 @@ import java.util.List;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.iit.domain.IitMyselfFile;
+import com.ruoyi.iit.mapper.IitMyselfFileMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.core.token.TokenService;
@@ -26,6 +28,9 @@ public class IitFileInfoServiceImpl implements IIitFileInfoService
     @Autowired
     private IitFileInfoMapper iitFileInfoMapper;
 
+    @Autowired
+    private IitMyselfFileMapper iitMyselfFileMapper;
+
     @Value("${ruoyi.profile}")
     private String profile;
 
@@ -55,6 +60,14 @@ public class IitFileInfoServiceImpl implements IIitFileInfoService
         return iitFileInfoMapper.selectIitFileInfoList(iitFileInfo);
     }
 
+    @Override
+    public List<IitFileInfo> selectMyselfList(IitFileInfo iitFileInfo) {
+        // 获取当前登录用户的id
+        Long userId = SecurityUtils.getUserId();
+        iitFileInfo.setUserId(userId);
+        return iitFileInfoMapper.selectMyselfList(iitFileInfo);
+    }
+
     /**
      * 新增文件管理
      *
@@ -84,7 +97,15 @@ public class IitFileInfoServiceImpl implements IIitFileInfoService
 
         iitFileInfo.setPushTimes(0);
 
-        return iitFileInfoMapper.insertIitFileInfo(iitFileInfo);
+        // 文件新增以后,保存至我的文件表
+        int insertResult = iitFileInfoMapper.insertIitFileInfo(iitFileInfo);
+        IitMyselfFile iitMyselfFile = new IitMyselfFile();
+        iitMyselfFile.setFileId(iitFileInfo.getId());
+        iitMyselfFile.setUserId(SecurityUtils.getUserId());
+        iitMyselfFile.setCreateTime(DateUtils.getNowDate());
+        iitMyselfFileMapper.insertIitMyselfFile(iitMyselfFile);
+        
+        return insertResult;
     }
 
     private Long getFileSize(String filePath) {

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/iit/service/impl/IitPushUserRelServiceImpl.java

@@ -2,7 +2,9 @@ package com.ruoyi.iit.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.iit.domain.IitMyselfFile;
 import com.ruoyi.iit.domain.IitPushUserRel;
+import com.ruoyi.iit.mapper.IitMyselfFileMapper;
 import com.ruoyi.iit.mapper.IitPushUserRelMapper;
 import com.ruoyi.iit.service.IIitPushUserRelService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +23,9 @@ public class IitPushUserRelServiceImpl implements IIitPushUserRelService {
     @Autowired
     private IitPushUserRelMapper iitPushUserRelMapper;
 
+    @Autowired
+    private IitMyselfFileMapper iitMyselfFileMapper;
+
     /**
      * 查询消息管理
      *
@@ -46,6 +51,12 @@ public class IitPushUserRelServiceImpl implements IIitPushUserRelService {
             result.setIsView(1);
             result.setViewTime(DateUtils.getNowDate());
             iitPushUserRelMapper.updateIitPushUserRel(result);
+            // 将改文件保存至我的文件
+            IitMyselfFile iitMyselfFile = new IitMyselfFile();
+            iitMyselfFile.setFileId(result.getFileId());
+            iitMyselfFile.setUserId(SecurityUtils.getUserId());
+            iitMyselfFile.setCreateTime(DateUtils.getNowDate());
+            iitMyselfFileMapper.insertIitMyselfFile(iitMyselfFile);
         }
         return result;
     }

+ 13 - 0
ruoyi-system/src/main/resources/mapper/iit/IitFileInfoMapper.xml

@@ -38,6 +38,19 @@
         order by u.create_time desc
     </select>
 
+    <select id="selectMyselfList" parameterType="IitFileInfo" resultMap="IitFileInfoResult">
+        select
+            u.id, u.name, u.file_name,u.file_type, u.file_size, u.file_path,
+            u.file_url, u.remark, u.create_time, u.user_id, u.user_name, u.dept_id,u.push_times
+        from iit_file_info u
+        INNER JOIN  iit_myself_file m on u.id = m.file_id
+        WHERE m.user_id = #{userId}
+        <if test="name != null  and name != ''"> and u.name like concat('%', #{name}, '%')</if>
+        <if test="fileName != null  and fileName != ''"> and u.file_name like concat('%', #{fileName}, '%')</if>
+        <if test="fileType != null "> and u.file_type = #{fileType}</if>
+        order by u.create_time desc
+    </select>
+
     <select id="selectIitFileInfoById" parameterType="Long" resultMap="IitFileInfoResult">
         <include refid="selectIitFileInfoVo"/>
         where id = #{id}

+ 63 - 0
ruoyi-system/src/main/resources/mapper/iit/IitMyselfFileMapper.xml

@@ -0,0 +1,63 @@
+<?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.iit.mapper.IitMyselfFileMapper">
+
+    <resultMap type="IitMyselfFile" id="IitMyselfFileResult">
+        <result property="id"    column="id"    />
+        <result property="fileId"    column="file_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="createTime"    column="create_time"    />
+    </resultMap>
+
+    <sql id="selectIitMyselfFileVo">
+        select id, file_id, user_id, create_time from iit_myself_file
+    </sql>
+
+    <select id="selectIitMyselfFileList" parameterType="IitMyselfFile" resultMap="IitMyselfFileResult">
+        <include refid="selectIitMyselfFileVo"/>
+        <where>
+        </where>
+    </select>
+
+    <select id="selectIitMyselfFileById" parameterType="Long" resultMap="IitMyselfFileResult">
+        <include refid="selectIitMyselfFileVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertIitMyselfFile" parameterType="IitMyselfFile" useGeneratedKeys="true" keyProperty="id">
+        insert into iit_myself_file
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fileId != null">file_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="createTime != null">create_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fileId != null">#{fileId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createTime != null">#{createTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateIitMyselfFile" parameterType="IitMyselfFile">
+        update iit_myself_file
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fileId != null">file_id = #{fileId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteIitMyselfFileById" parameterType="Long">
+        delete from iit_myself_file where id = #{id}
+    </delete>
+
+    <delete id="deleteIitMyselfFileByIds" parameterType="String">
+        delete from iit_myself_file where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 2 - 0
ruoyi-system/src/main/resources/mapper/iit/IitPushUserRelMapper.xml

@@ -13,6 +13,7 @@
         <result property="isView" column="is_view"/>
         <result property="viewTime" column="view_time"/>
         <result property="pushName" column="push_name"/>
+        <result property="fileId" column="file_id"/>
         <result property="fileName" column="file_name"/>
         <result property="fileType" column="file_type"/>
         <result property="fileRemark" column="file_remark"/>
@@ -34,6 +35,7 @@
             u.is_view,
             u.view_time,
             p.user_name as push_name,
+            i.id as file_id,
             i.file_name,
             i.file_type,
             i.remark as file_remark,

+ 8 - 0
ruoyi-ui/src/api/iit/file.js

@@ -9,6 +9,14 @@ export function listInfo(query) {
   })
 }
 
+export function listMyselfInfo(query) {
+  return request({
+    url: '/iit/file/myself/list',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询文件管理详细
 export function getInfo(id) {
   return request({

+ 252 - 0
ruoyi-ui/src/views/iit/myself/index.vue

@@ -0,0 +1,252 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="名称" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="请输入名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="文件名称" prop="fileName">
+        <el-input
+          v-model="queryParams.fileName"
+          placeholder="请输入文件名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="文件类型" prop="fileType">
+        <el-select v-model="queryParams.fileType" placeholder="请选择文件类型" clearable>
+          <el-option
+            v-for="dict in dict.type.iit_file_type"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
+      <!--      <el-table-column type="selection" width="55" align="center"/>-->
+      <el-table-column label="ID" align="center" prop="id" width="60" :show-overflow-tooltip="true"/>
+      <el-table-column label="名称" align="left" prop="name" :show-overflow-tooltip="true"/>
+      <el-table-column label="文件名称" align="left" prop="fileName" :show-overflow-tooltip="true" width="350"/>
+      <el-table-column label="文件类型" align="center" prop="fileType" width="120">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.iit_file_type" :value="scope.row.fileType"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="文件大小" align="center" prop="fileSize" width="120" :show-overflow-tooltip="true">
+        <template slot-scope="scope">
+          {{ formatFileSize(scope.row.fileSize) }}
+        </template>
+      </el-table-column>
+      <el-table-column label="推送次数" align="center" prop="pushTimes" width="100"/>
+      <el-table-column label="文件备注" align="left" prop="remark" :show-overflow-tooltip="true"/>
+      <el-table-column label="上传用户" align="left" prop="userName" width="120" :show-overflow-tooltip="true"/>
+      <el-table-column label="上传时间" align="left" prop="createTime" width="160"/>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
+        <template slot-scope="scope">
+          <el-button size="mini" type="text" icon="el-icon-view" @click="handleFileInfo(scope.row)"
+                     v-hasPermi="['iit:file:query']">文件详情
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
+                @pagination="getList"/>
+
+    <!-- 添加或修改消息管理对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="70px">
+        <el-row>
+          <el-col :span="14">
+            <el-form-item label="文件名称" prop="fileName">
+              <el-input v-model="form.fileName" :disabled="true"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="10">
+            <el-form-item label="文件类型" prop="fileType">
+              <el-select v-model="form.fileType" :disabled="true">
+                <el-option
+                  v-for="dict in dict.type.iit_file_type"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="8">
+            <el-form-item label="上传用户" prop="userName">
+              <el-input v-model="form.userName" style="width: 180px" :disabled="true"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="上传时间" prop="createTime">
+              <el-input v-model="form.createTime" style="width: 180px" :disabled="true"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="文件大小" prop="fileSize">
+              <el-input v-model="form.fileSize" style="width: 180px" :disabled="true"/>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-form-item label="文件备注" prop="remark">
+          <el-input type="textarea" :rows="4" v-model="form.remark" :disabled="true"/>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="downloadFile">文件下载</el-button>
+        <el-button @click="cancel">关 闭</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {listMyselfInfo} from "@/api/iit/file";
+
+export default {
+  name: "Myself",
+  dicts: ['iit_file_type'],
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 文件管理表格数据
+      infoList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        name: null,
+        fileName: null,
+        fileType: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {}
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    downloadFile() {
+      window.open(process.env.VUE_APP_BASE_API + this.form.fileUrl);
+    },
+    handleFileInfo(row) {
+      console.log(row);
+      let fileType = row.fileType
+      this.form = row;
+      // this.form.fileSize = this.form.fileSize < 1024 ? (this.form.fileSize.toFixed(0) + ' KB') : (this.form.fileSize / 1024).toFixed(2) + ' MB\';
+      this.form.fileType = fileType.toString();
+      this.open = true;
+      this.title = "文件详情";
+    },
+    formatFileSize(fileSize) {
+      if (fileSize < 1024) {
+        return fileSize.toFixed(0) + ' KB';
+      } else {
+        return (fileSize / 1024).toFixed(2) + ' MB';
+      }
+    },
+    /** 查询文件管理列表 */
+    getList() {
+      this.loading = true;
+      listMyselfInfo(this.queryParams).then(response => {
+        this.infoList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        name: null,
+        fileName: null,
+        fileType: null,
+        fileSize: null,
+        filePath: null,
+        fileUrl: null,
+        remark: null,
+        createTime: null,
+        userId: null,
+        userName: null,
+        deptId: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length !== 1
+      this.multiple = !selection.length
+    },
+  }
+};
+</script>
+<style scoped>
+/* 自定义左右面板宽度 */
+::v-deep .el-transfer-panel {
+  width: 300px; /* 单个面板宽度 */
+  height: 500px;
+}
+
+::v-deep .el-transfer-panel__body {
+  height: 100%;
+}
+
+::v-deep .el-transfer-panel__list {
+  height: 100%;
+}
+
+/* 自定义按钮区域样式 */
+::v-deep .el-transfer__buttons {
+  width: 210px; /* 按钮区域宽度 */
+  padding: 0 10px;
+}
+</style>