diff --git a/app/adminapi/controller/AppUpdateController.php b/app/adminapi/controller/AppUpdateController.php new file mode 100644 index 0000000..485f855 --- /dev/null +++ b/app/adminapi/controller/AppUpdateController.php @@ -0,0 +1,92 @@ +dataLists(new AppUpdateLists()); + } + + + /** + * @notes 添加app更新 + * @return Json + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function add(): Json + { + $params = (new AppUpdateValidate())->post()->goCheck('add'); + $result = AppUpdateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(AppUpdateLogic::getError()); + } + + + /** + * @notes 编辑app更新 + * @return Json + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function edit(): Json + { + $params = (new AppUpdateValidate())->post()->goCheck('edit'); + $result = AppUpdateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AppUpdateLogic::getError()); + } + + + /** + * @notes 删除app更新 + * @return Json + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function delete(): Json + { + $params = (new AppUpdateValidate())->post()->goCheck('delete'); + AppUpdateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取app更新详情 + * @return Json + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function detail(): Json + { + $params = (new AppUpdateValidate())->goCheck('detail'); + $result = AppUpdateLogic::detail($params); + return $this->data($result); + } + + + } \ No newline at end of file diff --git a/app/adminapi/lists/AppUpdateLists.php b/app/adminapi/lists/AppUpdateLists.php new file mode 100644 index 0000000..de5e177 --- /dev/null +++ b/app/adminapi/lists/AppUpdateLists.php @@ -0,0 +1,60 @@ + ['title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'], + ]; + } + + + /** + * @notes 获取app更新列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function lists(): array + { + return AppUpdate::where($this->searchWhere) + ->field(['id', 'title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet', 'create_time', 'update_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取app更新数量 + * @return int + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function count(): int + { + return AppUpdate::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/logic/AppUpdateLogic.php b/app/adminapi/logic/AppUpdateLogic.php new file mode 100644 index 0000000..c089103 --- /dev/null +++ b/app/adminapi/logic/AppUpdateLogic.php @@ -0,0 +1,104 @@ + $params['title'], + 'content' => $params['content'], + 'type' => $params['type'], + 'version' => $params['version'], + 'dow_url' => $params['dow_url'], + 'force' => $params['force'], + 'quiet' => $params['quiet'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑app更新 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + AppUpdate::where('id', $params['id'])->update([ + 'title' => $params['title'], + 'content' => $params['content'], + 'type' => $params['type'], + 'version' => $params['version'], + 'dow_url' => $params['dow_url'], + 'force' => $params['force'], + 'quiet' => $params['quiet'], + 'update_time'=>time() + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除app更新 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public static function delete(array $params): bool + { + return AppUpdate::destroy($params['id']); + } + + + /** + * @notes 获取app更新详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public static function detail($params): array + { + return AppUpdate::findOrEmpty($params['id'])->toArray(); + } + } \ No newline at end of file diff --git a/app/adminapi/validate/AppUpdateValidate.php b/app/adminapi/validate/AppUpdateValidate.php new file mode 100644 index 0000000..78b90d7 --- /dev/null +++ b/app/adminapi/validate/AppUpdateValidate.php @@ -0,0 +1,89 @@ + 'require', + 'title' => 'require', + 'content' => 'require', + 'type' => 'require', + 'version' => 'require', + 'dow_url' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '标题', + 'content' => '内容', + 'type' => '1ios 2安卓', + 'version' => '版本', + 'dow_url' => 'app链接', + ]; + + + /** + * @notes 添加场景 + * @return AppUpdateValidate + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function sceneAdd() + { + return $this->only(['title','content','type','version','dow_url']); + } + + + /** + * @notes 编辑场景 + * @return AppUpdateValidate + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function sceneEdit() + { + return $this->only(['id','title','content','type','version','dow_url']); + } + + + /** + * @notes 删除场景 + * @return AppUpdateValidate + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return AppUpdateValidate + * @author likeadmin + * @date 2023/08/31 11:08 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + } \ No newline at end of file diff --git a/app/common/model/AppUpdate.php b/app/common/model/AppUpdate.php new file mode 100644 index 0000000..40a7e18 --- /dev/null +++ b/app/common/model/AppUpdate.php @@ -0,0 +1,16 @@ +