diff --git a/app/adminapi/controller/DataReceptionController.php b/app/adminapi/controller/DataReceptionController.php new file mode 100644 index 000000000..5de2c8a59 --- /dev/null +++ b/app/adminapi/controller/DataReceptionController.php @@ -0,0 +1,108 @@ +dataLists(new DataReceptionLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function add() + { + $params = (new DataReceptionValidate())->post()->goCheck('add'); + $result = DataReceptionLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DataReceptionLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function edit() + { + $params = (new DataReceptionValidate())->post()->goCheck('edit'); + $result = DataReceptionLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DataReceptionLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function delete() + { + $params = (new DataReceptionValidate())->post()->goCheck('delete'); + DataReceptionLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function detail() + { + $params = (new DataReceptionValidate())->goCheck('detail'); + $result = DataReceptionLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/DataReceptionLists.php b/app/adminapi/lists/DataReceptionLists.php new file mode 100644 index 000000000..360893bcb --- /dev/null +++ b/app/adminapi/lists/DataReceptionLists.php @@ -0,0 +1,77 @@ + ['num', 'project', 'project_num'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function lists(): array + { + return DataReception::where($this->searchWhere) + ->field(['id', 'dataid', 'num', 'project', 'project_num', 'apptime', 'person', 'number', 'position', 'tips']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function count(): int + { + return DataReception::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/DataReceptionLogic.php b/app/adminapi/logic/DataReceptionLogic.php new file mode 100644 index 000000000..c0bbb658b --- /dev/null +++ b/app/adminapi/logic/DataReceptionLogic.php @@ -0,0 +1,136 @@ + $params['dataid'], + 'num' => $params['num'], + 'project' => $params['project'], + 'project_num' => $params['project_num'], + 'apptime' => $params['apptime'], + 'person' => $params['person'], + 'number' => $params['number'], + 'position' => $params['position'], + 'tips' => $params['tips'], + 'bidding_file' => $params['bidding_file'], + 'zbkzj_file' => $params['zbkzj_file'], + 'gczjht_file' => $params['gczjht_file'], + 'xmbgqzzl_file' => $params['xmbgqzzl_file'], + 'ssgsysjs_file' => $params['ssgsysjs_file'], + 'wlhj_file' => $params['wlhj_file'], + 'other_file' => $params['other_file'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + DataReception::where('id', $params['id'])->update([ + 'dataid' => $params['dataid'], + 'num' => $params['num'], + 'project' => $params['project'], + 'project_num' => $params['project_num'], + 'apptime' => $params['apptime'], + 'person' => $params['person'], + 'number' => $params['number'], + 'position' => $params['position'], + 'tips' => $params['tips'], + 'bidding_file' => $params['bidding_file'], + 'zbkzj_file' => $params['zbkzj_file'], + 'gczjht_file' => $params['gczjht_file'], + 'xmbgqzzl_file' => $params['xmbgqzzl_file'], + 'ssgsysjs_file' => $params['ssgsysjs_file'], + 'wlhj_file' => $params['wlhj_file'], + 'other_file' => $params['other_file'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public static function delete(array $params): bool + { + return DataReception::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public static function detail($params): array + { + return DataReception::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/DataReceptionValidate.php b/app/adminapi/validate/DataReceptionValidate.php new file mode 100644 index 000000000..2e8a8f8a8 --- /dev/null +++ b/app/adminapi/validate/DataReceptionValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return DataReceptionValidate + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return DataReceptionValidate + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return DataReceptionValidate + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return DataReceptionValidate + * @author likeadmin + * @date 2024/02/23 09:21 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/DataReception.php b/app/common/model/DataReception.php new file mode 100644 index 000000000..be2740264 --- /dev/null +++ b/app/common/model/DataReception.php @@ -0,0 +1,34 @@ +