diff --git a/application/KitchenScale/controller/app/Base.php b/application/KitchenScale/controller/app/Base.php index 34b96eb..e07320e 100644 --- a/application/KitchenScale/controller/app/Base.php +++ b/application/KitchenScale/controller/app/Base.php @@ -11,8 +11,14 @@ use PHPMailer\PHPMailer\PHPMailer; class Base extends Controller{ protected $base_use_db_name = [ - '1'=>'test_app_data_log', + '1'=>'app_data_log', + '2'=>'app_card_data', + '3'=>'app_user_data', + '4'=>'pc_vitalcapacity_standard', + '5'=>'admin_estimate', + '6'=>'app_account_number' ]; + protected $token_time = 30;//30天的秒数 protected $file_size = 5*1024*1024; protected $return_data_all = [ '10001'=>'关键参数缺失', @@ -52,6 +58,61 @@ class Base extends Controller{ Log::record($logContent, 'api_log'); } + + // 判断token是否过期 + public function token_time_validate($token){ + // 591b70e0d80b5fa6d77e6e1384453ab9 + if(is_string($token)){ + $length = strlen($token); + if ($length < 10 ) { + Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,字符串长度小于10', 'token_log'); + return false; + } + }else{ + Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,不是字符串', 'token_log'); + return false; + } + + $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time')->find(); + if(!$user_login){ + Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,未找到用户token', 'token_log'); + return false; + } + + // 创建 DateTime 对象来表示指定的日期和时间 + $specifiedDateTime = new \DateTime($user_login['login_time']); + + // 获取当前时间的 DateTime 对象 + $currentDateTime = new \DateTime(); + + // 计算两个日期之间的差异(以秒为单位) + $interval = $currentDateTime->diff($specifiedDateTime); + + // 将差异转换为天数(注意:这里的天数可能不是整数,因为差异可能包括小时、分钟等) + $daysDifference = $interval->days; + + // 如果需要更精确的计算(包括小时、分钟等转换成的天数),可以使用以下方式: + // $totalSecondsDifference = $interval->format('%a') * 86400 + $interval->format('%h') * 3600 + $interval->format('%i') * 60 + $interval->format('%s'); + // $daysDifference = floor($totalSecondsDifference / 86400); // 将总秒数转换为天数并取整 + + // 判断差异是否超过指定的天数 + if ($daysDifference > $this->token_time) { + // echo "超过 {$specifiedDays} 天"; + Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token,或该token已经超过30天', 'token_log'); + return false; + } else { + // echo "未超过 {$specifiedDays} 天"; + $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]); + if($user_login){ + Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.date('Y-m-d H:i:s'), 'token_log'); + return true; + }else{ + Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,数据库更新时间未成功', 'token_log'); + return true; + } + + } + } /* 接口说明(发邮件) * $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......] * $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123'] diff --git a/application/KitchenScale/controller/app/Cookbook.php b/application/KitchenScale/controller/app/Cookbook.php index 7fcd393..da2c657 100644 --- a/application/KitchenScale/controller/app/Cookbook.php +++ b/application/KitchenScale/controller/app/Cookbook.php @@ -15,6 +15,7 @@ class Cookbook extends Base{ ]; protected $kitchenscale_db_msg = [ 'cookbook'=>'app_user_cookbook',//菜谱表 + 'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表 'uploadimg'=>'app_user_upload_img',//素材表 'followlist'=>'app_user_follow_list',//关注列表 'collect_list'=>'app_user_collect_list',//收藏列表 @@ -289,24 +290,18 @@ class Cookbook extends Base{ // } } // 计算当前食材重量的卡路里(OK) - public function food_count_kcal($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_name'=>'鸡肉','food_weight'=>456.37]){ + public function food_count_kcal($data=['food_name'=>'鸡肉','food_weight'=>456.37]){ // 尝试捕获异常 // try { if(count(input('post.')) > 0){ $data = input('post.'); } - if(!array_key_exists('token', $data)){ - return $this->msg(10001,'token is miss'); - } if(!array_key_exists('food_name', $data)){ return $this->msg(10001,'food_name is miss'); } if(!array_key_exists('food_weight', $data)){ return $this->msg(10001,'food_weight is miss'); } - if(!$this->verify_data_is_ok($data['token'],'str')){ - return $this->msg(10005,'token type is error'); - } if(!$this->verify_data_is_ok($data['food_name'],'str')){ return $this->msg(10005,'food_name type is error'); } @@ -332,21 +327,15 @@ class Cookbook extends Base{ // } } // 食材列表查询接口(OK) - public function find_food($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_name'=>'鸡肉']){ + public function find_food($data=['food_name'=>'鸡肉']){ // 尝试捕获异常 // try { if(count(input('post.')) > 0){ $data = input('post.'); } - if(!array_key_exists('token', $data)){ - return $this->msg(10001,'token is miss'); - } if(!array_key_exists('food_name', $data)){ return $this->msg(10001,'food_name is miss'); } - if(!$this->verify_data_is_ok($data['token'],'str')){ - return $this->msg(10005,'token type is error'); - } if(!$this->verify_data_is_ok($data['food_name'],'str')){ return $this->msg(10005,'food_name type is error'); } @@ -368,31 +357,91 @@ class Cookbook extends Base{ // return json(['status' => 'error', 'message' => '系统错误']); // } } - + // 获取所有食材列表 + public function get_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a']){ + // 尝试捕获异常 + // try { + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + + $return_data = $this->get_food_list_action($data); + return $return_data; + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["file"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // // 记录日志 + // // $this->record_api_log($data, $logContent, null); + // return json(['status' => 'error', 'message' => '系统错误']); + // } + } + // 获取所有食谱label + public function get_cookbook_label_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a']){ + // 尝试捕获异常 + // try { + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + + $return_data = $this->get_cookbook_label_list_action($data); + return $return_data; + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["file"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // // 记录日志 + // // $this->record_api_log($data, $logContent, null); + // return json(['status' => 'error', 'message' => '系统错误']); + // } + } #######################################################################action####################################################################### #######################################################################action####################################################################### #######################################################################action####################################################################### public function add_cookbook_action($data){ - // 获取账号下信息以及用户信息 $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); if(!$user_data){ - return $this->msg(10005,'账号信息错误'); + return $this->msg(20001,'账号信息错误'); } if(count($data['food_list']) < 1){ - return $this->msg(10005,'至少添加一个食物'); + return $this->msg(10001,'至少添加一个食物'); } if(count($data['step_list']) < 1){ - return $this->msg(10005,'至少添加一个步骤'); + return $this->msg(10001,'至少添加一个步骤'); } $food_type = []; // 检验一下food_list是否合规(食材列表) foreach ($data['food_list'] as $key => $value) { if (!array_key_exists('name', $value) || !array_key_exists('weight', $value)) { - return $this->msg(10005,'食材缺少名称或者重量'); + return $this->msg(10001,'食材缺少名称或者重量'); } if(!$this->verify_data_is_ok($value['name'],'str')){ return $this->msg(10005,'食材名称格式错误'); @@ -407,7 +456,7 @@ class Cookbook extends Base{ // 检验一下step_list是否合规(步骤列表) foreach ($data['step_list'] as $key => $value) { if (!array_key_exists('description', $value) || !array_key_exists('pic_list', $value)) { - return $this->msg(10005,'步骤缺少描述或者图片'); + return $this->msg(10001,'步骤缺少描述或者图片'); } if(!$this->verify_data_is_ok($value['description'],'str')){ return $this->msg(10005,'步骤描述格式错误,需要正常字符'); @@ -452,6 +501,11 @@ class Cookbook extends Base{ } } public function find_by_cook_label_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } $page_now = $data['page']; $page_total = $data['page']; $page_num = 20; @@ -496,6 +550,11 @@ class Cookbook extends Base{ ]); } public function find_by_food_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } $page_now = $data['page']; $page_total = $data['page']; $page_num = 20; @@ -540,12 +599,17 @@ class Cookbook extends Base{ ]); } public function cookbook_details_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } $cfc = Db::connect('cfc_db'); $img_arr = []; // 查询菜谱详情 $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->find(); if(!$cookbook_data){ - return $this->msg(10002,'菜谱不存在'); + return $this->msg(10004,'菜谱不存在'); } $cookbook_data['food_data'] = json_decode($cookbook_data['food_data'],true); $cookbook_data['step_data'] = json_decode($cookbook_data['step_data'],true); @@ -645,6 +709,11 @@ class Cookbook extends Base{ return $this->msg($cookbook_data); } public function cookbook_follow_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } // dump($data); $cfc = Db::connect('cfc_db'); // $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->field('id,create_user_token')->find(); @@ -653,7 +722,7 @@ class Cookbook extends Base{ // } if($data['token'] == $data['being_followed']){ // 如果查询跟作者一致 - return $this->msg(10002,'不能关注自己'); + return $this->msg(10003,'不能关注自己'); } $follow_data = $cfc->table($this->kitchenscale_db_msg['followlist']) ->where([ @@ -683,7 +752,7 @@ class Cookbook extends Base{ if($follow_result){ return $this->msg([]); }else{ - return $this->msg(10001,'操作失败'); + return $this->msg(10002,'操作失败'); } } public function cookbook_like_action($data){ @@ -691,13 +760,14 @@ class Cookbook extends Base{ // 获取账号下信息以及用户信息 $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); if(!$user_data){ - return $this->msg(10005,'账号信息错误'); + return $this->msg(20001,'账号信息错误'); } + $cfc = Db::connect('cfc_db'); $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->field('id,create_user_token,likes_num')->find(); if(!$cookbook_data){ - return $this->msg(10002,'未找到菜谱'); + return $this->msg(10004,'未找到菜谱'); } // return $this->msg(10002,'是这里'); // if($data['token'] == $cookbook_data['create_user_token']){ @@ -742,7 +812,7 @@ class Cookbook extends Base{ } catch (\Exception $e) { // 回滚事务 Db::rollback(); - return $this->msg(10001,'操作失败.'); + return $this->msg(10002,'操作失败.'); } }else{ // 启动事务 @@ -764,7 +834,7 @@ class Cookbook extends Base{ } catch (\Exception $e) { // 回滚事务 Db::rollback(); - return $this->msg(10001,'操作失败'); + return $this->msg(10002,'操作失败'); } } } @@ -772,7 +842,7 @@ class Cookbook extends Base{ $cfc = Db::connect('cfc_db'); $food_data = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where(['name'=>$data['food_name']])->field("kcal")->find(); if(!$food_data){ - return $this->msg(10002,'未登记的食材'); + return $this->msg(10004,'未登记的食材'); } $weight = bcdiv($data['food_weight'],100,2); $kcal = bcmul($weight,$food_data['kcal'],2); @@ -792,9 +862,64 @@ class Cookbook extends Base{ if(count($food_data)>0){ return $this->msg($food_data); }else{ - return $this->msg(10002,'未找到该食材'); + return $this->msg(10004,'未找到该食材'); } } + public function get_food_list_action($data){ + $cfc = Db::connect('cfc_db'); + // 获取食材分类列表start + $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); + $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select(); + $foodlist3 = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("is_del = 0")->field('id,name,two_id,kcal,unit')->select(); + // dump($foodlist3); + foreach ($foodlist1 as $key => $value) { + unset($foodlist1[$key]['ROW_NUMBER']); + $foodlist1[$key]['list'] = []; + foreach ($foodlist2 as $k => $v) { + $foodlist2[$k]['list'] = []; + foreach ($foodlist3 as $k3 => $v3) { + if($v3['two_id'] == $v['id']){ + unset($foodlist3[$k3]['ROW_NUMBER']); + $foodlist3[$k3]['one_id'] = $v['one_id']; + array_push($foodlist2[$k]['list'],$foodlist3[$k3]); + // unset($foodlist3[$k3]); + } + } + if($v['one_id'] == $value['id']){ + unset($foodlist2[$k]['ROW_NUMBER']); + array_push($foodlist1[$key]['list'],$foodlist2[$k]); + // unset($foodlist2[$k]); + } + } + } + return $this->msg($foodlist1); + } + public function get_cookbook_label_list_action(){ + $cfc = Db::connect('cfc_db'); + // 获取菜谱分类标签start + $cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label']) + ->where("is_del = 0") + ->field('id,name') + ->select(); + $temporary_label = []; + foreach ($cook_label as $key => $value) { + unset($cook_label[$key]['ROW_NUMBER']); + $cook_label[$key]['list'] = []; + $temporary_label[$value['id']] = $key; + } + $content_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->alias('a') + ->join($this->kitchenscale_db_msg['uploadimg'].' b','a.cover = b.id','LEFT') + ->where(['a.is_del'=>0]) + ->field('a.id,a.cook_label,a.title,b.pic_url as cover') + ->select(); + foreach ($content_list as $key => $value) { + unset($content_list[$key]['ROW_NUMBER']); + array_push($cook_label[$temporary_label[$value['cook_label']]]['list'],$content_list[$key]); + } + return $this->msg($cook_label); + // 获取菜谱分类标签end + } diff --git a/application/KitchenScale/controller/app/Index.php b/application/KitchenScale/controller/app/Index.php index 202d906..dac3493 100644 --- a/application/KitchenScale/controller/app/Index.php +++ b/application/KitchenScale/controller/app/Index.php @@ -22,6 +22,7 @@ class Index extends Base{ 'foodlist3'=>'app_food_type_three',//食材列表3 'collect_list'=>'app_user_collect_list',//点赞表 'banner'=>'app_banner_data',//banner + 'version'=>'app_version_log',//版本表 ]; @@ -33,6 +34,47 @@ class Index extends Base{ ################################################################接口################################################################ ################################################################接口################################################################ + // 检测版本及判断是否登录失效 + public function login_invalid_version($data = ['token'=>'']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001); + } + $result = Db::table($this->kitchenscale_db_msg['version'])->order('is_del,id desc')->find(); + if($result){ + $version = $result['version_num_original']; + $url = $result['download_url']; + }else{ + $version = ''; + $url = ''; + } + if($this->token_time_validate($data['token']) === false){ + $this->record_api_log($data, null, ['code'=>-1,'msg'=>'未登录',['version'=>$version,'url'=>$url]]); + return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url]); + }else{ + $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',['version'=>$version,'url'=>$url]]); + return $this->msg(['version'=>$version,'url'=>$url]); + } + + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + } + // 获取默认配置信息(包含:食材的分类列表,用户角色信息)(OK) public function get_default_config($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){ // try { @@ -135,41 +177,46 @@ class Index extends Base{ #######################################################################action####################################################################### public function get_default_config_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } $return_data = [ - 'food_list'=>[], - 'cook_label'=>[], + // 'food_list'=>[], + // 'cook_label'=>[], 'account'=>[], ]; $cfc = Db::connect('cfc_db'); - // 获取食材分类列表start - $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); - $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select(); - $foodlist3 = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("is_del = 0")->field('id,name,two_id,kcal')->select(); - // dump($foodlist3); - foreach ($foodlist1 as $key => $value) { - unset($foodlist1[$key]['ROW_NUMBER']); - $foodlist1[$key]['list'] = []; - foreach ($foodlist2 as $k => $v) { - $foodlist2[$k]['list'] = []; - foreach ($foodlist3 as $k3 => $v3) { - if($v3['two_id'] == $v['id']){ - unset($foodlist3[$k3]['ROW_NUMBER']); - $foodlist3[$k3]['one_id'] = $v['one_id']; - array_push($foodlist2[$k]['list'],$foodlist3[$k3]); - // unset($foodlist3[$k3]); - } - } - if($v['one_id'] == $value['id']){ - unset($foodlist2[$k]['ROW_NUMBER']); - array_push($foodlist1[$key]['list'],$foodlist2[$k]); - // unset($foodlist2[$k]); - } - } - } - $return_data['food_list'] = $foodlist1; - // 获取食材分类列表end + // // 获取食材分类列表start + // $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); + // $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select(); + // $foodlist3 = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("is_del = 0")->field('id,name,two_id,kcal')->select(); + // // dump($foodlist3); + // foreach ($foodlist1 as $key => $value) { + // unset($foodlist1[$key]['ROW_NUMBER']); + // $foodlist1[$key]['list'] = []; + // foreach ($foodlist2 as $k => $v) { + // $foodlist2[$k]['list'] = []; + // foreach ($foodlist3 as $k3 => $v3) { + // if($v3['two_id'] == $v['id']){ + // unset($foodlist3[$k3]['ROW_NUMBER']); + // $foodlist3[$k3]['one_id'] = $v['one_id']; + // array_push($foodlist2[$k]['list'],$foodlist3[$k3]); + // // unset($foodlist3[$k3]); + // } + // } + // if($v['one_id'] == $value['id']){ + // unset($foodlist2[$k]['ROW_NUMBER']); + // array_push($foodlist1[$key]['list'],$foodlist2[$k]); + // // unset($foodlist2[$k]); + // } + // } + // } + // $return_data['food_list'] = $foodlist1; + // // 获取食材分类列表end // 获取菜谱分类标签start $cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label']) ->where("is_del = 0") @@ -194,6 +241,11 @@ class Index extends Base{ public function get_homepage_information_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } $return_data = [ 'banner'=>[], 'jingang_region'=>[ @@ -240,7 +292,12 @@ class Index extends Base{ } public function search_column_action($data){ - $cookbook = new Cookbook(); + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(20001,'账号信息错误'); + } + // $cookbook = new Cookbook(); $cfc = Db::connect('cfc_db'); // 获取菜谱信息 $content_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) diff --git a/application/route.php b/application/route.php index cd96bfb..167003d 100644 --- a/application/route.php +++ b/application/route.php @@ -417,6 +417,10 @@ Route::any('/testedition/kitchenscale/pic_upload_action', 'app/kitchenscale/test // 首页内容################################################################ + +// 检测版本及判断是否登录失效 +Route::any('/kitchenscale/login_invalid_version', 'app/Kitchenscale/app.Index/login_invalid_version'); +Route::any('/testedition/kitchenscale/login_invalid_version', 'app/kitchenscale/testapp.index/login_invalid_version'); // 获取配置类信息 Route::any('/kitchenscale/get_default_config', 'app/Kitchenscale/app.Index/get_default_config'); Route::any('/testedition/kitchenscale/get_default_config', 'app/kitchenscale/testapp.index/get_default_config'); @@ -453,6 +457,14 @@ Route::any('/testedition/kitchenscale/food_count_kcal', 'app/kitchenscale/testap // 获取当前食材重量卡路里 Route::any('/kitchenscale/find_food', 'app/kitchenscale/app.cookbook/find_food'); Route::any('/testedition/kitchenscale/find_food', 'app/kitchenscale/testapp.cookbook/find_food'); +// 获取当前食材重量卡路里 +Route::any('/kitchenscale/get_food_list', 'app/kitchenscale/app.cookbook/get_food_list'); +Route::any('/testedition/kitchenscale/get_food_list', 'app/kitchenscale/testapp.cookbook/get_food_list'); +// 获取所有食谱label +Route::any('/kitchenscale/get_cookbook_label_list', 'app/kitchenscale/app.cookbook/get_cookbook_label_list'); +Route::any('/testedition/kitchenscale/get_cookbook_label_list', 'app/kitchenscale/testapp.cookbook/get_cookbook_label_list'); + + // 计食器################################################################