Bläddra i källkod

add invent api

wang jun 3 år sedan
förälder
incheckning
5eadc52026

+ 31 - 1
application/index/controller/Company.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 10:57:14
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:27:57
+ * @Last Modified time: 2022-01-19 15:56:26
  * 微信类
  */
 namespace app\index\controller;
@@ -13,6 +13,11 @@ use think\Controller;
 
 class Company extends Base
 {
+    /**
+     * 新建数据
+     * 20220118
+     * wj
+     */
     public function newinfo()
     {
         $param = request()->param();
@@ -23,6 +28,11 @@ class Company extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 根据id获取信息
+     * 20220118
+     * wj
+     */
     public function getinfobyid()
     {
         $param = request()->param();
@@ -33,6 +43,11 @@ class Company extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 根据id修改信息
+     * 20220118
+     * wj
+     */
     public function updatebyid()
     {
         $param = request()->param();
@@ -43,4 +58,19 @@ class Company extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 根据id获取全部信息 包括岗位
+     * 20220118
+     * wj
+     */
+    public function getinfowitchinventbyid()
+    {
+        $param = request()->param();
+        $l_c = new companylogic();
+        $result = $l_c->getinfowitchinventbyid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
 }

+ 77 - 0
application/index/controller/Invent.php

@@ -0,0 +1,77 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 10:57:14
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 15:22:04
+ * 微信类
+ */
+namespace app\index\controller;
+
+use app\index\logic\inventlogic;
+use think\Controller;
+
+class Invent extends Base
+{
+    /**
+     * 新建信息
+     * 20220119
+     * wj
+     */
+    public function newinfo()
+    {
+        $param = request()->param();
+        $l_i = new inventlogic();
+        $result = $l_i->newinfo($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
+    /**
+     * 获取数据根据id
+     * 20220119
+     * wj
+     */
+    public function getinfobyid()
+    {
+        $param = request()->param();
+        $l_i = new inventlogic();
+        $result = $l_i->getinfobyid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
+    /**
+     * 获取列表根据id
+     * 20220119
+     * wj
+     */
+    public function getlist()
+    {
+        $param = request()->param();
+        $l_i = new inventlogic();
+        $result = $l_i->getlistbywhere($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
+    /**
+     * 修改数据根据id
+     * 20220119
+     * wj
+     */
+    public function updatebyid()
+    {
+        $param = request()->param();
+        $l_i = new inventlogic();
+        $result = $l_i->updatebyid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
+
+}

+ 19 - 4
application/index/controller/Resume.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 10:57:14
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 13:24:23
+ * @Last Modified time: 2022-01-19 15:32:41
  * 微信类
  */
 namespace app\index\controller;
@@ -22,7 +22,7 @@ class Resume extends Base
     {
         $param = request()->param();
         $l_r = new resumelogic();
-        $result = $l_r->newinfo($param);
+        $result = $l_r->newinfobyopenid($param);
         if (1 != $result['status']) {
             return backjson(0, $result['msg']);
         } else {
@@ -38,7 +38,7 @@ class Resume extends Base
     {
         $param = request()->param();
         $l_r = new resumelogic();
-        $result = $l_r->newebinfo($param);
+        $result = $l_r->newebinfobyopenid($param);
         if (1 != $result['status']) {
             return backjson(0, $result['msg']);
         } else {
@@ -54,11 +54,26 @@ class Resume extends Base
     {
         $param = request()->param();
         $l_r = new resumelogic();
-        $result = $l_r->newweinfo($param);
+        $result = $l_r->newweinfobyopenid($param);
         if (1 != $result['status']) {
             return backjson(0, $result['msg']);
         } else {
             return backjson(200, $result['data']);
         }
     }
+    /**
+     * 获取数据根据openid
+     * 20220119
+     * wj
+     */
+    public function getinfobyid()
+    {
+        $param = request()->param();
+        $l_r = new resumelogic();
+        $result = $l_r->getinfobyopenid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
 }

+ 31 - 1
application/index/controller/User.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 10:57:14
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:26:29
+ * @Last Modified time: 2022-01-19 15:46:05
  * 微信类
  */
 namespace app\index\controller;
@@ -13,6 +13,11 @@ use think\Controller;
 
 class User extends Base
 {
+    /**
+     * 新建数据
+     * 20220118
+     * wj
+     */
     public function newinfo()
     {
         $param = request()->param();
@@ -23,6 +28,11 @@ class User extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 实名认证
+     * 20220118
+     * wj
+     */
     public function realauth()
     {
         $param = request()->param();
@@ -33,6 +43,11 @@ class User extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 认证为企业
+     * 20220118
+     * wj
+     */
     public function authcompany()
     {
         $param = request()->param();
@@ -43,4 +58,19 @@ class User extends Base
         }
         return backjson(200, $result['data']);
     }
+    /**
+     * 根据openid获取字段
+     * 20220118
+     * wj
+     */
+    public function getfieldbyopenid()
+    {
+        $param = request()->param();
+        $l_u = new userlogic();
+        $result = $l_u->getfieldbyopenid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(200, $result['data']);
+    }
 }

+ 3 - 2
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 13:36:02
+ * @Last Modified time: 2022-01-19 15:58:46
  * 微信类
  */
 namespace app\index\logic;
@@ -43,7 +43,7 @@ class baselogic
                     $name = $value['name'];
                     $title = $value['title'];
                     //必填
-                    if ($value['require']) {
+                    if (isset($value['require']) && $value['require']) {
                         if (!isset($param[$name])) {
                             throw new \Exception($title . '未填');
                         }
@@ -88,5 +88,6 @@ class baselogic
                 return backarr(0, "请求错误");
             }
         }
+        return backarr(1, 'success');
     }
 }

+ 24 - 1
application/index/logic/companylogic.php

@@ -3,12 +3,13 @@
  * @Author: wang jun
  * @Date: 2022-01-18 11:12:23
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:28:59
+ * @Last Modified time: 2022-01-19 15:51:59
  * 微信类
  */
 namespace app\index\logic;
 
 use app\index\model\companymodel;
+use app\index\model\inventmodel;
 use app\index\model\usermodel;
 
 class companylogic extends baselogic
@@ -79,6 +80,28 @@ class companylogic extends baselogic
         }
         return backarr(1, "获取成功", $info);
     }
+    /**
+     * 根据id获取企业信息包括岗位
+     * wj
+     * 20220119
+     */
+    public function getinfowitchinventbyid($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $id = $arr['id'];
+        $m_c = new companymodel();
+        $info = $m_c->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $m_i = new inventmodel();
+        $ilist = $m_i->getlist(['company_id' => $info['id'], "*", 1, 0]);
+        $info['invent_list'] = $ilist;
+        return backarr(1, "获取成功", $info);
+    }
     /**
      * 根据id修改企业信息
      * wj

+ 151 - 0
application/index/logic/inventlogic.php

@@ -0,0 +1,151 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 11:12:23
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 16:07:27
+ * 微信类
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\inventmodel;
+use app\index\model\usermodel;
+
+class inventlogic extends baselogic
+{
+    /**
+     * 设置请求数据规则
+     * 20220107
+     * wj
+     */
+    protected function setrules()
+    {
+        $list = [
+            'newinfo' => [
+                ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
+                ['name' => 'openid', 'title' => 'openid', 'type' => 'string'],
+            ],
+            'getlistbywhere' => [
+                ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
+                ['name' => 'passstate', 'title' => 'passstate', 'type' => 'numeric', 'regex' => '[0|1|2]'],
+                ['name' => 'activestate', 'title' => 'activestate', 'type' => 'numeric', 'regex' => '[0|1]'],
+                ['name' => 'title', 'title' => 'title', 'type' => 'string', 'regex' => '*{5,}'],
+            ],
+            'updatebyid' => [
+                ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
+            ],
+            'getinfobyid' => [
+                ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
+            ],
+        ];
+        return $list;
+    }
+    /**
+     * 新建数据
+     * 20220119
+     * wj
+     */
+    public function newinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $companyid = $arr['companyid'];
+        $m_c = new companymodel();
+        $cinfo = $m_c->getinfobyid($companyid);
+        if (empty($cinfo)) {
+            return backarr(0, "企业信息不存在");
+        }
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $uinfo = $m_u->getinfobyopenid($openid);
+        if (empty($uinfo)) {
+            return backarr(0, "用户信息不存在");
+        }
+        $m_i = new inventmodel();
+        $arr['company_id'] = $companyid;
+        $arr['create_user_id'] = $uinfo['id'];
+        $id = $m_i->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "新增失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+    /**
+     * 获取列表数据 根据条件
+     * 20220119
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $companyid = $arr['companyid'];
+        $m_c = new companymodel();
+        $cinfo = $m_c->getinfobyid($companyid);
+        if (empty($cinfo)) {
+            return backarr(0, "企业信息不存在");
+        }
+        $m_i = new inventmodel();
+        $where = ['company_id' => $companyid];
+        if (isset($arr['title'])) {
+            $where['title'] = ['like' => '%' . $arr['title'] . '%'];
+        }
+        if (isset($arr['activestate'])) {
+            $where['active_state'] = $arr['passstate'];
+        }
+        if (isset($arr['passstate'])) {
+            $where['pass_state'] = $arr['passstate'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_i->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_i->getList($where, '*', $page, $size);
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 修改数据根据id
+     * 20220119
+     * wj
+     */
+    public function updatebyid($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $id = $arr['id'];
+        $m_i = new inventmodel();
+        $row = $m_i->updatebyid($id, $arr);
+        if (empty($row)) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "获取成功", ['id' => $id]);
+    }
+    /**
+     * 获取数据根据id
+     * 20220119
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $id = $arr['id'];
+        $m_i = new inventmodel();
+        $iinfo = $m_i->getinfobyid($id);
+        if (empty($iinfo)) {
+            return backarr(0, "数据不存在");
+        }
+        return backarr(1, "获取成功", $iinfo);
+    }
+}

+ 38 - 7
application/index/logic/resumelogic.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 13:36:15
+ * @Last Modified time: 2022-01-19 15:48:24
  * 微信类
  */
 namespace app\index\logic;
@@ -23,13 +23,16 @@ class resumelogic extends baselogic
     protected function setrules()
     {
         $list = [
-            'newinfo' => [
+            'newinfobyopenid' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
-            'newebinfo' => [
+            'newebinfobyopenid' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
-            'newweinfo' => [
+            'newweinfobyopenid' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+            'getinfobyopenid' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
         ];
@@ -40,7 +43,7 @@ class resumelogic extends baselogic
      * 20200119
      * wj
      */
-    public function newinfo($arr)
+    public function newinfobyopenid($arr)
     {
         $result = $this->checkparam(__FUNCTION__, $arr);
         if (1 != $result['status']) {
@@ -70,7 +73,7 @@ class resumelogic extends baselogic
      * 20200119
      * wj
      */
-    public function newebinfo($arr)
+    public function newebinfobyopenid($arr)
     {
         $result = $this->checkparam(__FUNCTION__, $arr);
         if (1 != $result['status']) {
@@ -104,7 +107,7 @@ class resumelogic extends baselogic
      * 20200119
      * wj
      */
-    public function newweinfo($arr)
+    public function newweinfobyopenid($arr)
     {
         $result = $this->checkparam(__FUNCTION__, $arr);
         if (1 != $result['status']) {
@@ -132,4 +135,32 @@ class resumelogic extends baselogic
         }
         return backarr(1, "新增成功", ['id' => $id]);
     }
+
+    public function getinfobyopenid($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'];
+        $m_eb = new educationbackgroundemodel();
+        $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
+        $rinfo['eblist'] = $eblist;
+        $m_we = new workexperiencemodel();
+        $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
+        $rinfo['welist'] = $welist;
+        return backarr(1, "查询成功", $rinfo);
+    }
 }

+ 24 - 1
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 13:31:28
+ * @Last Modified time: 2022-01-19 15:48:53
  * 微信类
  */
 namespace app\index\logic;
@@ -29,6 +29,9 @@ class userlogic extends baselogic
             'updateiscompanybyopenid' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
+            'getfieldbyopenid' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
         ];
         return $list;
     }
@@ -151,4 +154,24 @@ class userlogic extends baselogic
         $m_u->updateiscompanybyopenid($openid, 1);
         return backarr(1, '修改成功', ['id' => $info['id']]);
     }
+    /**
+     * 获取数据根据openid
+     * wj
+     * 20220118
+     */
+    public function getfieldbyopenid($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company"];
+        $info = $m_u->getfieldbyopenid($openid, $field);
+        if (empty($info)) {
+            return backarr(0, '无用户');
+        }
+        return backarr(1, '查询成功', $info);
+    }
 }

+ 4 - 4
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-19 13:28:44
+ * @Last Modified time: 2022-01-19 14:11:48
  */
 namespace app\index\model;
 
@@ -34,9 +34,9 @@ class companymodel extends Model
     {
         $useData = [];
         $fields = $this->getTableFields();
-        foreach ($fields as $key => $value) {
-            if (isset($data[$value])) {
-                $useData[$value] = $data[$value];
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
             }
         }
         return $useData;

+ 4 - 4
application/index/model/educationbackgroundemodel.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-19 13:28:56
+ * @Last Modified time: 2022-01-19 15:29:03
  */
 namespace app\index\model;
 
@@ -33,9 +33,9 @@ class educationbackgroundemodel extends Model
     {
         $useData = [];
         $fields = $this->getTableFields();
-        foreach ($fields as $key => $value) {
-            if (isset($data[$value])) {
-                $useData[$value] = $data[$value];
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
             }
         }
         return $useData;

+ 107 - 0
application/index/model/inventmodel.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 15:06:15
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class inventmodel extends Model
+{
+    protected $table = 't_invent';
+
+    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 ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $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 getinfobyid($id)
+    {
+        $where = ['id' => $id];
+        $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;
+    }
+}

+ 4 - 4
application/index/model/resumemodel.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-19 13:29:15
+ * @Last Modified time: 2022-01-19 14:11:58
  */
 namespace app\index\model;
 
@@ -33,9 +33,9 @@ class resumemodel extends Model
     {
         $useData = [];
         $fields = $this->getTableFields();
-        foreach ($fields as $key => $value) {
-            if (isset($data[$value])) {
-                $useData[$value] = $data[$value];
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
             }
         }
         return $useData;

+ 15 - 4
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-19 11:41:57
+ * @Last Modified time: 2022-01-19 15:42:39
  */
 namespace app\index\model;
 
@@ -34,9 +34,9 @@ class usermodel extends Model
     {
         $useData = [];
         $fields = $this->getTableFields();
-        foreach ($fields as $key => $value) {
-            if (isset($data[$value])) {
-                $useData[$value] = $data[$value];
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
             }
         }
         return $useData;
@@ -90,6 +90,17 @@ class usermodel extends Model
         $info = $this->where($where)->find();
         return $info;
     }
+    /**
+     * 根据openid获取信息
+     * wj
+     * 20220118
+     */
+    public function getfieldbyopenid($openid, $field = "")
+    {
+        $where = ['openid' => $openid];
+        $info = $this->field($field)->where($where)->find();
+        return $info;
+    }
     /**
      * 根据openid获取信息
      * wj

+ 4 - 4
application/index/model/workexperiencemodel.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-19 13:37:45
+ * @Last Modified time: 2022-01-19 14:12:06
  */
 namespace app\index\model;
 
@@ -33,9 +33,9 @@ class workexperiencemodel extends Model
     {
         $useData = [];
         $fields = $this->getTableFields();
-        foreach ($fields as $key => $value) {
-            if (isset($data[$value])) {
-                $useData[$value] = $data[$value];
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
             }
         }
         return $useData;