workermodel = new workermodel(); $this->userinfomodel = new userinfomodel(); } public function getinfobyid($id) { $where = ['id' => $id]; $info = $this->workermodel->getInfo($where); return $info; } public function getinfobyuserid($userid) { $where = ['userid' => $userid]; $info = $this->workermodel->getInfo($where); return $info; } public function insertinfo($info) { $userid = $info['userid']; if (empty($userid)) { return backjson(0, "请求数据错误"); } $userinfo = $this->userinfomodel->getInfo(['id' => $userid], 'id'); if (!$userinfo) { return backArr(0, "无用户信息"); } $workinfo = $this->getinfobyuserid($userid); if ($workinfo) { return backArr(0, "用户信息已存在"); } $id = $this->workermodel->insertData($info); if (!$id) { return backArr(0, "添加失败"); } return backArr(1, "添加成功", ['id' => $id]); } public function updateinfobyid($id, $updateData) { $where = ['id' => $id]; $result = $this->workermodel->updateinfo($where, $updateData); return $result; } public function updateinfobyuserid($userid, $updateData) { $where = ['userid' => $userid]; $result = $this->workermodel->updateinfo($where, $updateData); return $result; } }