12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- * 系统用户
- */
- namespace app\common\model;
- use think\Model;
- class Sysusermodel extends Model
- {
- protected $table = 'sys_user';
- public function insertData($data)
- {
- $field = $this->getTableFields();
- $insertData = [];
- foreach ($field as $key => $value) {
- if (in_array($value, array_keys($data))) {
- $insertData[$value] = $data[$value];
- }
- }
- unset($insertData['id']);
- $data = $insertData;
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- 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->count();
- }
- return $data;
- }
- /**
- * 根据token获取用户信息
- *
- * @param [type] $token
- * @return void
- * @author wj
- * @date 2023-09-02
- */
- public function getinfobytoken($token)
- {
- $where = ['token' => $token];
- $field = $this->getTableFields();
- unset($field['password']);
- $info = $this->field($field)->where($where)->find();
- return empty($info) ? false : $info;
- }
- }
|