提交其他文件
This commit is contained in:
48
app/storeapi/logic/TrainingLogic.php
Normal file
48
app/storeapi/logic/TrainingLogic.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user