wang jun 3 éve
szülő
commit
03c15c2a36

+ 4 - 4
application/index/logic/userlogic.php

@@ -32,9 +32,9 @@ class userlogic extends baselogic
             'getfieldbyopenid' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
-            'getfieldbyid'=>[
+            'getfieldbyid' => [
                 ['name' => 'userid', 'title' => 'userid', 'require' => true, 'type' => 'string'],
-            ]
+            ],
         ];
         return $list;
     }
@@ -170,7 +170,7 @@ class userlogic extends baselogic
         }
         $openid = $arr['openid'];
         $m_u = new usermodel();
-        $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company"];
+        $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company", "company_id", "origin", "nation", "address"];
         $info = $m_u->getfieldbyopenid($openid, $field);
         if (empty($info)) {
             return backarr(0, '无用户');
@@ -190,7 +190,7 @@ class userlogic extends baselogic
         }
         $userid = $arr['userid'];
         $m_u = new usermodel();
-        $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company"];
+        $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company", "company_id", "origin", "nation", "address"];
         $info = $m_u->getfieldbyid($userid, $field);
         if (empty($info)) {
             return backarr(0, '无用户');

+ 47 - 0
application/index/logic/userloglogic.php

@@ -0,0 +1,47 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 11:12:23
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 15:48:53
+ * 微信类
+ */
+namespace app\index\logic;
+
+use app\index\model\userlogmodel;
+
+class userloglogic extends baselogic
+{
+    /**
+     * 设置请求数据规则
+     * 20220107
+     * wj
+     */
+    protected function setrules()
+    {
+        $list = [
+            'addlog' => [
+
+            ],
+        ];
+        return $list;
+    }
+    /**
+     * 新建用户日志
+     * wj
+     * 20220118
+     */
+    public function addlog($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $m_u = new userlogmodel();
+        $id = $m_u->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "新增失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+}

+ 82 - 0
application/index/model/userlogmodel.php

@@ -0,0 +1,82 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 15:42:39
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class usermodel extends Model
+{
+    protected $table = 't_userlog';
+
+    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;
+    }
+}