add current_week,lesson_color
This commit is contained in:
parent
f77abd4c21
commit
e341222f8e
6
coc.py
6
coc.py
@ -1,5 +1,5 @@
|
|||||||
# 引入文件夹中的文件
|
# 引入文件夹中的文件
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS #跨域访问
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('./lib')
|
sys.path.append('./lib')
|
||||||
from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGet, manageDetail, manageComment
|
from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGet, manageDetail, manageComment
|
||||||
@ -7,7 +7,9 @@ from allFunction import manageLogin, managePhoto, manageAdd, manageDel, manageGe
|
|||||||
from flask import Flask, request, session
|
from flask import Flask, request, session
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app, resources=r'/*') # 注册CORS, "/*" 允许访问所有api
|
|
||||||
|
#取消跨域访问限制,方便本地测试
|
||||||
|
#CORS(app, resources=r'/*') # 注册CORS, "/*" 允许访问所有api
|
||||||
|
|
||||||
# 登录接口,前端提供cid和pwd,包装在data里边然后md5校验也就是data:{cid,pwd,sign}
|
# 登录接口,前端提供cid和pwd,包装在data里边然后md5校验也就是data:{cid,pwd,sign}
|
||||||
@app.route('/api/login',methods=['POST'])
|
@app.route('/api/login',methods=['POST'])
|
||||||
|
BIN
lib/__pycache__/db.cpython-37.pyc
Normal file
BIN
lib/__pycache__/db.cpython-37.pyc
Normal file
Binary file not shown.
BIN
lib/__pycache__/photoUpload.cpython-37.pyc
Normal file
BIN
lib/__pycache__/photoUpload.cpython-37.pyc
Normal file
Binary file not shown.
@ -168,6 +168,12 @@ def getGrade(Ip, S):
|
|||||||
|
|
||||||
def getSchedule(Ip, S):
|
def getSchedule(Ip, S):
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
r = S.post(
|
||||||
|
url='http://'+Ip[0]+'-'+Ip[1]+'-'+Ip[2]+'-'+Ip[3]+'-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/GetHomeCurWeekTime?sf_request_type=ajax',
|
||||||
|
data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}),
|
||||||
|
headers=headers
|
||||||
|
)
|
||||||
|
CurWeek = json.loads(r.content.decode('utf-8'))['data']['CurWeek']
|
||||||
r = S.post(
|
r = S.post(
|
||||||
url='http://'+Ip[0]+'-'+Ip[1]+'-'+Ip[2]+'-'+Ip[3]+'-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/QueryStudentScheduleData?sf_request_type=ajax',
|
url='http://'+Ip[0]+'-'+Ip[1]+'-'+Ip[2]+'-'+Ip[3]+'-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/QueryStudentScheduleData?sf_request_type=ajax',
|
||||||
data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}),
|
data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}),
|
||||||
@ -179,12 +185,15 @@ def getSchedule(Ip, S):
|
|||||||
time = ['AM__TimePieces','PM__TimePieces','EV__TimePieces']
|
time = ['AM__TimePieces','PM__TimePieces','EV__TimePieces']
|
||||||
data = data['data']['AdjustDays']
|
data = data['data']['AdjustDays']
|
||||||
days_per_week = [0] * 23
|
days_per_week = [0] * 23
|
||||||
lesson = [[0] * 7 for _ in range(6)]
|
lesson = [[0] * 6 for _ in range(7)]
|
||||||
|
lesson_set = {}
|
||||||
|
color_set = [0] * 9
|
||||||
|
color_used = 9
|
||||||
for i in range(7):
|
for i in range(7):
|
||||||
for j in range(3):
|
for j in range(3):
|
||||||
for k in range(2):
|
for k in range(2):
|
||||||
if( data[i][time[j]][k]['Dtos'] ):
|
if( data[i][time[j]][k]['Dtos'] ):
|
||||||
lesson[j*2+k][i] = []
|
lesson[i][j*2+k] = []
|
||||||
for l in data[i][time[j]][k]['Dtos']:
|
for l in data[i][time[j]][k]['Dtos']:
|
||||||
temp_lesson = {}
|
temp_lesson = {}
|
||||||
Time = [0] * 23
|
Time = [0] * 23
|
||||||
@ -194,6 +203,16 @@ def getSchedule(Ip, S):
|
|||||||
temp_lesson[m['Key']] += ','+m['Name']
|
temp_lesson[m['Key']] += ','+m['Name']
|
||||||
else:
|
else:
|
||||||
temp_lesson[m['Key']] = m['Name']
|
temp_lesson[m['Key']] = m['Name']
|
||||||
|
if lesson_set.get(l['Content'][0]['Name']):
|
||||||
|
temp_lesson['color'] = lesson_set[l['Content'][0]['Name']]
|
||||||
|
else:
|
||||||
|
color = random.randint(0, 8)
|
||||||
|
while color_set[color] and color_used:
|
||||||
|
color = random.randint(0, 8)
|
||||||
|
temp_lesson['color'] = color
|
||||||
|
lesson_set[l['Content'][0]['Name']] = color
|
||||||
|
color_used -= 1
|
||||||
|
color_set[color] = 1
|
||||||
temp_Time = temp_lesson['Time']
|
temp_Time = temp_lesson['Time']
|
||||||
if '单周' in temp_Time:
|
if '单周' in temp_Time:
|
||||||
mod = 'single'
|
mod = 'single'
|
||||||
@ -223,17 +242,6 @@ def getSchedule(Ip, S):
|
|||||||
Time[int(n[0])] = 1
|
Time[int(n[0])] = 1
|
||||||
index += 1
|
index += 1
|
||||||
temp_lesson['Time_split'] = Time
|
temp_lesson['Time_split'] = Time
|
||||||
lesson[j*2+k][i].append(temp_lesson)
|
lesson[i][j*2+k].append(temp_lesson)
|
||||||
data_cache = {'lesson':lesson,'days_per_week':days_per_week}
|
data_cache = {'lesson':lesson,'days_per_week':days_per_week,'cur_week':CurWeek}
|
||||||
return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache}
|
return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache}
|
||||||
|
|
||||||
def getCurrentTime(Ip, S):
|
|
||||||
headers = {'Content-Type': 'application/json'}
|
|
||||||
r = S.post(
|
|
||||||
url='http://192-168-223-71-8080-p.webvpn.cust.edu.cn:8118/api/ClientStudent/Home/StudentHomeApi/GetHomeCurWeekTime?sf_request_type=ajax',
|
|
||||||
data=json.dumps({"param":"JTdCJTdE","__permission":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Operation":0},"__log":{"MenuID":"F71C97D5-D3E2-4FDA-9209-D7FA8626390E","Logtype":6,"Context":"查询"}}),
|
|
||||||
headers=headers
|
|
||||||
)
|
|
||||||
data = json.loads(r.content.decode('utf-8'))
|
|
||||||
data_cache = data['data'].pop('DateList')
|
|
||||||
return {'errcode': 200, 'errmsg': 'ok', 'data': data_cache}
|
|
Loading…
x
Reference in New Issue
Block a user