Caozuoguifan.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 = ['info'];
  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)->order('id desc')->paginate();
  20. $total = $list->total();
  21. $list = $list->items();
  22. $list = list_domain_image($list,['image','videofile']);
  23. $rs = [
  24. 'list' => $list,
  25. 'total'=> $total,
  26. ];
  27. $this->success(1,$rs);
  28. }
  29. public function add(){
  30. $data = [
  31. 'company_id' => $this->auth->company_id,
  32. 'title' => input('title',''),
  33. 'type_id' => input('type_id',0),
  34. 'image' => input('image',''),
  35. 'content' => input('content','','htmlspecialchars_decode'),
  36. 'videofile' => input('videofile',''),
  37. 'createtime' => time(),
  38. 'updatetime' => time(),
  39. ];
  40. Db::name($this->table)->insertGetId($data);
  41. $this->success();
  42. }
  43. public function info(){
  44. $id = input('id',0);
  45. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  46. $info = info_domain_image($info,['image','videofile']);
  47. $this->success(1,$info);
  48. }
  49. public function edit(){
  50. $id = input('id',0);
  51. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  52. if(empty($info)){
  53. $this->error('没找到该信息,请刷新重试');
  54. }
  55. $data = [
  56. 'title' => input('title',''),
  57. 'type_id' => input('type_id',0),
  58. 'image' => input('image',''),
  59. 'content' => input('content','','htmlspecialchars_decode'),
  60. 'videofile' => input('videofile',''),
  61. 'updatetime' => time(),
  62. ];
  63. Db::name($this->table)->where('id',$id)->update($data);
  64. $this->success();
  65. }
  66. public function del(){
  67. $ids = input('ids','');
  68. $ids = explode(',',$ids);
  69. if (empty($ids)) {
  70. $this->error();
  71. }
  72. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  73. $this->success();
  74. }
  75. }