新增后台管理系统app版本管理模块
This commit is contained in:
parent
bfcf793447
commit
2a73450bc3
@ -38,5 +38,15 @@ class AppUpdateDao extends BaseDao
|
||||
return AppUpdate::class;
|
||||
}
|
||||
|
||||
public function search(array $where = [])
|
||||
{
|
||||
return AppUpdate::getDB()
|
||||
->when(isset($where['id']) && $where['id'] !== '',function($query) use($where){
|
||||
$query->where('id',$where['id']);
|
||||
})
|
||||
->when(isset($where['type']) && $where['type'] !== '',function($query) use($where){
|
||||
$query->where('type',$where['type']);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,4 +40,19 @@ class LhappRepository extends BaseRepository
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
public function getList($where, $page, $limit)
|
||||
{
|
||||
$query = $this->dao->search($where);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->order('id DESC')->select();
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$find = $this->dao->search(['id' => $id])->find();
|
||||
if (!$find) throw new ValidateException('数据不存在');
|
||||
return $find;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
namespace app\controller\admin\system;
|
||||
|
||||
use app\common\repositories\system\LhappRepository;
|
||||
use think\exception\ValidateException;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
|
||||
@ -31,4 +32,42 @@ class Lhapp extends BaseController
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['type']);
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->repository->create($this->getValidParams());
|
||||
return app('json')->success('添加成功');
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
if (!$this->repository->exists($id)) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
$this->repository->update($id, $this->getValidParams());
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
public function detail($id)
|
||||
{
|
||||
$data = $this->repository->detail($id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
protected function getValidParams()
|
||||
{
|
||||
$data = $this->request->params(['title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet']);
|
||||
if (empty($data['title'])) throw new ValidateException('title标题不能为空');
|
||||
if (empty($data['content'])) throw new ValidateException('content内容不能为空');
|
||||
if (empty($data['type'])) throw new ValidateException('type类型不能为空');
|
||||
if (empty($data['version'])) throw new ValidateException('version版本号不能为空');
|
||||
if (empty($data['dow_url'])) throw new ValidateException('dow_url下载地址不能为空');
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,10 +177,10 @@ Route::group(function () {
|
||||
Route::get('detail/:id', '/detail')->name('appVersionDetail')->option([
|
||||
'_alias' => 'APP版本详情',
|
||||
]);
|
||||
Route::post('add', '/add')->name('appVersionAdd')->option([
|
||||
Route::post('create', '/create')->name('appVersionAdd')->option([
|
||||
'_alias' => '新增APP版本',
|
||||
]);
|
||||
Route::post('edit/:id', '/edit')->name('appVersionEdit')->option([
|
||||
Route::post('edit/:id', '/update')->name('appVersionEdit')->option([
|
||||
'_alias' => '编辑APP版本',
|
||||
]);
|
||||
})->prefix('admin.system.Lhapp')->option([
|
||||
|
Loading…
x
Reference in New Issue
Block a user