<?php

namespace app\admin\controller;
use think\Controller;
use think\Db;
class  Cac extends Common
{
public function lst()
{
$list=Db::query("select * from vw_cac ");
$this->assign('list',$list);
return $this->fetch();
}
public function add()
{
$bdzs=Db::query("select id,mc from bdz ");
$cags=Db::query("select id,name from cag ");
if (request()->isPost()){
$data = input('post.');
if(db('cac')->insert($data)){
return $this->success('ok','lst');
}
else {
return $this->error('false');
}
return ;
}
$this->assign('bdzs',$bdzs);
$this->assign('cags',$cags);
return $this->fetch();
}
public function edit(){
$id=input('id');
$cacs=db('cac')->find($id);
$bdzs=Db::query("select id,mc from bdz ");
$cags=Db::query("select id,name from cag ");
if(request()->ispost()){
$data=[
'id'=>input('id'),
'name'=>input('name'),
'cagid'=>input('cagid'),
'bdzid'=>input('bdzid'),
'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('cac')->update($data);
if($save !== false){
$this->success('修改大数据推送平台成功！','lst');
}else{
$this->error('修改大数据推送平台失败！');
}
return;
}
$this->assign('cacs',$cacs);
$this->assign('bdzs',$bdzs);
$this->assign('cags',$cags);
return $this->fetch();
}
public function del(){
$id=input('id');
if(db('cac')->delete(input('id'))){
$this->success('删除大数据推送平台成功！','lst');
}else{
$this->error('删除大数据推送平台失败！');
}
}
public function logout(){
session(null);
$this->success('退出成功！','Login/index');
}
}
?>