<?php

namespace app\admin\controller;
use think\Controller;
use think\Db;
class  Cag extends Common
{
public function lst()
{
$list=Db::query("select * from cag ");
$this->assign('list',$list);
return $this->fetch();
}
public function add()
{
if (request()->isPost()){
$data = input('post.');
if(db('cag')->insert($data)){
return $this->success('ok','lst');
}
else {
return $this->error('false');
}
return ;
}
return $this->fetch();
}
public function edit(){
$id=input('id');
$cags=db('cag')->find($id);
if(request()->ispost()){
$data=[
'id'=>input('id'),
'name'=>input('name'),
'manufacture'=>input('manufacture'),
'factoryint'=>input('factoryint'),
'manufacturedate'=>input('manufacturedate'),
'rundate'=>input('rundate'),
'location'=>input('location'),
'note'=>input('note'),
'diskfree'=>input('diskfree'),
'downip'=>input('downip'),
'upip'=>input('upip'),
];
$save=db('cag')->update($data);
if($save !== false){
$this->success('修改主站平台信息成功！','lst');
}else{
$this->error('修改主站平台信息失败！');
}
return;
}
$this->assign('cags',$cags);
return $this->fetch();
}
public function del(){
$id=input('id');
if(db('cag')->delete(input('id'))){
$this->success('删除主站平台信息成功！','lst');
}else{
$this->error('删除主站平台信息失败！');
}
}
public function logout(){
session(null);
$this->success('退出成功！','Login/index');
}
}
?>