|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\admin\dao;
- /**
- * Created by PhpStorm.
- * User: nizongfeng
- * Date: 2023/2/7
- * Time: 11:00
- */
-
- use app\admin\command\Util;
- use app\admin\model\File;
- use think\Exception;
-
- class FileDao
- {
- /**
- * 添加详情
- * @param $type
- * @param $file
- * @param $id
- * @return array
- */
- public function addInfo($type, $file, $name, $id, $create_id){
- try{
- $fileModel = new File();
- $data = [
- "type"=>$type,
- "file"=>$file,
- "name"=>$name,
- "obj_id"=>$id,
- "create_id"=>$create_id
- ];
- if (!empty($create_id)) {
- $adminDao = new AdminDao();
- $admin = $adminDao->getInfoById($create_id);
- if ($admin["flag"]) {
- $data["create_name"] = $admin["data"]["nickname"];
- }
- }
- $fileModel->insert($data);
- return Util::returnArrSu("成功");
- }catch (Exception $e){
- return Util::returnArrEr("失败:".$e->getMessage());
- }
- }
-
- /**
- * 获取列表
- * @param $type
- * @param $file
- * @param $id
- * @return array
- */
- public function getList($type, $id){
- try{
- $fileModel = new File();
- $where = [
- "type"=>$type,
- "obj_id"=>$id
- ];
- $list = $fileModel->where($where)->order("id","DESC")->select()->toArray();
- return Util::returnArrSu("成功", $list);
- }catch (Exception $e){
- return Util::returnArrEr("失败:".$e->getMessage());
- }
- }
- }
|