123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare (strict_types = 1);
- namespace app\model\api;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Upsource extends Model
- {
- private $typeAr = [
- ["type"=>"img","title"=>"普通图片"],
- ["type"=>"icon","title"=>"图标"]
- ];
-
- public function getTypeData(){
- return $typeAr;
- }
-
-
- /**
- * 获取列表
- * @param type $post
- * @param type $field
- * @return type
- */
- public function getListData($post,$field="*"){
- $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
- $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"];
- $where=[];
- $where[]=["is_del","=",0];
- 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"]}%"];
- }
- if(!empty($post["type"])){
- $where[]=["type","=",$post["type"]];
- }
- $totalCount = $this->where($where)->count();
- $data=null;
- if($totalCount>0){
- $data = $this
- ->field($field)
- ->where($where)
- ->order("id", "desc")
- ->page($post["page"], $post["pageSize"])
- ->select();
- if(!empty($data)){
- $data = $data->toArray();
- }
- }
- $data = empty($data)?[]:$data;
- foreach($data as $k=>$v){
- $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]);
- }
- return ["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount];
- }
-
- public function saveData(){
-
- }
-
- public function delData(){
-
- }
-
-
- }
|