From 0977093fdaec103dc4e6988805c6d92249f9eddc Mon Sep 17 00:00:00 2001
From: heshupeng <hsp@bronet.cn>
Date: Mon, 25 Jan 2021 16:51:53 +0800
Subject: [PATCH] 收藏的题目

---
 application/mobile/controller/User.php |  9 ++++++---
 public/mobile.html                     |  6 ++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/application/mobile/controller/User.php b/application/mobile/controller/User.php
index f5df2c4..372e64d 100644
--- a/application/mobile/controller/User.php
+++ b/application/mobile/controller/User.php
@@ -1408,9 +1408,11 @@ class User extends Api
 				"user_id": 16, //用户ID
 				"question_id": 1, //题目ID
 				"createtime": "2020.09.03 19:25", //收藏时间
+                "is_answer": 1, //是否已作答:0=否,1=是
 				"question": { //题目信息
 					"title": "测定混凝土立方体抗压强度时,标准试件的尺寸是(      )㎜。", //题目
-					"type": "1" //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
+					"type": "1", //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
+                    "target_type":"1" //题目归属类型:1=全能题库,2=模拟试题,3=历年真题,4=每日一练,5=通关密卷
 				}
 			}]
 		}
@@ -1423,14 +1425,15 @@ class User extends Api
         $data = QuestionCollect::with(['question'])
             ->alias('a')
             ->join('mobile_question b','a.question_id = b.id')
+            ->join('mobile_question_answer c','c.question_id = b.id and c.user_id = '.$this->auth->id,'left')
         	->where('a.user_id',$this->auth->id)
         	->order('a.createtime desc')
-            ->field('a.*')
+            ->field('a.*,if(c.id > 0,1,0) is_answer')
         	->paginate($page_num,false,['page'=>$page])
             ->each(function($v){
                 $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
                 if($v->getRelation('question')){
-                    $v->getRelation('question')->visible(['title','type']);
+                    $v->getRelation('question')->visible(['title','type','target_type']);
                 }
             })->toArray();
         $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
diff --git a/public/mobile.html b/public/mobile.html
index ec8f96d..1c1f490 100644
--- a/public/mobile.html
+++ b/public/mobile.html
@@ -16097,9 +16097,11 @@
 				"user_id": 16, //用户ID
 				"question_id": 1, //题目ID
 				"createtime": "2020.09.03 19:25", //收藏时间
+                "is_answer": 1, //是否已作答:0=否,1=是
 				"question": { //题目信息
 					"title": "测定混凝土立方体抗压强度时,标准试件的尺寸是(      )㎜。", //题目
-					"type": "1" //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
+					"type": "1", //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
+                    "target_type":"1" //题目归属类型:1=全能题库,2=模拟试题,3=历年真题,4=每日一练,5=通关密卷
 				}
 			}]
 		}
@@ -23080,7 +23082,7 @@
 
             <div class="row mt0 footer">
                 <div class="col-md-6" align="left">
-                    Generated on 2021-01-25 09:52:58                </div>
+                    Generated on 2021-01-25 16:51:12                </div>
                 <div class="col-md-6" align="right">
                     <a href="./" target="_blank">企智帮</a>
                 </div>
--
libgit2 0.24.0