Tiaoshiweixiu.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 调试维修
  7. */
  8. class Tiaoshiweixiu extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['info'];
  12. protected $table = 'tiaoshiweixiu';
  13. public function index(){
  14. $search = [];
  15. $title = input('title','');
  16. if(!empty($title)){
  17. $search['a.title'] = ['LIKE','%'.$title.'%'];
  18. }
  19. $list = Db::name($this->table)->alias('a')
  20. ->field('a.id,a.logo_id,a.title,a.createtime,logo.title as logo_title,logo.image as logo_image')
  21. ->join('tiaoshiweixiu_logo logo','a.logo_id = logo.id','LEFT')
  22. ->where('a.company_id',$this->auth->company_id)
  23. ->where($search)
  24. ->order('a.id desc')
  25. ->paginate();
  26. $total = $list->total();
  27. $list = $list->items();
  28. $list = list_domain_image($list,['image']);
  29. $rs = [
  30. 'list' => $list,
  31. 'total'=> $total,
  32. ];
  33. $this->success(1,$rs);
  34. }
  35. public function add(){
  36. $data = [
  37. 'logo_id' => input('logo_id',0),
  38. 'title' => input('title',''),
  39. 'content' => input('content','','htmlspecialchars_decode'),
  40. 'company_id' => $this->auth->company_id,
  41. 'createtime' => time(),
  42. 'updatetime' => time(),
  43. ];
  44. Db::name($this->table)->insertGetId($data);
  45. $this->success();
  46. }
  47. public function info(){
  48. $id = input('id',0);
  49. $info = Db::name($this->table)->alias('a')
  50. ->field('a.id,a.logo_id,a.title,a.content,a.createtime,logo.title as logo_title,logo.image as logo_image')
  51. ->join('tiaoshiweixiu_logo logo','a.logo_id = logo.id','LEFT')
  52. ->where('a.id',$id)->where('a.company_id',$this->auth->company_id)
  53. ->find();
  54. $info = info_domain_image($info,['logo_image']);
  55. $this->success(1,$info);
  56. }
  57. public function edit(){
  58. $id = input('id',0);
  59. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  60. if(empty($info)){
  61. $this->error('没找到该信息,请刷新重试');
  62. }
  63. $data = [
  64. 'logo_id' => input('logo_id',0),
  65. 'title' => input('title',''),
  66. 'content' => input('content','','htmlspecialchars_decode'),
  67. 'updatetime' => time(),
  68. ];
  69. Db::name($this->table)->where('id',$id)->update($data);
  70. $this->success();
  71. }
  72. public function del(){
  73. $ids = input('ids','');
  74. $ids = explode(',',$ids);
  75. if (empty($ids)) {
  76. $this->error();
  77. }
  78. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  79. $this->success();
  80. }
  81. }