32 lines
800 B
PHP
32 lines
800 B
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\adminapi\logic\farm\FarmLogic;
|
|
use app\adminapi\validate\farm\FarmValidate;
|
|
use app\common\model\farm\Farm;
|
|
|
|
class FarmController extends BaseApiController
|
|
{
|
|
public function list()
|
|
{
|
|
$where = [
|
|
['user_id','=',$this->userId]
|
|
];
|
|
$data = Farm::where($where)->order('create_time desc')->select()->toArray();
|
|
return $this->success('请求成功',$data);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$params = (new FarmValidate())->post()->goCheck('add');
|
|
$params['user_id'] = $this->userId;
|
|
$result = FarmLogic::add($params);
|
|
if (true === $result) {
|
|
return $this->success('添加成功', [], 1, 1);
|
|
}
|
|
return $this->fail(FarmLogic::getError());
|
|
}
|
|
|
|
|
|
} |