1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace catchAdmin\wechat\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\wechat\model\Banner as bannerModel;
- class Banner extends CatchController
- {
- protected $bannerModel;
-
- public function __construct(BannerModel $bannerModel)
- {
- $this->bannerModel = $bannerModel;
- }
-
- /**
- * 列表
- * @time 2021年05月28日 11:38
- * @param Request $request
- */
- public function index(Request $request) : \think\Response
- {
- return CatchResponse::paginate($this->bannerModel->getList());
- }
-
- /**
- * 保存信息
- * @time 2021年05月28日 11:38
- * @param Request $request
- */
- public function save(Request $request) : \think\Response
- {
- $data = $request->post();
- if(!$data['school_id']){
- return CatchResponse::success('请选择学校');
- }
- if(!$data['author']){
- return CatchResponse::success('公告作者不能为空');
- }
- if(!$data['title']){
- return CatchResponse::success('公告标题不能为空');
- }
- if(!$data['content']){
- return CatchResponse::success('公告内容不能为空');
- }
- if($data['grade_id']){
- $data['type'] = 2;
- }
- $data['put_time'] = time();
- return CatchResponse::success($this->bannerModel->storeBy($request->post()));
- }
-
- /**
- * 读取
- * @time 2021年05月28日 11:38
- * @param $id
- */
- public function read($id) : \think\Response
- {
- return CatchResponse::success($this->bannerModel->findBy($id));
- }
-
- /**
- * 更新
- * @time 2021年05月28日 11:38
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id) : \think\Response
- {
- return CatchResponse::success($this->bannerModel->updateBy($id, $request->post()));
- }
-
- /**
- * 删除
- * @time 2021年05月28日 11:38
- * @param $id
- */
- public function delete($id) : \think\Response
- {
- return CatchResponse::success($this->bannerModel->deleteBy($id,true));
- }
- }
|