You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ArticleController extends Controller
|
|
{
|
|
public function GetList()
|
|
{
|
|
$searchInfo=request('searchInfo');
|
|
$list = DB::table('articles')->where(['type'=>$searchInfo['ArticleType'],'is_del'=>0,'status'=>1]);
|
|
$count=$list->count();
|
|
$list=$list->orderBy('order','asc')->get();
|
|
return \Yz::Return(true,"查询完成",['list'=>$list,'count'=>$count]);
|
|
}
|
|
public function Save()
|
|
{
|
|
$Info=request('Info');
|
|
if(!isset($Info['id'])) return \Yz::echoError1("id不能为空");
|
|
$data=[
|
|
'title'=>$Info['title'],
|
|
'type'=>$Info['type'],
|
|
'head_img'=>$Info['head_img'],
|
|
'content'=>$Info['content'],
|
|
'author'=>$Info['author'],
|
|
'order'=>$Info['order'],
|
|
];
|
|
$do=false;
|
|
if($Info['id']===0){
|
|
$do=DB::table('articles')->insert($data);
|
|
}else{
|
|
$do= DB::table('articles')->where(['id'=>$Info['id'],'is_del'=>0])->update($data);
|
|
}
|
|
if($do){
|
|
return \Yz::Return(true,"操作成功",[]);
|
|
}else{
|
|
return \Yz::echoError1("操作失败");
|
|
}
|
|
}
|
|
|
|
//获取详情
|
|
public function GetDetail()
|
|
{
|
|
$id=request('id');
|
|
$info = DB::table('articles')->where(['id'=>$id,'is_del'=>0,'status'=>1])->first();
|
|
if($info){
|
|
return \Yz::Return(true,"查询完成",$info);
|
|
}else{
|
|
return \Yz::echoError1("文章内容查询失败");
|
|
}
|
|
|
|
}
|
|
public function Del()
|
|
{
|
|
$id=request('id');
|
|
$d=DB::table('articles')->where(['id'=>$id])->update(['is_del'=>1]);
|
|
if($d){
|
|
return \Yz::Return(true,"操作完成",[]);
|
|
}else{
|
|
return \Yz::echoError1("删除失败");
|
|
}
|
|
}
|
|
}
|