Explorar o código

add resume api

wang jun %!s(int64=3) %!d(string=hai) anos
pai
achega
df66852444

+ 64 - 0
application/index/controller/Resume.php

@@ -0,0 +1,64 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 10:57:14
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 13:24:23
+ * 微信类
+ */
+namespace app\index\controller;
+
+use app\index\logic\resumelogic;
+use think\Controller;
+
+class Resume extends Base
+{
+    /**
+     * 新增简历
+     * 20220119
+     * wj
+     */
+    public function newinfobyopenid()
+    {
+        $param = request()->param();
+        $l_r = new resumelogic();
+        $result = $l_r->newinfo($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        } else {
+            return backjson(200, $result['data']);
+        }
+    }
+    /**
+     * 新增教育背景
+     * 20220119
+     * wj
+     */
+    public function saveebbyopenid()
+    {
+        $param = request()->param();
+        $l_r = new resumelogic();
+        $result = $l_r->newebinfo($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        } else {
+            return backjson(200, $result['data']);
+        }
+    }
+    /**
+     * 新增工作经历
+     * 20220119
+     * wj
+     */
+    public function savewebyopenid()
+    {
+        $param = request()->param();
+        $l_r = new resumelogic();
+        $result = $l_r->newweinfo($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        } else {
+            return backjson(200, $result['data']);
+        }
+    }
+}

+ 1 - 1
application/index/logic/baselogic.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 11:12:23
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:33:22
+ * @Last Modified time: 2022-01-19 13:36:02
  * 微信类
  */
 namespace app\index\logic;

+ 135 - 0
application/index/logic/resumelogic.php

@@ -0,0 +1,135 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 11:12:23
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 13:36:15
+ * 微信类
+ */
+namespace app\index\logic;
+
+use app\index\model\educationbackgroundemodel;
+use app\index\model\resumemodel;
+use app\index\model\usermodel;
+use app\index\model\workexperiencemodel;
+
+class resumelogic extends baselogic
+{
+    /**
+     * 设置请求数据规则
+     * 20220107
+     * wj
+     */
+    protected function setrules()
+    {
+        $list = [
+            'newinfo' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+            'newebinfo' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+            'newweinfo' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+        ];
+        return $list;
+    }
+    /**
+     * 新增信息
+     * 20200119
+     * wj
+     */
+    public function newinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $uinfo = $m_u->getinfobyopenid($openid);
+        if (empty($uinfo)) {
+            return backarr(0, "用户信息不存在");
+        }
+        $userid = $uinfo['id'];
+        $m_r = new resumemodel();
+        $rinfo = $m_r->getinfobyuserid($userid);
+        if (!empty($rinfo)) {
+            return backarr(0, "简历已存在");
+        }
+        $arr['user_id'] = $uinfo['id'];
+        $id = $m_r->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "新增失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+    /**
+     * 新增教育背景
+     * 20200119
+     * wj
+     */
+    public function newebinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $uinfo = $m_u->getinfobyopenid($openid);
+        if (empty($uinfo)) {
+            return backarr(0, "用户信息不存在");
+        }
+        $userid = $uinfo['id'];
+        $m_r = new resumemodel();
+        $rinfo = $m_r->getinfobyuserid($userid);
+        if (empty($rinfo)) {
+            return backarr(0, "简历不存在");
+        }
+        $resumeid = $rinfo['id'];
+        $arr['resume_id'] = $resumeid;
+        $arr['user_id'] = $userid;
+        $m_eb = new educationbackgroundemodel();
+        $id = $m_eb->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "新增失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+
+    }
+    /**
+     * 新增工作经历
+     * 20200119
+     * wj
+     */
+    public function newweinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $uinfo = $m_u->getinfobyopenid($openid);
+        if (empty($uinfo)) {
+            return backarr(0, "用户信息不存在");
+        }
+        $userid = $uinfo['id'];
+        $m_r = new resumemodel();
+        $rinfo = $m_r->getinfobyuserid($userid);
+        if (empty($rinfo)) {
+            return backarr(0, "简历不存在");
+        }
+        $resumeid = $rinfo['id'];
+        $arr['resume_id'] = $resumeid;
+        $arr['user_id'] = $userid;
+        $m_we = new workexperiencemodel();
+        $id = $m_we->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "新增失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+}

+ 8 - 2
application/index/logic/userlogic.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 11:12:23
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:24:58
+ * @Last Modified time: 2022-01-19 13:31:28
  * 微信类
  */
 namespace app\index\logic;
@@ -43,8 +43,14 @@ class userlogic extends baselogic
         if (1 != $result['status']) {
             return $result;
         }
+        $openid = $arr['openid'];
         $m_u = new usermodel();
-        $id = $m_u->insertData($arr);
+        $uinfo = $m_u->getinfobyopenid($openid);
+        if (!empty($uinfo)) {
+            $id = $uinfo['id'];
+        } else {
+            $id = $m_u->insertData($arr);
+        }
         if (empty($id)) {
             return backarr(0, "新增失败");
         }

+ 24 - 1
application/index/model/companymodel.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 09:43:33
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-18 16:58:11
+ * @Last Modified time: 2022-01-19 13:28:44
  */
 namespace app\index\model;
 
@@ -18,10 +18,29 @@ class companymodel extends Model
         if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
             $data['create_time'] = date("Y-m-d H:i:s");
         }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
         $id = $this->insertGetId($data);
         return empty($id) ? false : $id;
     }
 
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($fields as $key => $value) {
+            if (isset($data[$value])) {
+                $useData[$value] = $data[$value];
+            }
+        }
+        return $useData;
+    }
     public function getInfo($where, $field = "*", $row = true)
     {
         $info = $this->field($field)->where($where);
@@ -80,6 +99,10 @@ class companymodel extends Model
     public function updatebyid($id, $updateData)
     {
         $where = ['id' => $id];
+        $updateData = $this->formatData($updateData);
+        if (empty($updateData)) {
+            return false;
+        }
         $row = $this->where($where)->update($updateData);
         return $row;
     }

+ 120 - 0
application/index/model/educationbackgroundemodel.php

@@ -0,0 +1,120 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 13:28:56
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class educationbackgroundemodel extends Model
+{
+    protected $table = 't_education_background';
+
+    public function insertData($data)
+    {
+        if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
+            $data['create_time'] = date("Y-m-d H:i:s");
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($fields as $key => $value) {
+            if (isset($data[$value])) {
+                $useData[$value] = $data[$value];
+            }
+        }
+        return $useData;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /**
+     * 根据userid获取信息
+     * wj
+     * 20220119
+     */
+    public function getinfobyuserid($userid)
+    {
+        $where = ['user_id' => $userid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /**
+     * 根据resumeid获取信息
+     * wj
+     * 20220119
+     */
+    public function getinfobyresumeid($resumeid)
+    {
+        $where = ['resume_id' => $resumeid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+
+    /**
+     * 根据id修改数据
+     * wj
+     * 20220118
+     */
+    public function updatebyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $updateData = $this->formatData($updateData);
+        if (empty($updateData)) {
+            return false;
+        }
+        $row = $this->where($where)->update($updateData);
+        return $row;
+    }
+}

+ 107 - 0
application/index/model/resumemodel.php

@@ -0,0 +1,107 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 13:29:15
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class resumemodel extends Model
+{
+    protected $table = 't_resume';
+
+    public function insertData($data)
+    {
+        if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
+            $data['create_time'] = date("Y-m-d H:i:s");
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($fields as $key => $value) {
+            if (isset($data[$value])) {
+                $useData[$value] = $data[$value];
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /**
+     * 根据userid获取信息
+     * wj
+     * 20220119
+     */
+    public function getinfobyuserid($userid)
+    {
+        $where = ['user_id' => $userid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /**
+     * 根据id修改数据
+     * wj
+     * 20220118
+     */
+    public function updatebyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $updateData = $this->formatData($updateData);
+        if (empty($updateData)) {
+            return false;
+        }
+        $row = $this->where($where)->update($updateData);
+        return $row;
+    }
+}

+ 25 - 2
application/index/model/usermodel.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 09:43:33
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-18 16:10:40
+ * @Last Modified time: 2022-01-19 11:41:57
  */
 namespace app\index\model;
 
@@ -18,10 +18,29 @@ class usermodel extends Model
         if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
             $data['create_time'] = date("Y-m-d H:i:s");
         }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+
         $id = $this->insertGetId($data);
         return empty($id) ? false : $id;
     }
-
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($fields as $key => $value) {
+            if (isset($data[$value])) {
+                $useData[$value] = $data[$value];
+            }
+        }
+        return $useData;
+    }
     public function getInfo($where, $field = "*", $row = true)
     {
         $info = $this->field($field)->where($where);
@@ -125,6 +144,10 @@ class usermodel extends Model
     public function updatebyid($id, $updateData)
     {
         $where = ['id' => $id];
+        $updateData = $this->formatData($updateData);
+        if (empty($updateData)) {
+            return false;
+        }
         $row = $this->where($where)->update($updateData);
         return $row;
     }

+ 119 - 0
application/index/model/workexperiencemodel.php

@@ -0,0 +1,119 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 13:37:45
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class workexperiencemodel extends Model
+{
+    protected $table = 't_work_experience';
+
+    public function insertData($data)
+    {
+        if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
+            $data['create_time'] = date("Y-m-d H:i:s");
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($fields as $key => $value) {
+            if (isset($data[$value])) {
+                $useData[$value] = $data[$value];
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /**
+     * 根据userid获取信息
+     * wj
+     * 20220119
+     */
+    public function getinfobyuserid($userid)
+    {
+        $where = ['user_id' => $userid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /**
+     * 根据resumeid获取信息
+     * wj
+     * 20220119
+     */
+    public function getinfobyresumeid($resumeid)
+    {
+        $where = ['resume_id' => $resumeid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+
+    /**
+     * 根据id修改数据
+     * wj
+     * 20220118
+     */
+    public function updatebyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $updateData = $this->formatData($updateData);
+        if (empty($updateData)) {
+            return false;
+        }
+        $row = $this->where($where)->update($updateData);
+        return $row;
+    }
+}