cxgj/modules/api/models/BallMarkForm.php
2023-11-27 09:45:13 +08:00

86 lines
2.0 KiB
PHP

<?php
/**
* @author Any
* @description KISS
* @date 2020-12-2
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\api\models;
use function AlibabaCloud\Client\value;
use app\components\FlashStorage;
use app\components\SiteHelper;
use app\models\BallMark;
use app\models\Coach;
use app\models\DeviceUniqueBindUser;
use app\models\Store;
use app\models\User;
use app\components\auth\AToken;
use app\components\EncryptHelper;
use app\modules\api\components\ApiHelper;
use app\modules\api\components\GetDistance;
use yii\data\Pagination;
class BallMarkForm extends ApiModel
{
public $page;
public $limit;
public $keywords;
public $status;
public $user_id;
public $cx_mch_id;
public function rules()
{
return [
[['keywords',], 'trim'],
[['keywords',], 'string'],
[['page', 'limit', 'status'], 'integer'],
[['page'], 'default', 'value' => 1],
[['limit'], 'default', 'value' => 20],
];
}
/**
* 型号列表
*/
public function search()
{
if (!$this->validate()) {
return $this->getModelError();
}
$query = BallMark::find()
->select('id,name,desc')
->where([
'is_delete' => 0
])
->andFilterWhere([
'OR',
['like', 'name', $this->keywords],
])->andFilterWhere([
'status' => $this->status
]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['created_at' => SORT_DESC])->asArray()->all();
$data = [];
$data['code'] = 0;
$data['msg'] = 'ok';
$data['data'] = $list;
$data['count'] = $count;
return $data;
}
}