123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use think\Db;
- /**
- * 检测下发
- */
- class Jianceproject extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['info'];
- 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,id 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'] = 0;
- }
- $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),
- ];
- if($info['pid'] == 0){
- $data['info'] = '';
- $data['type'] = 0;
- }
- 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();
- }
- }
|