当前路径:app/common/model/ac/Attachment.php <?php declare(strict_types=1); namespace app\common\model\ac; use app\common\model\Base; use think\facade\Db; use Exception; use Error; use think\facade\Log; /** * Class Attachment * @package app\common\model\ac */ class Attachment { /** * @param int $pIndex * @param int $pSize * @param int $total * @return array */ /*public static function search(int $pIndex = 1, int $pSize = 10, &$total = 0) { try { $total = Db::table('ac_attachments')->count(); $query = Db::table('ac_attachments'); if (!empty($pIndex)) { $query->page($pIndex, $pSize); } $data = $query->select()->toArray(); if (!empty($data)) { $storage = Base::createStorage(); $data = array_map(function ($val) use ($storage) { $val['resource'] = $storage->domainUrl() . $val['resource']; }, $data); return $data; } else { return []; } } catch (Exception $e) { Log::channel('myError')->write($e->getMessage(), \think\Log::ERROR); } return []; }*/ /** * @param string $tmp * @param string $suffix * @return array|Error|\think\Exception */ /*public static function add(string $tmp, string $suffix) { try { $storage = Base::createStorage(); $video = "exam/attach/" . md5(uniqid()) . $suffix; $tmp = $storage->put($video, $tmp); $data['resource'] = $tmp['filename']; if (is_error($tmp)) { return error(-1, '上传失败请重试'); } $data['title'] = md5(uniqid()); $data['time_created'] = time(); $id = Db::table('ac_attachments')->insertGetId($data); return ['id' => $id,'url' => $tmp['url']]; } catch (Exception $e) { Log::channel('myError')->write($e->getMessage(), \think\Log::ERROR); } return error(-1, '上传失败请重试'); }*/ /** * @param int $id * @return bool */ /*public static function delete(int $id) { try { $resouce = Db::table('ac_attachments')->where(['id' => $id])->value('resource'); $res = Db::table('ac_attachments')->where(['id' => $id])->delete(); $res = $res !== false; if (!$res) { return false; } $storage = Base::createStorage(); $resouce = $storage->domainUrl() . $resouce; $storage->delete($resouce, true); return true; } catch (Exception $e) { Log::channel('myError')->write($e->getMessage(), \think\Log::ERROR); } return false; }*/ }
相关源码
- 可旋转的彩色立方体C#源代码2021-10-29
- 在线考试系统2021-10-15
- EduSoho开源网校系统源码2019-06-27
- 仿拼多多小程序商城源码2019-06-06
- PHP5网站运行监测系统源码2017-04-14
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号