ResumeMaterialService.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Services\Person;
  3. use App\Exceptions\ResponseException;
  4. use App\Models\Resume;
  5. use App\Models\ResumeAuthInfo;
  6. use App\Services\Person\ResumeService;
  7. use Illuminate\Support\Facades\DB;
  8. class ResumeMaterialService
  9. {
  10. protected $resumeService;
  11. public function __construct(ResumeService $resumeService)
  12. {
  13. $this->resumeService = $resumeService;
  14. }
  15. public function resumeUpdate($data, $user = '')
  16. {
  17. $pid = $data['pid'];//简历的id
  18. $c_id = $data['c_id'];//大分类id,论文、荣誉大分类id
  19. $a_id = $data['a_id'];//小分类id,依据小分类personal_category的id
  20. //全删除当前保存大分类下对应uid、简历的表中保存信息
  21. $where["uid"] = $user->id;
  22. $where["pid"] = $pid;
  23. $where["lager"] = $c_id;
  24. DB::beginTransaction();
  25. try {
  26. ResumeAuthInfo::where($where)->delete();
  27. $this->resumeService->antic_personnel($user->id);
  28. $insert_data = [];
  29. //添加对应信息
  30. if (!empty($a_id)) {
  31. foreach ($a_id as $key => $val) {
  32. $insert_data["uid"] = $user->id;
  33. $insert_data["pid"] = $pid;
  34. $insert_data["duties"] = $val;
  35. $insert_data["audit"] = 0;
  36. $insert_data["addtime"] = time();
  37. $insert_data["lager"] = $c_id;
  38. ResumeAuthInfo::create($insert_data);
  39. }
  40. }
  41. DB::commit();
  42. return ['code' => 1, 'info' => '保存成功!'];
  43. } catch (\Exception $e) {
  44. DB::rollback();
  45. return ['code' => 0, 'info' => '保存失败!'];
  46. }
  47. }
  48. public function isOwn($data, $user = '')
  49. {
  50. $where['id'] = $data['pid'];
  51. $where['uid'] = $user->id;
  52. $resume = Resume::where($where)->first();
  53. if (!$resume) {
  54. throw new ResponseException('对不起,您只能操作自己的简历!');
  55. }
  56. }
  57. }