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

分類模塊練習(xí)

Original 2019-04-07 21:25:09 237
abstract:<?php /**  * Created by PhpStorm.  * User: Admin  * Date: 2019/4/6  * Time: 21:42  */ namespace app\admin\controller; use
<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2019/4/6
 * Time: 21:42
 */

namespace app\admin\controller;
use app\admin\controller\Common;
use think\Db;
use think\facade\Request;
use think\facade\Session;

class Sort extends Common
{
     public function index()
     {
         $type['title'] = Db::table('sort')->order('id','desc')->paginate(8);
         return $this->fetch('',$type);
     }
     public function add()
     {
         return $this->fetch();
     }
     public function edit()
     {
         $id = Request::param('id');
         $data['type']=Db::table('sort')->where('id',$id)->find();
         return $this->fetch('',$data);
     }
     public function DoAdd()
     {
         $data=Request::param();
         $data['time']=time();
         $data['username']=Session::get('username');
         if(Db::table('sort')->insert($data)){
             return ['res'=>1,'msg'=>'添加成功'];
         }else{
             return ['res'=>0,'mag'=>'添加失敗'];
         }
     }
     public function DoEdit()
     {
         $data=Request::param();
         if (Db::table('sort')->data([
             'title'=>$data['title'],
             'username'=>Session::get('username'),
             'time'=>time()
         ])->where('id',$data['id'])->update()){
             return ['res'=>1,'msg'=>'修改成功'];
         }else{
             return ['res'=>0,'mag'=>'修改失敗'];
         }
     }
     public function del()
     {
         $id=Request::param('id');
         if(Db::table('sort')->where('id',$id)->delete()){
             return ['res'=>1,'msg'=>'刪除成功'];
         }else{
             return ['res'=>0,'mag'=>'刪除失敗'];
         }
     }

}


Correcting teacher:天蓬老師Correction time:2019-04-08 09:42:18
Teacher's summary:代碼寫得很工整, 不錯(cuò)的, 格式也規(guī)范, 類中的每個(gè)方法, 上面最好有phpdoc的注釋內(nèi)容,會更好些,特別是在團(tuán)隊(duì)開發(fā)中

Release Notes

Popular Entries