1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Services\Person;
- use App\Exceptions\ResponseException;
- use App\Models\Resume;
- use App\Models\ResumeAuthInfo;
- use App\Services\Person\ResumeService;
- use Illuminate\Support\Facades\DB;
- class ResumeMaterialService
- {
- protected $resumeService;
- public function __construct(ResumeService $resumeService)
- {
- $this->resumeService = $resumeService;
- }
- public function resumeUpdate($data, $user = '')
- {
- $pid = $data['pid'];//简历的id
- $c_id = $data['c_id'];//大分类id,论文、荣誉大分类id
- $a_id = $data['a_id'];//小分类id,依据小分类personal_category的id
- //全删除当前保存大分类下对应uid、简历的表中保存信息
- $where["uid"] = $user->id;
- $where["pid"] = $pid;
- $where["lager"] = $c_id;
- DB::beginTransaction();
- try {
- ResumeAuthInfo::where($where)->delete();
- $this->resumeService->antic_personnel($user->id);
- $insert_data = [];
- //添加对应信息
- if (!empty($a_id)) {
- foreach ($a_id as $key => $val) {
- $insert_data["uid"] = $user->id;
- $insert_data["pid"] = $pid;
- $insert_data["duties"] = $val;
- $insert_data["audit"] = 0;
- $insert_data["addtime"] = time();
- $insert_data["lager"] = $c_id;
- ResumeAuthInfo::create($insert_data);
- }
- }
- DB::commit();
- return ['code' => 1, 'info' => '保存成功!'];
- } catch (\Exception $e) {
- DB::rollback();
- return ['code' => 0, 'info' => '保存失败!'];
- }
- }
- public function isOwn($data, $user = '')
- {
- $where['id'] = $data['pid'];
- $where['uid'] = $user->id;
- $resume = Resume::where($where)->first();
- if (!$resume) {
- throw new ResponseException('对不起,您只能操作自己的简历!');
- }
- }
- }
|