81 lines
1.7 KiB
PHP
Raw Normal View History

2020-01-09 08:21:44 +08:00
<?php
namespace catchAdmin\permissions\controller;
2020-01-09 22:20:36 +08:00
use catchAdmin\permissions\model\Job as JobModel;
2020-01-09 08:21:44 +08:00
use catcher\base\CatchController;
2020-01-09 22:20:36 +08:00
use catcher\base\CatchRequest;
use catcher\CatchResponse;
2020-01-09 08:21:44 +08:00
class Job extends CatchController
{
2020-01-09 22:20:36 +08:00
protected $job;
2020-01-09 08:21:44 +08:00
2020-01-09 22:20:36 +08:00
public function __construct(JobModel $job)
{
$this->job = $job;
}
/**
* 列表
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
2020-01-17 15:17:51 +08:00
* @throws \think\db\exception\DbException
2020-01-09 22:20:36 +08:00
*/
2020-01-13 21:23:24 +08:00
public function index(): \think\response\Json
2020-01-09 22:20:36 +08:00
{
2020-01-13 21:23:24 +08:00
return CatchResponse::paginate($this->job->getList());
2020-01-09 22:20:36 +08:00
}
/**
* 保存
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
*/
public function save(CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->job->storeBy($request->post()));
}
/**
* 更新
*
* @time 2020年01月09日
* @param $id
* @param CatchRequest $request
* @return \think\response\Json
*/
public function update($id, CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->job->updateBy($id, $request->post()));
}
/**
* 删除
*
* @time 2020年01月09日
* @param $id
* @return \think\response\Json
*/
public function delete($id): \think\response\Json
{
return CatchResponse::success($this->job->deleteBy($id));
}
2020-01-12 09:30:56 +08:00
/**
* 获取所有
*
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAll()
{
return CatchResponse::success($this->job->field(['id', 'job_name'])->select());
}
2020-01-09 08:21:44 +08:00
}