Beispiel #1
0
def delCurrentSystem(request):
    dataJson = json.loads(_post(request, "data"))
    respJson = {}
    product_id = dataJson.get("product_id")
    propertyId = CurrentSystemService.getPropertyById(product_id)
    delProductRow = CurrentSystemService.delProduct(product_id)
    if(delProductRow > 0):
        delPropertyRow = CurrentSystemService.delProperty(propertyId[0]['hsh_property_id'])
    if(delPropertyRow > 0):
        respJson["result"] = Resp.SUCCESS
    else:
        respJson["result"] = Resp.ERROR
    return HttpResponse(toJson(respJson));
Beispiel #2
0
def saveCurrentSystem(request):
    dataJson = json.loads(_post(request, "data"))
    #先添加产品属性表中
    addPrpertyRow = CurrentSystemService.addPrperty(dataJson)
    #再获取上面添加到的id添加到产品表中
    if(addPrpertyRow > 0):
        if(dataJson["product_id"]):
            addProductRow = CurrentSystemService.addProduct_update(dataJson, addPrpertyRow)
        else:
            addProductRow = CurrentSystemService.addProduct_insert(dataJson, addPrpertyRow)
    if addProductRow > 0:
        return HttpResponse(toJson({"state": "ok"}))
    else:
        return HttpResponse(toJson({"error": "添加失败"}))
Beispiel #3
0
def updateCurrentSystemImage(request):
    #获取前端上传的图片
    file = request.FILES.getlist('files')
    product_id = _post(request, "id")
    file_name1 = ""
    
    #判断是否为空,默认
    if len(file) == 0:
        return;
    for f in file:
        name = f.name
        file_name = name.split(".")[0] + "_"+ DateUtil.time_stamp() +"."+ name.split(".")[1]
        img_path = os.path.join(Resp.IMAGEUPLOAD, file_name)
        file_name1+="/images/currentsystem_images/" + file_name+","
    #写入到文件中
        with open(img_path,'wb') as  ff:
            for item in f.chunks():
                ff.write(item)
    saveImageRow =  CurrentSystemService.updateCurrentSystemImage(file_name1, product_id)
    #路径保存到数据库
    respJson = {}
    if saveImageRow > 0:
        respJson["product_id"] = saveImageRow
    else:
        respJson["ERROR"] = Resp.ERROR
    return HttpResponse(toJson(respJson));
Beispiel #4
0
def updateCurrentSystem(request):
    dataJson = json.loads(_post(request, "data"))
    
    #先根据product_id获取产品属性Id
    pid = CurrentSystemService.getPropertyIdByProductId(dataJson.get("product_id"))
    #先修改产品属性
    property_id = pid[0]["hsh_property_id"]
    updatePropertyRow = CurrentSystemService.updateProperty(dataJson, property_id)
    if(updatePropertyRow > 0):
        updateProductRow = CurrentSystemService.updateProduct(dataJson)
    respJson = {}
    if updateProductRow > 0:
        respJson["result"] = Resp.SUCCESS
    else:
        respJson["result"] = Resp.ERROR
    return HttpResponse(toJson(respJson));
Beispiel #5
0
def getEOLSystemList(request):
    search_text = _post(request, "search_text")
    page = _post(request, "page")
    json = toJson(CurrentSystemService.getEOLSystemList(search_text, page))
    return HttpResponse(json)
Beispiel #6
0
def getProductById(request):
    product_id = _post(request, "product_id")
    return HttpResponse(toJson(CurrentSystemService.getProductById(product_id)))
Beispiel #7
0
def getCategoryList(request):
    return HttpResponse(CurrentSystemService.getCategoryList())