DeviceLog.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\common\model;
  3. use app\common\util\AppAuth;
  4. use think\Db;
  5. class DeviceLog extends Base {
  6. const TYPE1 = 1;//医废秤
  7. const TYPE2 = 2;//蓝牙点
  8. const TYPE3 = 3;//考勤机
  9. const TYPE4 = 4;//报警器
  10. const TYPE5 = 5;//温控计
  11. const TYPE6 = 6;//打印机
  12. public $type= [
  13. 1=>"医废秤",
  14. 2=>"蓝牙点",
  15. 3=>"考勤机",
  16. 4=>"报警器",
  17. 5=>"温控计",
  18. 6=>"打印机",
  19. ];
  20. protected $createTime = 'create_time';
  21. protected $updateTime = 'update_time';
  22. protected $table = 'device_log';
  23. protected $validateName = 'DeviceLog';
  24. public function updates(){
  25. $data = request()->post();
  26. $result = validate($this->validateName)->check($data,[],'');
  27. if(true !== $result){
  28. $this->error = validate($this->validateName)->getError();
  29. return false;
  30. }
  31. $id = $data['id'];
  32. unset($data['id']);
  33. if($id > 0){
  34. $data['update_time'] = date('Y-m-d H:i:s');
  35. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  36. }else{
  37. $data['create_time'] = date('Y-m-d H:i:s');
  38. $ret = $this->allowField(true)->save($data);
  39. }
  40. if(!$ret){
  41. $this->error = '操作失败';
  42. return false;
  43. }
  44. return true;
  45. }
  46. }