厨房秤提交测试
This commit is contained in:
parent
9d043259a6
commit
1761d8d325
|
|
@ -150,6 +150,7 @@ class Base extends Controller{
|
||||||
####################################################图片选择上传start##############################################################
|
####################################################图片选择上传start##############################################################
|
||||||
public function pic_chose_list($page = 1) {
|
public function pic_chose_list($page = 1) {
|
||||||
$data = input();
|
$data = input();
|
||||||
|
$page_num = 20;
|
||||||
if(!array_key_exists('token',$data)){
|
if(!array_key_exists('token',$data)){
|
||||||
return $this->msg(10001,'token is miss');
|
return $this->msg(10001,'token is miss');
|
||||||
}
|
}
|
||||||
|
|
@ -164,8 +165,8 @@ class Base extends Controller{
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
|
|
||||||
$num = $cfc->table('app_user_upload_img')->where($parameter_data)->count();
|
$num = $cfc->table('app_user_upload_img')->where($parameter_data)->count();
|
||||||
$result = $cfc->table('app_user_upload_img')->where($parameter_data)->order('id desc')->page($page,20)->field('id,pic_name,pic_url')->select();
|
$result = $cfc->table('app_user_upload_img')->where($parameter_data)->order('id desc')->page($page,$page_num)->field('id,pic_name,pic_url')->select();
|
||||||
$return_result['total_num'] = $num;
|
$return_result['page_total'] = $page_total = ceil($num/$page_num);
|
||||||
$return_result['page_now'] = $page;
|
$return_result['page_now'] = $page;
|
||||||
$return_result['result'] = $result;
|
$return_result['result'] = $result;
|
||||||
return $this->msg($return_result);
|
return $this->msg($return_result);
|
||||||
|
|
@ -180,6 +181,9 @@ class Base extends Controller{
|
||||||
if(!$token){
|
if(!$token){
|
||||||
return $this->msg(10001,'token is miss');
|
return $this->msg(10001,'token is miss');
|
||||||
}
|
}
|
||||||
|
if(count($files)>5){
|
||||||
|
return $this->msg(10001,'单次最多上传5张图片');
|
||||||
|
}
|
||||||
if($files){
|
if($files){
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
$name = $file->getInfo()['name'];
|
$name = $file->getInfo()['name'];
|
||||||
|
|
@ -200,7 +204,6 @@ class Base extends Controller{
|
||||||
'user_token'=>$token,
|
'user_token'=>$token,
|
||||||
'pic_name'=>$new_filename,
|
'pic_name'=>$new_filename,
|
||||||
'pic_url'=>"https://tc.pcxbc.com/kitchenscale_all/user_upload/".$new_filename,
|
'pic_url'=>"https://tc.pcxbc.com/kitchenscale_all/user_upload/".$new_filename,
|
||||||
// 'pic_url'=>"http://wm.tcxbc.com/kitchenscale_all/user_upload/".$new_filename,
|
|
||||||
'create_time'=>date('Y-m-d H:i:s'),
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
];
|
];
|
||||||
$pic_id = $cfc->table('app_user_upload_img')->insertGetId($temporary_data);
|
$pic_id = $cfc->table('app_user_upload_img')->insertGetId($temporary_data);
|
||||||
|
|
@ -217,47 +220,11 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->msg(['error_data'=>$miss_data,'insert_data'=>$insert_data]);
|
return $this->msg(['error_num'=>$miss_data,'insert_data'=>$insert_data]);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'未选择图片');
|
return $this->msg(10001,'未选择图片');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// dump($file);
|
|
||||||
// die;
|
|
||||||
|
|
||||||
// if($file){
|
|
||||||
// $name = $file->getInfo()['name'];
|
|
||||||
// // 使用 pathinfo() 函数获取文件名的扩展名
|
|
||||||
// $pathinfo = pathinfo($name);
|
|
||||||
// $extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较
|
|
||||||
// $file_name = $pathinfo['filename'];
|
|
||||||
// // 判断扩展名是否不是 .png 或 .gif
|
|
||||||
// if ($extension !== 'png' && $extension !== 'gif') {
|
|
||||||
// // 修改文件名,将扩展名改为 .jpg
|
|
||||||
// $new_filename = date('YmdHis').$file_name . '.jpg';
|
|
||||||
// } else {
|
|
||||||
// $new_filename = date('YmdHis').$name;
|
|
||||||
// }
|
|
||||||
// $info = $file->validate(['size'=>$this->file_size,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'upload_pic',$new_filename);
|
|
||||||
// if($info){
|
|
||||||
// $insert_data = [
|
|
||||||
// 'url_data'=>"https://tc.pcxbc.com/upload_pic/".$new_filename,
|
|
||||||
// 'name'=>$new_filename,
|
|
||||||
// 'create_time'=>date('Y-m-d H:i:s'),
|
|
||||||
// ];
|
|
||||||
// $pic_result = Db::table('admin_pic_manage')->insertGetId($insert_data);
|
|
||||||
// if($pic_result){
|
|
||||||
// return $this->msg(['url'=>$insert_data['url_data'],'id'=>$pic_result]);
|
|
||||||
// }else{
|
|
||||||
// return $this->msg(10002,'图片数据保存失败');
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// return $this->msg(10002,'图片上传失败');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,11 @@ class Cookbook extends Base{
|
||||||
'uploadimg'=>'app_user_upload_img',//素材表
|
'uploadimg'=>'app_user_upload_img',//素材表
|
||||||
'followlist'=>'app_user_follow_list',//关注列表
|
'followlist'=>'app_user_follow_list',//关注列表
|
||||||
'collect_list'=>'app_user_collect_list',//收藏列表
|
'collect_list'=>'app_user_collect_list',//收藏列表
|
||||||
|
'foodlist1'=>'app_food_type_one',//食材列表3
|
||||||
|
'foodlist2'=>'app_food_type_two',//食材列表3
|
||||||
'foodlist3'=>'app_food_type_three',//食材列表3
|
'foodlist3'=>'app_food_type_three',//食材列表3
|
||||||
|
'user_kcal_log'=>'app_user_kcal_log',//食材列表3
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
|
|
@ -64,6 +68,9 @@ class Cookbook extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['description'],'str')){
|
if(!$this->verify_data_is_ok($data['description'],'str')){
|
||||||
return $this->msg(10005,'description type is error');
|
return $this->msg(10005,'description type is error');
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['cook_label'],'intnum')){
|
||||||
|
return $this->msg(10005,'cook_label type is error');
|
||||||
|
}
|
||||||
if (!is_array($data['food_list'])) {
|
if (!is_array($data['food_list'])) {
|
||||||
return $this->msg(10005,'food_list type is error');
|
return $this->msg(10005,'food_list type is error');
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +97,7 @@ class Cookbook extends Base{
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
// 根据菜谱标签查询列表(首页用)(OK)
|
// 根据菜谱标签查询列表(首页用)(OK)
|
||||||
public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>'家常菜谱','page'=>'1']){
|
public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>2,'page'=>'1']){
|
||||||
// 尝试捕获异常
|
// 尝试捕获异常
|
||||||
// try {
|
// try {
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
|
|
@ -108,7 +115,7 @@ class Cookbook extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type is error');
|
return $this->msg(10005,'token type is error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['cook_label'],'str')){
|
if(!$this->verify_data_is_ok($data['cook_label'],'intnum')){
|
||||||
return $this->msg(10005,'cook_label type is error');
|
return $this->msg(10005,'cook_label type is error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||||
|
|
@ -174,7 +181,7 @@ class Cookbook extends Base{
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
// 查询食谱的详情(OK)
|
// 查询食谱的详情(OK)
|
||||||
public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'17']){
|
public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'21']){
|
||||||
// 尝试捕获异常
|
// 尝试捕获异常
|
||||||
// try {
|
// try {
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
|
|
@ -324,8 +331,8 @@ class Cookbook extends Base{
|
||||||
// return json(['status' => 'error', 'message' => '系统错误']);
|
// return json(['status' => 'error', 'message' => '系统错误']);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
// 保存每日餐食食物信息
|
// 食材列表查询接口(OK)
|
||||||
public function save_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_list'=>[['name'=>'鸡肉','weight'=>456.37,'kcal'=>761.52]]]){
|
public function find_food($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_name'=>'鸡肉']){
|
||||||
// 尝试捕获异常
|
// 尝试捕获异常
|
||||||
// try {
|
// try {
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
|
|
@ -334,15 +341,17 @@ class Cookbook extends Base{
|
||||||
if(!array_key_exists('token', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001,'token is miss');
|
return $this->msg(10001,'token is miss');
|
||||||
}
|
}
|
||||||
if(!array_key_exists('food_list', $data)){
|
if(!array_key_exists('food_name', $data)){
|
||||||
return $this->msg(10001,'food_list is miss');
|
return $this->msg(10001,'food_name is miss');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type is error');
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data = $this->find_food_action($data);
|
||||||
$return_data = $this->save_food_list_action($data);
|
|
||||||
return $return_data;
|
return $return_data;
|
||||||
// } catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
// // 捕获异常
|
// // 捕获异常
|
||||||
|
|
@ -359,11 +368,20 @@ class Cookbook extends Base{
|
||||||
// return json(['status' => 'error', 'message' => '系统错误']);
|
// return json(['status' => 'error', 'message' => '系统错误']);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#######################################################################action#######################################################################
|
#######################################################################action#######################################################################
|
||||||
#######################################################################action#######################################################################
|
#######################################################################action#######################################################################
|
||||||
#######################################################################action#######################################################################
|
#######################################################################action#######################################################################
|
||||||
|
|
||||||
public function add_cookbook_action($data){
|
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,'账号信息错误');
|
||||||
|
}
|
||||||
|
|
||||||
if(count($data['food_list']) < 1){
|
if(count($data['food_list']) < 1){
|
||||||
return $this->msg(10005,'至少添加一个食物');
|
return $this->msg(10005,'至少添加一个食物');
|
||||||
}
|
}
|
||||||
|
|
@ -382,8 +400,10 @@ class Cookbook extends Base{
|
||||||
if(!$this->verify_data_is_ok($value['weight'],'intnum')){
|
if(!$this->verify_data_is_ok($value['weight'],'intnum')){
|
||||||
return $this->msg(10005,'食材重量格式错误,需整数数字');
|
return $this->msg(10005,'食材重量格式错误,需整数数字');
|
||||||
}
|
}
|
||||||
|
if(!in_array($value['name'], $food_type)){
|
||||||
array_push($food_type, $value['name']);
|
array_push($food_type, $value['name']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 检验一下step_list是否合规(步骤列表)
|
// 检验一下step_list是否合规(步骤列表)
|
||||||
foreach ($data['step_list'] as $key => $value) {
|
foreach ($data['step_list'] as $key => $value) {
|
||||||
if (!array_key_exists('description', $value) || !array_key_exists('pic_list', $value)) {
|
if (!array_key_exists('description', $value) || !array_key_exists('pic_list', $value)) {
|
||||||
|
|
@ -392,24 +412,22 @@ class Cookbook extends Base{
|
||||||
if(!$this->verify_data_is_ok($value['description'],'str')){
|
if(!$this->verify_data_is_ok($value['description'],'str')){
|
||||||
return $this->msg(10005,'步骤描述格式错误,需要正常字符');
|
return $this->msg(10005,'步骤描述格式错误,需要正常字符');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($value['pic_list'] as $k => $v) {
|
foreach ($value['pic_list'] as $k => $v) {
|
||||||
if(!$this->verify_data_is_ok($v,'intnum')){
|
if(!$this->verify_data_is_ok($v,'intnum')){
|
||||||
return $this->msg(10005,'步骤中图片ID错误,需整数数字');
|
return $this->msg(10005,'步骤中图片ID错误,需整数数字');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
// 获取账号下信息以及用户信息
|
// 获取账号下信息以及用户信息
|
||||||
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find();
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find();
|
||||||
|
|
||||||
// 处理食材卡路里start
|
// 处理食材卡路里start
|
||||||
$kcal_data = $this->count_calorie($data['food_list'],$data['step_list']);
|
$kcal_data = $this->count_calorie($data['food_list'],$data['step_list']);
|
||||||
$data['food_list'] =$kcal_data[0];
|
$data['food_list'] =$kcal_data;
|
||||||
$data['step_list'] = $kcal_data[1];
|
|
||||||
// 处理食材卡路里end
|
// 处理食材卡路里end
|
||||||
|
|
||||||
|
|
||||||
$insert_data = [
|
$insert_data = [
|
||||||
'title'=>$data['title'],
|
'title'=>$data['title'],
|
||||||
'cover'=>$data['cover'],
|
'cover'=>$data['cover'],
|
||||||
|
|
@ -423,6 +441,8 @@ class Cookbook extends Base{
|
||||||
'cook_label'=>$data['cook_label'],
|
'cook_label'=>$data['cook_label'],
|
||||||
'create_time'=>date('Y-m-d H:i:s')
|
'create_time'=>date('Y-m-d H:i:s')
|
||||||
];
|
];
|
||||||
|
// dump($insert_data);
|
||||||
|
// die;
|
||||||
$cook_book_result = $cfc->table($this->kitchenscale_db_msg['cookbook'])->insert($insert_data);
|
$cook_book_result = $cfc->table($this->kitchenscale_db_msg['cookbook'])->insert($insert_data);
|
||||||
|
|
||||||
if($cook_book_result){
|
if($cook_book_result){
|
||||||
|
|
@ -447,7 +467,7 @@ class Cookbook extends Base{
|
||||||
->alias('cookbook')
|
->alias('cookbook')
|
||||||
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
||||||
->where(['cookbook.cook_label'=>$cook_label])
|
->where(['cookbook.cook_label'=>$cook_label])
|
||||||
->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num')
|
->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num')
|
||||||
->page("$page_now,$page_num")
|
->page("$page_now,$page_num")
|
||||||
->select();
|
->select();
|
||||||
|
|
||||||
|
|
@ -460,9 +480,9 @@ class Cookbook extends Base{
|
||||||
foreach ($content_list as $key => $value) {
|
foreach ($content_list as $key => $value) {
|
||||||
// if(in_array($value['id'],$my_collect_list)){
|
// if(in_array($value['id'],$my_collect_list)){
|
||||||
if(array_key_exists($value['id'],$my_collect_list)){
|
if(array_key_exists($value['id'],$my_collect_list)){
|
||||||
$content_list[$key]['is_me_like_it'] = 1;
|
$content_list[$key]['is_me_like_it'] = 'yes';
|
||||||
}else{
|
}else{
|
||||||
$content_list[$key]['is_me_like_it'] = 0;
|
$content_list[$key]['is_me_like_it'] = 'no';
|
||||||
}
|
}
|
||||||
if($value['cover'] == null){
|
if($value['cover'] == null){
|
||||||
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
||||||
|
|
@ -490,7 +510,7 @@ class Cookbook extends Base{
|
||||||
->alias('cookbook')
|
->alias('cookbook')
|
||||||
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
||||||
->where("cookbook.food_type like '%$food_name%'")
|
->where("cookbook.food_type like '%$food_name%'")
|
||||||
->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num')
|
->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num')
|
||||||
->page("$page_now,$page_num")
|
->page("$page_now,$page_num")
|
||||||
->select();
|
->select();
|
||||||
|
|
||||||
|
|
@ -503,9 +523,9 @@ class Cookbook extends Base{
|
||||||
foreach ($content_list as $key => $value) {
|
foreach ($content_list as $key => $value) {
|
||||||
// if(in_array($value['id'],$my_collect_list)){
|
// if(in_array($value['id'],$my_collect_list)){
|
||||||
if(array_key_exists($value['id'],$my_collect_list)){
|
if(array_key_exists($value['id'],$my_collect_list)){
|
||||||
$content_list[$key]['is_me_like_it'] = 1;
|
$content_list[$key]['is_me_like_it'] = 'yes';
|
||||||
}else{
|
}else{
|
||||||
$content_list[$key]['is_me_like_it'] = 0;
|
$content_list[$key]['is_me_like_it'] = 'no';
|
||||||
}
|
}
|
||||||
if($value['cover'] == null){
|
if($value['cover'] == null){
|
||||||
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
||||||
|
|
@ -568,30 +588,30 @@ class Cookbook extends Base{
|
||||||
}else{
|
}else{
|
||||||
$cookbook_data['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
$cookbook_data['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
||||||
}
|
}
|
||||||
// 处理关注跟收藏信息
|
// // 处理关注跟收藏信息
|
||||||
if($data['token'] == $cookbook_data['create_user_token']){
|
// if($data['token'] == $cookbook_data['create_user_token']){
|
||||||
// 如果查询跟作者一致
|
// // 如果查询跟作者一致
|
||||||
$cookbook_data['follow_status'] = 'myself';
|
// $cookbook_data['follow_status'] = 'myself';
|
||||||
$cookbook_data['collect_status'] = 'myself';
|
// $cookbook_data['collect_status'] = 'myself';
|
||||||
}else{
|
// }else{
|
||||||
$follow_data = $cfc->table($this->kitchenscale_db_msg['followlist'])
|
// $follow_data = $cfc->table($this->kitchenscale_db_msg['followlist'])
|
||||||
->where([
|
// ->where([
|
||||||
'follow_user_token'=>$data['token'],
|
// 'follow_user_token'=>$data['token'],
|
||||||
'being_follow_user_token'=>$cookbook_data['create_user_token'],
|
// 'being_follow_user_token'=>$cookbook_data['create_user_token'],
|
||||||
])
|
// ])
|
||||||
->find();
|
// ->find();
|
||||||
if($follow_data){
|
// if($follow_data){
|
||||||
if($follow_data['is_del'] == 0){
|
// if($follow_data['is_del'] == 0){
|
||||||
// 如果有结果并且没被删过
|
// // 如果有结果并且没被删过
|
||||||
$cookbook_data['follow_status'] = 'yes';
|
// $cookbook_data['follow_status'] = 'yes';
|
||||||
}else{
|
// }else{
|
||||||
// 如果有结果被删过
|
// // 如果有结果被删过
|
||||||
$cookbook_data['follow_status'] = 'no';
|
// $cookbook_data['follow_status'] = 'no';
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
// 如果没结果
|
// // 如果没结果
|
||||||
$cookbook_data['follow_status'] = 'no';
|
// $cookbook_data['follow_status'] = 'no';
|
||||||
}
|
// }
|
||||||
|
|
||||||
$collect_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
$collect_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
||||||
->where([
|
->where([
|
||||||
|
|
@ -611,12 +631,12 @@ class Cookbook extends Base{
|
||||||
// 如果没结果
|
// 如果没结果
|
||||||
$cookbook_data['collect_status'] = 'no';
|
$cookbook_data['collect_status'] = 'no';
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
// 添加阅读量
|
// 添加阅读量
|
||||||
$read_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('read_it');
|
// $read_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('read_it');
|
||||||
if($read_num){
|
// if($read_num){
|
||||||
$cookbook_data['read_it'] = $cookbook_data['read_it']+1;
|
// $cookbook_data['read_it'] = $cookbook_data['read_it']+1;
|
||||||
}
|
// }
|
||||||
// unset($cookbook_data['create_user_token']);
|
// unset($cookbook_data['create_user_token']);
|
||||||
unset($cookbook_data['create_time']);
|
unset($cookbook_data['create_time']);
|
||||||
unset($cookbook_data['cook_label']);
|
unset($cookbook_data['cook_label']);
|
||||||
|
|
@ -667,21 +687,24 @@ class Cookbook extends Base{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function cookbook_like_action($data){
|
public function cookbook_like_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,'账号信息错误');
|
||||||
|
}
|
||||||
|
|
||||||
$cfc = Db::connect('cfc_db');
|
$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();
|
$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){
|
if(!$cookbook_data){
|
||||||
return $this->msg(10002,'未找到菜谱');
|
return $this->msg(10002,'未找到菜谱');
|
||||||
}
|
}
|
||||||
|
// return $this->msg(10002,'是这里');
|
||||||
// if($data['token'] == $cookbook_data['create_user_token']){
|
// if($data['token'] == $cookbook_data['create_user_token']){
|
||||||
// // 如果查询跟作者一致
|
// // 如果查询跟作者一致
|
||||||
// return $this->msg(10002,'不能收藏自己');
|
// return $this->msg(10002,'不能收藏自己');
|
||||||
// }
|
// }
|
||||||
$like_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
$like_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token'],'cookbook_id'=>$data['cookbook_id']])->find();
|
||||||
->where([
|
|
||||||
'token'=>$data['token'],
|
|
||||||
'cookbook_id'=>$data['cookbook_id'],
|
|
||||||
])
|
|
||||||
->find();
|
|
||||||
|
|
||||||
$like_data_state = 0;
|
$like_data_state = 0;
|
||||||
if($like_data){
|
if($like_data){
|
||||||
|
|
@ -698,17 +721,28 @@ class Cookbook extends Base{
|
||||||
->where(['id'=>$like_data['id']])
|
->where(['id'=>$like_data['id']])
|
||||||
->update(['is_del'=>$like_data_state]);
|
->update(['is_del'=>$like_data_state]);
|
||||||
if($like_data_state == 0){
|
if($like_data_state == 0){
|
||||||
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('like_it');
|
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('likes_num');
|
||||||
}else{
|
}else{
|
||||||
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setDec('like_it');
|
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setDec('likes_num');
|
||||||
}
|
}
|
||||||
// 提交事务
|
// 提交事务
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $this->msg([]);
|
if($like_data_state==0){
|
||||||
|
$likes_num = $cookbook_data['likes_num']+1;
|
||||||
|
}else{
|
||||||
|
$likes_num = $cookbook_data['likes_num']-1;
|
||||||
|
if($likes_num <= 0){
|
||||||
|
$likes_num = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->msg([
|
||||||
|
'collect_status'=>$like_data_state==0?'yes':'no',
|
||||||
|
'likes_num'=>$likes_num
|
||||||
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return $this->msg(10001,'操作失败');
|
return $this->msg(10001,'操作失败.');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// 启动事务
|
// 启动事务
|
||||||
|
|
@ -720,10 +754,13 @@ class Cookbook extends Base{
|
||||||
'cookbook_id'=>$data['cookbook_id'],
|
'cookbook_id'=>$data['cookbook_id'],
|
||||||
'create_time'=>date('Y-m-d H:i:s')
|
'create_time'=>date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('like_it');
|
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('likes_num');
|
||||||
// 提交事务
|
// 提交事务
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $this->msg([]);
|
return $this->msg([
|
||||||
|
'collect_status'=>"yes",
|
||||||
|
'likes_num'=>$cookbook_data['likes_num']+1
|
||||||
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
|
@ -741,36 +778,24 @@ class Cookbook extends Base{
|
||||||
$kcal = bcmul($weight,$food_data['kcal'],2);
|
$kcal = bcmul($weight,$food_data['kcal'],2);
|
||||||
return $this->msg(['value'=>$kcal,'unit'=>'kcal']);
|
return $this->msg(['value'=>$kcal,'unit'=>'kcal']);
|
||||||
}
|
}
|
||||||
public function save_food_list_action($data){
|
public function find_food_action($data){
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
foreach ($data['food_list'] as $key => $value) {
|
$food_data = $cfc->query("select f3.id,f3.name,f3.kcal,f2.id as up_one_level_id,f1.id as up_two_level_id
|
||||||
if(!array_key_exists('name', $value) || !array_key_exists('weight', $value) || !array_key_exists('kcal', $value)){
|
from ".$this->kitchenscale_db_msg['foodlist3']." as f3
|
||||||
return $this->msg(10001,'food_list content lost');
|
LEFT JOIN ".$this->kitchenscale_db_msg['foodlist2']." as f2
|
||||||
}
|
on f3.two_id = f2.id
|
||||||
if(!$this->verify_data_is_ok($value['name'],'str')){
|
LEFT JOIN ".$this->kitchenscale_db_msg['foodlist1']." as f1
|
||||||
return $this->msg(10005,'name type is error');
|
on f2.one_id = f1.id
|
||||||
}
|
where f3.is_del=0 AND f3.name like '%".$data['food_name']."%'
|
||||||
if(!$this->verify_data_is_ok($value['weight'],'num')){
|
");
|
||||||
return $this->msg(10005,'weight type is error');
|
|
||||||
}
|
if(count($food_data)>0){
|
||||||
if(!$this->verify_data_is_ok($value['kcal'],'num')){
|
return $this->msg($food_data);
|
||||||
return $this->msg(10005,'kcal type is error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!array_key_exists('eat_time', $data)){
|
|
||||||
$data['eat_time'] = date('Y-m-d H:i:s');
|
|
||||||
}else{
|
}else{
|
||||||
if(!$this->verify_data_is_ok($value['kcal'],'datetime')){
|
return $this->msg(10002,'未找到该食材');
|
||||||
return $this->msg(10005,'kcal type is error');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $cfc->table($this->kitchenscale_db_msg['foodlist3'])
|
|
||||||
->insert([
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -799,19 +824,19 @@ class Cookbook extends Base{
|
||||||
$data[$key]['weight'] = $data[$key]['weight'].'g';
|
$data[$key]['weight'] = $data[$key]['weight'].'g';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($step as $key => $value) {
|
// foreach ($step as $key => $value) {
|
||||||
foreach ($value['foot_list'] as $k => $v) {
|
// foreach ($value['foot_list'] as $k => $v) {
|
||||||
|
|
||||||
if(array_key_exists($v['name'], $foot_kcal2)){
|
// if(array_key_exists($v['name'], $foot_kcal2)){
|
||||||
$step[$key]['foot_list'][$k]['kcal'] = $this->count_calorie_action($v['weight'],$foot_kcal2[$v['name']]).'kcal';
|
// $step[$key]['foot_list'][$k]['kcal'] = $this->count_calorie_action($v['weight'],$foot_kcal2[$v['name']]).'kcal';
|
||||||
}else{
|
// }else{
|
||||||
$step[$key]['foot_list'][$k]['kcal'] = '0kcal';
|
// $step[$key]['foot_list'][$k]['kcal'] = '0kcal';
|
||||||
}
|
// }
|
||||||
$step[$key]['foot_list'][$k]['weight'] = $step[$key]['foot_list'][$k]['weight'].'g';
|
// $step[$key]['foot_list'][$k]['weight'] = $step[$key]['foot_list'][$k]['weight'].'g';
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
return [$data,$step];
|
return [$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,19 @@ use think\Db;
|
||||||
|
|
||||||
class Login extends Base{
|
class Login extends Base{
|
||||||
|
|
||||||
protected $code_time = 50;
|
|
||||||
// protected $token_time = 2592000;//30天的秒数
|
|
||||||
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
|
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
|
||||||
protected $login_use_db_name = [
|
protected $reedaw_db_msg = [
|
||||||
'1'=>'app_account_number',
|
'zhanghao'=>'app_account_number',//账号表
|
||||||
|
'juese'=>'app_user_data',//角色表
|
||||||
|
];
|
||||||
|
protected $kitchenscale_db_msg = [
|
||||||
|
'cookbook'=>'app_user_cookbook',//菜谱表
|
||||||
|
'uploadimg'=>'app_user_upload_img',//素材表
|
||||||
|
'followlist'=>'app_user_follow_list',//关注列表
|
||||||
|
'collect_list'=>'app_user_collect_list',//收藏列表
|
||||||
|
'foodlist3'=>'app_food_type_three',//食材列表3
|
||||||
|
'user_kcal_log'=>'app_user_kcal_log',//食材列表3
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
|
|
@ -21,46 +29,73 @@ class Login extends Base{
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
||||||
// 注册
|
// 保存每日餐食食物信息
|
||||||
|
public function save_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_list'=>[['name'=>'鸡肉','weight'=>456.37,'kcal'=>761.52]]]){
|
||||||
public function login_api($data = ['account'=>123,'password'=>456]){
|
// 尝试捕获异常
|
||||||
try {
|
// try {
|
||||||
// 你的业务逻辑
|
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
}
|
}
|
||||||
if(!array_key_exists('account', $data) && !array_key_exists('password', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001,'token is miss');
|
||||||
}
|
}
|
||||||
$return_data = $this->login_action($data);
|
if(!array_key_exists('food_list', $data)){
|
||||||
// 成功
|
return $this->msg(10001,'food_list is miss');
|
||||||
$this->record_api_log($data, null, $return_data);
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005,'token type is error');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$return_data = $this->save_food_list_action($data);
|
||||||
return $return_data;
|
return $return_data;
|
||||||
} catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
// 捕获异常
|
// // 捕获异常
|
||||||
$logContent["flie"] = $e->getFile();
|
// $logContent["file"] = $e->getFile();
|
||||||
$logContent["line"] = $e->getLine();
|
// $logContent["line"] = $e->getLine();
|
||||||
$logContent['all_content'] = "异常信息:\n";
|
// $logContent['all_content'] = "异常信息:\n";
|
||||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||||
$this->record_api_log($data, $logContent, null);
|
// // 记录日志
|
||||||
return $this->msg(99999);
|
// // $this->record_api_log($data, $logContent, null);
|
||||||
}
|
// return json(['status' => 'error', 'message' => '系统错误']);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
#######################################################################action#######################################################################
|
#######################################################################action#######################################################################
|
||||||
public function login_action($data){
|
#######################################################################action#######################################################################
|
||||||
// dump($data);
|
#######################################################################action#######################################################################
|
||||||
$user = Db::table('admin_user_account_number')->where(["account_num"=>$data['account'],'password'=>$data['password']])->find();
|
|
||||||
// dump($user);
|
public function save_food_list_action($data){
|
||||||
// die;
|
$cfc = Db::connect('cfc_db');
|
||||||
if($user){
|
foreach ($data['food_list'] as $key => $value) {
|
||||||
return $this->msg(['token'=>$user['token']]);
|
if(!array_key_exists('name', $value) || !array_key_exists('weight', $value) || !array_key_exists('kcal', $value)){
|
||||||
}else{
|
return $this->msg(10001,'food_list content lost');
|
||||||
return $this->msg(10004);
|
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($value['name'],'str')){
|
||||||
|
return $this->msg(10005,'name type is error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($value['weight'],'num')){
|
||||||
|
return $this->msg(10005,'weight type is error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($value['kcal'],'num')){
|
||||||
|
return $this->msg(10005,'kcal type is error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!array_key_exists('eat_time', $data)){
|
||||||
|
$data['eat_time'] = date('Y-m-d H:i:s');
|
||||||
|
}else{
|
||||||
|
if(!$this->verify_data_is_ok($data['eat_time'],'datetime')){
|
||||||
|
return $this->msg(10005,'eat_time type is error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $cfc->table($this->kitchenscale_db_msg['user_kcal_log'])
|
||||||
|
->insert([
|
||||||
|
'food_name'=>
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,16 @@ class Index extends Base{
|
||||||
protected $reedaw_db_msg = [
|
protected $reedaw_db_msg = [
|
||||||
'zhanghao'=>'app_account_number',//账号表
|
'zhanghao'=>'app_account_number',//账号表
|
||||||
'juese'=>'app_user_data',//角色表
|
'juese'=>'app_user_data',//角色表
|
||||||
'banner'=>'admin_notice_banner',//banner
|
|
||||||
];
|
];
|
||||||
protected $kitchenscale_db_msg = [
|
protected $kitchenscale_db_msg = [
|
||||||
'cookbook'=>'app_user_cookbook',//菜谱表
|
'cookbook'=>'app_user_cookbook',//菜谱表
|
||||||
|
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
|
||||||
'uploadimg'=>'app_user_upload_img',//图片素材表
|
'uploadimg'=>'app_user_upload_img',//图片素材表
|
||||||
'foodlist1'=>'app_food_type_one',//食材列表1
|
'foodlist1'=>'app_food_type_one',//食材列表1
|
||||||
'foodlist2'=>'app_food_type_two',//食材列表2
|
'foodlist2'=>'app_food_type_two',//食材列表2
|
||||||
'foodlist3'=>'app_food_type_three',//食材列表3
|
'foodlist3'=>'app_food_type_three',//食材列表3
|
||||||
'collect_list'=>'app_user_collect_list',//素材表
|
'collect_list'=>'app_user_collect_list',//点赞表
|
||||||
|
'banner'=>'app_banner_data',//banner
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ class Index extends Base{
|
||||||
|
|
||||||
// 获取首页信息(banner,金刚区,label_list)(OK)
|
// 获取首页信息(banner,金刚区,label_list)(OK)
|
||||||
public function get_homepage_information($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
public function get_homepage_information($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||||
try {
|
// try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
|
@ -79,25 +80,25 @@ class Index extends Base{
|
||||||
// 成功
|
// 成功
|
||||||
$this->record_api_log($data, null, $return_data);
|
$this->record_api_log($data, null, $return_data);
|
||||||
return $return_data;
|
return $return_data;
|
||||||
} catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
// 捕获异常
|
// // 捕获异常
|
||||||
$logContent["flie"] = $e->getFile();
|
// $logContent["flie"] = $e->getFile();
|
||||||
$logContent["line"] = $e->getLine();
|
// $logContent["line"] = $e->getLine();
|
||||||
$logContent['all_content'] = "异常信息:\n";
|
// $logContent['all_content'] = "异常信息:\n";
|
||||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
$logContent['all_content'] .= "接口: (get_homepage_information)\n";
|
// $logContent['all_content'] .= "接口: (get_homepage_information)\n";
|
||||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||||
$this->record_api_log($data, $logContent, null);
|
// $this->record_api_log($data, $logContent, null);
|
||||||
return $this->msg(99999);
|
// return $this->msg(99999);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 首页搜索接口(OK)
|
// 首页搜索接口(OK)
|
||||||
public function search_column($data = ['search_data'=>'鱼','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
public function search_column($data = ['search_data'=>'鱼','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||||
try {
|
// try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
if(count(input('post.')) > 0){
|
if(count(input('post.')) > 0){
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
|
@ -113,20 +114,20 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
$return_data = $this->search_column_action($data);
|
$return_data = $this->search_column_action($data);
|
||||||
return $return_data;
|
return $return_data;
|
||||||
} catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
// 捕获异常
|
// // 捕获异常
|
||||||
$logContent["flie"] = $e->getFile();
|
// $logContent["flie"] = $e->getFile();
|
||||||
$logContent["line"] = $e->getLine();
|
// $logContent["line"] = $e->getLine();
|
||||||
$logContent['all_content'] = "异常信息:\n";
|
// $logContent['all_content'] = "异常信息:\n";
|
||||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
$logContent['all_content'] .= "接口: (search_column)\n";
|
// $logContent['all_content'] .= "接口: (search_column)\n";
|
||||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||||
$this->record_api_log($data, $logContent, null);
|
// $this->record_api_log($data, $logContent, null);
|
||||||
return $this->msg(99999);
|
// return $this->msg(99999);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################################################action#######################################################################
|
#######################################################################action#######################################################################
|
||||||
|
|
@ -136,8 +137,11 @@ class Index extends Base{
|
||||||
public function get_default_config_action($data){
|
public function get_default_config_action($data){
|
||||||
$return_data = [
|
$return_data = [
|
||||||
'food_list'=>[],
|
'food_list'=>[],
|
||||||
|
'cook_label'=>[],
|
||||||
'account'=>[],
|
'account'=>[],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
// 获取食材分类列表start
|
// 获取食材分类列表start
|
||||||
$foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select();
|
$foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select();
|
||||||
|
|
@ -152,6 +156,7 @@ class Index extends Base{
|
||||||
foreach ($foodlist3 as $k3 => $v3) {
|
foreach ($foodlist3 as $k3 => $v3) {
|
||||||
if($v3['two_id'] == $v['id']){
|
if($v3['two_id'] == $v['id']){
|
||||||
unset($foodlist3[$k3]['ROW_NUMBER']);
|
unset($foodlist3[$k3]['ROW_NUMBER']);
|
||||||
|
$foodlist3[$k3]['one_id'] = $v['one_id'];
|
||||||
array_push($foodlist2[$k]['list'],$foodlist3[$k3]);
|
array_push($foodlist2[$k]['list'],$foodlist3[$k3]);
|
||||||
// unset($foodlist3[$k3]);
|
// unset($foodlist3[$k3]);
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +170,16 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
$return_data['food_list'] = $foodlist1;
|
$return_data['food_list'] = $foodlist1;
|
||||||
// 获取食材分类列表end
|
// 获取食材分类列表end
|
||||||
|
// 获取菜谱分类标签start
|
||||||
|
$cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label'])
|
||||||
|
->where("is_del = 0")
|
||||||
|
->field('id,name')
|
||||||
|
->select();
|
||||||
|
foreach ($cook_label as $key => $value) {
|
||||||
|
unset($cook_label[$key]['ROW_NUMBER']);
|
||||||
|
}
|
||||||
|
$return_data['cook_label'] = $cook_label;
|
||||||
|
// 获取菜谱分类标签end
|
||||||
// 获取账号下信息以及用户信息start
|
// 获取账号下信息以及用户信息start
|
||||||
$user_account = Db::table($this->reedaw_db_msg['zhanghao'])
|
$user_account = Db::table($this->reedaw_db_msg['zhanghao'])
|
||||||
->alias('zhanghao')
|
->alias('zhanghao')
|
||||||
|
|
@ -187,51 +202,38 @@ class Index extends Base{
|
||||||
['name'=>'热量计算','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
|
['name'=>'热量计算','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
|
||||||
['name'=>'健康食谱','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
|
['name'=>'健康食谱','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
|
||||||
],
|
],
|
||||||
'label_list'=>[],
|
|
||||||
];
|
];
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
|
|
||||||
// 获取banner
|
// 获取banner
|
||||||
$banner_list = Db::table($this->reedaw_db_msg['banner'])
|
$banner_list = $cfc->query("select b.id,b.title,b.cover,b.create_user_head_pic,b.create_user_nickname
|
||||||
->where("is_del = 0 AND scene_data IN (21)")
|
from ".$this->kitchenscale_db_msg['banner']." as a
|
||||||
->order('sort_num desc,id desc')
|
LEFT JOIN ".$this->kitchenscale_db_msg['cookbook']." as b
|
||||||
->field('id,title,pic,type,jump_url,create_time,scene_data,sort_num,parameter_data')
|
on a.cookbook_id = b.id
|
||||||
->select();
|
where a.is_del=0
|
||||||
|
ORDER BY a.sort_num desc,a.id desc
|
||||||
|
");
|
||||||
|
$collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token']])->column('cookbook_id');
|
||||||
|
|
||||||
|
|
||||||
foreach ($banner_list as $key => $value) {
|
foreach ($banner_list as $key => $value) {
|
||||||
if($value['type'] == '1'){
|
if(array_key_exists($value['id'],$collect_list)){
|
||||||
$banner_list[$key]['type'] = 'h5';
|
$banner_list[$key]['is_me_like_it'] = 1;
|
||||||
$banner_list[$key]['id'] = $value['parameter_data'];
|
|
||||||
}else{
|
}else{
|
||||||
$banner_list[$key]['type'] = 'wechat';
|
$banner_list[$key]['is_me_like_it'] = 0;
|
||||||
// 提取查询字符串部分(?后面的部分)
|
|
||||||
$queryString = substr($banner_list[$key]['jump_url'], strpos($banner_list[$key]['jump_url'], '?') + 1);
|
|
||||||
// 使用parse_str解析查询字符串
|
|
||||||
$params = [];
|
|
||||||
parse_str($queryString, $params);
|
|
||||||
// 提取appid和path的值
|
|
||||||
$appid = isset($params['appid']) ? $params['appid'] : null;
|
|
||||||
$path = isset($params['path']) ? $params['path'] : null;
|
|
||||||
$banner_list[$key]['appid'] = $appid;
|
|
||||||
$banner_list[$key]['path'] = $path;
|
|
||||||
// 重新定义跳转链接为中间页
|
|
||||||
$banner_list[$key]['jump_url'] = "https://tc.pcxbc.com/open_wechat_content";
|
|
||||||
}
|
}
|
||||||
unset($banner_list[$key]['scene_data']);
|
|
||||||
unset($banner_list[$key]['sort_num']);
|
|
||||||
unset($banner_list[$key]['ROW_NUMBER']);
|
unset($banner_list[$key]['ROW_NUMBER']);
|
||||||
unset($banner_list[$key]['parameter_data']);
|
|
||||||
}
|
}
|
||||||
$return_data['banner'] = $banner_list;
|
$return_data['banner'] = $banner_list;
|
||||||
|
|
||||||
|
|
||||||
// 获取菜谱列表
|
// 获取菜谱列表
|
||||||
$label_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])->group('cook_label')->field('cook_label,count(*) as num')->select();
|
// $label_list = $cfc->query("select id,name from ".$this->kitchenscale_db_msg['cookbook_label']." where is_del=0 ORDER BY id");
|
||||||
// dump($label_list);
|
// if(count($label_list) <= 0){
|
||||||
if(count($label_list) <= 0){
|
// $return_data['label_list'] = [];
|
||||||
$return_data['label_list'] = [];
|
// return $this->msg($return_data);
|
||||||
return $this->msg($return_data);
|
// }
|
||||||
}
|
// $return_data['label_list'] = $label_list;
|
||||||
$return_data['label_list'] = $label_list;
|
|
||||||
return $this->msg($return_data);
|
return $this->msg($return_data);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -245,7 +247,7 @@ class Index extends Base{
|
||||||
->alias('cookbook')
|
->alias('cookbook')
|
||||||
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT')
|
||||||
->where("cookbook.title LIKE '%".$data['search_data']."%' OR cookbook.describe_data LIKE '%".$data['search_data']."%'")
|
->where("cookbook.title LIKE '%".$data['search_data']."%' OR cookbook.describe_data LIKE '%".$data['search_data']."%'")
|
||||||
->field("cookbook.id,cookbook.title,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num,uploadimg.pic_url as cover")
|
->field("cookbook.id,cookbook.title,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num,uploadimg.pic_url as cover")
|
||||||
->select();
|
->select();
|
||||||
if(count($content_list)<=0){
|
if(count($content_list)<=0){
|
||||||
return $this->msg([]);
|
return $this->msg([]);
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace app\KitchenScale\controller\app;
|
|
||||||
|
|
||||||
use think\Db;
|
|
||||||
|
|
||||||
class Login extends Base{
|
|
||||||
|
|
||||||
protected $code_time = 50;
|
|
||||||
// protected $token_time = 2592000;//30天的秒数
|
|
||||||
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
|
|
||||||
protected $login_use_db_name = [
|
|
||||||
'1'=>'app_account_number',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 加 bcadd(,,20)
|
|
||||||
// 减 bcsub(,,20)
|
|
||||||
// 乘 bcmul(,,20)
|
|
||||||
// 除 bcdiv(,,20)
|
|
||||||
################################################################接口################################################################
|
|
||||||
################################################################接口################################################################
|
|
||||||
################################################################接口################################################################
|
|
||||||
|
|
||||||
// 注册
|
|
||||||
|
|
||||||
public function login_api($data = ['account'=>123,'password'=>456]){
|
|
||||||
try {
|
|
||||||
// 你的业务逻辑
|
|
||||||
if(count(input('post.')) > 0){
|
|
||||||
$data = input('post.');
|
|
||||||
}
|
|
||||||
if(!array_key_exists('account', $data) && !array_key_exists('password', $data)){
|
|
||||||
return $this->msg(10001);
|
|
||||||
}
|
|
||||||
$return_data = $this->login_action($data);
|
|
||||||
// 成功
|
|
||||||
$this->record_api_log($data, null, $return_data);
|
|
||||||
return $return_data;
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#######################################################################action#######################################################################
|
|
||||||
public function login_action($data){
|
|
||||||
// dump($data);
|
|
||||||
$user = Db::table('admin_user_account_number')->where(["account_num"=>$data['account'],'password'=>$data['password']])->find();
|
|
||||||
// dump($user);
|
|
||||||
// die;
|
|
||||||
if($user){
|
|
||||||
return $this->msg(['token'=>$user['token']]);
|
|
||||||
}else{
|
|
||||||
return $this->msg(10004);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\KitchenScale\controller\app;
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class Product extends Base
|
||||||
|
{
|
||||||
|
protected $is_default = 1;
|
||||||
|
|
||||||
|
// 获取配置信息
|
||||||
|
public function get_default_configuration()
|
||||||
|
{
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
// $data = input();
|
||||||
|
|
||||||
|
|
||||||
|
// 2. 获取所点击选项的所有直属上级配置项
|
||||||
|
$content_num = $cfc->table("ceshi3_option")
|
||||||
|
->alias('xuanxiang')
|
||||||
|
->join('ceshi2_configuration peizhi','xuanxiang.parent_id = peizhi.id','LEFT')
|
||||||
|
->where(['peizhi.is_default'=>$this->is_default])
|
||||||
|
->field("xuanxiang.*,peizhi.name")
|
||||||
|
->select();
|
||||||
|
$temporary = [];
|
||||||
|
foreach ($content_num as $key => $value) {
|
||||||
|
$temporary[$value['name']]['id'] = $value['parent_id'];
|
||||||
|
$temporary[$value['name']]['name'] = $value['name'];
|
||||||
|
$temporary[$value['name']]['type'] = "configuration";
|
||||||
|
$temporary[$value['name']]['list'][$value['value']] = [];
|
||||||
|
$temporary[$value['name']]['list'][$value['value']]['id'] = $value['id'];
|
||||||
|
$temporary[$value['name']]['list'][$value['value']]['name'] = $value['value'];
|
||||||
|
$temporary[$value['name']]['list'][$value['value']]['type'] = "parameter";
|
||||||
|
$temporary[$value['name']]['list'][$value['value']]['list'] = [];
|
||||||
|
}
|
||||||
|
// dump($temporary);
|
||||||
|
// die;
|
||||||
|
return $this->msg($temporary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所点击选项的所有直属上级配置项
|
||||||
|
private function getAncestorConfigurations($cfc, $optionId)
|
||||||
|
{
|
||||||
|
$ancestors = [];
|
||||||
|
|
||||||
|
// 获取当前选项的配置项
|
||||||
|
$currentConfig = $cfc->query("
|
||||||
|
SELECT c.id, c.name, c.parent_id
|
||||||
|
FROM configurations c
|
||||||
|
JOIN options o ON c.id = o.config_id
|
||||||
|
WHERE o.id = ?
|
||||||
|
", [$optionId]);
|
||||||
|
|
||||||
|
if (!empty($currentConfig)) {
|
||||||
|
$currentConfig = $currentConfig[0];
|
||||||
|
|
||||||
|
// 获取直属上级配置项
|
||||||
|
if ($currentConfig['parent_id']) {
|
||||||
|
$parentConfig = $cfc->query("
|
||||||
|
SELECT c.id, c.name
|
||||||
|
FROM configurations c
|
||||||
|
WHERE c.id = ?
|
||||||
|
", [$currentConfig['parent_id']]);
|
||||||
|
|
||||||
|
if (!empty($parentConfig)) {
|
||||||
|
$parentConfig = $parentConfig[0];
|
||||||
|
$ancestors[] = $parentConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ancestors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\KitchenScale\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class Usercenter extends Base{
|
||||||
|
|
||||||
|
protected $code_time = 50;
|
||||||
|
// protected $token_time = 2592000;//30天的秒数
|
||||||
|
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
|
||||||
|
protected $page_num = 20;
|
||||||
|
protected $reedaw_db_msg = [
|
||||||
|
'zhanghao'=>'app_account_number',//账号表
|
||||||
|
'juese'=>'app_user_data',//角色表
|
||||||
|
];
|
||||||
|
protected $kitchenscale_db_msg = [
|
||||||
|
'cookbook'=>'app_user_cookbook',//菜谱表
|
||||||
|
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
|
||||||
|
'uploadimg'=>'app_user_upload_img',//图片素材表
|
||||||
|
'foodlist1'=>'app_food_type_one',//食材列表1
|
||||||
|
'foodlist2'=>'app_food_type_two',//食材列表2
|
||||||
|
'foodlist3'=>'app_food_type_three',//食材列表3
|
||||||
|
'collect_list'=>'app_user_collect_list',//点赞表
|
||||||
|
'banner'=>'app_banner_data',//banner
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
// 获取用户收藏点赞列表(OK)
|
||||||
|
public function get_user_collect_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1,'search_data'=>'']){
|
||||||
|
// 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('page', $data)){
|
||||||
|
return $this->msg(10001,'page 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['page'],'intnum')){
|
||||||
|
return $this->msg(10005,'page type is error');
|
||||||
|
}
|
||||||
|
$return_data = $this->get_user_collect_list_action($data);
|
||||||
|
return $return_data;
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
// // 捕获异常
|
||||||
|
// $logContent["flie"] = $e->getFile();
|
||||||
|
// $logContent["line"] = $e->getLine();
|
||||||
|
// $logContent['all_content'] = "异常信息:\n";
|
||||||
|
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
|
// $logContent['all_content'] .= "接口: (get_default_config)\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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 我的菜谱
|
||||||
|
public function get_my_cookbook($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1]){
|
||||||
|
// 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('page', $data)){
|
||||||
|
return $this->msg(10001,'page 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['page'],'intnum')){
|
||||||
|
return $this->msg(10005,'page type is error');
|
||||||
|
}
|
||||||
|
$return_data = $this->get_my_cookbook_action($data);
|
||||||
|
return $return_data;
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
// // 捕获异常
|
||||||
|
// $logContent["flie"] = $e->getFile();
|
||||||
|
// $logContent["line"] = $e->getLine();
|
||||||
|
// $logContent['all_content'] = "异常信息:\n";
|
||||||
|
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
|
// $logContent['all_content'] .= "接口: (get_default_config)\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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################action#######################################################################
|
||||||
|
#######################################################################action#######################################################################
|
||||||
|
#######################################################################action#######################################################################
|
||||||
|
public function get_user_collect_list_action($data){
|
||||||
|
// 获取账号下信息以及用户信息
|
||||||
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
||||||
|
if($user_data<=0){
|
||||||
|
return $this->msg(10005,'账号信息错误');
|
||||||
|
}
|
||||||
|
$search_sql_str = "a.token = '".$data['token']."' AND a.is_del = 0";
|
||||||
|
if(!array_key_exists('search_data', $data)){
|
||||||
|
$data['search_data'] = "";
|
||||||
|
}else{
|
||||||
|
if($data['search_data'] === ""){
|
||||||
|
$data['search_data'] = "";
|
||||||
|
}else{
|
||||||
|
$data['search_data'] = " AND (b.title LIKE '%".$data['search_data']."%' OR b.describe_data LIKE '%".$data['search_data']."%')";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$search_sql_str = $search_sql_str.$data['search_data'];
|
||||||
|
// "a.token = 'asdasdasdasda' AND a.is_del = 0 AND b.title LIKE '%鱼%' OR b.describe_data LIKE '%鱼%'";
|
||||||
|
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
|
||||||
|
$content_num = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
||||||
|
->alias('a')
|
||||||
|
->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT')
|
||||||
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
||||||
|
->where($search_sql_str)
|
||||||
|
->count();
|
||||||
|
$page_total = ceil($content_num/$this->page_num);;
|
||||||
|
$collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
||||||
|
->alias('a')
|
||||||
|
->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT')
|
||||||
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
||||||
|
->where($search_sql_str)
|
||||||
|
->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname")
|
||||||
|
->page($data['page'],$this->page_num)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
return $this->msg([
|
||||||
|
'page_now'=>$data['page'],
|
||||||
|
'page_total'=>$page_total,
|
||||||
|
'content_list'=>$collect_list
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_my_cookbook_action($data){
|
||||||
|
// 获取账号下信息以及用户信息
|
||||||
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
||||||
|
if($user_data<=0){
|
||||||
|
return $this->msg(10005,'账号信息错误');
|
||||||
|
}
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
$content_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])
|
||||||
|
->alias('b')
|
||||||
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
||||||
|
->where(['b.create_user_token'=>$data['token'],'b.is_del'=>0])
|
||||||
|
->count();
|
||||||
|
$page_total = ceil($content_num/$this->page_num);;
|
||||||
|
$collect_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])
|
||||||
|
->alias('b')
|
||||||
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
||||||
|
->where(['b.create_user_token'=>$data['token'],'b.is_del'=>0])
|
||||||
|
->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname")
|
||||||
|
->page($data['page'],$this->page_num)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
return $this->msg([
|
||||||
|
'page_now'=>$data['page'],
|
||||||
|
'page_total'=>$page_total,
|
||||||
|
'content_list'=>$collect_list
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ class Login extends Base{
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
||||||
// 注册
|
// 注册
|
||||||
public function register_action($data = ['data'=>18530934717,'password'=>'ceshi','code'=>'746119']){
|
public function register_action($data = ['data'=>13408173311,'password'=>'123','code'=>'746119']){
|
||||||
try {
|
try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
// 验证是否前段发送过来的数据
|
// 验证是否前段发送过来的数据
|
||||||
|
|
@ -46,11 +46,14 @@ class Login extends Base{
|
||||||
if($montage_data == false){
|
if($montage_data == false){
|
||||||
return $this->msg(10005);
|
return $this->msg(10005);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询账号是否已经注册
|
// 查询账号是否已经注册
|
||||||
$inspect_repeat = Db::table($this->login_use_db_name['1'])->where([$montage_data=>$data['data'],'is_del'=>0])->count();
|
$inspect_repeat = Db::table($this->login_use_db_name['1'])->where([$montage_data=>$data['data'],'is_del'=>0])->count();
|
||||||
if($inspect_repeat >= 0){
|
|
||||||
|
if($inspect_repeat > 0){
|
||||||
return $this->msg(10002,'注册失败,账号已存在');
|
return $this->msg(10002,'注册失败,账号已存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查验证码
|
// 检查验证码
|
||||||
$code_result = $this->check_code($data['data'],$data['code']);
|
$code_result = $this->check_code($data['data'],$data['code']);
|
||||||
if($code_result !== true){
|
if($code_result !== true){
|
||||||
|
|
|
||||||
|
|
@ -450,6 +450,29 @@ Route::any('/testedition/kitchenscale/cookbook_like', 'app/kitchenscale/testapp.
|
||||||
// 获取当前食材重量卡路里
|
// 获取当前食材重量卡路里
|
||||||
Route::any('/kitchenscale/food_count_kcal', 'app/kitchenscale/app.cookbook/food_count_kcal');
|
Route::any('/kitchenscale/food_count_kcal', 'app/kitchenscale/app.cookbook/food_count_kcal');
|
||||||
Route::any('/testedition/kitchenscale/food_count_kcal', 'app/kitchenscale/testapp.cookbook/food_count_kcal');
|
Route::any('/testedition/kitchenscale/food_count_kcal', 'app/kitchenscale/testapp.cookbook/food_count_kcal');
|
||||||
|
// 获取当前食材重量卡路里
|
||||||
|
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/save_food_list', 'app/kitchenscale/app.cookbook/save_food_list');
|
||||||
|
Route::any('/testedition/kitchenscale/save_food_list', 'app/kitchenscale/testapp.cookbook/save_food_list');
|
||||||
|
|
||||||
|
// 我的################################################################
|
||||||
|
// 账号收藏点赞列表
|
||||||
|
Route::any('/kitchenscale/get_user_collect_list', 'app/kitchenscale/app.usercenter/get_user_collect_list');
|
||||||
|
Route::any('/testedition/kitchenscale/get_user_collect_list', 'app/kitchenscale/testapp.usercenter/get_user_collect_list');
|
||||||
|
// 我的菜谱
|
||||||
|
Route::any('/kitchenscale/get_my_cookbook', 'app/kitchenscale/app.usercenter/get_my_cookbook');
|
||||||
|
Route::any('/testedition/kitchenscale/get_my_cookbook', 'app/kitchenscale/testapp.usercenter/get_my_cookbook');
|
||||||
|
|
||||||
|
|
||||||
|
// 测试用内容################################################################
|
||||||
|
Route::any('/kitchenscale/get_default_configuration', 'app/kitchenscale/app.product/get_default_configuration');
|
||||||
|
// Route::any('/kitchenscale/getRelatedConfigurations', 'app/kitchenscale/app.product/getRelatedConfigurations');
|
||||||
|
// Route::any('/kitchenscale/getOptionConfigurations', 'app/kitchenscale/app.product/getOptionConfigurations');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
<script>
|
<script>
|
||||||
// 设置最终提交变量(important)
|
// 设置最终提交变量(important)
|
||||||
var post_data = {
|
var post_data = {
|
||||||
"cook_label": '家常菜谱', //菜谱标签,属于什么菜系之类的
|
"cook_label": '2', //菜谱标签,属于什么菜系之类的
|
||||||
"token": 'caadd1be045a65f30b92aa805f1de54a', //菜谱标签,属于什么菜系之类的
|
"token": 'caadd1be045a65f30b92aa805f1de54a', //菜谱标签,属于什么菜系之类的
|
||||||
"cover": '', //封面图片
|
"cover": '', //封面图片
|
||||||
"title": '', //菜谱标题
|
"title": '', //菜谱标题
|
||||||
|
|
@ -401,6 +401,7 @@
|
||||||
// };
|
// };
|
||||||
// 最终数据格式示意end
|
// 最终数据格式示意end
|
||||||
console.log(post_data)
|
console.log(post_data)
|
||||||
|
// return
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// url:"https://tc.pcxbc.com/kitchenscale/add_cookbook", //请求的url地址
|
// url:"https://tc.pcxbc.com/kitchenscale/add_cookbook", //请求的url地址
|
||||||
url:"http://wm.tcxbc.com/kitchenscale/add_cookbook", //请求的url地址
|
url:"http://wm.tcxbc.com/kitchenscale/add_cookbook", //请求的url地址
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>挖掘机配置</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0 0;
|
||||||
|
padding: 0 0;
|
||||||
|
}
|
||||||
|
.big_box {
|
||||||
|
width: 90vw;
|
||||||
|
height: 90vh;
|
||||||
|
border: 1px solid red;
|
||||||
|
position: absolute;
|
||||||
|
top: 3vh;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.left {
|
||||||
|
width: 30vw;
|
||||||
|
border-right: 1px solid red;
|
||||||
|
}
|
||||||
|
.left_c {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 4vw;
|
||||||
|
text-align: center;
|
||||||
|
margin: 3vw 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.left_c:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
.right {
|
||||||
|
width: 60vw;
|
||||||
|
}
|
||||||
|
.right_c {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
margin: 2vw 0;
|
||||||
|
padding: 0 2vw;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.child {
|
||||||
|
width: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 5px 0;
|
||||||
|
padding: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
.child:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../x_admin/js/jq.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="big_box">
|
||||||
|
<div class="left" id="left-box">
|
||||||
|
<!-- 动态加载配置名 -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="right" id="right-box">
|
||||||
|
<!-- 动态加载配置项 -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var initial_data
|
||||||
|
var temporary_str = ''
|
||||||
|
var leftBox = $('#left-box');
|
||||||
|
var rightBox = $('#right-box');
|
||||||
|
$(document).ready(function(){
|
||||||
|
// 页面加载完成后执行的代码
|
||||||
|
load_action();
|
||||||
|
});
|
||||||
|
|
||||||
|
function load_action(){
|
||||||
|
$.ajax({
|
||||||
|
url:"/kitchenscale/get_default_configuration", //请求的url地址
|
||||||
|
dataType:"json", //返回格式为json
|
||||||
|
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||||
|
data:{"id":"value"}, //参数值
|
||||||
|
type:"POST", //请求方式
|
||||||
|
success:function(req){
|
||||||
|
//请求成功时处理
|
||||||
|
console.log(req);
|
||||||
|
initial_data = req.data; // 将请求结果保存到initial_data中
|
||||||
|
renderLeftBox(); // 渲染左侧配置名
|
||||||
|
|
||||||
|
},
|
||||||
|
error:function(){
|
||||||
|
//请求出错处理
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function renderLeftBox() {
|
||||||
|
leftBox.empty(); // 清空左侧内容
|
||||||
|
rightBox.empty(); // 清空左侧内容
|
||||||
|
for (var key in initial_data) {
|
||||||
|
temporary_str = '';
|
||||||
|
if(initial_data[key]['type'] == 'configuration'){
|
||||||
|
leftBox.append('<div class="left_c">' + initial_data[key]['name'] + '</div>');
|
||||||
|
temporary_str = '<div class="right_c"><div class="title">'+initial_data[key]['name']+'</div>'
|
||||||
|
}
|
||||||
|
// if(){
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
for (var k in initial_data[key]['list']) {
|
||||||
|
if(initial_data[key]['list'][k]['type'] == 'parameter'){
|
||||||
|
temporary_str = temporary_str + '<div class="child" onclick="get_configuration('+initial_data[key]['list'][k]['id']+')">'+initial_data[key]['list'][k]['name']+'</div>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temporary_str = temporary_str + '</div>';
|
||||||
|
rightBox.append(temporary_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue