50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"] <= 0 ? 1 : (int)$post["page"]; $where = []; if (isset($post["status"]) && in_array((string)$post["status"], ["0", "1"])) { $where[] = ["status", "=", (int)$post["status"]]; } if (!empty($post["name"])) { $where[] = ["name", "like", "%{$post["name"]}%"]; } $totalCount = $this->where($where)->count(); $data = null; if ($totalCount > 0) { $data = $this ->field($field) ->where($where) ->order("sort", "desc") ->order("id", "desc") ->page($post["page"], $post["pageSize"]) ->select(); if (!empty($data)) { $data = $data->toArray(); } } $data = empty($data) ? [] : $data; return ["list" => $data, "pageSize" => $post["pageSize"], "page" => $post["page"], "totalCount" => $totalCount]; } /** * 获取所有启用的荣誉(用于下拉选择) * @return array */ public function getAllEnabled() { $data = $this ->field("id,name,icon") ->where("status", 1) ->order("sort", "desc") ->order("id", "desc") ->select(); if (!empty($data)) { $data = $data->toArray(); } return empty($data) ? [] : $data; } }