48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\storeapi\logic;
|
|
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\Training;
|
|
use app\common\service\FileService;
|
|
|
|
class TrainingLogic extends BaseLogic
|
|
{
|
|
public static function trainingList($post){
|
|
$search = "";
|
|
if(isset($post['search'])){
|
|
if($post['search']!=""&&$post['search']!=null){
|
|
$a = $post['search'];
|
|
$search = "title like '%".$a."%'";
|
|
}
|
|
}
|
|
$count = Training::where("type_id",2)->where($search)->count();
|
|
$lists = Training::where("type_id",2)
|
|
->where($search)
|
|
->page($post['page'], $post['size'])
|
|
->order("id","desc")
|
|
->select()
|
|
->toarray();
|
|
foreach($lists as $key=>$value){
|
|
$lists[$key]['image'] = FileService::getImgUrl($value['image']);
|
|
$lists[$key]['dtime'] = date("Y-m-d H:i:s",$value['dtime']);
|
|
}
|
|
$data = [
|
|
'list' => $lists,
|
|
'page' => $post['page'],
|
|
'size' => $post['size'],
|
|
'count' => $count,
|
|
'more' => is_more($count, $post['page'], $post['size'])
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
public static function trainingDetails($data){
|
|
$result = Training::where("id",$data['id'])
|
|
->find();
|
|
$result['image'] = FileService::getImgUrl($result['image']);
|
|
$result['dtime'] = date("Y-m-d H:i:s",$result['dtime']);
|
|
$d['details'] = $result;
|
|
return $d;
|
|
}
|
|
} |