コード例 #1
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {"updated": ""}}
     errors = utils.errors
     success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.')
     try:
         if not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({"error": 1, "message": errors["json"]})
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({"error": 1, "message": val_error})
                 resp.body = json.dumps(output_dict)
             else:
                 indict = input_dict["data"]
                 #compGrp = Table("mw_company_group", schema="mint_loan")
                 compMaster = Table("mw_company_master",schema="mint_loan")
                 #compCityMap = Table("mw_company_city_mapping", schema="mint_loan")
                 #compDocMap = Table("mw_company_document_mapping",schema="mint_loan")
                 #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan")
                 #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan")
                 #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                 q1=Query.from_(compMaster).select(compMaster.SHORT_NAME).where(compMaster.AUTO_ID==input_dict["data"]["companyID"])
                 companyName=db.runQuery(q1)["data"]
                 if companyName!=[]:
                     inserted = db.Insert(db="mint_loan", table="mw_company_city_mapping", compulsory=False,date=False,
                                                 **utils.mergeDicts({"COMPANY_NAME":input_dict["data"]["companyName"] if input_dict["data"]["companyName"] else None,
                                                 "COMPANY_ID":input_dict["data"]["companyID"] if input_dict["data"]["companyID"] else None,
                                                 "DOCUMENT_ID":input_dict["data"]["documentID"] if input_dict["data"]["documentID"] else None,
                                                 "CREATED_BY":input_dict["msgHeader"]["authLoginID"],
                                                 "CREATED_DATE":datetime.now().strftime("%Y-%m-%d %H:%M:%S")}))#(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S"))
                     token = generate(db).AuthToken()
                     if token["updated"]:
                         output_dict["data"].update({"error": 0, "message": "document mapped successfully"})
                         output_dict["msgHeader"]["authToken"] = token["token"]
                     else:
                         output_dict["data"].update({"error": 1, "message": errors["token"]})
                 else:
                     token = generate(db).AuthToken()
                     output_dict["data"].update({"error": 0, "message": "document "})
                     output_dict["msgHeader"]["authToken"] = token["token"]
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise
コード例 #2
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {}}
     errors = utils.errors
     #success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.')
     try:
         if not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({"error": 1, "message": errors["json"]})
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({"error": 1, "message": val_error})
                 resp.body = json.dumps(output_dict)
             else:
                 #loginID = input_dict["data"]["loginID"]
                 cityMaster=Table("mw_city_master",schema="mint_loan")
                 #compGrp = Table("mw_company_group", schema="mint_loan")
                 #compMaster = Table("mw_company_master",schema="mint_loan")
                 #compCityMap = Table("mw_company_city_mapping", schema="mint_loan")
                 #compDocMap = Table("mw_company_document_mapping",schema="mint_loan")
                 #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan")
                 #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan")
                 kyc = Table("mw_kyc_document_type",schema="mint_loan")
                 #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                 q1=Query.from_(kyc).select(kyc.DOCUMENT_TYPE_ID,kyc.DOCUMENT_TYPE,kyc.DOCUMENT_GROUP)
                 doc=db.runQuery(q1)["data"]
                 if doc!=[]:
                     token = generate(db).AuthToken()
                     if token["updated"]:
                         output_dict["data"].update({"error": 0, "message": "document details found","doc":doc})
                         output_dict["msgHeader"]["authToken"] = token["token"]
                     else:
                         output_dict["data"].update({"error": 1, "message": errors["token"]})
                 else:
                     token = generate(db).AuthToken()
                     output_dict["data"].update({"error": 0, "message":"document details not found"})
                     output_dict["msgHeader"]["authToken"] = token["token"]    
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise
コード例 #3
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {}}
     errors = utils.errors
     success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON',
                                'The JSON was incorrect.')
     try:
         if not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({
                 "error": 1,
                 "message": errors["json"]
             })
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(
                 token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({
                     "error": 1,
                     "message": val_error
                 })
                 resp.body = json.dumps(output_dict)
             else:
                 #loginID = input_dict["data"]["loginID"]
                 compGrp = Table("mw_company_group", schema="mint_loan")
                 compMaster = Table("mw_company_master", schema="mint_loan")
                 #cityMaster =Table("mw_city_master",schema="mint_loan")
                 #compCityMap = Table("mw_company_city_mapping", schema="mint_loan")
                 #compDocMap = Table("mw_company_document_mapping",schema="mint_loan")
                 #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan")
                 #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan")
                 #kyc=Table("mw_kyc_document_type",schema="mint_loan")
                 q1 = Query.from_(compMaster).join(
                     compGrp, how=JoinType.left).on(
                         compGrp.ID == compMaster.GROUP_ID).select(
                             compMaster.SHORT_NAME, compMaster.DISPLAY_NAME,
                             compMaster.COMPANY_NAME, compMaster.GROUP_ID,
                             compGrp.GROUP_NAME)
                 company = db.runQuery(q1)["data"]
                 #print(company)
                 q2 = Query.from_(compGrp).select('*')
                 cmGroup = db.runQuery(q2)["data"]
                 print(cmGroup)
             if True:
                 token = generate(db).AuthToken()
                 if token["updated"]:
                     #output_dict["data"]["updated"] = company
                     output_dict["data"].update({
                         "company": company,
                         "group": cmGroup
                     })
                     output_dict["data"].update({
                         "error": 0,
                         "message": success
                     })
                     output_dict["msgHeader"]["authToken"] = token["token"]
                 else:
                     output_dict["data"].update({
                         "error": 1,
                         "message": errors["token"]
                     })
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise
コード例 #4
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {}}
     errors = utils.errors
     success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON',
                                'The JSON was incorrect.')
     try:
         if not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({
                 "error": 1,
                 "message": errors["json"]
             })
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(
                 token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({
                     "error": 1,
                     "message": val_error
                 })
                 resp.body = json.dumps(output_dict)
             else:
                 #loginID = input_dict["data"]["loginID"]
                 compGrp = Table("mw_company_group", schema="mint_loan")
                 #compMaster = Table("mw_company_master",schema="mint_loan")
                 #compCityMap = Table("mw_company_city_mapping", schema="mint_loan")
                 #compDocMap = Table("mw_company_document_mapping",schema="mint_loan")
                 #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan")
                 #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan")
                 #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                 if db.Query(primaryTable="mw_company_master",
                             fields={"A": ["*"]},
                             conditions={
                                 "SHORT_NAME =":
                                 input_dict["data"]["shortName"]
                             },
                             Data=False)["count"] == 0:
                     q1 = Query.from_(compGrp).select(
                         compGrp.ID).where(compGrp.GROUP_NAME ==
                                           input_dict["data"]["groupName"])
                     groupID = db.runQuery(q1)
                     if groupID["data"]:
                         groupId = str(groupID["data"][0]["ID"])
                     else:
                         groupId = None
                     print(groupId)
                     inserted = db.Insert(
                         db="mint_loan",
                         table="mw_company_master",
                         compulsory=False,
                         date=False,
                         **utils.mergeDicts({
                             "SHORT_NAME":
                             input_dict["data"]["shortName"]
                             if input_dict["data"]["groupName"] else None,
                             "DISPLAY_NAME":
                             input_dict["data"]["displayName"]
                             if input_dict["data"]["displayName"] else None,
                             "COMPANY_NAME":
                             input_dict["data"]["companyName"]
                             if input_dict["data"]["companyName"] else None,
                             "PAN_NUMBER":
                             input_dict["data"]["panNumber"]
                             if input_dict["data"]["panNumber"] else None,
                             "IS_VENDOR":
                             input_dict["data"]["isVendor"]
                             if input_dict["data"]["isVendor"] else None,
                             "PREFERRED":
                             input_dict["data"]["preferred"]
                             if input_dict["data"]["preferred"] else None,
                             "ICON_URL":
                             input_dict["data"]["iconUrl"]
                             if input_dict["data"]["iconUrl"] else None,
                             "OTHER_DETAILS_WEB_URL":
                             input_dict["data"]["webUrl"]
                             if input_dict["data"]["webUrl"] else '',
                             "GROUP_ID":
                             str(groupId),
                             "CREATED_BY":
                             input_dict["msgHeader"]["authLoginID"],
                             "CREATED_DATE":
                             datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                         }))
                     token = generate(db).AuthToken()
                     if token["updated"] and inserted:
                         #output_dict["data"]["updated"] = updated
                         output_dict["data"].update({
                             "error":
                             0,
                             "message":
                             "company added successfully"
                         })
                         output_dict["msgHeader"]["authToken"] = token[
                             "token"]
                     else:
                         output_dict["data"].update({
                             "error":
                             1,
                             "message":
                             errors["token"]
                         })
                 else:
                     token = generate(db).AuthToken()
                     output_dict["data"].update({
                         "error":
                         0,
                         "message":
                         "company already exist"
                     })
                     output_dict["msgHeader"]["authToken"] = token["token"]
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise
コード例 #5
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {}}
     errors = utils.errors
     success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON',
                                'The JSON was incorrect.')
     try:
         if not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({
                 "error": 1,
                 "message": errors["json"]
             })
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(
                 token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({
                     "error": 1,
                     "message": val_error
                 })
                 resp.body = json.dumps(output_dict)
             else:
                 #loginID = input_dict["data"]["loginID"]
                 compGrp = Table("mw_company_group", schema="mint_loan")
                 compMaster = Table("mw_company_master", schema="mint_loan")
                 cityMaster = Table("mw_city_master", schema="mint_loan")
                 compCityMap = Table("mw_company_city_mapping",
                                     schema="mint_loan")
                 compDocMap = Table("mw_company_document_mapping",
                                    schema="mint_loan")
                 compCityProdMap = Table("mw_company_city_product_mapping",
                                         schema="mint_loan")
                 compOtherMap = Table("mw_company_other_details_mapping",
                                      schema="mint_loan")
                 kyc = Table("mw_kyc_document_type", schema="mint_loan")
                 #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                 q1 = Query.from_(compGrp).select(compGrp.ID).where(
                     compGrp.GROUP_NAME == input_dict["data"]["groupName"])
                 groupID = db.runQuery(q1)
                 if groupID["data"]:
                     groupId = groupID["data"][0]["ID"]
                 else:
                     groupId = None
                 #print(groupId)
                 q2 = Query.from_(compMaster).select('*').where(
                     compMaster.GROUP_ID == groupId)
                 company = db.runQuery(q2)
                 companyShortName = list(
                     ele["SHORT_NAME"] for ele in
                     company["data"]) if company["data"] else None
                 print(companyShortName)
                 join = Query.from_(cityMaster).join(
                     compCityMap,
                     how=JoinType.inner).on_field("CITY_ID").select(
                         cityMaster.CITY, compCityMap.CITY_ID,
                         compCityMap.COMPANY_SHORT_NAME,
                         compCityMap.INSURANCE_ENABLED)
                 q3 = join.where(
                     compCityMap.COMPANY_SHORT_NAME.isin(companyShortName))
                 cityData = db.runQuery(q3)
                 join = Query.from_(kyc).join(
                     compDocMap,
                     how=JoinType.inner).on(kyc.DOCUMENT_TYPE_ID ==
                                            compDocMap.DOCUMENT_ID).select(
                                                compDocMap.DOCUMENT_ID,
                                                kyc.DOCUMENT_TYPE,
                                                compDocMap.COMPANY_ID,
                                                compDocMap.COMPANY_NAME,
                                                compDocMap.UPFRONT_REQUIRED)
                 q4 = join.where(
                     compDocMap.COMPANY_NAME.isin(companyShortName))
                 docData = db.runQuery(q4)
             if True:
                 token = generate(db).AuthToken()
                 if token["updated"]:
                     #output_dict["data"]["updated"] = company
                     output_dict["data"].update({
                         "city": cityData["data"],
                         "document": docData["data"],
                         "company": company["data"]
                     })
                     output_dict["data"].update({
                         "error": 0,
                         "message": success
                     })
                     output_dict["msgHeader"]["authToken"] = token["token"]
                 else:
                     output_dict["data"].update({
                         "error": 1,
                         "message": errors["token"]
                     })
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise
コード例 #6
0
 def on_post(self, req, resp):
     """Handles POST requests"""
     output_dict = {"msgHeader": {"authToken": ""}, "data": {}}
     errors = utils.errors
     success = "company group successfully created"
     try:
         raw_json = req.stream.read()
         input_dict = json.loads(raw_json, encoding='utf-8')
     except Exception as ex:
         raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON',
                                'The JSON was incorrect.')
     try:
         if False:  #not validate.Request(api='companyGroup', request=input_dict):
             output_dict["data"].update({
                 "error": 1,
                 "message": errors["json"]
             })
             resp.body = json.dumps(output_dict)
         else:
             db = DB(input_dict["msgHeader"]["authLoginID"])
             val_error = validate(db).basicChecks(
                 token=input_dict["msgHeader"]["authToken"])
             if val_error:
                 output_dict["data"].update({
                     "error": 1,
                     "message": val_error
                 })
                 resp.body = json.dumps(output_dict)
             else:
                 indict = input_dict["data"]
                 #compGrp = Table("mw_company_group", schema="mint_loan")
                 compMaster = Table("mw_company_master", schema="mint_loan")
                 cityMaster = Table("mw_city_master", schema="mint_loan")
                 compCityMap = Table("mw_company_city_mapping",
                                     schema="mint_loan")
                 #compDocMap = Table("mw_company_document_mapping",schema="mint_loan")
                 #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan")
                 #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan")
                 #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                 #join = Query.from_(cityMaster).join(compCityMap,how=JoinType.inner).on_field("CITY_ID").select(functions.Count(compCityMap.CITY_ID).as_("cityCount"))
                 #q3=join.where((cityMaster.CITY==input_dict["data"]["city"]) &(compCityMap.COMPANY_SHORT_NAME==input_dict["data"]["shortName"]))
                 #cityCount=db.runQuery(q3)["data"]
                 #print(cityCount)
                 #cityExist= cityCount[0]["cityCount"]  if cityCount!=[] else 0
                 #print(cityExist)
                 q1 = Query.from_(compCityMap).select(
                     compCityMap.COMPANY_SHORT_NAME).where(
                         compCityMap.CITY_ID == input_dict["data"]
                         ["cityID"])
                 companyName = db.runQuery(q1)["data"]
                 if companyName == []:
                     #city_id=db.runQuery(Query.from_(cityMaster).select(cityMaster.CITY_ID).where(cityMaster.CITY==input_dict["data"]["city"]))["data"]
                     #print(city_id)
                     inserted = db.Insert(
                         db="mint_loan",
                         table="mw_company_city_mapping",
                         compulsory=False,
                         date=False,
                         **utils.mergeDicts({
                             "COMPANY_SHORT_NAME":
                             input_dict["data"]["companyShortName"]
                             if input_dict["data"]["companyShortName"] else
                             None,
                             "CITY_ID":
                             input_dict["data"]["cityID"]
                             if input_dict["data"]["cityID"] else None,
                             "INSURANCE_ENABLED":
                             0,
                             "CREATED_BY":
                             input_dict["msgHeader"]["authLoginID"],
                             "CREATED_DATE":
                             datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                         })
                     )  #(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")
                     token = generate(db).AuthToken()
                     if token["updated"] and inserted:
                         output_dict["data"].update({
                             "error":
                             0,
                             "message":
                             "city mapped successfully"
                         })
                         output_dict["msgHeader"]["authToken"] = token[
                             "token"]
                     else:
                         output_dict["data"].update({
                             "error":
                             1,
                             "message":
                             errors["token"]
                         })
                 else:
                     token = generate(db).AuthToken()
                     output_dict["data"].update({
                         "error":
                         0,
                         "message":
                         "city already mapped"
                     })
                     output_dict["msgHeader"]["authToken"] = token["token"]
             resp.body = json.dumps(output_dict)
             db._DbClose_()
     except Exception as ex:
         # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.')
         raise