PersonFavoriteController.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. namespace App\Http\Controllers\Web\Person;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Models\PersonJobsSubscribe;
  5. use App\Models\Resume;
  6. use App\Services\Common\CategoryService;
  7. use App\Services\Person\PersonFavoriteService;
  8. use App\Services\Person\ResumeService;
  9. use App\Validators\PersonValidatorRequest;
  10. class PersonFavoriteController extends WebBaseController
  11. {
  12. /**
  13. * @var PersonFavoriteService
  14. */
  15. protected $PersonFavoriteService;
  16. protected $resumeService;
  17. protected $categoryService;
  18. /**
  19. * PersonFavoriteController constructor.
  20. * @param PersonFavoriteService $PersonFavoriteService
  21. * @param ResumeService $resumeService
  22. * @param CategoryService $categoryService
  23. */
  24. public function __construct(PersonFavoriteService $PersonFavoriteService, ResumeService $resumeService, CategoryService $categoryService)
  25. {
  26. $this->PersonFavoriteService = $PersonFavoriteService;
  27. $this->resumeService = $resumeService;
  28. $this->categoryService = $categoryService;
  29. }
  30. public function jobsF()
  31. {
  32. $res = $this->PersonFavoriteService->jobsF(auth('web-member')->user());
  33. return view('app.person.jobs_favorite', ['content'=>$res]);
  34. }
  35. public function delPersonFavorite()
  36. {
  37. if (request()->method()=='POST') {
  38. $res = $this->PersonFavoriteService->delPersonFavorite(request()->id,auth('web-member')->user());
  39. if ($res) {
  40. return $this->sendSuccessResponse('删除成功');
  41. } else {
  42. return $this->sendErrorResponse('删除失败');
  43. }
  44. } else {
  45. return view('app.person.ajax.resume_delete', ['tpis'=>'删除后将无法恢复,您确定要删除选中的收藏职位吗?']);
  46. }
  47. }
  48. public function resumeApply()
  49. {
  50. if (request()->method()=='POST') {
  51. $res = $this->PersonFavoriteService->resumeApply(request()->all(), auth('web-member')->user());
  52. if ($res['code']==1) {
  53. return $this->sendSuccessResponse($res['info']);
  54. } else {
  55. return $this->sendErrorResponse($res['info']);
  56. }
  57. } else {
  58. $timeG = config('aix.personal_set.per_set.per_set.apply_job_space');
  59. if ($timeG>0) {
  60. $res = $this->resumeService->getSuccessResumeCount(auth('web-member')->user());
  61. if ($res['code']==0) {
  62. return json_encode(['code'=>0,'info'=>$res['info']]);
  63. } elseif ($res['code']==1) {
  64. $html = view('app.person.ajax.apply_resume', ['resume'=>$res['info'],'timeG'=>$timeG])->render();
  65. return json_encode(['code'=>1,'info'=>$html]);
  66. } else {
  67. $html = view('app.person.ajax.resume_tip', ['resume'=>$res['info'],'tpis'=>$timeG.'天内已投递的职位不再投递!'])->render();
  68. return json_encode(['code'=>1,'info'=>$html]);
  69. }
  70. } else {
  71. return json_encode(['code'=>0,'info'=>'投递功能已关闭!']);
  72. }
  73. }
  74. }
  75. public function attentionCom()
  76. {
  77. $res = $this->PersonFavoriteService->attentionCom(auth('web-member')->user());
  78. return view('app.person.attention_com', ['content'=>$res]);
  79. }
  80. public function deleteCompany()
  81. {
  82. $res = $this->PersonFavoriteService->deleteCompany(request()->id,auth('web-member')->user());
  83. if ($res) {
  84. return $this->sendSuccessResponse('删除成功');
  85. } else {
  86. return $this->sendErrorResponse('删除失败');
  87. }
  88. }
  89. public function getJobsSub()
  90. {
  91. $res = $this->PersonFavoriteService->getJobsSub();
  92. $count = $this->PersonFavoriteService->getCount();
  93. return view('app.person.attention_sub', ['content'=>$res,'count'=>$count]);
  94. }
  95. public function getJobsSubEdit()
  96. {
  97. $back_url = \Illuminate\Support\Facades\URL::previous();
  98. if(request()->id){
  99. $sub_info = PersonJobsSubscribe::find(request()->id);
  100. if(!$sub_info){
  101. return $this->showMessage('对不起,您只能查看自己的职位订阅器!', $back_url, true, '上一页', '3');
  102. }
  103. if($sub_info->uid!=auth('web-member')->user()->id){
  104. return $this->showMessage('对不起,您只能查看自己的职位订阅器!', $back_url, true, '上一页', '3');
  105. }
  106. }
  107. $res = $this->PersonFavoriteService->getJobsSubEdit(request()->id);
  108. $district = $this->categoryService->getDefaultDistrict();
  109. return view('app.person.attention_sub_edit', ['content'=>$res['sub'],'defaultCity'=>$district->defaultCity]);
  110. }
  111. public function getJobsSubAdd(PersonValidatorRequest $request)
  112. {
  113. if($request->id) {
  114. $id = $request->id;
  115. $user = auth('web-member')->user();
  116. $this->PersonFavoriteService->isOwn($id,$user);
  117. }
  118. $res= $this->PersonFavoriteService->getJobsSubAdd($request->all(), auth('web-member')->user());
  119. if ($res) {
  120. return $this->sendSuccessResponse('更新成功');
  121. } else {
  122. return $this->sendErrorResponse('更新失败');
  123. }
  124. }
  125. public function getJobsSubout()
  126. {
  127. $id = request()->get('id');
  128. $user = auth('web-member')->user();
  129. $this->PersonFavoriteService->isOwn($id,$user);
  130. $res= $this->PersonFavoriteService->getJobsSubout(request()->all());
  131. if ($res['code']==1) {
  132. return $this->sendSuccessResponse($res['data']);
  133. } else {
  134. return $this->sendErrorResponse('退订失败');
  135. }
  136. }
  137. public function getJobsAddVar()
  138. {
  139. $res= $this->PersonFavoriteService->getJobsAddVar();
  140. if ($res) {
  141. return $this->sendSuccessResponse('ok');
  142. } else {
  143. return $this->sendErrorResponse('您最多可以添加 5 个职位订阅器');
  144. }
  145. }
  146. public function getJobsSubDel()
  147. {
  148. if (request()->method()=='POST') {
  149. $id = request()->get('id');
  150. $user = auth('web-member')->user();
  151. $this->PersonFavoriteService->isOwn($id,$user);
  152. $res= $this->PersonFavoriteService->getJobsSubDel(request()->id);
  153. if ($res) {
  154. return $this->sendSuccessResponse('删除成功');
  155. } else {
  156. return $this->sendErrorResponse('删除失败');
  157. }
  158. } else {
  159. return view('app.person.ajax.resume_delete', ['tpis'=>'删除后将无法恢复,您确定要删除该订阅器吗?']);
  160. }
  161. }
  162. }