|
|
@@ -0,0 +1,44 @@
|
|
|
+require("fwutils.webapi")
|
|
|
+local M = {}
|
|
|
+
|
|
|
+ M.add = function(file_size,filepath,desc,conn)
|
|
|
+ local ppst = conn:setsql("INSERT INTO fw_file (role_id,custom_id,file_size,filepath,`desc`) VALUES (?,?,?,?,?)")
|
|
|
+ local user_data = cjson.decode(request.get("user_data"))
|
|
|
+ ppst:set_i32(1,user_data.role_id)
|
|
|
+ ppst:set_i32(2,user_data.id)
|
|
|
+ ppst:set_i64(3,file_size)
|
|
|
+ ppst:set_str(4,filepath)
|
|
|
+ ppst:set_str(5,desc)
|
|
|
+ if ppst:update() == 1 then
|
|
|
+ return true
|
|
|
+ end
|
|
|
+ return false
|
|
|
+end
|
|
|
+M.use = function(id,conn)
|
|
|
+ local ppst = conn:setsql("UPDATE fw_file SET use_time = NOW() WHERE id = ?")
|
|
|
+ ppst:set_i32(1,id)
|
|
|
+ if ppst:update() == 1 then
|
|
|
+ return true
|
|
|
+ end
|
|
|
+ return false
|
|
|
+end
|
|
|
+M.delete_by_id = function(id,conn)
|
|
|
+ local ppst = conn:setsql("UPDATE fw_file SET delete_time = NOW() WHERE id = ?")
|
|
|
+ ppst:set_i32(1,id)
|
|
|
+ if ppst:update() == 1 then
|
|
|
+ return true
|
|
|
+ end
|
|
|
+ return false
|
|
|
+end
|
|
|
+M.delete_by_filepath = function(filepath,conn)
|
|
|
+ local ppst = conn:setsql("UPDATE fw_file SET delete_time = NOW() WHERE role_id = ? AND custom_id = ? AND filepath = ?")
|
|
|
+ local user_data = cjson.decode(request.get("user_data"))
|
|
|
+ ppst:set_i32(1,user_data.role_id)
|
|
|
+ ppst:set_i32(2,user_data.id)
|
|
|
+ ppst:set_str(3,filepath)
|
|
|
+ if ppst:update() == 1 then
|
|
|
+ return true
|
|
|
+ end
|
|
|
+ return false
|
|
|
+end
|
|
|
+return M
|