Caozuoguifan.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 操作规范
  7. */
  8. class Caozuoguifan extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. protected $table = 'caozuoguifan';
  13. public function index(){
  14. $type_id = input('type_id',0);
  15. $where = [];
  16. if($type_id){
  17. $where['type_id'] = $type_id;
  18. }
  19. $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->where($where)->select();
  20. $list = list_domain_image($list,['image']);
  21. $this->success(1,$list);
  22. }
  23. public function add(){
  24. $data = [
  25. 'company_id' => $this->auth->company_id,
  26. 'title' => input('title',''),
  27. 'type_id' => input('type_id',0),
  28. 'image' => input('image',''),
  29. 'content' => input('content',''),
  30. 'createtime' => time(),
  31. 'updatetime' => time(),
  32. ];
  33. Db::name($this->table)->insertGetId($data);
  34. $this->success();
  35. }
  36. public function info(){
  37. $id = input('id',0);
  38. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  39. $info = info_domain_image($info,['image']);
  40. $this->success(1,$info);
  41. }
  42. public function edit(){
  43. $id = input('id',0);
  44. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  45. if(empty($info)){
  46. $this->error('没找到该信息,请刷新重试');
  47. }
  48. $data = [
  49. 'title' => input('title',''),
  50. 'type_id' => input('type_id',0),
  51. 'image' => input('image',''),
  52. 'content' => input('content',''),
  53. 'updatetime' => time(),
  54. ];
  55. Db::name($this->table)->where('id',$id)->update($data);
  56. $this->success();
  57. }
  58. public function del(){
  59. $ids = input('ids','');
  60. $ids = explode(',',$ids);
  61. if (empty($ids)) {
  62. $this->error();
  63. }
  64. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  65. $this->success();
  66. }
  67. }