PersonFavoriteController.php 6.6 KB

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