Browse Source

检测项目

lizhen_gitee 6 months ago
parent
commit
d9ff46d6b4
1 changed files with 99 additions and 0 deletions
  1. 99 0
      application/company/controller/Jianceproject.php

+ 99 - 0
application/company/controller/Jianceproject.php

@@ -0,0 +1,99 @@
+<?php
+
+namespace app\company\controller;
+
+use app\common\controller\Apic;
+use think\Db;
+/**
+ * 检测下发
+ */
+class Jianceproject extends Apic
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = [];
+
+    protected $table = 'jiance_project';
+
+    //检测项目,父+子,一次给出
+    public function index(){
+        $lists = Db::name('jiance_project')->field('id,pid as parentId,title,createtime')
+            ->where('company_id',$this->auth->company_id)
+            ->where('deletetime',NULL)->order('weigh asc')->select();
+
+        $this->success(1,$lists);
+    }
+
+
+    public function add(){
+
+        $data = [
+            'company_id' => $this->auth->company_id,
+            'pid'        => input('pid',0),
+            'title'      => input('title',''),
+            'type'       => input('type',1),
+            'info'       => input('info',''),
+            'weigh'      => input('weigh',0),
+            'createtime' => time(),
+        ];
+
+        if($data['pid'] == 0){
+            $data['info'] = '';
+            $data['type'] = 1;
+        }
+
+        $id = Db::name($this->table)->insertGetId($data);
+
+        if($data['weigh'] == 0){
+            Db::name($this->table)->where('id',$id)->update(['weigh'=>$id]);
+        }
+
+        $this->success();
+    }
+
+    public function info(){
+        $id = input('id',0);
+        $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
+
+        $this->success(1,$info);
+    }
+
+    public function edit(){
+        $id = input('id',0);
+        $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
+        if(empty($info)){
+            $this->error('没找到该信息,请刷新重试');
+        }
+
+        //
+        $data = [
+            'title'      => input('title',''),
+            'type'       => input('type',1),
+            'info'       => input('info',''),
+            'weigh'      => input('weigh',$id),
+        ];
+
+        Db::name($this->table)->where('id',$id)->update($data);
+
+        $this->success();
+    }
+
+    public function del(){
+        $ids = input('ids','');
+
+        if (empty($ids)) {
+            $this->error();
+        }
+
+        Db::name($this->table)->where('id',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
+        Db::name($this->table)->where('pid',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
+        $this->success();
+    }
+
+
+
+
+
+
+
+
+}