Best Python code snippet using refurb_python
views.py
Source:views.py
1from django.shortcuts import render2from django.shortcuts import HttpResponse3from my_project.service.SamePic import SamePic4from my_project.service.SimilarityPic import SimilarityPic5from my_project.service.GoodsPic import GoodsPic6from my_project.service.Auxiliary import get_file_content7import json8import os9# Create your views here.10user_list = [11 {"user":"jack", "pwd":"abc"},12 {"user":"tom", "pwd":"ABC"}13]14# ç¸åå¾ç±»å«åå
¸15samePicCategoryDict = {16 "ç½ç§äººç·æ§":"1", "ç½ç§äººå¥³æ§":"2", "é»ç§äººç·æ§":"3", "é»ç§äººå¥³æ§":"4", "é»ç§äººç·æ§":"5", "é»ç§äººå¥³æ§":"6", "澳大å©äºäººç§ç·æ§":"7", "澳大å©äºäººç§å¥³æ§":"8", "åºä¹³å¨ç©":"9",17 "两æ å¨ç©":"10", "æè«":"11", "鱼类":"12", "é¸ç±»":"13", "åºä¸ç¨å":"14", "å¨å«ç¨å":"15", "家ç¨çµå¨":"16", "家å
·":"17", "æ¥å¸¸ç¨å":"18",18 "饮æ":"19", "é£ç©":"20", "æºå¨è½¦":"21", "éæºå¨è½¦":"22", "é£æº":"23", "è¹":"24", "èªå¤©å¨":"25", "èªç¶é£å
":"26", "åå¸é£å
":"27",19 "æ
游åè":"28", "other":"29"20}21# ç¸ä¼¼å¾ç±»å«åå
¸22similarPicCategoryDict = {23 "ç½ç§äººç·æ§":"1", "ç½ç§äººå¥³æ§":"2", "é»ç§äººç·æ§":"3", "é»ç§äººå¥³æ§":"4", "é»ç§äººç·æ§":"5", "é»ç§äººå¥³æ§":"6", "澳大å©äºäººç§ç·æ§":"7", "澳大å©äºäººç§å¥³æ§":"8", "åºä¹³å¨ç©":"9",24 "两æ å¨ç©":"10", "æè«":"11", "鱼类":"12", "é¸ç±»":"13", "åºä¸ç¨å":"14", "å¨å«ç¨å":"15", "家ç¨çµå¨":"16", "家å
·":"17", "æ¥å¸¸ç¨å":"18",25 "饮æ":"19", "é£ç©":"20", "æºå¨è½¦":"21", "éæºå¨è½¦":"22", "é£æº":"23", "è¹":"24", "èªå¤©å¨":"25", "èªç¶é£å
":"26", "åå¸é£å
":"27",26 "æ
游åè":"28", "other":"30"27}28# ååå¾ç±»å«åå
¸29productPicCategoryDict = {30 "女è£
":"1", "女é":"2", "ç·è£
":"3", "ç·é":"4", "å
è¡£":"5", "æ¯å©´":"6", "ææº":"7", "æ°ç ":"8", "家çµ":"9",31 "ç¾å¦":"10", "ç®±å
":"11", "è¿å¨":"12", "æ·å¤":"13", "家è£
":"14", "家纺":"15", "å±
家ç¾è´§":"16", "é²è±å® ç©":"17", "é
饰":"18",32 "é£å":"19", "çé²":"20", "汽车æ©æ":"21", "å»è¯":"22", "å¾ä¹¦":"23", "éä¿¡":"24", "æ´æ¤":"25", "ä¹å¨":"26", "other":"27"33}34def index(request):35 # request.POST36 # request.GET37 # return HttpResponse('Hello world!')38 if request.method == "POST":39 username = request.POST.get("username", None)40 password = request.POST.get("password", None)41 print(username, password)42 temp = {"user":username, "pwd":password}43 user_list.append(temp)44 return render(request, "index.html",{"data":user_list})45def index_same(request):46 return render(request, "admin-same.html")47def index_similar(request):48 return render(request, "admin-similar.html")49def index_product(request):50 return render(request, "admin-product.html")51def index_same_url(request):52 return render(request, "admin-same-url.html")53def index_similar_url(request):54 return render(request, "admin-similar-url.html")55def index_product_url(request):56 return render(request, "admin-product-url.html")57# ç¸åå¾å
¥åº58def same_put_in(request):59 if request.method == "POST":60 # è·å表åä¼ è¿æ¥çå¾ç61 image = request.FILES.get("image")62 # è·å表åä¼ è¿æ¥çå¾çç±»å63 category = request.POST.get("category", "other")64 if samePicCategoryDict.get(category):65 category_id = samePicCategoryDict[category]66 else:67 category_id = samePicCategoryDict["other"]68 filePath = '/assets/img/same/'+image.name69 # å°å¾çä¿åå°imgç®å½ä¸é¢70 filePath1 = 'assets/img/same/'+image.name71 f = open(filePath1,'wb')72 f.write(image.file.getvalue())73 f.close()74 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡75 sp = SamePic()76 sp.image = get_file_content(filePath1)77 # æ件å78 (filename, extension) = os.path.splitext(image.name)79 # ç»å¾çå¢å æè¿°80 sp.options["brief"] = "{\"name\":\""+filename+"\", \"url\":\""+filePath+"\"}"81 # ç»å¾çå¢å ç±»å82 sp.options["tags"] = category_id83 # æå¾çæè¿°çæ¬å°å¾çå
¥åº84 data = sp.putIn(1)85 # å¤ææ¯å¦æ¯è¿åé误信æ¯86 if 'error_msg' in data.keys():87 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})88 else:89 return render(request, 'admin-same.html', {"sign": 1})90# ç¸åå¾æ£ç´¢91def same_check(request):92 # å¤æ请æ±æ¹æ³ä¸ºpost93 if request.method == "POST":94 # è·å表åä¼ è¿æ¥çå¾ç95 image = request.FILES.get("image")96 # è·å表åä¼ è¿æ¥çå¾çç±»å97 category = request.POST.get("category", None)98 if samePicCategoryDict.get(category):99 category_id = samePicCategoryDict[category]100 else:101 category_id = samePicCategoryDict["other"]102 if category:103 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡104 print(category,category_id)105 sp = SamePic()106 sp.image = image.file.getvalue()107 # 设置å¯éåæ°108 sp.options["tags"] = category_id109 sp.options["tag_logic"] = "0"110 sp.options["pn"] = "0"111 sp.options["rn"] = "1000"112 # æ¬å°å¾çæ£ç´¢113 data = sp.check(1)114 # å°å符串转为åå
¸115 for image in data['result']:116 print(image['brief'])117 image['brief'] = json.loads(image['brief'])118 # å¤ææ¯å¦æ¯è¿åé误信æ¯119 if 'error_msg' in data.keys():120 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})121 else:122 return render(request, "admin-gallery.html", {"data": data})123 else:124 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡125 sp = SamePic()126 sp.image = image.file.getvalue()127 # æ¬å°å¾çæ£ç´¢128 data = sp.check(0)129 # å°å符串转为åå
¸130 for image in data['result']:131 print("hello",image['brief'])132 image['brief'] = json.loads(image['brief'])133 # å¤ææ¯å¦æ¯è¿åé误信æ¯134 if 'error_msg' in data.keys():135 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})136 else:137 return render(request, "admin-gallery.html", {"data": data})138# ç¸åå¾æ´æ°139def same_update(request):140 # å¤æ请æ±æ¹æ³ä¸ºpost141 if request.method == "POST":142 # è·å表åä¼ è¿æ¥çå¾ç143 image = request.FILES.get("image")144 # è·å表åä¼ è¿æ¥çå¾çç±»å145 category = request.POST.get("category",None)146 if samePicCategoryDict.get(category):147 category_id = samePicCategoryDict[category]148 else:149 category_id = samePicCategoryDict["other"]150 if category:151 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡152 sp = SamePic()153 sp.image = image.file.getvalue()154 # å¯éåæ°155 # sp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"156 sp.options["tags"] = category_id157 # æ¬å°å¾çæ´æ°158 data = sp.update(1)159 # å¤ææ¯å¦æ¯è¿åé误信æ¯160 if 'error_msg' in data.keys():161 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})162 else:163 return render(request, 'admin-same.html', {"sign": 1})164 else:165 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡166 sp = SamePic()167 sp.image = image.file.getvalue()168 # æ¬å°å¾çæ´æ°169 data = sp.update(0)170 # å¤ææ¯å¦æ¯è¿åé误信æ¯171 if 'error_msg' in data.keys():172 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})173 else:174 return render(request, 'admin-same.html', {"sign": 1})175# ç¸åå¾å é¤176def same_delete(request):177 # å¤æ请æ±æ¹æ³ä¸ºpost178 if request.method == "POST":179 # è·å表åä¼ è¿æ¥çå¾ç180 image = request.FILES.get("image")181 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡182 sp = SamePic()183 sp.image = image.file.getvalue()184 # æ¬å°å¾çæ´æ°185 data = sp.delete(0)186 # å¤ææ¯å¦æ¯è¿åé误信æ¯187 if 'error_msg' in data.keys():188 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})189 else:190 return render(request, 'admin-same.html', {"sign": 1})191# ç¸ä¼¼å¾å
¥åº192def similar_put_in(request):193 if request.method == "POST":194 # è·å表åä¼ è¿æ¥çå¾ç195 image = request.FILES.get("image")196 # è·å表åä¼ è¿æ¥çå¾çç±»å197 category = request.POST.get("category", None)198 if similarPicCategoryDict.get(category):199 category_id = similarPicCategoryDict[category]200 else:201 category_id = similarPicCategoryDict["other"]202 filePath = '/assets/img/similar/'+image.name203 # å°å¾çä¿åå°imgç®å½ä¸é¢204 filePath1 = 'assets/img/similar/'+image.name205 f = open(filePath1,'wb')206 f.write(image.file.getvalue())207 f.close()208 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡209 sp = SimilarityPic()210 sp.image = get_file_content(filePath1)211 # æ件å212 (filename, extension) = os.path.splitext(image.name)213 # ç»å¾çå¢å æè¿°214 sp.options["brief"] = "{\"name\":\""+filename+"\", \"url\":\""+filePath+"\"}"215 # ç»å¾çå¢å ç±»å216 sp.options["tags"] = category_id217 # æå¾çæè¿°çæ¬å°å¾çå
¥åº218 data = sp.putIn(1)219 # å¤ææ¯å¦æ¯è¿åé误信æ¯220 if 'error_msg' in data.keys():221 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})222 else:223 return render(request, 'admin-similar.html', {"sign": 1})224# ç¸ä¼¼å¾æ£ç´¢225def similar_check(request):226 # å¤æ请æ±æ¹æ³ä¸ºpost227 if request.method == "POST":228 # è·å表åä¼ è¿æ¥çå¾ç229 image = request.FILES.get("image")230 # è·å表åä¼ è¿æ¥çå¾çç±»å231 category = request.POST.get("category", None)232 if similarPicCategoryDict.get(category):233 category_id = similarPicCategoryDict[category]234 else:235 category_id = similarPicCategoryDict["other"]236 if category:237 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡238 sp = SimilarityPic()239 sp.image = image.file.getvalue()240 # 设置å¯éåæ°241 sp.options["tags"] = category_id242 sp.options["tag_logic"] = "0"243 sp.options["pn"] = "0"244 sp.options["rn"] = "1000"245 # æ¬å°å¾çæ£ç´¢246 data = sp.check(1)247 # å°å符串转为åå
¸248 for image in data['result']:249 print(image['brief'])250 image['brief'] = json.loads(image['brief'])251 # å¤ææ¯å¦æ¯è¿åé误信æ¯252 if 'error_msg' in data.keys():253 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})254 else:255 return render(request, "admin-gallery.html", {"data": data})256 else:257 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡258 sp = SimilarityPic()259 sp.image = image.file.getvalue()260 # æ¬å°å¾çæ£ç´¢261 data = sp.check(0)262 # å°å符串转为åå
¸263 for image in data['result']:264 print("hello", image['brief'])265 image['brief'] = json.loads(image['brief'])266 # å¤ææ¯å¦æ¯è¿åé误信æ¯267 if 'error_msg' in data.keys():268 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})269 else:270 return render(request, "admin-gallery.html", {"data": data})271# ç¸ä¼¼å¾æ´æ°272def similar_update(request):273 # å¤æ请æ±æ¹æ³ä¸ºpost274 if request.method == "POST":275 # è·å表åä¼ è¿æ¥çå¾ç276 image = request.FILES.get("image")277 # è·å表åä¼ è¿æ¥çå¾çç±»å278 category = request.POST.get("category", None)279 if similarPicCategoryDict.get(category):280 category_id = similarPicCategoryDict[category]281 else:282 category_id = similarPicCategoryDict["other"]283 if category:284 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡285 sp = SimilarityPic()286 sp.image = image.file.getvalue()287 # å¯éåæ°288 # sp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"289 sp.options["tags"] = category_id290 # æ¬å°å¾çæ´æ°291 data = sp.update(1)292 # å¤ææ¯å¦æ¯è¿åé误信æ¯293 if 'error_msg' in data.keys():294 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})295 else:296 return render(request, 'admin-similar.html', {"sign": 1})297 else:298 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡299 sp = SimilarityPic()300 sp.image = image.file.getvalue()301 # æ¬å°å¾çæ´æ°302 data = sp.update(0)303 # å¤ææ¯å¦æ¯è¿åé误信æ¯304 if 'error_msg' in data.keys():305 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})306 else:307 return render(request, 'admin-similar.html', {"sign": 1})308# ç¸ä¼¼å¾å é¤309def similar_delete(request):310 # å¤æ请æ±æ¹æ³ä¸ºpost311 if request.method == "POST":312 # è·å表åä¼ è¿æ¥çå¾ç313 image = request.FILES.get("image")314 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡315 sp = SimilarityPic()316 sp.image = image.file.getvalue()317 # æ¬å°å¾çæ´æ°318 data = sp.delete(0)319 # å¤ææ¯å¦æ¯è¿åé误信æ¯320 if 'error_msg' in data.keys():321 return render(request, "admin-similar.html", {"error_msg": data['error_msg'], "sign": 0})322 else:323 return render(request, 'admin-similar.html', {"sign": 1})324# ååå¾å
¥åº325def product_put_in(request):326 if request.method == "POST":327 # è·å表åä¼ è¿æ¥çå¾ç328 image = request.FILES.get("image")329 # è·åè¡¨è¾¾ä¼ è¿æ¥çå¾çç±»å330 category = request.POST.get("category", None)331 if productPicCategoryDict.get(category):332 category_id = productPicCategoryDict[category]333 else:334 category_id = productPicCategoryDict["other"]335 filePath = '/assets/img/product/'+image.name336 # å°å¾çä¿åå°imgç®å½ä¸é¢337 filePath1 = 'assets/img/product/'+image.name338 f = open(filePath1,'wb')339 f.write(image.file.getvalue())340 f.close()341 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡342 gp = GoodsPic()343 gp.image = get_file_content(filePath1)344 # æ件å345 (filename, extension) = os.path.splitext(image.name)346 # ç»å¾çå¢å æè¿°347 gp.options["brief"] = "{\"name\":\""+filename+"\", \"url\":\""+filePath+"\"}"348 # ç»å¾çå¢å ç±»å349 gp.options["class_id1"] = int(category_id)350 # æå¾çæè¿°çæ¬å°å¾çå
¥åº351 data = gp.putIn(1)352 print(data)353 # å¤ææ¯å¦æ¯è¿åé误信æ¯354 if 'error_msg' in data.keys():355 return render(request, "admin-product.html", {"error_msg":data['error_msg'], "sign":0})356 else:357 return render(request, 'admin-product.html', {"sign":1})358# ååå¾æ£ç´¢359def product_check(request):360 # å¤æ请æ±æ¹æ³ä¸ºpost361 if request.method == "POST":362 # è·å表åä¼ è¿æ¥çå¾ç363 image = request.FILES.get("image")364 # è·å表åä¼ è¿æ¥çå¾çç±»å365 category = request.POST.get("category", None)366 if productPicCategoryDict.get(category):367 category_id = productPicCategoryDict[category]368 else:369 category_id = productPicCategoryDict["other"]370 if category:371 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡372 gp = GoodsPic()373 gp.image = image.file.getvalue()374 # 设置å¯éåæ°375 gp.options["class_id1"] = int(category_id)376 gp.options["pn"] = "0"377 gp.options["rn"] = "1000"378 # æ¬å°å¾çæ£ç´¢379 data = gp.check(1)380 # å°å符串转为åå
¸381 for image in data['result']:382 print(image['brief'])383 image['brief'] = json.loads(image['brief'])384 # å¤ææ¯å¦æ¯è¿åé误信æ¯385 if 'error_msg' in data.keys():386 return render(request, "admin-product.html", {"error_msg": data['error_msg'], "sign": 0})387 else:388 return render(request, "admin-gallery.html", {"data": data})389 else:390 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡391 gp = GoodsPic()392 gp.image = image.file.getvalue()393 # æ¬å°å¾çæ£ç´¢394 data = gp.check(0)395 # å°å符串转为åå
¸396 for image in data['result']:397 print("hello", image['brief'])398 image['brief'] = json.loads(image['brief'])399 # å¤ææ¯å¦æ¯è¿åé误信æ¯400 if 'error_msg' in data.keys():401 return render(request, "admin-product.html", {"error_msg": data['error_msg'], "sign": 0})402 else:403 return render(request, "admin-gallery.html", {"data": data})404# ååå¾æ´æ°405def product_update(request):406 # å¤æ请æ±æ¹æ³ä¸ºpost407 if request.method == "POST":408 # è·å表åä¼ è¿æ¥çå¾ç409 image = request.FILES.get("image")410 # è·å表åä¼ è¿æ¥çå¾çç±»å411 category = request.POST.get("category", None)412 if productPicCategoryDict.get(category):413 category_id = productPicCategoryDict[category]414 else:415 category_id = productPicCategoryDict["other"]416 if category:417 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡418 gp = GoodsPic()419 gp.image = image.file.getvalue()420 # å¯éåæ°421 gp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"422 gp.options["class_id1"] = int(category_id)423 # æ¬å°å¾çæ´æ°424 data = gp.update(1)425 # å¤ææ¯å¦æ¯è¿åé误信æ¯426 if 'error_msg' in data.keys():427 return render(request, "admin-product.html", {"error_msg": data['error_msg'], "sign": 0})428 else:429 return render(request, 'admin-product.html', {"sign": 1})430 else:431 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡432 gp = GoodsPic()433 gp.image = image.file.getvalue()434 # æ¬å°å¾çæ´æ°435 data = gp.update(0)436 # å¤ææ¯å¦æ¯è¿åé误信æ¯437 if 'error_msg' in data.keys():438 return render(request, "admin-product.html", {"error_msg": data['error_msg'], "sign": 0})439 else:440 return render(request, 'admin-product.html', {"sign": 1})441# ååå¾å é¤442def product_delete(request):443 # å¤æ请æ±æ¹æ³ä¸ºpost444 if request.method == "POST":445 # è·å表åä¼ è¿æ¥çå¾ç446 image = request.FILES.get("image")447 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡448 gp = GoodsPic()449 gp.image = image.file.getvalue()450 # æ¬å°å¾çæ´æ°451 data = gp.delete(0)452 # å¤ææ¯å¦æ¯è¿åé误信æ¯453 if 'error_msg' in data.keys():454 return render(request, "admin-product.html", {"error_msg": data['error_msg'], "sign": 0})455 else:456 return render(request, 'admin-product.html', {"sign": 1})457# ç¸åå¾å
¥åº458def same_put_in_url(request):459 if request.method == "POST":460 # è·å表åä¼ è¿æ¥çç½ç»å°å461 image_url = request.POST.get("URL")462 # è·å表åä¼ è¿æ¥çå¾çç±»å463 category = request.POST.get("category", None)464 if samePicCategoryDict.get(category):465 category_id = samePicCategoryDict[category]466 else:467 category_id = samePicCategoryDict["other"]468 # è·åå¾çå称469 image_name = request.POST.get("name", None)470 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡471 sp = SamePic()472 sp.url = image_url473 # ç»å¾çå¢å æè¿°474 sp.options["brief"] = "{\"name\":\""+image_name+"\", \"url\":\""+image_url+"\"}"475 # ç»å¾çå¢å ç±»å476 sp.options["tags"] = category_id477 # æå¾çæè¿°çæ¬å°å¾çå
¥åº478 data = sp.putIn(3)479 # å¤ææ¯å¦æ¯è¿åé误信æ¯480 if 'error_msg' in data.keys():481 return render(request, "admin-same-url.html", {"error_msg": data['error_msg'], "sign": 0})482 else:483 return render(request, 'admin-same-url.html', {"sign": 1})484# ç¸åå¾æ£ç´¢485def same_check_url(request):486 # å¤æ请æ±æ¹æ³ä¸ºpost487 if request.method == "POST":488 # è·å表åä¼ è¿æ¥çç½ç»å°å489 image_url = request.POST.get("URL")490 # è·å表åä¼ è¿æ¥çå¾çç±»å491 category = request.POST.get("category", None)492 if samePicCategoryDict.get(category):493 category_id = samePicCategoryDict[category]494 else:495 category_id = samePicCategoryDict["other"]496 if category:497 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡498 sp = SamePic()499 sp.url = image_url500 # 设置å¯éåæ°501 sp.options["tags"] = category_id502 sp.options["tag_logic"] = "0"503 sp.options["pn"] = "0"504 sp.options["rn"] = "1000"505 # æ¬å°å¾çæ£ç´¢506 data = sp.check(3)507 # å°å符串转为åå
¸508 for image in data['result']:509 print(image['brief'])510 image['brief'] = json.loads(image['brief'])511 # å¤ææ¯å¦æ¯è¿åé误信æ¯512 if 'error_msg' in data.keys():513 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})514 else:515 return render(request, "admin-gallery.html", {"data": data})516 else:517 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡518 sp = SamePic()519 sp.url = image_url520 # æ¬å°å¾çæ£ç´¢521 data = sp.check(2)522 # å°å符串转为åå
¸523 for image in data['result']:524 print("hello",image['brief'])525 image['brief'] = json.loads(image['brief'])526 # å¤ææ¯å¦æ¯è¿åé误信æ¯527 if 'error_msg' in data.keys():528 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})529 else:530 return render(request, "admin-gallery.html", {"data": data})531# ç¸åå¾æ´æ°532def same_update_url(request):533 # å¤æ请æ±æ¹æ³ä¸ºpost534 if request.method == "POST":535 # è·å表åä¼ è¿æ¥çURL536 image_url = request.POST.get("URL")537 # è·å表åä¼ è¿æ¥çå¾çç±»å538 category = request.POST.get("category",None)539 if samePicCategoryDict.get(category):540 category_id = samePicCategoryDict[category]541 else:542 category_id = samePicCategoryDict["other"]543 if category:544 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡545 sp = SamePic()546 sp.url = image_url547 # å¯éåæ°548 # sp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"549 sp.options["tags"] = category_id550 # æ¬å°å¾çæ´æ°551 data = sp.update(3)552 # å¤ææ¯å¦æ¯è¿åé误信æ¯553 if 'error_msg' in data.keys():554 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})555 else:556 return render(request, 'admin-same.html', {"sign": 1})557 else:558 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡559 sp = SamePic()560 sp.url = image_url561 # æ¬å°å¾çæ´æ°562 data = sp.update(2)563 # å¤ææ¯å¦æ¯è¿åé误信æ¯564 if 'error_msg' in data.keys():565 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})566 else:567 return render(request, 'admin-same.html', {"sign": 1})568# ç¸åå¾å é¤569def same_delete_url(request):570 # å¤æ请æ±æ¹æ³ä¸ºpost571 if request.method == "POST":572 # è·å表åä¼ è¿æ¥çURL573 image_url = request.POST.get("URL")574 # å®ä¹ä¸ä¸ªç¸åå¾å¯¹è±¡575 sp = SamePic()576 sp.url = image_url577 # æ¬å°å¾çæ´æ°578 data = sp.delete(1)579 # å¤ææ¯å¦æ¯è¿åé误信æ¯580 if 'error_msg' in data.keys():581 return render(request, "admin-same.html", {"error_msg": data['error_msg'], "sign": 0})582 else:583 return render(request, 'admin-same.html', {"sign": 1})584# ç¸ä¼¼å¾å
¥åº585def similar_put_in_url(request):586 if request.method == "POST":587 # è·å表åä¼ è¿æ¥çç½ç»å°å588 image_url = request.POST.get("URL")589 # è·å表åä¼ è¿æ¥çå¾çç±»å590 category = request.POST.get("category", None)591 if similarPicCategoryDict.get(category):592 category_id = similarPicCategoryDict[category]593 else:594 category_id = similarPicCategoryDict["other"]595 # è·åå¾çå称596 image_name = request.POST.get("name", None)597 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡598 sp = SimilarityPic()599 sp.url = image_url600 # ç»å¾çå¢å æè¿°601 sp.options["brief"] = "{\"name\":\""+image_name+"\", \"url\":\""+image_url+"\"}"602 # ç»å¾çå¢å ç±»å603 sp.options["tags"] = category_id604 # æå¾çæè¿°çæ¬å°å¾çå
¥åº605 data = sp.putIn(3)606 # å¤ææ¯å¦æ¯è¿åé误信æ¯607 if 'error_msg' in data.keys():608 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})609 else:610 return render(request, 'admin-similar-url.html', {"sign": 1})611# ç¸ä¼¼å¾æ£ç´¢612def similar_check_url(request):613 # å¤æ请æ±æ¹æ³ä¸ºpost614 if request.method == "POST":615 # è·å表åä¼ è¿æ¥çç½ç»å°å616 image_url = request.POST.get("URL")617 # è·å表åä¼ è¿æ¥çå¾çç±»å618 category = request.POST.get("category", None)619 if similarPicCategoryDict.get(category):620 category_id = similarPicCategoryDict[category]621 else:622 category_id = similarPicCategoryDict["other"]623 if category:624 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡625 sp = SimilarityPic()626 sp.url = image_url627 # 设置å¯éåæ°628 sp.options["tags"] = category_id629 sp.options["tag_logic"] = "0"630 sp.options["pn"] = "0"631 sp.options["rn"] = "1000"632 # æ¬å°å¾çæ£ç´¢633 data = sp.check(3)634 # å°å符串转为åå
¸635 for image in data['result']:636 print(image['brief'])637 image['brief'] = json.loads(image['brief'])638 # å¤ææ¯å¦æ¯è¿åé误信æ¯639 if 'error_msg' in data.keys():640 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})641 else:642 return render(request, "admin-gallery.html", {"data": data})643 else:644 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡645 sp = SimilarityPic()646 sp.url = image_url647 # æ¬å°å¾çæ£ç´¢648 data = sp.check(2)649 # å°å符串转为åå
¸650 for image in data['result']:651 print("hello", image['brief'])652 image['brief'] = json.loads(image['brief'])653 # å¤ææ¯å¦æ¯è¿åé误信æ¯654 if 'error_msg' in data.keys():655 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})656 else:657 return render(request, "admin-gallery.html", {"data": data})658# ç¸ä¼¼å¾æ´æ°659def similar_update_url(request):660 # å¤æ请æ±æ¹æ³ä¸ºpost661 if request.method == "POST":662 # è·å表åä¼ è¿æ¥çURL663 image_url = request.POST.get("URL")664 # è·å表åä¼ è¿æ¥çå¾çç±»å665 category = request.POST.get("category", None)666 if similarPicCategoryDict.get(category):667 category_id = similarPicCategoryDict[category]668 else:669 category_id = similarPicCategoryDict["other"]670 if category:671 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡672 sp = SimilarityPic()673 sp.url = image_url674 # å¯éåæ°675 # sp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"676 sp.options["tags"] = category_id677 # æ¬å°å¾çæ´æ°678 data = sp.update(3)679 # å¤ææ¯å¦æ¯è¿åé误信æ¯680 if 'error_msg' in data.keys():681 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})682 else:683 return render(request, 'admin-similar-url.html', {"sign": 1})684 else:685 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡686 sp = SimilarityPic()687 sp.url = image_url688 # æ¬å°å¾çæ´æ°689 data = sp.update(2)690 # å¤ææ¯å¦æ¯è¿åé误信æ¯691 if 'error_msg' in data.keys():692 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})693 else:694 return render(request, 'admin-similar-url.html', {"sign": 1})695# ç¸ä¼¼å¾å é¤696def similar_delete_url(request):697 # å¤æ请æ±æ¹æ³ä¸ºpost698 if request.method == "POST":699 # è·å表åä¼ è¿æ¥çURL700 image_url = request.POST.get("URL")701 # å®ä¹ä¸ä¸ªç¸ä¼¼å¾å¯¹è±¡702 sp = SimilarityPic()703 sp.url = image_url704 # æ¬å°å¾çæ´æ°705 data = sp.delete(1)706 # å¤ææ¯å¦æ¯è¿åé误信æ¯707 if 'error_msg' in data.keys():708 return render(request, "admin-similar-url.html", {"error_msg": data['error_msg'], "sign": 0})709 else:710 return render(request, 'admin-similar-url.html', {"sign": 1})711# ååå¾å
¥åº712def product_put_in_url(request):713 if request.method == "POST":714 # è·å表åä¼ è¿æ¥çç½ç»å°å715 image_url = request.POST.get("URL")716 # è·å表åä¼ è¿æ¥çå¾çç±»å717 category = request.POST.get("category", None)718 if productPicCategoryDict.get(category):719 category_id = productPicCategoryDict[category]720 else:721 category_id = productPicCategoryDict["other"]722 # è·åå¾çå称723 image_name = request.POST.get("name", None)724 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡725 gp = GoodsPic()726 gp.url = image_url727 # ç»å¾çå¢å æè¿°728 gp.options["brief"] = "{\"name\":\""+image_name+"\", \"url\":\""+image_url+"\"}"729 # ç»å¾çå¢å ç±»å730 gp.options["class_id1"] = int(category_id)731 # æå¾çæè¿°çæ¬å°å¾çå
¥åº732 data = gp.putIn(3)733 # å¤ææ¯å¦æ¯è¿åé误信æ¯734 if 'error_msg' in data.keys():735 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})736 else:737 return render(request, 'admin-product-url.html', {"sign": 1})738# ååå¾æ£ç´¢739def product_check_url(request):740 # å¤æ请æ±æ¹æ³ä¸ºpost741 if request.method == "POST":742 # è·å表åä¼ è¿æ¥çç½ç»å°å743 image_url = request.POST.get("URL")744 # è·å表åä¼ è¿æ¥çå¾çç±»å745 category = request.POST.get("category", None)746 if productPicCategoryDict.get(category):747 category_id = productPicCategoryDict[category]748 else:749 category_id = productPicCategoryDict["other"]750 if category:751 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡752 gp = GoodsPic()753 gp.url = image_url754 # 设置å¯éåæ°755 gp.options["class_id1"] = int(category_id)756 gp.options["pn"] = "0"757 gp.options["rn"] = "1000"758 # æ¬å°å¾çæ£ç´¢759 data = gp.check(3)760 # å°å符串转为åå
¸761 for image in data['result']:762 print(image['brief'])763 image['brief'] = json.loads(image['brief'])764 # å¤ææ¯å¦æ¯è¿åé误信æ¯765 if 'error_msg' in data.keys():766 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})767 else:768 return render(request, "admin-gallery.html", {"data": data})769 else:770 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡771 gp = GoodsPic()772 gp.url = image_url773 # æ¬å°å¾çæ£ç´¢774 data = gp.check(2)775 # å°å符串转为åå
¸776 for image in data['result']:777 print("hello", image['brief'])778 image['brief'] = json.loads(image['brief'])779 # å¤ææ¯å¦æ¯è¿åé误信æ¯780 if 'error_msg' in data.keys():781 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})782 else:783 return render(request, "admin-gallery.html", {"data": data})784# ååå¾æ´æ°785def product_update_url(request):786 # å¤æ请æ±æ¹æ³ä¸ºpost787 if request.method == "POST":788 # è·å表åä¼ è¿æ¥çURL789 image_url = request.POST.get("URL")790 # è·å表åä¼ è¿æ¥çå¾çç±»å791 category = request.POST.get("category", None)792 if productPicCategoryDict.get(category):793 category_id = productPicCategoryDict[category]794 else:795 category_id = productPicCategoryDict["other"]796 if category:797 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡798 gp = GoodsPic()799 gp.url = image_url800 # å¯éåæ°801 gp.options["brief"] = "{\"name\":\"å¨æ°ä¼¦\", \"id\":\"666\"}"802 gp.options["class_id1"] = int(category_id)803 # æ¬å°å¾çæ´æ°804 data = gp.update(3)805 # å¤ææ¯å¦æ¯è¿åé误信æ¯806 if 'error_msg' in data.keys():807 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})808 else:809 return render(request, 'admin-product-url.html', {"sign": 1})810 else:811 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡812 gp = GoodsPic()813 gp.url = image_url814 # æ¬å°å¾çæ´æ°815 data = gp.update(2)816 # å¤ææ¯å¦æ¯è¿åé误信æ¯817 if 'error_msg' in data.keys():818 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})819 else:820 return render(request, 'admin-product-url.html', {"sign": 1})821# ååå¾å é¤822def product_delete_url(request):823 # å¤æ请æ±æ¹æ³ä¸ºpost824 if request.method == "POST":825 # è·å表åä¼ è¿æ¥çURL826 image_url = request.POST.get("URL")827 # å®ä¹ä¸ä¸ªååå¾å¯¹è±¡828 gp = GoodsPic()829 gp.url = image_url830 # æ¬å°å¾çæ´æ°831 data = gp.delete(1)832 # å¤ææ¯å¦æ¯è¿åé误信æ¯833 if 'error_msg' in data.keys():834 return render(request, "admin-product-url.html", {"error_msg": data['error_msg'], "sign": 0})835 else:...
mobile.py
Source:mobile.py
1#!/usr/bin/env python3.52# -*- coding: utf-8 -*-3"""4__author__ = xyy5__mtime__ = 2016/10/136"""7from pyramid.view import view_config8from ..common.sendsms import send9from ..common import constant10from ..common.jsonutils import other_response11from ..common.redisutil import create_redis12from ..common.base import BaseUtil13class MobileView(BaseUtil):14 @view_config(route_name='sendCode', renderer='json')15 def send_code(self):16 """17 åééªè¯ç 18 :param self:19 :return:20 """21 error_msg = ''22 dbs = self.request.dbsession23 user_phone = self.request.POST.get('phone', '')24 user_name = self.request.POST.get('name', '')25 if not user_phone:26 error_msg = 'ç¨æ·ææºä¸è½ä¸ºç©ºï¼'27 elif not user_name:28 error_msg = 'ç¨æ·å§åä¸è½ä¸ºç©ºï¼'29 if not error_msg:30 code = self.sendSmsService.make_random(6)31 content = constant.SMS_DESC % code32 redis_host = self.request.registry.settings['redis.sessions.host']33 r = create_redis(redis_host)34 # num = r.get(self.request.client_addr)35 # num = int(num) if num else 036 # if num:37 # if num <= 9:38 self.sendSmsService.add_code_redis(user_phone, code, redis_host)39 self.sendSmsService.add_ip_no_redis(self.request.client_addr, (lambda x: x+1)(1), redis_host)40 # self.sendSmsService.add_ip_no_redis(self.request.client_addr, (lambda x: x+1)(num), redis_host)41 send(user_phone, content)42 error_msg = self.sendSmsService.add_sms(dbs, sms_content=content, phone=user_phone)43 if error_msg:44 json_a = {45 'returnCode': constant.CODE_ERROR,46 'returnMsg': error_msg47 }48 else:49 json_a = {50 'returnCode': constant.CODE_SUCCESS,51 'returnMsg': ''52 }53 self.hyLog.log_in(self.request.client_addr, ('sendCode failed ' +54 error_msg if error_msg else 'sendCode success'), 'mobile')55 resp = other_response(json_a=json_a)56 return resp57 @view_config(route_name='accountBinding', renderer='json')58 def account_binding(self):59 """60 设å¤åå§åç»å½61 :param self:62 :return:63 """64 error_msg = ''65 dbs = self.request.dbsession66 error_code = constant.CODE_ERROR67 user_phone = self.request.POST.get('phone', '')68 user_name = self.request.POST.get('name', '')69 verification_code = self.request.POST.get('verificationCode', '')70 is_risk = 071 indiinstflag = ''72 if not user_phone:73 error_msg = 'ç¨æ·ææºä¸è½ä¸ºç©ºï¼'74 elif not user_name:75 error_msg = 'ç¨æ·å§åä¸è½ä¸ºç©ºï¼'76 elif not verification_code:77 error_msg = 'éªè¯ç ä¸è½ä¸ºç©ºï¼'78 if not error_msg:79 redis_host = self.request.registry.settings['redis.sessions.host']80 crm_path = self.request.registry.settings['crm_path']81 auth_key = self.request.registry.settings['crm_auth_key']82 r = create_redis(redis_host)83 user_info = self.customerService.count_bind(user_phone, user_name, crm_path, auth_key)84 if not user_info:85 error_msg = 'crmæå¡è¿æ¥é误ï¼'86 else:87 random_code = r.get(user_phone)88 random_code = int(random_code) if random_code else 089 if random_code != int(verification_code):90 error_msg = 'éªè¯ç æ误请éæ°è¾å
¥ï¼'91 error_code = constant.CODE_WRONG92 else:93 custid = user_info['objects']['custid']94 indiinstflag = user_info['objects']['indiinstflag']95 risklevel = user_info['objects']['risklevel']96 is_risk = 1 if risklevel else 097 cust_info_id = self.customerService.add_customer(dbs, cust_id=custid,98 indiinst_flag=indiinstflag, cust_name=user_name,99 phone=user_phone, risk_level=risklevel)100 if error_msg:101 json_a = {102 'returnCode': error_code,103 'returnMsg': error_msg,104 }105 else:106 json_a = {107 'returnCode': constant.CODE_SUCCESS,108 'returnMsg': '',109 'isRiskAssess': is_risk,110 'wechatId': cust_info_id,111 'indiinstflag': indiinstflag112 }113 self.hyLog.log_in(self.request.client_addr, ('accountBinding failed ' + error_msg if error_msg114 else 'sendCode success'), 'mobile')115 resp = other_response(json_a=json_a)116 return resp117 @view_config(route_name='riskQuestion', renderer='json')118 def risk_question(self):119 """120 é£é©é¢ç®æ¥è¯¢121 :param self:122 :return:123 """124 error_msg = ''125 error_code = constant.CODE_ERROR126 dbs = self.request.dbsession127 wechat_id = self.request.POST.get('wechatId', '')128 type = self.request.POST.get('type', '0')129 if not wechat_id:130 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'131 if not error_msg:132 questions = self.riskService.search_questions(dbs, type)133 # error_msg, error_code = self.customerService.search_cust_bind(dbs, wechat_id)134 if error_msg:135 json_a = {136 'returnCode': error_code,137 'returnMsg': error_msg138 }139 else:140 json_a = {141 'returnCode': constant.CODE_SUCCESS,142 'returnMsg': '',143 'questionList': questions144 }145 self.hyLog.log_in(self.request.client_addr,146 ('riskQuestion failed ' + error_msg if error_msg else 'riskQuestion success'),147 'mobile')148 resp = other_response(json_a=json_a)149 return resp150 @view_config(route_name='riskAssess', renderer='json')151 def risk_assess(self):152 """153 é£é©è¯ä¼°154 :param self:155 :return:156 """157 error_msg = ''158 error_code = constant.CODE_ERROR159 dbs = self.request.dbsession160 wechat_id = self.request.POST.get('wechatId', '')161 risk_answers = self.request.POST.get('riskAnswer', '')162 type = self.request.POST.get('type', '')163 cert_type = self.request.POST.get('certType', '')164 cert_no = self.request.POST.get('certNo', '')165 if not wechat_id:166 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'167 elif not risk_answers:168 error_msg = 'é£é©é¢ç®çæ¡ï¼'169 elif not type:170 error_msg = '对ç§å¯¹å
¬æ å¿ä¸è½ä¸ºç©ºï¼'171 if not error_msg:172 crm_path = self.request.registry.settings['crm_path']173 auth_key = self.request.registry.settings['crm_auth_key']174 risk_level = self.riskService.add_risk_assess(dbs, wechat_id, risk_answers,175 type, cert_type, cert_no, crm_path, auth_key)176 error_msg, error_code = self.customerService.search_cust_bind(dbs, wechat_id)177 if error_msg:178 json_a = {179 'returnCode': error_code,180 'returnMsg': error_msg181 }182 else:183 json_a = {184 'returnCode': constant.CODE_SUCCESS,185 'returnMsg': '',186 'riskLevel': risk_level187 }188 self.hyLog.log_in(self.request.client_addr,189 ('riskAssess failed ' + error_msg if error_msg else 'riskAssess success'),190 'mobile')191 resp = other_response(json_a=json_a)192 return resp193 @view_config(route_name='riskSearch', renderer='json')194 def risk_search(self):195 """196 é£é©è¯ä¼°æ¥è¯¢197 :param self:198 :return:199 """200 error_msg = ''201 dbs = self.request.dbsession202 wechat_id = self.request.POST.get('wechatId', '')203 if not wechat_id:204 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'205 if not error_msg:206 error_msg, error_code = self.customerService.search_cust_bind(dbs, wechat_id)207 if not error_msg:208 error_msg, error_code, risk_level, risk_msg, risk_type_level, indiinst_flag = self.riskService.search_customer_risk_level(dbs, wechat_id)209 if error_msg:210 json_a = {211 'returnCode': error_code,212 'returnMsg': error_msg213 }214 else:215 json_a = {216 'returnCode': constant.CODE_SUCCESS,217 'returnMsg': '',218 'riskLevel': risk_level,219 'indiinstflag': indiinst_flag,220 'riskMessage': risk_msg,221 'riskType': risk_type_level222 }223 self.hyLog.log_in(self.request.client_addr,224 ('riskSearch failed ' + error_msg if error_msg else 'riskSearch success'),225 'mobile')226 resp = other_response(json_a=json_a)227 return resp228 @view_config(route_name='navList', renderer='json')229 def nav_list(self):230 """231 é£é©è¯ä¼°åå¼èµ°å¿232 :param self:233 :return:234 """235 error_msg = ''236 dbms = self.request.mysqldbsession237 wechat_id = self.request.POST.get('wechatId', '')238 pro_id = self.request.POST.get('productId', '')239 nav_type = self.request.POST.get('navType', 1)240 if not wechat_id:241 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'242 elif not pro_id:243 error_msg = '产åidä¸è½ä¸ºç©ºï¼'244 elif not nav_type:245 error_msg = 'åå¼èµ°å¿ç±»åä¸è½ä¸ºç©ºï¼'246 if not error_msg:247 nav_list = self.productService.search_navs(dbms, wechat_id, pro_id, nav_type)248 if error_msg:249 json_a = {250 'returnCode': constant.CODE_ERROR,251 'returnMsg': error_msg252 }253 else:254 json_a = {255 'returnCode': constant.CODE_SUCCESS,256 'returnMsg': '',257 'navList': nav_list258 }259 self.hyLog.log_in(self.request.client_addr,260 ('navList failed ' + error_msg if error_msg else 'navList success'),261 'mobile')262 resp = other_response(json_a=json_a)263 return resp264 @view_config(route_name='productList', renderer='json')265 def product_list(self):266 """267 æ¥æ¾äº§åå表268 :param self:269 :return:270 """271 error_msg = ''272 error_code = constant.CODE_ERROR273 dbs = self.request.dbsession274 dbms = self.request.mysqldbsession275 wechat_id = self.request.POST.get('wechatId', '')276 page_no = self.request.POST.get('pageNo', 0)277 search_key = self.request.POST.get('searchKey', '')278 if not wechat_id:279 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'280 elif not page_no:281 error_msg = '页ç ä¸è½ä¸ºç©ºï¼'282 if not error_msg:283 error_msg, error_code = self.customerService.search_cust_bind(dbs, wechat_id)284 if not error_msg:285 error_msg, error_code, risk_level, risk_msg, risk_type_level, indiinst_flag = self.riskService.search_customer_risk_level(286 dbs, wechat_id)287 pro_list, count_pros, count_user_pros = self.productService.search_products(dbms, wechat_id, page_no, search_key, risk_level)288 if error_msg:289 json_a = {290 'returnCode': error_code,291 'returnMsg': error_msg292 }293 else:294 json_a = {295 'returnCode': constant.CODE_SUCCESS,296 'returnMsg': '',297 'productList': pro_list,298 'allNum': count_pros if count_pros else 0,299 'filterNum': count_user_pros if count_user_pros else 0300 }301 self.hyLog.log_in(self.request.client_addr,302 ('productList failed ' + error_msg if error_msg else 'productList success'),303 'mobile')304 resp = other_response(json_a=json_a)305 return resp306 @view_config(route_name='productDetail', renderer='json')307 def product_detail(self):308 """309 æ¥æ¾äº§å详æ
310 :param self:311 :return:312 """313 error_msg = ''314 error_code = constant.CODE_ERROR315 dbs = self.request.dbsession316 dbms = self.request.mysqldbsession317 wechat_id = self.request.POST.get('wechatId', '')318 product_id = self.request.POST.get('productId', 0)319 if not wechat_id:320 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'321 elif not product_id:322 error_msg = '产åIDä¸è½ä¸ºç©ºï¼'323 if not error_msg:324 error_msg, error_code, risk_level, risk_msg, risk_type_level, indiinst_flag = self.riskService.search_customer_risk_level(325 dbs, wechat_id)326 product = self.productService.search_product_info(dbs, dbms, wechat_id, product_id)327 if error_msg:328 json_a = {329 'returnCode': error_code,330 'returnMsg': error_msg331 }332 else:333 json_a = {334 'returnCode': constant.CODE_SUCCESS,335 'returnMsg': '',336 'product': product337 }338 self.hyLog.log_in(self.request.client_addr,339 ('productDetail failed ' + error_msg if error_msg else 'productDetail success'),340 'mobile')341 resp = other_response(json_a=json_a)342 return resp343 @view_config(route_name='productCollect', renderer='json')344 def product_collect(self):345 """346 产åæ¶è347 :param self:348 :return:349 """350 error_msg = ''351 dbs = self.request.dbsession352 wechat_id = self.request.POST.get('wechatId', '')353 product_id = self.request.POST.get('productId', 0)354 if not wechat_id:355 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'356 elif not product_id:357 error_msg = '产åIDä¸è½ä¸ºç©ºï¼'358 if not error_msg:359 coll_state = self.customerService.collect_product_by_id(dbs, wechat_id, product_id)360 if error_msg:361 json_a = {362 'returnCode': constant.CODE_ERROR,363 'returnMsg': error_msg364 }365 else:366 json_a = {367 'returnCode': constant.CODE_SUCCESS,368 'returnMsg': '',369 'isCollect': coll_state370 }371 self.hyLog.log_in(self.request.client_addr,372 ('productCollect failed ' + error_msg if error_msg else 'productCollect success'),373 'mobile')374 resp = other_response(json_a=json_a)375 return resp376 @view_config(route_name='productBook', renderer='json')377 def product_book(self):378 """379 产åé¢çº¦380 :param self:381 :return:382 """383 error_msg = ''384 error_code = constant.CODE_ERROR385 dbs = self.request.dbsession386 wechat_id = self.request.POST.get('wechatId', '')387 phone = self.request.POST.get('phone', 0)388 pro_id = self.request.POST.get('proId', '')389 pro_name = self.request.POST.get('proName', '')390 if not wechat_id:391 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'392 elif not pro_name:393 error_msg = '产åå称ä¸è½ä¸ºç©ºï¼'394 elif not pro_id:395 error_msg = '产åIdä¸è½ä¸ºç©ºï¼'396 elif not phone:397 error_msg = 'èç³»çµè¯ä¸è½ä¸ºç©ºï¼'398 if not error_msg:399 crm_path = self.request.registry.settings['crm_path']400 auth_key = self.request.registry.settings['crm_auth_key']401 error_msg, error_code = self.customerService.book_product_by_id(dbs, wechat_id, pro_name, phone, pro_id,402 crm_path, auth_key)403 if error_msg:404 json_a = {405 'returnCode': error_code,406 'returnMsg': error_msg407 }408 else:409 json_a = {410 'returnCode': constant.CODE_SUCCESS,411 'returnMsg': ''412 }413 self.hyLog.log_in(self.request.client_addr,414 ('productCollect failed ' + error_msg if error_msg else 'productCollect success'),415 'mobile')416 resp = other_response(json_a=json_a)417 return resp418 @view_config(route_name='myCollect', renderer='json')419 def my_collect(self):420 """421 æçæ¶è422 :param self:423 :return:424 """425 error_msg = ''426 error_code = constant.CODE_ERROR427 dbms = self.request.mysqldbsession428 dbs = self.request.dbsession429 wechat_id = self.request.POST.get('wechatId', '')430 page_no = self.request.POST.get('pageNo', 0)431 if not wechat_id:432 error_msg = 'ç¨æ·wechat_idä¸è½ä¸ºç©ºï¼'433 if not error_msg:434 pro_col_list = self.customerService.search_coll_product(dbs, dbms, wechat_id, page_no)435 error_msg, error_code = self.customerService.search_cust_bind(dbs, wechat_id)436 if error_msg:437 json_a = {438 'returnCode': error_code,439 'returnMsg': error_msg440 }441 else:442 json_a = {443 'returnCode': constant.CODE_SUCCESS,444 'returnMsg': '',445 'productList': pro_col_list446 }447 self.hyLog.log_in(self.request.client_addr,448 ('myCollect failed ' + error_msg if error_msg else 'myCollect success'),449 'mobile')450 resp = other_response(json_a=json_a)...
stock_error.py
Source:stock_error.py
1ERROR_MSG = {}2ERROR_MSG[0] = "æå"3ERROR_MSG[-1] = "表示交ææç½ç»è¿æ¥å¤±è´¥"4ERROR_MSG[-2] = "表示交æææªå¤ç请æ±è¶
è¿è®¸å¯æ°"5ERROR_MSG[-3] = "表示交æææ¯ç§åé请æ±æ°è¶
è¿è®¸å¯æ°"6ERROR_MSG[3] = "表示交æææå¡å¨æªç»å½æå"7ERROR_MSG[4] = "ç¨æ·æªç»å½"8ERROR_MSG[5] = "éæ¬äº¤ææAPIç»å½"9ERROR_MSG[6] = "APIçæ¬ä¿¡æ¯åºé"10ERROR_MSG[7] = "ç³»ç»æ£å¨åå§å"11ERROR_MSG[8] = "éå¤çç»å½"12ERROR_MSG[9] = "å¯ç é"13ERROR_MSG[10] = "ç¨æ·æªæ¾å°"14ERROR_MSG[12] = "æ´æ°å¯ç 失败"15ERROR_MSG[13] = "çæå¯ç 失败"16ERROR_MSG[14] = "æ¥è¯¢ä¿¡æ¯å¤±è´¥"17ERROR_MSG[16] = "æ¤åæ¶æªæ¾å°åå§æ¥å"18ERROR_MSG[17] = "æ¥åå¨åå¾äº¤ææä¹å被æ¤å"19ERROR_MSG[18] = "æ¥åç¶æ为已æ¤åç¶æä¸å¯æ¤å"20ERROR_MSG[19] = "æ¥åç¶æ为å
¨é¨æ交ç¶æä¸å¯æ¤å"21ERROR_MSG[20] = "æ¥å为éåä¸å¯æ¤å"22ERROR_MSG[21] = "æ¤åæ¶åå§æ¥å为ä¸å¯æ¤åç¶æ"23ERROR_MSG[22] = "éå¤çæ¥å"24ERROR_MSG[23] = "æ¥åæ¶æªæ¾å°å¯¹åºçå约信æ¯"25ERROR_MSG[24] = "æ¥åæ¶ä¹°åæ¹åå段é误"26ERROR_MSG[25] = "æ¥åæ¶æææç±»åå段é误"27ERROR_MSG[26] = "æ¥åæ¶ä»·æ ¼å段é误"28ERROR_MSG[27] = "æ¥åæ¶æ°éå段é误"29ERROR_MSG[28] = "æ¥åä»·æ ¼æ¡ä»¶é误"30ERROR_MSG[29] = "æ¥åæ¶æªè·åå°å®¢æ·å¯¹åºçèµéä¿¡æ¯"31ERROR_MSG[30] = "æ¥åæ¶èµéä¸è¶³"32ERROR_MSG[32] = "ä¸è½æ¤éå
¶ä»å®¢æ·æ¥å"33ERROR_MSG[33] = "æ¥åæ¶ä»·æ ¼ä¿¡æ¯ä¸ç¬¦åæå°ä»·ä½åå¨è¦æ±"34ERROR_MSG[34] = "æ¥åæ¶æ°éä¿¡æ¯ä¸ç¬¦åæå°æ°éåå¨è¦æ±"35ERROR_MSG[35] = "å¸ä»·åéé¢ä¸ç¬¦åç³»ç»è¦æ±"36ERROR_MSG[36] = "ç¨æ·ä¿¡æ¯éªè¯å¤±è´¥"37ERROR_MSG[37] = "æå¡å¨åé
ä¼è¯ä¿¡æ¯å¤±è´¥"38ERROR_MSG[38] = "æ¥å
è¿åº¦äº¤æè¡ä¸º"39ERROR_MSG[39] = "大é¢æ¥æ¤åè¡ä¸º"40ERROR_MSG[40] = "é¢ç¹æ¤åè¡ä¸º"41ERROR_MSG[41] = "æå交å²æ¥çå约ä¸å
许å¼ä»"42ERROR_MSG[42] = "ææºå¥ä¿æ è®°é误"43ERROR_MSG[43] = "å¼å¹³æ å¿é误"44ERROR_MSG[44] = "ä¹°åæ¹åé误"45ERROR_MSG[45] = "æ¥åä»·æ ¼æ¡ä»¶é误"46ERROR_MSG[46] = "æææç±»åé误"47ERROR_MSG[47] = "æ交éç±»åé误"48ERROR_MSG[48] = "触åæ¡ä»¶é误"49ERROR_MSG[49] = "å½åç¶æç¦æ¢æ¤é¡¹æä½"50ERROR_MSG[50] = "å¹³ä»æ¶å®¢æ·æä»ä¸è¶³"51ERROR_MSG[51] = "ä»·æ ¼è¶
åºæ¶¨åæ¿"52ERROR_MSG[52] = "ä»·æ ¼è·ç ´è·åæ¿"53ERROR_MSG[53] = "æä½æ å¿é误"54ERROR_MSG[54] = "ä¸æ¯æ该交æææ¥åæ交ææå段ä¸æ£ç¡®"55ERROR_MSG[55] = "è·å客æ·ç«¯è¿æ¥å°åä¿¡æ¯æ¶åºé"56ERROR_MSG[56] = "å约类åä¸å¯¹"57ERROR_MSG[57] = "å¤å
åªè½æ¯åå¼æä¹°å¹³"58ERROR_MSG[58] = "å¤å
å¼ä»æ¶æ çå约æä»ä¸è¶³"59ERROR_MSG[59] = "è·ç¦»äº¤å²æ¥æ¶é´å¤ªçä¸å
许å¼ä¹å¡ä»"60ERROR_MSG[60] = "ç»åææåæ å¿é"61ERROR_MSG[61] = "ä¸æ¯æ该ç»åçç¥"...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!