<?php

namespace app\admin\lists\user_label;


use app\admin\lists\BaseAdminDataLists;
use app\common\model\user_label\UserLabel;
use app\common\lists\ListsSearchInterface;


/**
 * 用户标签列表
 * Class UserLabelLists
 * @package app\admin\listsuser_label
 */
class UserLabelLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author admin
     * @date 2024/06/17 17:02
     */
    public function setSearch(): array
    {
        return [
            '=' => ['label_name'],
        ];
    }


    /**
     * @notes 获取用户标签列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author admin
     * @date 2024/06/17 17:02
     */
    public function lists(): array
    {
        return UserLabel::where($this->searchWhere)
            ->field(['label_id', 'label_name'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order(['label_id' => 'desc'])
            ->select()
            ->toArray();
    }


    /**
     * @notes 获取用户标签数量
     * @return int
     * @author admin
     * @date 2024/06/17 17:02
     */
    public function count(): int
    {
        return UserLabel::where($this->searchWhere)->count();
    }

}