def insert_form(cls, data: dict = None): if data is None: data = dict() meta = data.get('meta', {}) lesson_id = meta.get('lesson', {}).get('lesson_id', None) if lesson_id is None: raise CustomError(500, 200, '课程不能为空') if not FormService.check_lesson_meta(meta): raise CustomError(500, 200, '该督导在该时间段, 听过别的课!时间冲突!') dao.Form.insert_form(data) form_model = dao.Form.formatter_total(data) LessonService.refresh_notices( data.get("meta", {}).get("lesson", {}).get("lesson_id")) #刷新听课次数 ModelLessonService.refresh_vote_nums( data.get("meta", {}).get("lesson", {}).get("lesson_id")) #刷新好评课程次数 send_kafka_message(topic='form_service', method='add_form', term=meta.get('term', None), bind_meta_name=form_model.get( 'bind_meta_name', None), username=meta.get('guider', None), form_id=form_model.get('_id', ''), lesson_id=lesson_id) cls.push_new_form_message(form_model) return True
def inser_lesson_record(): guiders = get_all_guider() for guider in guiders: LessonService.refresh_lesson_record(guider)
def run(): model_lessons, num = dao.ModelLesson.query_model_lessons() for model_lesson in model_lessons: print("更新: ", model_lesson['lesson_name']) LessonService.refresh_notices(model_lesson['lesson_id']) ModelLessonService.refresh_vote_nums(model_lesson['lesson_id'])