def note_delete(note_id): token = request.cookies.get('token') if token: # 根据token获取user_id uid = UserService.get_user_id_by_token(token) if request.method == 'POST': NoteService.delete_note_info(note_id, uid) resp = make_response(redirect('/note', '302')) return resp else: resp = make_response(redirect('/login', '302')) return resp
def note(): # 获取当前token token = request.cookies.get('token') if token: # 根据token获取user_id uid = UserService.get_user_id_by_token(token) # user = UserService.get_user_info(token) # uid = user.get('uid') # 根据user_id 获取note_list note_list = NoteService.get_note_list(uid) return render_template('note_list.html', note_list=note_list) else: resp = make_response(redirect('/login', '302')) return resp
def note_detail(note_id): token = request.cookies.get('token') if token: # 根据token获取user_id uid = UserService.get_user_id_by_token(token) if request.method == 'POST': title = request.form['title'] content = request.form['content'] NoteService.update_note_info(note_id, uid, title, content) resp = make_response(redirect(f'/note/{note_id}', '302')) return resp elif request.method == 'GET': # 通过note_id, user_id查看当前笔记 note_info = NoteService.get_note_info(note_id, uid) return render_template('note_info.html', note_info=note_info) else: resp = make_response(redirect('/login', '302')) return resp