|
@@ -52,7 +52,10 @@ async def insert_school(
|
|
|
location_name: str = Form(default=''),
|
|
|
Lng: str = Form(default=''),
|
|
|
Lat: str = Form(default=''),
|
|
|
- address : str = Form(default='')
|
|
|
+ address : str = Form(default=''),
|
|
|
+ introduction : str = Form(default=''),
|
|
|
+ email : str = Form(default=''),
|
|
|
+ phone : str = Form(default='')
|
|
|
):
|
|
|
try:
|
|
|
new_school = await Schools.create(
|
|
@@ -60,7 +63,10 @@ async def insert_school(
|
|
|
longitude=Lng,
|
|
|
latitude=Lat,
|
|
|
address = address,
|
|
|
- update_time = datetime.now()
|
|
|
+ update_time = datetime.now(),
|
|
|
+ introduction = introduction ,
|
|
|
+ email= email,
|
|
|
+ phone = phone
|
|
|
)
|
|
|
|
|
|
return {"msg": "success", "code": 200, "location_id": new_school.id}
|
|
@@ -127,7 +133,8 @@ async def insert_event(
|
|
|
registration_start: datetime = Form(default=datetime.now()),
|
|
|
registration_end: datetime = Form(default=datetime.now()),
|
|
|
number_limit: int = Form(default=0),
|
|
|
- remark : str = Form(default='詳細 請至觀看課程資訊 查看')
|
|
|
+ remark : str = Form(default='詳細 請至觀看課程資訊 查看'),
|
|
|
+ ATM_address: str = Form(default='')
|
|
|
):
|
|
|
try:
|
|
|
|
|
@@ -149,16 +156,19 @@ async def insert_event(
|
|
|
people=people,
|
|
|
fee_method=fee_method,
|
|
|
registration_way=registration_way,
|
|
|
- remark=remark
|
|
|
- )
|
|
|
-
|
|
|
- await Class_date.create(
|
|
|
- class_list_id = new_class.id,
|
|
|
- registration_start = registration_start,
|
|
|
- registration_end = registration_end,
|
|
|
- number_limit = number_limit,
|
|
|
- amount_left = number_limit
|
|
|
+ remark=remark,
|
|
|
+ ATM_address=ATM_address
|
|
|
)
|
|
|
+ try:
|
|
|
+ await Class_date.create(
|
|
|
+ class_list_id = new_class.id,
|
|
|
+ registration_start = registration_start,
|
|
|
+ registration_end = registration_end,
|
|
|
+ number_limit = number_limit,
|
|
|
+ amount_left = number_limit
|
|
|
+ )
|
|
|
+ except:
|
|
|
+ pass
|
|
|
|
|
|
return {"msg": "success", "code": 200, "class_id": new_class.id}
|
|
|
except Exception as e:
|
|
@@ -238,7 +248,10 @@ async def update_school(
|
|
|
location_name: str = Form(default=''),
|
|
|
Lng: str = Form(default=''),
|
|
|
Lat: str = Form(default=''),
|
|
|
- address : str = Form(default='')
|
|
|
+ address : str = Form(default=''),
|
|
|
+ introduction : str = Form(default=None),
|
|
|
+ email : str = Form(default=None),
|
|
|
+ phone : str = Form(default=None)
|
|
|
):
|
|
|
try:
|
|
|
school = await Schools.get(id=location_id)
|
|
@@ -254,6 +267,15 @@ async def update_school(
|
|
|
|
|
|
if address.strip() != '':
|
|
|
school.address = address
|
|
|
+
|
|
|
+ if introduction:
|
|
|
+ school.introduction = introduction
|
|
|
+
|
|
|
+ if email:
|
|
|
+ school.email = email
|
|
|
+
|
|
|
+ if phone:
|
|
|
+ school.phone = phone
|
|
|
|
|
|
await school.save()
|
|
|
|
|
@@ -344,7 +366,8 @@ async def update_event(
|
|
|
registration_start: datetime = Form(default=datetime.now()),
|
|
|
registration_end: datetime = Form(default=datetime.now()),
|
|
|
number_limit: int = Form(default=0),
|
|
|
- remark : str = Form(default='')
|
|
|
+ remark : str = Form(default=''),
|
|
|
+ ATM_address :str = Form(default='')
|
|
|
):
|
|
|
try:
|
|
|
class_obj = await Class_list.get(id=id)
|
|
@@ -388,6 +411,9 @@ async def update_event(
|
|
|
if remark.strip() != '':
|
|
|
class_obj.remark = remark
|
|
|
|
|
|
+ if ATM_address.strip() != '':
|
|
|
+ class_obj.ATM_address = ATM_address
|
|
|
+
|
|
|
try :
|
|
|
class_date_obj = await Class_date.get(class_list_id=id)
|
|
|
|
|
@@ -631,7 +657,8 @@ async def get_school(
|
|
|
keyword : Optional[str] = None,
|
|
|
location_keyword : Optional[str] = None,
|
|
|
page_num : Optional[int] = None,
|
|
|
- page_amount : Optional[int] = None
|
|
|
+ page_amount : Optional[int] = None,
|
|
|
+ category : Optional[str] = None
|
|
|
):
|
|
|
try:
|
|
|
school_list = Schools.all()
|
|
@@ -644,6 +671,18 @@ async def get_school(
|
|
|
|
|
|
if location_keyword :
|
|
|
school_list = school_list.filter(Q(address__icontains=location_keyword)).all()
|
|
|
+
|
|
|
+ Q_word = Q()
|
|
|
+ if category:
|
|
|
+ for tmp_word in category.split(",") :
|
|
|
+ Q_word = Q_word | Q(category__icontains=tmp_word)
|
|
|
+
|
|
|
+ school_list_tmp = await school_list.all()
|
|
|
+
|
|
|
+ for school_obj in school_list_tmp:
|
|
|
+ class_list = await Class_name.filter(Q(school_id = school_obj.id) & Q_word)
|
|
|
+ if class_list == []:
|
|
|
+ school_list = school_list.exclude(id = school_obj.id)
|
|
|
|
|
|
count = await school_list.all().count()
|
|
|
|
|
@@ -656,16 +695,11 @@ async def get_school(
|
|
|
|
|
|
for school_obj in school_list:
|
|
|
try :
|
|
|
- school_data = {
|
|
|
- "location_id": school_obj.id,
|
|
|
- "location_name": school_obj.name,
|
|
|
- "Lng": school_obj.longitude,
|
|
|
- "Lat": school_obj.latitude,
|
|
|
- "address": school_obj.address,
|
|
|
- "update_time":school_obj.update_time
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ school_data = school_obj.show_data()
|
|
|
+
|
|
|
schools.append(school_data)
|
|
|
+
|
|
|
|
|
|
except:
|
|
|
schools.append({"msg : data wrong"})
|
|
@@ -727,7 +761,7 @@ async def get_class_name(
|
|
|
if recommend :
|
|
|
Q_word = Q_word & Q(recommend = recommend)
|
|
|
|
|
|
- if is_inner:
|
|
|
+ if is_inner!=None:
|
|
|
Q_word = Q_word & Q(is_inner = is_inner)
|
|
|
|
|
|
class_name_list = class_name_list.filter(Q_word).all()
|
|
@@ -951,7 +985,7 @@ async def insert_online_course(
|
|
|
category : str = Form(default=''),
|
|
|
create_time :str = Form(default=datetime.now()),
|
|
|
content : str = Form(default=''),
|
|
|
- vedio_url :str = Form(default='')
|
|
|
+ video_url :str = Form(default='')
|
|
|
):
|
|
|
try:
|
|
|
new_online_course = await Online_course.create(
|
|
@@ -959,7 +993,7 @@ async def insert_online_course(
|
|
|
create_time=create_time,
|
|
|
category=category,
|
|
|
content=content,
|
|
|
- vedio_url=vedio_url,
|
|
|
+ video_url=video_url,
|
|
|
group_id = 8
|
|
|
)
|
|
|
|
|
@@ -974,7 +1008,7 @@ async def update_online_course(
|
|
|
category : str = Form(default=''),
|
|
|
create_time :str = Form(default=datetime.now()),
|
|
|
content : str = Form(default=''),
|
|
|
- vedio_url :str = Form(default='')
|
|
|
+ video_url :str = Form(default='')
|
|
|
):
|
|
|
try:
|
|
|
online_course_obj = await Online_course.get(id=id)
|
|
@@ -991,8 +1025,8 @@ async def update_online_course(
|
|
|
if content.strip() != '':
|
|
|
online_course_obj.content = content
|
|
|
|
|
|
- if vedio_url.strip() != '':
|
|
|
- online_course_obj.vedio_url = vedio_url
|
|
|
+ if video_url.strip() != '':
|
|
|
+ online_course_obj.video_url = video_url
|
|
|
|
|
|
await online_course_obj.save()
|
|
|
|
|
@@ -1002,13 +1036,33 @@ async def update_online_course(
|
|
|
|
|
|
@classes.get("/get_online_courese")
|
|
|
async def get_online_courese(
|
|
|
- online_courese_id : Optional[int] = None
|
|
|
+ online_courese_id : Optional[int] = None,
|
|
|
+ category:Optional[int] = None,
|
|
|
+ group_id : Optional[int] = None,
|
|
|
+ page_num : Optional[int] = None,
|
|
|
+ page_amount : Optional[int] = None
|
|
|
+
|
|
|
):
|
|
|
try:
|
|
|
+ online_courese_list = Online_course.all()
|
|
|
+ Q_word = Q()
|
|
|
+
|
|
|
+ if group_id:
|
|
|
+ Q_word = Q_word & Q(group_id = group_id)
|
|
|
+
|
|
|
+ if category:
|
|
|
+ for tmp_word in category.split(",") :
|
|
|
+ Q_word = Q_word | Q(category__icontains=tmp_word)
|
|
|
+
|
|
|
if online_courese_id :
|
|
|
- online_courese_list = await Online_course.filter(id = online_courese_id).all()
|
|
|
- else :
|
|
|
- online_courese_list = await Online_course.all()
|
|
|
+ Q_word = Q_word & Q(id = online_courese_id)
|
|
|
+
|
|
|
+ count = await online_courese_list.all().count()
|
|
|
+
|
|
|
+ if page_num and page_amount:
|
|
|
+ online_courese_list = online_courese_list.offset((page_num-1)*page_amount).limit(page_amount)
|
|
|
+
|
|
|
+ online_courese_list = await online_courese_list.all().order_by("-id")
|
|
|
|
|
|
online_coureses = []
|
|
|
for online_coures_obj in online_courese_list:
|
|
@@ -1019,11 +1073,11 @@ async def get_online_courese(
|
|
|
"create_time": online_coures_obj.create_time,
|
|
|
"click_time": online_coures_obj.click_time,
|
|
|
"content": online_coures_obj.content,
|
|
|
- "vedio_url":online_coures_obj.vedio_url
|
|
|
+ "video_url":online_coures_obj.video_url
|
|
|
}
|
|
|
online_coureses.append(online_coures_data)
|
|
|
|
|
|
- return {"msg": "success", "code": 200, "online_coures": online_coureses}
|
|
|
+ return {"msg": "success", "code": 200, "total_num" : count,"online_coures": online_coureses}
|
|
|
except Exception as e:
|
|
|
return {"msg": str(e), "code": 500}
|
|
|
|