123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\admin\controller\base\other;
- /**
- * @title: 节日
- */
- use app\admin\controller\Base;
- use app\common\model\base\other\Festival as festivalModel;
- class Festival extends Base
- {
- protected $noNeedAuth = ['getList'];
- protected $festivalModel = null;
- public function initialize()
- {
- parent::initialize();
- $this->festivalModel = new festivalModel;
- }
- /**
- * @title: 节日列表
- * @return array
- * @Author: wangkewei
- * @Date: 2021/5/18 9:13
- */
- public function getList()
- {
- $list = $this->festivalModel->order("weigh ASC")->select();
- $list = FieldConverList($list);
- return res(1,"获取成功",$list);
- }
- /**
- * @title: 节日编辑
- * @param array
- * @return array
- * @Author: wangkewei
- * @Date: 2021/5/18 9:13
- */
- public function doEdit()
- {
- $data = $this->request->param();
- try{
- $this->festivalModel->replace()->save($data);
- slog(1,"编辑了节日".$data['festival_name']);
- return res(1,"保存成功");
- }catch(Exception $e){
- return res(2,"保存失败".$e->getMessage());
- }
- }
- /**
- * @title: 节日删除
- * @param {int} {ids} {必填} {id}
- * @return array
- * @Author: wangkewei
- * @Date: 2021/5/18 9:14
- */
- public function doDelete()
- {
- $data = $this->request->param();
- if(empty($data['ids']))return res(2,"参数错误");
- $info = $this->festivalModel->where("festival_id",$data['ids'])->find();
- $this->festivalModel->where("festival_id",$data['ids'])->delete();
- slog(1,"删除了节日".$info->festival_name);
- return res(1,"删除成功");
- }
- }
|