Caozuoguifantype.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 操作规范type
  7. */
  8. class Caozuoguifantype extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['index','info'];
  12. protected $table = 'caozuoguifan_type';
  13. public function index(){
  14. $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->order('id desc')->select();
  15. $this->success(1,$list);
  16. }
  17. public function add(){
  18. $data = [
  19. 'name' => input('name',''),
  20. 'company_id' => $this->auth->company_id,
  21. ];
  22. Db::name($this->table)->insertGetId($data);
  23. $this->success();
  24. }
  25. public function info(){
  26. $id = input('id',0);
  27. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  28. $this->success(1,$info);
  29. }
  30. public function edit(){
  31. $id = input('id',0);
  32. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  33. if(empty($info)){
  34. $this->error('没找到该信息,请刷新重试');
  35. }
  36. $data = [
  37. 'name' => input('name',''),
  38. ];
  39. Db::name($this->table)->where('id',$id)->update($data);
  40. $this->success();
  41. }
  42. public function del(){
  43. $ids = input('ids','');
  44. $ids = explode(',',$ids);
  45. if (empty($ids)) {
  46. $this->error();
  47. }
  48. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  49. $this->success();
  50. }
  51. }