QueueAutoRefreshService.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Services\Common;
  3. use App\Exceptions\ResponseException;
  4. use App\Repositories\QueueAutoRefreshRepository;
  5. use http\Exception\RuntimeException;
  6. /**
  7. * 自动刷新。
  8. * Class QueueAutoRefreshService
  9. * @package App\Services\Common
  10. */
  11. class QueueAutoRefreshService
  12. {
  13. protected $queueAutoRefreshRepository;
  14. /**
  15. * QqService constructor.
  16. */
  17. public function __construct(QueueAutoRefreshRepository $queueAutoRefreshRepository)
  18. {
  19. $this->queueAutoRefreshRepository = $queueAutoRefreshRepository;
  20. }
  21. public function getQueuAutoRefresh($pid, $utype)
  22. {
  23. $where['pid'] = $pid;
  24. $where['utype'] = $utype;
  25. $res = $this->queueAutoRefreshRepository->findData($where);
  26. $status = false;
  27. $refresh_start = '';
  28. $refresh_end = '';
  29. $id = '';
  30. if($res){
  31. if($res->refreshtime>=time() && $res->start_time){
  32. $status = true;
  33. $refresh_start = date('Y-m-d', $res->start_time);
  34. $refresh_end = date('Y-m-d', $res->refreshtime);
  35. $id = $res->id;
  36. }
  37. }
  38. return ['status'=>$status,'refresh_start'=>$refresh_start,'refresh_end'=>$refresh_end,'id'=>$id];
  39. }
  40. public function delRefreshResume($id,$user)
  41. {
  42. if(!$id) {
  43. throw new ResponseException('参数错误!');
  44. }
  45. $autoRefresh = $this->queueAutoRefreshRepository->findData(['id'=>$id]);
  46. if(!$autoRefresh) {
  47. throw new ResponseException('简历不存在!');
  48. }
  49. if($autoRefresh->uid != $user->id) {
  50. throw new ResponseException('对不起,您只能操作自己的简历!');
  51. }
  52. return $this->queueAutoRefreshRepository->delRefreshResume(['id'=>$id]);
  53. }
  54. }