diff --git a/app/adminapi/logic/fence_house/FenceHouseLogic.php b/app/adminapi/logic/fence_house/FenceHouseLogic.php index ead30e3..55ef4b0 100644 --- a/app/adminapi/logic/fence_house/FenceHouseLogic.php +++ b/app/adminapi/logic/fence_house/FenceHouseLogic.php @@ -50,9 +50,8 @@ class FenceHouseLogic extends BaseLogic 'capacity' => $params['capacity'], 'master' => $params['master'], 'master_phone' => $params['master_phone'], - 'status' => $params['status'], - 'qr_code' => $params['qr_code'], - 'image' => $params['image'], + 'status' => 1, + 'pic' => $params['pic'], ]); Db::commit(); @@ -86,8 +85,7 @@ class FenceHouseLogic extends BaseLogic 'master' => $params['master'], 'master_phone' => $params['master_phone'], 'status' => $params['status'], - 'qr_code' => $params['qr_code'], - 'image' => $params['image'], + 'pic' => $params['pic'], ]); Db::commit(); diff --git a/app/api/controller/AnimalInfoController.php b/app/api/controller/AnimalInfoController.php new file mode 100644 index 0000000..373107d --- /dev/null +++ b/app/api/controller/AnimalInfoController.php @@ -0,0 +1,108 @@ +dataLists(new AnimalInfoLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function add() + { + $params = (new AnimalInfoValidate())->post()->goCheck('add'); + $result = AnimalInfoLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(AnimalInfoLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function edit() + { + $params = (new AnimalInfoValidate())->post()->goCheck('edit'); + $result = AnimalInfoLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AnimalInfoLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function delete() + { + $params = (new AnimalInfoValidate())->post()->goCheck('delete'); + AnimalInfoLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function detail() + { + $params = (new AnimalInfoValidate())->goCheck('detail'); + $result = AnimalInfoLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/api/controller/FenceHouseController.php b/app/api/controller/FenceHouseController.php index 38b7461..cf182a5 100644 --- a/app/api/controller/FenceHouseController.php +++ b/app/api/controller/FenceHouseController.php @@ -2,13 +2,17 @@ namespace app\api\controller; -use app\adminapi\lists\fence_house\FenceHouseLists; use app\adminapi\logic\fence_house\FenceHouseLogic; use app\adminapi\validate\fence_house\FenceHouseValidate; +use app\api\lists\FenceHouseLists; use think\response\Json; class FenceHouseController extends BaseApiController { + public function list() + { + return $this->dataLists(new FenceHouseLists()); + } public function add() { $params = (new FenceHouseValidate())->post()->goCheck('add'); diff --git a/app/api/lists/AnimalInfoLists.php b/app/api/lists/AnimalInfoLists.php new file mode 100644 index 0000000..8d1c79e --- /dev/null +++ b/app/api/lists/AnimalInfoLists.php @@ -0,0 +1,78 @@ + ['sn', 'fence_house_id'], + + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function lists(): array + { + return AnimalInfo::where($this->searchWhere) + ->field(['id', 'fence_house_id', 'sn', 'animal_type', 'brand', 'physi_stage', 'gender', 'blood_purity', 'animal_source', 'current_estimation', 'algebra', 'birth', 'entry_date', 'birth_estimation', 'health_condition']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2024/01/10 15:53 + */ + public function count(): int + { + return AnimalInfo::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/api/lists/FenceHouseLists.php b/app/api/lists/FenceHouseLists.php new file mode 100644 index 0000000..8d8b7f5 --- /dev/null +++ b/app/api/lists/FenceHouseLists.php @@ -0,0 +1,77 @@ + ['fence_house_name'], + + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/01/10 15:15 + */ + public function lists(): array + { + return FenceHouse::where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2024/01/10 15:15 + */ + public function count(): int + { + return FenceHouse::where($this->searchWhere)->count(); + } + +} \ No newline at end of file