酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\admin\dao;
  3. /**
  4. * Created by PhpStorm.
  5. * User: nizongfeng
  6. * Date: 2023/2/7
  7. * Time: 11:00
  8. */
  9. use app\admin\command\Util;
  10. use app\admin\model\File;
  11. use think\Exception;
  12. class FileDao
  13. {
  14. /**
  15. * 添加详情
  16. * @param $type
  17. * @param $file
  18. * @param $id
  19. * @return array
  20. */
  21. public function addInfo($type, $file, $name, $id, $create_id){
  22. try{
  23. $fileModel = new File();
  24. $data = [
  25. "type"=>$type,
  26. "file"=>$file,
  27. "name"=>$name,
  28. "obj_id"=>$id,
  29. "create_id"=>$create_id
  30. ];
  31. if (!empty($create_id)) {
  32. $adminDao = new AdminDao();
  33. $admin = $adminDao->getInfoById($create_id);
  34. if ($admin["flag"]) {
  35. $data["create_name"] = $admin["data"]["nickname"];
  36. }
  37. }
  38. $fileModel->insert($data);
  39. return Util::returnArrSu("成功");
  40. }catch (Exception $e){
  41. return Util::returnArrEr("失败:".$e->getMessage());
  42. }
  43. }
  44. /**
  45. * 获取列表
  46. * @param $type
  47. * @param $file
  48. * @param $id
  49. * @return array
  50. */
  51. public function getList($type, $id){
  52. try{
  53. $fileModel = new File();
  54. $where = [
  55. "type"=>$type,
  56. "obj_id"=>$id
  57. ];
  58. $list = $fileModel->where($where)->order("id","DESC")->select()->toArray();
  59. return Util::returnArrSu("成功", $list);
  60. }catch (Exception $e){
  61. return Util::returnArrEr("失败:".$e->getMessage());
  62. }
  63. }
  64. }