wzh %!s(int64=5) %!d(string=hai) anos
pai
achega
4369aefcc2

+ 6 - 6
api/application/config/database.php

@@ -77,9 +77,9 @@ if (ENVIRONMENT === 'production') {
 	$db['default'] = array(
 		'dsn'	=> '',
 		'hostname' => 'rm-wz98r5cn33zq4ou980o.mysql.rds.aliyuncs.com',
-		'username' => 'inhealth',
-		'password' => 'inhealth@2019',
-		'database' => 'inhealth',
+		'username' => 'idcol20',
+		'password' => 'idcol@1234',
+		'database' => 'idcol',
 		'dbdriver' => 'mysqli',
 		'dbprefix' => '',
 		'pconnect' => FALSE,
@@ -99,9 +99,9 @@ if (ENVIRONMENT === 'production') {
 	$db['default'] = array(
 		'dsn'	=> '',
 		'hostname' => 'rm-wz98r5cn33zq4ou980o.mysql.rds.aliyuncs.com',
-		'username' => 'inhealth',
-		'password' => 'inhealth@2019',
-		'database' => 'inhealth',
+		'username' => 'idcol20',
+		'password' => 'idcol@1234',
+		'database' => 'idcol',
 		'dbdriver' => 'mysqli',
 		'dbprefix' => '',
 		'pconnect' => FALSE,

+ 2 - 184
api/application/config/response.php

@@ -25,98 +25,7 @@ $config['response']['0101'] = '用户名或密码错误';
 $config['response']['0102'] = '用户不存在';
 $config['response']['0103'] = '当前账号已被停用';
 $config['response']['0104'] = '用户名不能为空';
-$config['response']['0105'] = '请输入验证码';
-$config['response']['0106'] = '验证码已经过期';
-$config['response']['0107'] = '验证码错误';
-$config['response']['0108'] = '请输入登录账号';
-$config['response']['0109'] = '请输入邮箱地址';
-$config['response']['0110'] = '账号未绑定邮箱地址';
-$config['response']['0111'] = '请输入新密码';
-$config['response']['0112'] = '验证错误';
-$config['response']['0113'] = '新密码跟旧密码不能相同';
-// 区域管理 0200-0299
-$config['response']['0200'] = '未查询到房间';
-$config['response']['0201'] = '请选择区域';
-$config['response']['0202'] = '请填写酒店名称';
-$config['response']['0203'] = '酒店名称不能超过20位';
-$config['response']['0204'] = '酒店名称重复';
-$config['response']['0205'] = '请选择酒店';
-$config['response']['0206'] = '请填写楼层数';
-$config['response']['0207'] = '楼层数必须为大于1的整数';
-$config['response']['0208'] = '请填写楼房名称';
-$config['response']['0209'] = '楼房名称不能超过20位';
-$config['response']['0210'] = '楼房名称已经存在';
-$config['response']['0211'] = '请选择楼房';
-$config['response']['0212'] = '请填写房间编号';
-$config['response']['0213'] = '房间编号格式错误,只能填写字母或数字';
-$config['response']['0214'] = '房间编号长度不能超过20位';
-$config['response']['0215'] = '房间编号已经存在';
-$config['response']['0216'] = '请先删除酒店下的楼房';
-$config['response']['0217'] = '请先删除楼房里的房间';
-$config['response']['0218'] = '请先删除房间里的设备';
-$config['response']['0219'] = '请选择开始楼层';
-$config['response']['0220'] = '请选择结束楼层';
-$config['response']['0221'] = '结束楼层必须大于开始楼层';
-$config['response']['0222'] = '请先删除楼层中的房间';
-$config['response']['0223'] = '房间SN号不能为空';
-// 设备管理 0300-0399
-$config['response']['0300'] = '设备名称不能为空';
-$config['response']['0301'] = '设备名称不能超过20位';
-$config['response']['0302'] = '设备ID不能为空';
-$config['response']['0303'] = '请选择楼层';
-$config['response']['0304'] = '请选择房间';
-$config['response']['0305'] = '设备名称已经存在';
-$config['response']['0306'] = '设备ID已经存在';
-$config['response']['0307'] = '设备ID为1-255的整数';
-$config['response']['0308'] = '数据更新失败,请稍后重试';
-$config['response']['0309'] = '设备编号已经存在';
-$config['response']['0310'] = '请填写设备编号';
-$config['response']['0311'] = '请选择新建设备';
-$config['response']['0312'] = '请填写列数';
-$config['response']['0313'] = '请先复制需要拷贝的设备';
-$config['response']['0314'] = '请先选择需要删除的设备';
-$config['response']['0315'] = '删除设备失败,请稍后重试';
-$config['response']['0316'] = '绑定设备失败,请稍后重试';
-$config['response']['0317'] = '设备未绑定网关';
-$config['response']['0318'] = '设备不存在';
-$config['response']['0319'] = '色温值范围错误';
-$config['response']['0320'] = '设备不支持';
-$config['response']['0321'] = '设备已关闭';
-$config['response']['0322'] = '设备不在线';
-$config['response']['0323'] = '文件名已经存在';
-$config['response']['0324'] = '未检测到设备版本信息,请尝试重新绑定设备';
-$config['response']['0325'] = '设备不支持';
-$config['response']['0326'] = '房间未绑定sensor设备';
-$config['response']['0327'] = '自动模式AQI值范围错误';
-// 用户管理 0400-0499
-$config['response']['0400'] = '名称不能为空';
-$config['response']['0401'] = '账号名称不能为空';
-$config['response']['0402'] = '账号名称必须为字母、数字或下划线组成';
-$config['response']['0403'] = '账号名称不能超过20位';
-$config['response']['0404'] = '名称已经存在';
-$config['response']['0405'] = '账号名称已经存在';
-$config['response']['0406'] = '手机号码格式错误';
-$config['response']['0407'] = '邮箱格式错误';
-$config['response']['0408'] = '密码不能为空';
-$config['response']['0409'] = '密码长度为6-16位';
-$config['response']['0410'] = '旧密码不能为空';
-$config['response']['0411'] = '新密码不能为空';
-$config['response']['0412'] = '确认密码错误';
-$config['response']['0413'] = '确认密码不能为空';
-$config['response']['0414'] = '旧密码错误';
-$config['response']['0415'] = '该人员已经存在';
-// 网关管理 0500-0599
-$config['response']['0500'] = '房间已经绑定填写的网关';
-$config['response']['0501'] = '网关ID已经存在';
-$config['response']['0502'] = '请先移除网关下的设备';
-$config['response']['0503'] = '未上传固件版本,请联系管理员';
-$config['response']['0504'] = '网关正在升级';
-// 故障管理 0600-0699
-$config['response']['0600'] = '故障还未处理,不能删除';
-$config['response']['0601'] = '手机号码不能为空';
-$config['response']['0602'] = '邮箱地址不能为空';
-$config['response']['0603'] = '手机号码已经存在';
-$config['response']['0604'] = '邮箱地址已经存在';
+
 
 // 英文版
 //通用 0000-0099
@@ -143,98 +52,7 @@ $config['response_en']['0101'] = 'ERROR Incorrect username or password';
 $config['response_en']['0102'] = 'User does not exist';
 $config['response_en']['0103'] = 'Account disabled';
 $config['response_en']['0104'] = 'User name can not be empty';
-$config['response_en']['0105'] = 'Please enter the verification code';
-$config['response_en']['0106'] = 'The verification code has expired';
-$config['response_en']['0107'] = 'Verification code error';
-$config['response_en']['0108'] = 'Please enter the login account';
-$config['response_en']['0109'] = 'Please enter email address';
-$config['response_en']['0110'] = 'Account is not bound to email address';
-$config['response_en']['0111'] = 'Please enter a new password';
-$config['response_en']['0112'] = 'Verification error';
-$config['response_en']['0113'] = 'The new password cannot be the same as the old password';
-// 区域管理 0200-0299
-$config['response_en']['0200'] = 'Room not found';
-$config['response_en']['0201'] = 'Please select area';
-$config['response_en']['0202'] = 'Please fill in the hotel name';
-$config['response_en']['0203'] = 'No more than 20 Hotel Names';
-$config['response_en']['0204'] = 'Duplicate hotel name';
-$config['response_en']['0205'] = 'Please select a hotel';
-$config['response_en']['0206'] = 'Please fill in the floor';
-$config['response_en']['0207'] = 'Number of floors must be an integer greater than 1';
-$config['response_en']['0208'] = 'Please fill in the building name';
-$config['response_en']['0209'] = 'Building name cannot exceed 20';
-$config['response_en']['0210'] = 'Building name already exists';
-$config['response_en']['0211'] = 'Please select a building';
-$config['response_en']['0212'] = 'Please fill in the room number';
-$config['response_en']['0213'] = 'Wrong room number format, only letters or numbers can be filled in';
-$config['response_en']['0214'] = 'Room number length cannot exceed 20 digits';
-$config['response_en']['0215'] = 'Room number already exists';
-$config['response_en']['0216'] = 'Please delete the building under the hotel first';
-$config['response_en']['0217'] = 'Please delete the rooms in the building first';
-$config['response_en']['0218'] = 'Please delete the equipment in the room first';
-$config['response_en']['0219'] = 'Please select the start floor';
-$config['response_en']['0220'] = 'Please select the close floor';
-$config['response_en']['0221'] = 'The end floor must be greater than the beginning floor';
-$config['response_en']['0222'] = 'Please delete the room on the floor first';
-$config['response_en']['0223'] = 'Room Sn number cannot be empty';
-// 灯控设备管理 0300-0399
-$config['response_en']['0300'] = 'Device name cannot be empty';
-$config['response_en']['0301'] = 'Device name cannot exceed 20 digits';
-$config['response_en']['0302'] = 'Device ID cannot be empty';
-$config['response_en']['0303'] = 'Please select a floor';
-$config['response_en']['0304'] = 'Please select a room';
-$config['response_en']['0305'] = 'Device name already exists';
-$config['response_en']['0306'] = 'Device ID already exists';
-$config['response_en']['0307'] = 'Integer with device ID 1-255';
-$config['response_en']['0308'] = 'Data update failed, please try again later';
-$config['response_en']['0309'] = 'Device number already exists';
-$config['response_en']['0310'] = 'Please fill in the equipment number';
-$config['response_en']['0311'] = 'Please select a new device';
-$config['response_en']['0312'] = 'Please fill in the number of columns';
-$config['response_en']['0313'] = 'Please copy the device to be copied first';
-$config['response_en']['0314'] = 'Please select the device to be deleted first';
-$config['response_en']['0315'] = 'Failed to delete device, please try again later';
-$config['response_en']['0316'] = 'Failed to bind device, please try again later';
-$config['response_en']['0317'] = 'Device not bound to gateway';
-$config['response_en']['0318'] = 'Device does not exist';
-$config['response_en']['0319'] = 'Color temperature value range error';
-$config['response_en']['0320'] = 'Device does not support';
-$config['response_en']['0321'] = 'Device is off';
-$config['response_en']['0322'] = 'Device not online';
-$config['response_en']['0323'] = 'File name already exists';
-$config['response_en']['0324'] = 'Device version information not detected, try rebinding device';
-$config['response_en']['0325'] = 'Device not supported';
-$config['response_en']['0326'] = 'Sensor device is not bound to the room';
-$config['response_en']['0327'] = 'Automatic mode AQI value range error';
-// 用户管理 0400-0499
-$config['response_en']['0400'] = 'Name cannot be empty';
-$config['response_en']['0401'] = 'Account name cannot be empty';
-$config['response_en']['0402'] = 'Account name must be composed of letters, numbers or underscores';
-$config['response_en']['0403'] = 'Account name cannot exceed 20 digits';
-$config['response_en']['0404'] = 'Name already exists';
-$config['response_en']['0405'] = 'Account name already exists';
-$config['response_en']['0406'] = 'Mobile number format error';
-$config['response_en']['0407'] = 'Mailbox format error';
-$config['response_en']['0408'] = 'Password cannot be empty';
-$config['response_en']['0409'] = 'Password length is 6-16 bits';
-$config['response_en']['0410'] = 'Old password cannot be empty';
-$config['response_en']['0411'] = 'New password cannot be empty';
-$config['response_en']['0412'] = 'Confirm password error';
-$config['response_en']['0413'] = 'Confirm password cannot be empty';
-$config['response_en']['0414'] = 'Old password error';
-$config['response_en']['0415'] = 'The person already exists';
-// 网关管理 0500-0599
-$config['response_en']['0500'] = 'The room has been bound to the gateway you filled in';
-$config['response_en']['0501'] = 'Gateway ID already exists';
-$config['response_en']['0502'] = 'Please remove the device under the gateway first';
-$config['response_en']['0503'] = 'Firmware version not uploaded, please contact administrator';
-$config['response_en']['0504'] = 'Gateway upgrading';
-// 故障管理 0600-0699
-$config['response_en']['0600'] = 'The fault has not been handled and cannot be deleted';
-$config['response_en']['0601'] = 'Mobile number cannot be empty';
-$config['response_en']['0602'] = 'Email address cannot be empty';
-$config['response_en']['0603'] = 'Mobile number already exists';
-$config['response_en']['0604'] = 'Email address already exists';
+
 
 
 

+ 1 - 253
api/application/controllers/Base_Controller.php

@@ -11,58 +11,15 @@ class Base_Controller extends CI_Controller {
 
         parent::__construct();
         $this->os = intval($this->input->post('os',true));
-        // if ($version === null) {
-        //     $version = $this->session->userdata('version');
-        // }
 
         $this->response = $this->config->config['response_en'];
-        $this->load->model('Operation_model');
-        $this->load->model('Room_model');
-        $this->load->model('Build_model');
-        $this->load->model('Hotel_model');
-        $this->load->model('Global_location_model');
         $this->load->model('User_model');
-        $this->load->model('Floor_model');
-        $this->load->model('Sensorlog_model');
-        $this->load->model('DevInfo_model');
-        $this->load->model('TempDevInfo_model');
-        $this->load->model('AlarmInfo_model');
-        $this->load->model('LampLog_model');
-        $this->load->model('AirPurifier_model');
-        $this->load->model('Network_model');
         $this->check_base_params();
 
         // 判断用户权限
         // $this->check_auth();
     }
-    // 检测用户权限
-    // private function check_auth(){
-    //     if ($this->userinfo['role'] != 1) {
-    //         $action = uri_string();
-    //         // 设置基本权限
-    //         $def = array();
-    //         if (!in_array($action, $def)) {
-    //             // 获取用户权限
-    //             $authid = $this->get_user_info('privilege_list');
-    //             if (empty($authid)) exit(json_result('0013',$this->response['0013']));
-    //             $authid = explode(',', $authid);
-    //             $this->load->model('Privilnode_model');
 
-    //             $actions = $this->Privilnode_model->get_list(['id'=>$authid],'action');
-    //             $actions = explode(',', implode(array_column($actions, 'action'), ','));
-                
-    //             if (!in_array($action, $actions)) {
-    //                 $asy_actions = ['group/inspectionSet','lamp/dimming','lamp/getParam','lamp/setParam','lamp/reset','group/set','lamp/update_lamp_info'];
-    //                 if (in_array($action, $asy_actions)) {
-    //                     $data = ['code'=>'0013','msg'=>$this->response['0013'],'data'=>['status'=>2]];
-    //                     $clientid = $this->input->post('clientid',true);
-    //                     exit(send_websocket($clientid,$data));
-    //                 }
-    //                 exit(json_result('0013',$this->response['0013']));
-    //             }
-    //         }
-    //     }
-    // }
     protected function check_base_params() {
         $username = $this->input->post('username',true);
         $token = $this->input->post('token',true);
@@ -120,216 +77,7 @@ class Base_Controller extends CI_Controller {
         ];
         $this->Operation_model->add($new);
     }
-    /**
-     * type  0 增加,1 减少 
-     * deviceType 设备类型(0 lights,1 circadian light,2 sensor,3 purifiers)
-     */
-    protected function change_room_device_count($roomId,$deviceType,$type,$count = 1){
-        if (empty($roomId)) return;
-        $roomData = $this->Room_model->get_one(array('id'=>$roomId),'deviceCount,lightCount,cicLightCount,sensorCount,airPurCount');
-        if (empty($roomData)) return;
-        if ($type == 1) {
-            $roomData['deviceCount'] = $roomData['deviceCount'] > $count ? $roomData['deviceCount'] - $count : 0;
-            if ($deviceType == 0) {
-                $roomData['lightCount'] = $roomData['lightCount'] > $count ? $roomData['lightCount'] - $count : 0;
-            }elseif ($deviceType == 1) {
-                $roomData['cicLightCount'] = $roomData['cicLightCount'] > $count ? $roomData['cicLightCount'] - $count : 0;
-            }elseif ($deviceType == 2) {
-                $roomData['sensorCount'] = $roomData['sensorCount'] > $count ? $roomData['sensorCount'] - $count : 0;
-            }else{
-                $roomData['airPurCount'] = $roomData['airPurCount'] > $count ? $roomData['airPurCount'] - $count : 0;
-            }
-        }else{
-            $roomData['deviceCount'] = $roomData['deviceCount'] + $count;
-            if ($deviceType == 0) {
-                $roomData['lightCount'] = $roomData['lightCount'] + $count;
-            }elseif ($deviceType == 1) {
-                $roomData['cicLightCount'] = $roomData['cicLightCount'] + $count;
-            }elseif ($deviceType == 2) {
-                $roomData['sensorCount'] = $roomData['sensorCount'] + $count;
-            }else{
-                $roomData['airPurCount'] = $roomData['airPurCount'] + $count;
-            }
-        }
-        $this->Room_model->update($roomData,array('id'=>$roomId));
-    }
-
-    // 获取时区,可根据房间、楼房、酒店、城市获取时区数据
-    protected function get_timezone($id = 0,$type = 0){
-        if (empty($id)) return 8;
-
-        $join = array(
-            ['table'=>'dev_info AS D','cond'=>'D.roomId = R.id','type'=>'left'],
-            ['table'=>'floor AS F','cond'=>'F.id = R.floorId','type'=>'left'],
-            ['table'=>'build AS B','cond'=>'F.buildId = B.id','type'=>'left'],
-            ['table'=>'hotel AS H','cond'=>'B.hotelId = H.id','type'=>'left'],
-            ['table'=>'global_location AS G','cond'=>'G.id = H.cityId','type'=>'left']
-        );
-        $where = array();
-        if ($type == ROOM) {
-            $where['R.id'] = $id;
-        }elseif ($type == HOTEL) {
-            $where['H.id'] = $id;
-        }elseif ($type == FLOOR) {
-            $where['F.id'] = $id;
-        }elseif ($type == BUILD) {
-            $where['B.id'] = $id;
-        }elseif ($type == CITY) {
-            $where['G.id'] = $id;
-        }elseif ($type == DEVICE) {
-            $where['D.id'] = $id;
-        }else{
-            return 8;
-        }
-        $res = $this->Room_model->get_list_by_multi_join($where, 'G.timezone',NULL, NULL, $join, NULL, NUll, 'R', true);
-        return empty($res) ? 8 : $res['timezone'];
-    }
-    /**
-     * type 0 房间,1 楼房
-     */
-    protected function update_user_personnel($id,$pid,$type=0){
-        if ($type == BUILD) {
-            $userList = $this->User_model->get_list(array('buildId|'=>$id),'hotelId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (empty($user['hotelId'])) {
-                        $this->User_model->update(array('hotelId'=>$pid),array('id'=>$user['id']));
-                    }else{
-                        $hotelArr = explode(',', $user['hotelId']);
-                        if (!in_array($pid, $hotelArr)) {
-                            $hotelArr[] = $pid;
-                            $ids = implode(',', $hotelArr);
-                            $this->User_model->update(array('hotelId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    
-                }
-            }
-        }elseif ($type == ROOM){
-            $buildData = $this->Build_model->get_one(array('id'=>$pid),'hotelId');
-            if (empty($buildData)) return;
-            $userList = $this->User_model->get_list(array('room|'=>$id),'hotelId,buildId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (empty($user['buildId'])) {
-                        $this->User_model->update(array('buildId'=>$pid),array('id'=>$user['id']));
-                    }else{
-                        $buildArr = explode(',', $user['buildId']);
-                        if (!in_array($pid, $buildArr)) {
-                            $buildArr[] = $pid;
-                            $ids = implode(',', $buildArr);
-                            $this->User_model->update(array('buildId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    if (empty($user['hotelId'])) {
-                        $this->User_model->update(array('hotelId'=>$buildData['hotelId']),array('id'=>$user['id']));
-                    }else{
-                        $hotelArr = explode(',', $user['hotelId']);
-                        if (!in_array($buildData['hotelId'], $hotelArr)) {
-                            $hotelArr[] = $buildData['hotelId'];
-                            $ids = implode(',', $hotelArr);
-                            $this->User_model->update(array('hotelId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * type ROOM 房间,BUILD 楼房,HOTEL 酒店,FLOOR 楼层
-     */
-    protected function del_user_personnel($id,$type=0){
-        if ($type == BUILD) {
-            $userList = $this->User_model->get_list(array('buildId|'=>$id),'buildId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (!empty($user['buildId'])) {
-                        $buildArr = explode(',', $user['buildId']);
-                        if (in_array($id, $buildArr)) {
-                            $temp = array();
-                            foreach ($buildArr as $bId) {
-                                if ($id != $bId) $temp[] = $bId;
-                            }
-                            $ids = empty($temp) ? '' : implode(',', $temp);
-                            $this->User_model->update(array('buildId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    
-                }
-            }
-        }elseif ($type == HOTEL) {
-            $userList = $this->User_model->get_list(array('hotelId|'=>$id),'hotelId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (!empty($user['hotelId'])) {
-                        $hotelArr = explode(',', $user['hotelId']);
-                        if (in_array($id, $hotelArr)) {
-                            $temp = array();
-                            foreach ($hotelArr as $bId) {
-                                if ($id != $bId) $temp[] = $bId;
-                            }
-                            $ids = empty($temp) ? '' : implode(',', $temp);
-                            $this->User_model->update(array('hotelId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    
-                }
-            }
-        }elseif ($type == ROOM) {
-            $userList = $this->User_model->get_list(array('roomId|'=>$id),'roomId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (!empty($user['roomId'])) {
-                        $roomArr = explode(',', $user['roomId']);
-                        if (in_array($id, $roomArr)) {
-                            $temp = array();
-                            foreach ($roomArr as $bId) {
-                                if ($id != $bId) $temp[] = $bId;
-                            }
-                            $ids = empty($temp) ? '' : implode(',', $temp);
-                            $this->User_model->update(array('roomId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    
-                }
-            }
-        }elseif ($type == FLOOR) {
-            $userList = $this->User_model->get_list(array('floorId|'=>$id),'floorId,id');
-            if (!empty($userList)) {
-                foreach ($userList as $user) {
-                    if (!empty($user['floorId'])) {
-                        $roomArr = explode(',', $user['floorId']);
-                        if (in_array($id, $roomArr)) {
-                            $temp = array();
-                            foreach ($roomArr as $bId) {
-                                if ($id != $bId) $temp[] = $bId;
-                            }
-                            $ids = empty($temp) ? '' : implode(',', $temp);
-                            $this->User_model->update(array('floorId'=>$ids),array('id'=>$user['id']));
-                        }
-                    }
-                    
-                }
-            }
-        }
-    }
-
-    // 获取酒店id
-    protected function get_hotel_ids(){
-        if ($this->get_user_info('role') == SYSTEM_ADMIN) {
-            $roomId = $this->get_user_info('roomId');
-            if (empty($roomId)) return array();
-            $join = array();
-            $join[] = ['table'=>'build as B','cond'=>'B.id = R.buildId','type'=>'left'];
-            $join[] = ['table'=>'hotel as H','cond'=>'H.id = B.hotelId','type'=>'left'];
-            $hotelList = $this->Room_model->get_list_by_join(array('R.id'=>explode(',', $roomId)), 'H.id as id',NULL, NULL, $join, NULL, NUll, 'R');
-        }else{
-            $hotelList = $this->Hotel_model->get_list(array(),'id');
-        }
-        $hotelIds = array_column($hotelList, 'id');
-        return $hotelIds;
-    }
+    
 
     // 导出数据
     protected function export($fileName = '导出数据', $titles = [], $data= []){

+ 104 - 0
api/application/controllers/Common.php

@@ -0,0 +1,104 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Common extends CI_Controller {
+    
+    var $response;
+    var $userinfo;
+    var $version;
+
+    public function __construct() {
+        parent::__construct();
+        $this->load->model('User_model');
+        $this->load->model('Hotel_model');
+        $this->load->model('Build_model');
+        $this->load->model('Floor_model');
+        $this->load->model('Room_model');
+        $this->response = $this->config->config['response_en'];
+    }
+
+    public function login() {
+        $username = $this->input->post('username',true);
+        $password = $this->input->post('password',true);
+        $client_key = $this->input->post('client_key',true);
+        $code = $this->input->post('code',true);
+        $os = intval($this->input->post('os',true));
+
+        if(empty($client_key)) exit(json_result('0003', $this->response['0003']));
+        if(empty($username) || empty($password)) exit(json_result('0100', $this->response['0100']));
+        $password = md5($password);
+
+        $user = $this->User_model->get_one(array('username'=>$username));
+        if(!empty($user)) {
+            if ($user['password'] != $password) {
+                exit(json_result('0101', $this->response['0101']));
+            }
+            $data = array(
+                'token' => generate_token($username, $password, $client_key),
+                'username' => $user['username'],
+                'id' => $user['id'],
+                'role' => intval($user['role']),
+                'name' => $user['name'],
+            );
+            
+            $this->userinfo = $user;
+            exit(json_result('0000', $this->response['0000'], $data));
+        } else {
+            exit(json_result('0102', $this->response['0102']));
+        }
+    }
+
+    // 图片上传
+    public function update_file(){
+
+        $type = intval($this->input->post("fileType",true));
+
+        if ($type == 0) {
+            $path = '../upload/image';
+            $config['file_name'] = md5(uniqid());   // 设置图片名字
+        }else{
+            $config['overwrite'] = true;
+            $filename = trim($_FILES['file']['name']);
+            if (strpos($filename, 'LampControl_') !== false) {
+                $path = '../upload/firewalld';
+                $config['file_name'] = $filename;
+            }else{
+                $path = '../upload/firewalld';
+                $config['file_name'] = 'openwrt-'.md5(uniqid());
+            }
+            
+        }
+        if (!file_exists($path)) {
+            mkdir($path);
+        }
+        $config['upload_path']      = $path.'/';   // 设置图片上传路径
+        $config['allowed_types']    = '*';  // 设置图片上传格式
+        $config['max_size']     = 10240;   // 设置文件上传大小
+        
+        $this->load->library('upload', $config);
+
+        if ( ! $this->upload->do_upload('file'))
+        {
+            $error = array('error' => $this->upload->display_errors('',''));
+
+            // if (empty($this->version)) {
+                // $data = array('error'=>transfer_error_tips($error['error']));
+            // }else{
+                $data = array('error'=>$error['error']);
+            // }
+            exit(json_result('0012',$this->response['0012'],$data));
+        }
+        else
+        {
+            $data = $this->upload->data();
+
+            if ($type == 0) {
+                $imagePath = '/upload/image/'.$data['file_name'];
+            }else{
+                $imagePath = '/upload/firewalld/'.$data['file_name'];
+            }
+            
+            exit(json_result('0000',$this->response['0000'],array('path'=>base_url($imagePath))));
+        }
+    }
+
+}

+ 0 - 10
api/application/models/AirPurifier_model.php

@@ -1,10 +0,0 @@
-<?php
-if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-
-class AirPurifier_model extends Base_Model
-{
-    protected $table = 'purifier_log';
-    
-}

+ 0 - 10
api/application/models/AlarmInfo_model.php

@@ -1,10 +0,0 @@
-<?php
-if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-
-class AlarmInfo_model extends Base_Model
-{
-    protected $table = 'alarm_info_log';
-    
-}

+ 0 - 8
api/application/models/Build_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Build_model extends Base_Model {
-
-    protected $table = 'build';
-            
-}

+ 0 - 8
api/application/models/DevInfo_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class DevInfo_model extends Base_Model {
-
-    protected $table = 'dev_info';
-            
-}

+ 0 - 8
api/application/models/Dev_info_ch.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Dev_info_ch extends Base_Model {
-
-    protected $table = 'dev_info_ch';
-            
-}

+ 0 - 8
api/application/models/Dev_info_cir.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Dev_info_cir extends Base_Model {
-
-    protected $table = 'dev_info_cir';
-            
-}

+ 0 - 8
api/application/models/Floor_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Floor_model extends Base_Model {
-
-    protected $table = 'floor';
-            
-}

+ 0 - 8
api/application/models/Global_location_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Global_location_model  extends Base_Model {
-
-	protected $table = 'global_location';
-	
-}

+ 0 - 8
api/application/models/Hotel_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Hotel_model extends Base_Model {
-
-    protected $table = 'hotel';
-            
-}

+ 0 - 8
api/application/models/LampLog_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class LampLog_model extends Base_Model {
-
-    protected $table = 'lamp_log';
-            
-}

+ 0 - 8
api/application/models/NetInfo_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class NetInfo_model extends Base_Model {
-
-    protected $table = 'net_info';
-
-}

+ 0 - 29
api/application/models/Network_model.php

@@ -1,29 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Network_model extends Base_Model {
-
-    protected $table = 'network';
-
-    // 添加路灯数(复用)
-    public function add_lamp_count($id,$count){
-        $sql = "update `{$this->table}` set `lampcount` = `lampcount` + {$count} WHERE `id`={$id}";
-        $this->db->query($sql);
-        if ($this->db->affected_rows() == 1) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    // 减少路灯数(复用)
-    public function minus_lamp_count($id,$count){
-        $sql = "update `{$this->table}` set `lampcount` = `lampcount` - {$count} WHERE `id`={$id} and `lampcount` >= {$count}";
-        $this->db->query($sql);
-        if ($this->db->affected_rows() == 1) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-}

+ 0 - 8
api/application/models/Operation_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Operation_model extends Base_Model {
-
-    protected $table = 'operation_log';
-            
-}

+ 0 - 8
api/application/models/RepairInfo_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class RepairInfo_model extends Base_Model {
-
-    protected $table = 'repair_info';
-            
-}

+ 0 - 8
api/application/models/Repair_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Repair_model extends Base_Model {
-
-    protected $table = 'hotel_repair';
-            
-}

+ 0 - 8
api/application/models/Room_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Room_model extends Base_Model {
-
-    protected $table = 'room';
-            
-}

+ 0 - 8
api/application/models/Sensorlog_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class Sensorlog_model extends Base_Model {
-
-    protected $table = 'sensor_log';
-
-}

+ 0 - 8
api/application/models/TempDevInfo_model.php

@@ -1,8 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-include_once(FCPATH . 'application/models/Base_model.php');
-class TempDevInfo_model extends Base_Model {
-
-    protected $table = 'temp_dev_info';
-            
-}