2024-01-15 15:32:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
2024-01-23 18:12:59 +08:00
|
|
|
use app\adminapi\logic\farm\FarmLogic;
|
|
|
|
use app\adminapi\validate\farm\FarmValidate;
|
2024-01-15 15:32:21 +08:00
|
|
|
use app\common\model\farm\Farm;
|
|
|
|
|
|
|
|
class FarmController extends BaseApiController
|
|
|
|
{
|
2024-01-17 17:05:16 +08:00
|
|
|
public function list()
|
2024-01-15 15:32:21 +08:00
|
|
|
{
|
|
|
|
$where = [
|
|
|
|
['user_id','=',$this->userId]
|
|
|
|
];
|
2024-01-17 17:05:16 +08:00
|
|
|
$data = Farm::where($where)->order('create_time desc')->select()->toArray();
|
2024-01-15 15:32:21 +08:00
|
|
|
return $this->success('请求成功',$data);
|
|
|
|
}
|
2024-01-23 18:12:59 +08:00
|
|
|
|
|
|
|
public function add()
|
|
|
|
{
|
|
|
|
$params = (new FarmValidate())->post()->goCheck('add');
|
2024-01-25 09:20:39 +08:00
|
|
|
$params['user_id'] = $this->userId;
|
2024-01-23 18:12:59 +08:00
|
|
|
$result = FarmLogic::add($params);
|
|
|
|
if (true === $result) {
|
|
|
|
return $this->success('添加成功', [], 1, 1);
|
|
|
|
}
|
|
|
|
return $this->fail(FarmLogic::getError());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-15 15:32:21 +08:00
|
|
|
}
|