<?php
/**
 *
 *User:Administrator
 *Date:2021/10/11
 */

namespace app\api\controller\v1;

use app\api\business\PesticidesBus;

class Pesticides
{
    public function selectPesticidesList()
    {
        //todo validate
        $pageNum = request()->param('pageNum', 1, 'int');
        $pageSize = request()->param('pageSize', 10, 'int');
        $key_word = request()->param('keyword', '', 'trim');
        $result = (new PesticidesBus())->selectPesticidesList($pageNum,$pageSize,$key_word);
        return showSuccess($result);
    }


    public function getPesticidesList(){
        $data = $this->request->post();
        $pageNum=$data['pageNum'];
        $pageSize=$data['pageSize'];
        if(isset($data['keyword'])){
            $res['rows'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->page($pageNum,$pageSize)->select();
            $res['total'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->count();

        }else{
            $res['rows'] = Db::name("pesticides")->page($pageNum,$pageSize)->select();
            $res['total'] = Db::name("pesticides")->count();

        }
        return $this->jsonSuccessData($res);

    }




}