NoteLog.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class NoteLog extends Model
  9. {
  10. public static function log($tem,$post,$type){
  11. $token=$post['token'];
  12. unset($post['token']);
  13. $in=$tem['bugNo'];
  14. unset($tem['bugNo']);
  15. $post['model_id'] = isset($post['model_id']) ? array_pop($post['model_id']):"";
  16. $item = array_diff_assoc($tem,$post);
  17. $user = VerifyTokens($token);
  18. $uid = isset($user['data']['id']) ? $user['data']['id'] :0;
  19. $name = isset($user['data']['nickname']) ? $user['data']['nickname'] :'';
  20. if(!empty($item)){
  21. $data=[];
  22. foreach ($item as $key=>$value){
  23. if(isset($post[$key])==false){
  24. continue;
  25. }
  26. $datai=[];
  27. $datai['action_uid']=$uid;
  28. $datai['action_name']=$name;
  29. $datai['type']=$type;
  30. // $datai['action_type']=$action_type;
  31. $datai['handle_name']=$key;
  32. $datai['action_item']=$value;
  33. $datai['action_after']=isset($post[$key]) ? $post[$key]:"";
  34. $datai['bugNo']=$in;
  35. $datai['addtime']=date("Y-m-d H:i:s");
  36. $data[]=$datai;
  37. }
  38. self::insertAll($data);
  39. }
  40. }
  41. }