summaryrefslogtreecommitdiff
path: root/src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java
diff options
context:
space:
mode:
authorzhanghongqing <[email protected]>2022-08-09 16:54:16 +0800
committerzhanghongqing <[email protected]>2022-08-09 16:54:16 +0800
commitb3fa11d4b1b5a68d7b04fde5eb6cfbda557927eb (patch)
treea49d344e49fc427fbf4cf00aa4963c4d04cd98a4 /src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java
parentd8a2be0d094ac9ba2d47c81ebf03b3fe6e34a078 (diff)
initializeHEADmain
Diffstat (limited to 'src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java')
-rw-r--r--src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java b/src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java
new file mode 100644
index 0000000..263945c
--- /dev/null
+++ b/src/main/java/com/mesasoft/cn/dao/DownloadedDAO.java
@@ -0,0 +1,53 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.dao.sqlprovider.DownloadedSqlProvider;
+import com.mesasoft.cn.model.DownloadRecord;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author pantao
+ * @since 2018/1/18
+ */
+@Repository
+public interface DownloadedDAO {
+
+ /**
+ * 新增一条下载记录
+ *
+ * @param userId 用户编号
+ * @param fileId 文件编号
+ */
+ @Insert("insert into download(user_id,file_id) values(#{userId},#{fileId})")
+ void insertDownload(@Param("userId") int userId, @Param("fileId") long fileId);
+
+ /**
+ * 查询下载记录
+ *
+ * @param userId 用户编号,不使用用户编号作为条件时设置值小于等于0即可
+ * @param fileId 文件编号,不使用文件编号作为条件时设置值小于等于0即可
+ * @param categoryId 分类编号,不用分类编号作为条件时设置值小于等于0即可
+ * @param fileName 文件名,不使用文件名作为条件时设置值为空即可
+ * @param offset 偏移
+ *
+ * @return 下载记录
+ */
+ @SelectProvider(type = DownloadedSqlProvider.class, method = "getDownloadBy")
+ List<DownloadRecord> listDownloadedBy(@Param("userId") int userId, @Param("fileId") long fileId, @Param
+ ("fileName") String fileName, @Param("categoryId") int categoryId, @Param("offset") int offset);
+
+ /**
+ * 删除文件
+ *
+ * @param fileId 文件编号
+ *
+ * @return 是否删除成功
+ */
+ @Delete("delete from download where file_id=#{fileId}")
+ boolean removeByFileId(long fileId);
+}