def api_parent_qrcode(request): dict_resp = auth_check(request, "GET", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: cur_type_user = get_type_current_user(request.user) if not isinstance(cur_type_user, Parent): raise BusinessException(ERR_WX_USE_PARENT) parent_id = request.GET.get("parent_id", "") school_id = request.GET.get("sid", "") if not parent_id: cur_type_user = get_type_current_user(request.user) if not isinstance(cur_type_user, Parent): raise BusinessException(ERR_WX_USE_PARENT) parent_id = cur_type_user.id school_id = cur_type_user.school_id cur_domain = get_cur_domain(request) dict_resp = agents.api_parent_qrcode(cur_domain, school_id, parent_id) # dictResp = paging_with_request(request, dict_resp) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_invite_parent1(request): dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: parent_id = request.POST.get("parent_id", "") parent = get_parentbyid(parent_id) user = parent.account mobile = request.POST.get("mobile", "") fullname = request.POST.get("fullname", "") sex = request.POST.get("sex", "") address = request.POST.get("address", "") # student_list_json = request.POST.get("student_list_json", "") messagecode = request.POST.get("messagecode", "") school_id = parent.school_id relation = request.POST.get("relation", "") dict_resp = agents.api_invite_parent1(user, school_id, mobile, address, fullname, sex, relation, messagecode) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_bind_parent(request): dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: mobile = request.POST.get("mobile", "") fullname = request.POST.get("fullname", "") sex = request.POST.get("sex", "") address = request.POST.get("address", "") student_list_json = request.POST.get("student_list_json", "") messagecode = request.POST.get("messagecode", "") openid = request.POST.get("openid", "") school_id = request.POST.get("sid", "") class_id = request.POST.get("class_id", "") only_check = request.POST.get("only_check", "") dict_resp = agents.api_bind_parent(openid, school_id, class_id, mobile, address, fullname, sex, student_list_json, messagecode, only_check=only_check) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def wx_service_list(request): dict_resp = auth_check(request, "GET", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: dict_resp = agents.get_wx_service_list(request.user) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_add_child_by_parent(request): dict_resp = auth_check(request, "POST", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: student_list_json = request.POST.get("student_list_json", "") dict_resp = agents.api_add_child_by_parent(request.user, student_list_json) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_fh_qrcode(request): dict_resp = auth_check(request, "GET", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: cur_domain = get_cur_domain(request) dict_resp = agents.api_fh_qrcode(cur_domain) # dictResp = paging_with_request(request, dict_resp) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_send_parent_bind_messagecode(request): dict_resp = auth_check(request, "GET", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: mobile = request.GET.get("mobile", "") dict_resp = agents.api_send_bind_messagecode(mobile, check_account_exist=False, check_user_bind=False) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_get_accountopenid(request): # 避免传入数据过大,本接口使用POST方式 dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: account_id_list = request.POST.get("account_id_list", "") school_id = request.POST.get("sid", "") dict_resp = agents.api_get_accountopenid(account_id_list, school_id) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def wx_get_jsconfig(request): log_request(request) school_id = request.POST.get("sid", "") if not school_id: # 不传sid就必须登陆。 dictResp = auth_check(request, "POST", check_login=True) if dictResp != {}: return HttpResponse(json.dumps(dictResp, ensure_ascii=False), content_type="application/json") school_id = request.user.school.id weixin_app_id = request.POST.get("appid", "") url = request.POST.get("url", "") try: weixinschool = get_weixin_school(school_id, weixin_app_id) result = agents.wx_get_jsconfig(weixinschool, url) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message) log_response(request, result) return response200(result)