|
@@ -97,6 +97,23 @@ class Course(BaseModel):
|
|
|
price_discount: int
|
|
|
hours: float
|
|
|
units: int
|
|
|
+@app.post("/get_courses_by_cid")
|
|
|
+async def get_courses(cids:List[int]):
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/openTalk?charset=utf8mb4')
|
|
|
+ cid_str = '('
|
|
|
+ for t in cids:
|
|
|
+ cid_str = cid_str + str(t) +','
|
|
|
+ cid_str = cid_str[:-1]+')'
|
|
|
+
|
|
|
+ courses = []
|
|
|
+ statement = 'SELECT * FROM course WHERE id IN'+cid_str
|
|
|
+
|
|
|
+ for row in db.query(statement):
|
|
|
+ courses.append({'id':row['course_id'],'title':row['title'],'url':row['url']
|
|
|
+ ,'teacher_name':['teacher_name'],'price':row['price'],'price_discount':row['price_discount'],'profile':row['profile']
|
|
|
+ ,'cover_img':'https://'+serverADDR + row['cover_img'],'hours':row['hours'],'units':row['units']})
|
|
|
+ return courses
|
|
|
+
|
|
|
|
|
|
@app.post("/get_courses")
|
|
|
async def get_courses(tags:List[int]):
|