123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- declare (strict_types = 1);
- namespace app\model\api;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class ServiceLabel extends Model
- {
- /**
- * 获取标签列表
- * @param type $post
- * @param type $field
- * @return type
- */
- public function getList($post,$field="*"){
- $post["pageSize"] = $post["pageSize"]>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["title"])){
- $where[]=["title","like","%{$post["title"]}%"];
- }
- $totalCount = $this->where($where)->count();
- $data=null;
- if($totalCount>0){
- $data = $this
- ->field($field)
- ->where($where)
- ->order("seq", "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];
- }
-
-
- public function getColumnList($field="id",$value="id",$in=[]){
- if(empty($in)){
- return [];
- }
- if(is_string($in)){
- $in = explode(",", $in);
- }
- $labelData = $this
- ->where("status",1)
- ->where($field,"in",$in)
- ->column($value);
- $labelData = empty($labelData)?[]:$labelData;
- return $labelData;
- }
-
-
- }
|