亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

小型企業(yè)站產(chǎn)品模塊

Original 2019-06-16 10:04:51 255
abstrakt:<?php  namespace app\admin\controller; use app\admin\controller\Commn; use think\facade\Request; use think\facade\Session; use app\admin\model\Newsl; use app\admin\model\Product; /** *  *

<?php 

namespace app\admin\controller;

use app\admin\controller\Commn;

use think\facade\Request;

use think\facade\Session;

use app\admin\model\Newsl;

use app\admin\model\Product;


/**

*/

class Productl extends Commn

{

//產(chǎn)品展示

public function index()

{

//查詢產(chǎn)品

$data = Product::order('product_id','desc')->paginate(4);

//分頁page

$page = $data->render();


$this->assign('page',$page);


$this->assign('data',$data);


return $this->fetch();

}

//圖片上傳頁面

public function uplode()

{

//獲取圖片信息

$file = Request::file('img');

if ($info = $file->validate(['ext'=>'jpg,png,jpeg,gif'])->move('upload')){

//返回上次成功信息

return json(['errno'=>0,'data'=>["/upload/" .$info->getSaveName()]]);

}else{

echo $info->getError();

}

}


public function add()

{

// //查詢產(chǎn)品分類

// $res = Product::all();

// $this->assign('res',$res);


return $this->fetch();

}

public function add_do()

{

$data = Request::param();


$data['username'] = Session::get('username');


$product_name = $data['product_name'];


if ($res = Product::where('product_name',$product_name)->find()) {

return json(['code'=>1,'msg'=>'產(chǎn)品名重復(fù),添加產(chǎn)品失敗']);

}

$data['create_time'] = time();

if ($product = Product::insert($data)) {

return json(['code'=>2,'msg'=>'添加產(chǎn)品成功']);

}else{

return json(['code'=>3,'msg'=>'添加產(chǎn)品失敗']);

}

}

public function upl()

{

$data = Request::param();



$product_id = $data['product_id'];


$res = Product::where('product_id',$product_id)->find();


$this->assign('res',$res);


return $this->fetch();

}

public function upl_do()

{

$data = Request::param();


$product_id = $data['product_id'];


$data['create_time'] = time();


//查詢這條用戶數(shù)據(jù)

$res = Product::where('product_id',$product_id)->find();



// //判斷如果傳過來的產(chǎn)品名稱重復(fù),是根據(jù)產(chǎn)品id查詢出來的產(chǎn)品一致

if ($res['product_name'] == $data['product_name']) {


if ($Productl = Product::where('product_id',$product_id)->update($data)) {

return json(['code'=>1,'msg'=>'修改產(chǎn)品成功']);

}else{

return json(['code'=>2,'msg'=>'修改產(chǎn)品失敗']);

}

}else{

if ($info = Product::where('product_id',$product_id)->all()) {

return json(['code'=>3,'msg'=>'修改產(chǎn)品名已經(jīng)存在,修改產(chǎn)品失敗']);

}

}

}

public function del()

{

//接值

$data = Request::param();


//產(chǎn)品id

$product_id = $data['id'];


//刪除操作

if ($Productl = Product::where('product_id',$product_id)->delete()) {

return json(['code'=>1,'msg'=>'刪除產(chǎn)品成功']);

}else{

return json(['code'=>2,'msg'=>'刪除產(chǎn)品失敗']);

}

}


}


















 ?>

1VC[8ME_E}AK6{[LLS0VFYR.png

Korrigierender Lehrer:查無此人Korrekturzeit:2019-06-17 09:31:47
Zusammenfassung des Lehrers:完成的不錯。一天做了很多作業(yè),對后臺管理應(yīng)該很熟悉了。繼續(xù)加油。

Versionshinweise

Beliebte Eintr?ge