2023-09-11 11:26:33 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
namespace app\controller\admin\system;
|
|
|
|
|
|
|
|
|
|
use app\common\repositories\system\LhappRepository;
|
2023-09-11 14:52:24 +08:00
|
|
|
|
use think\exception\ValidateException;
|
2023-09-11 11:26:33 +08:00
|
|
|
|
use crmeb\basic\BaseController;
|
|
|
|
|
use think\App;
|
|
|
|
|
|
|
|
|
|
class Lhapp extends BaseController
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var LhappRepository
|
|
|
|
|
*/
|
|
|
|
|
protected $repository;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CacheRepository constructor.
|
|
|
|
|
* @param App $app
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(App $app, LhappRepository $repository)
|
|
|
|
|
{
|
|
|
|
|
parent::__construct($app);
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 14:52:24 +08:00
|
|
|
|
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('修改成功');
|
|
|
|
|
}
|
2023-09-11 15:27:11 +08:00
|
|
|
|
|
2023-09-11 14:52:24 +08:00
|
|
|
|
public function detail($id)
|
|
|
|
|
{
|
|
|
|
|
$data = $this->repository->detail($id);
|
|
|
|
|
return app('json')->success($data);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 15:27:11 +08:00
|
|
|
|
public function delete($id)
|
|
|
|
|
{
|
|
|
|
|
$res = $this->repository->delete($id);
|
|
|
|
|
if ($res) {
|
|
|
|
|
return app('json')->success('删除成功');
|
|
|
|
|
} else {
|
|
|
|
|
return app('json')->fail('删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 14:52:24 +08:00
|
|
|
|
protected function getValidParams()
|
|
|
|
|
{
|
2023-09-11 15:18:06 +08:00
|
|
|
|
$data = $this->request->params(['title', 'content', 'type', 'phone_brand', 'version', 'dow_url', 'force', 'quiet']);
|
2023-09-11 14:52:24 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 11:26:33 +08:00
|
|
|
|
}
|