Password.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 密码
  7. */
  8. class Password extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['info'];
  12. protected $table = 'password';
  13. public function index(){
  14. $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->order('id desc')->paginate();
  15. $total = $list->total();
  16. $list = $list->items();
  17. $list = list_domain_image($list,['logo_image']);
  18. $rs = [
  19. 'list' => $list,
  20. 'total'=> $total,
  21. ];
  22. $this->success(1,$rs);
  23. }
  24. public function add(){
  25. $data = [
  26. 'brand' => input('brand',''),
  27. 'logo_image' => input('logo_image',''),
  28. 'typename' => input('typename',''),
  29. 'name' => input('name',''),
  30. 'password' => input('password',''),
  31. 'company_id' => $this->auth->company_id,
  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,['logo_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. 'brand' => input('brand',''),
  50. 'logo_image' => input('logo_image',''),
  51. 'typename' => input('typename',''),
  52. 'name' => input('name',''),
  53. 'password' => input('password',''),
  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. }