def get(self, club_id: str) -> 'json': """对应 /api/clubs/<string:club_id>. 获取特定的Club. """ club = club_dao.get_club_by_id(club_id) dto = convert_from_model_to_dto(club) return util.obj2json(dto)
def post(self) -> 'json': """对应 /api/clubs. 新增一个Club. """ club = convert_from_request_to_model(request.data.decode("utf-8")) club_dao.add_club(club) club = club_dao.get_club_by_id(club.club_id) dto = convert_from_model_to_dto(club) return util.obj2json(dto)
def put(self, club_id: str) -> 'json': """对应 /api/clubs/<string:club_id>. 修改特定的Club. """ club = convert_from_request_to_model(request.data.decode("utf-8"), club_id) print(club.club_name) club_dao.update_club(club) club = club_dao.get_club_by_id(club_id) dto = convert_from_model_to_dto(club) return util.obj2json(dto)