Festival.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\admin\controller\base\other;
  3. /**
  4. * @title: 节日
  5. */
  6. use app\admin\controller\Base;
  7. use app\common\model\base\other\Festival as festivalModel;
  8. class Festival extends Base
  9. {
  10. protected $noNeedAuth = ['getList'];
  11. protected $festivalModel = null;
  12. public function initialize()
  13. {
  14. parent::initialize();
  15. $this->festivalModel = new festivalModel;
  16. }
  17. /**
  18. * @title: 节日列表
  19. * @return array
  20. * @Author: wangkewei
  21. * @Date: 2021/5/18 9:13
  22. */
  23. public function getList()
  24. {
  25. $list = $this->festivalModel->order("weigh ASC")->select();
  26. $list = FieldConverList($list);
  27. return res(1,"获取成功",$list);
  28. }
  29. /**
  30. * @title: 节日编辑
  31. * @param array
  32. * @return array
  33. * @Author: wangkewei
  34. * @Date: 2021/5/18 9:13
  35. */
  36. public function doEdit()
  37. {
  38. $data = $this->request->param();
  39. try{
  40. $this->festivalModel->replace()->save($data);
  41. slog(1,"编辑了节日".$data['festival_name']);
  42. return res(1,"保存成功");
  43. }catch(Exception $e){
  44. return res(2,"保存失败".$e->getMessage());
  45. }
  46. }
  47. /**
  48. * @title: 节日删除
  49. * @param {int} {ids} {必填} {id}
  50. * @return array
  51. * @Author: wangkewei
  52. * @Date: 2021/5/18 9:14
  53. */
  54. public function doDelete()
  55. {
  56. $data = $this->request->param();
  57. if(empty($data['ids']))return res(2,"参数错误");
  58. $info = $this->festivalModel->where("festival_id",$data['ids'])->find();
  59. $this->festivalModel->where("festival_id",$data['ids'])->delete();
  60. slog(1,"删除了节日".$info->festival_name);
  61. return res(1,"删除成功");
  62. }
  63. }