|
@@ -49,6 +49,88 @@ class Conf extends BaseController
|
|
|
return app_show(0,"获取成功",$info);
|
|
|
}
|
|
|
|
|
|
- public function add(){}
|
|
|
+ public function add(){
|
|
|
+ $post = $this->request->post();
|
|
|
+ $name = isset($post['name'])&& $post['name']!='' ? trim($post['name']) :"";
|
|
|
+ if($name==""){
|
|
|
+ return error_show(1004,"参数name 不能为空");
|
|
|
+ }
|
|
|
+ $ist = Db::name("config")->where(["name"=>$name,"is_del"=>0])->find();
|
|
|
+ if(!empty($ist)){
|
|
|
+ return error_show(1004,"配置名称已存在");
|
|
|
+ }
|
|
|
+ $setv = isset($post['setv'])&& $post['setv']!='' ? trim($post['setv']) :"";
|
|
|
+ if($setv==""){
|
|
|
+ return error_show(1004,"参数setv 不能为空");
|
|
|
+ }
|
|
|
+ $start= isset($post['start'])&& $post['start']!='' ? $post['start'] :date("Y-m-d H:i:s");
|
|
|
+ $end= isset($post['end'])&& $post['end']!='' ? $post['end'] :null;
|
|
|
+ $status= isset($post['status'])&& $post['status']!='' ? intval($post['satus']) :"1";
|
|
|
+ $data= [
|
|
|
+ "name"=>$name,
|
|
|
+ "setv"=>$setv,
|
|
|
+ 'status'=>$status,
|
|
|
+ "starttime"=>$start,
|
|
|
+ "endtime"=>$end,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $iser=Db::name("config")->insert($data);
|
|
|
+ return $iser ? app_show(0,"新建成功"):error_show(1008,"新建失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function edit(){
|
|
|
+ $post = $this->request->post();
|
|
|
+ $id = isset($post['id'])&& $post['id']!='' ? intval($post['id']) :"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1004,"参数id 不能为空");
|
|
|
+ }
|
|
|
+ $data = Db::name("config")->where(['id'=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($data)){
|
|
|
+ return error_show(1005,"未找到数据");
|
|
|
+ }
|
|
|
+ $name = isset($post['name'])&& $post['name']!='' ? trim($post['name']) :"";
|
|
|
+ if($name==""){
|
|
|
+ return error_show(1004,"参数name 不能为空");
|
|
|
+ }
|
|
|
+ $ist = Db::name("config")->where(["name"=>$name,"is_del"=>0])->find();
|
|
|
+ if(!empty($ist)&&$ist['id']!=$id){
|
|
|
+ return error_show(1004,"配置名称已存在");
|
|
|
+ }
|
|
|
+ $setv = isset($post['setv'])&& $post['setv']!='' ? trim($post['setv']) :"";
|
|
|
+ if($setv==""){
|
|
|
+ return error_show(1004,"参数setv 不能为空");
|
|
|
+ }
|
|
|
+ $start= isset($post['start'])&& $post['start']!='' ? $post['start'] :date("Y-m-d H:i:s");
|
|
|
+ $end= isset($post['end'])&& $post['end']!='' ? $post['end'] :null;
|
|
|
+ $status= isset($post['status'])&& $post['status']!='' ? intval($post['satus']) :"1";
|
|
|
+ $data= [
|
|
|
+ "id"=>$id,
|
|
|
+ "name"=>$name,
|
|
|
+ "setv"=>$setv,
|
|
|
+ 'status'=>$status,
|
|
|
+ "starttime"=>$start,
|
|
|
+ "endtime"=>$end,
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $iser=Db::name("config")->save($data);
|
|
|
+ return $iser ? app_show(0,"新建成功"):error_show(1008,"新建失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delete(){
|
|
|
+ $post = $this->request->post();
|
|
|
+ $id = isset($post['id'])&& $post['id']!='' ? intval($post['id']) :"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1004,"参数id 不能为空");
|
|
|
+ }
|
|
|
+ $data = Db::name("config")->where(['id'=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($data)){
|
|
|
+ return error_show(1005,"未找到数据");
|
|
|
+ }
|
|
|
+ $data['is_del']=1;
|
|
|
+ $data['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $iser=Db::name("config")->save($data);
|
|
|
+ return $iser ? app_show(0,"删除成功"):error_show(1008,"删除失败");
|
|
|
+ }
|
|
|
|
|
|
}
|