summaryrefslogtreecommitdiff
path: root/src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.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/sqlprovider/AuthSqlProvider.java
parentd8a2be0d094ac9ba2d47c81ebf03b3fe6e34a078 (diff)
initializeHEADmain
Diffstat (limited to 'src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.java')
-rw-r--r--src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.java b/src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.java
new file mode 100644
index 0000000..3c9c10f
--- /dev/null
+++ b/src/main/java/com/mesasoft/cn/dao/sqlprovider/AuthSqlProvider.java
@@ -0,0 +1,48 @@
+package com.mesasoft.cn.dao.sqlprovider;
+
+import com.mesasoft.cn.SketchApplication;
+import com.mesasoft.cn.modules.constant.ConfigConsts;
+import com.zhazhapan.util.Checker;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.jdbc.SQL;
+
+/**
+ * @author pantao
+ * @since 2018/1/19
+ */
+public class AuthSqlProvider {
+
+ public String updateAuthById() {
+ return CommonSqlProvider.updateAuthById("auth");
+ }
+
+ public String batchDelete(@Param("ids") String ids) {
+ return "delete from auth where id in " + (ids.startsWith("(") ? "" : "(") + ids + (ids.endsWith(")") ? "" :
+ ")");
+ }
+
+ public String getAuthBy(@Param("id") long id, @Param("userId") int userId, @Param("fileId") long fileId, @Param
+ ("fileName") String fileName, @Param("offset") int offset) {
+ String sql = new SQL() {{
+ SELECT("a.id,a.user_id,a.file_id,u.username,f.name file_name,f.local_url,a.is_downloadable,a" + "" + "" +
+ ".is_uploadable,a.is_deletable,a.is_updatable,a.is_visible,a.create_time");
+ FROM("auth a");
+ JOIN("user u on u.id=a.user_id");
+ JOIN("file f on f.id=a.file_id");
+ if (id > 0) {
+ WHERE("a.id=#{id}");
+ }
+ if (userId > 0) {
+ WHERE("u.id=#{userId}");
+ }
+ if (fileId > 0) {
+ WHERE("f.id=#{fileId}");
+ } else if (Checker.isNotEmpty(fileName)) {
+ WHERE("f.local_url like '%" + fileName + "%'");
+ }
+ ORDER_BY("a." + SketchApplication.settings.getStringUseEval(ConfigConsts.AUTH_ORDER_BY_OF_SETTINGS));
+ }}.toString();
+ int size = SketchApplication.settings.getIntegerUseEval(ConfigConsts.AUTH_PAGE_SIZE_OF_SETTINGS);
+ return sql + " limit " + (offset * size) + "," + size;
+ }
+}