def del_goods(data): goods_id = fun.warp_data(data)['id'] p = GoodsissueGoods.objects.get(id=goods_id) if p: p.delete() else: return -1
def search(request): if request.method == 'GET': return render(request,'search_test.html') else: data = fun.warp_data(request.POST) goods_name = data['keywords'] goods_info = GoodsReleased.objects.filter(title__contains = goods_name) return render(request,'Good_Searched.html',locals(),)
def get_goods_detail(data): condition = fun.warp_data(data) id = condition.get('id') u = GoodsissueGoods.objects.get(id=id) if u: return u else: return {}
def user_login(date): condition = fun.warp_data(date) email = condition['email'] passwd = fun.mk_md5(condition['passwd']) r = LoginUser.objects.get(email=email) #判断数据库的账号匹配结果是否存在以及密码是否匹配 if not r or passwd != r.passwd: r = {} return r
def search(request): if request.method == 'GET': msg = '非法访问!!!' return render_to_response('error_msg.html', locals()) data = fun.warp_data(request.POST) goods_name = data['keywords'] # goods_info = GoodsissueGoods.objects.filter(name__contains=goods_name) return render_to_response('goods_list.html', locals(), context_instance=requestuestContext(request))
def purchase(data, buyer_id): condition = fun.warp_data(data) tradeDate = fun.now() condition['buyer_id'] = buyer_id u = GoodsissueSaler(**condition) u.tradedate = tradeDate u.save() if u: return 1 else: return -1
def user_login(date): condition = fun.warp_data(date) email = condition['email'] #change start if not LoginUser.objects.filter(email=condition['email']): return -1 #change end r = LoginUser.objects.get(email=email) passwd = fun.mk_md5(condition['passwd']) #判断数据库的账号匹配结果是否存在以及密码是否匹配 if not r or passwd != r.passwd: r = {} return r
def purchase(data, buyer_id): condition = fun.warp_data(data) goods = GoodsissueGoods.objects.get(id = condition['goods_id']) #change goods.status = 0 #change goods.save() #change tradeDate = fun.now() condition['buyer_id'] = buyer_id u = GoodsissueSaler(**condition) u.tradedate = tradeDate u.save() if u: return 1 else: return -1
def user_register(date): condition = fun.warp_data(date) # print(condition) if condition['passwd'] != condition['repasswd']: return 0 del condition['repasswd'] passwd = fun.mk_md5(condition['passwd']) condition['passwd'] = passwd #数据库的存储 u = LoginUser(**condition) u.save() if u.name: return 1 else: return -1
def store_goods(data, extends): condition = fun.warp_data(data) issueDate = fun.now() #定义存储商品发布者信息的字典 issuer = {} # issuer['issueDate'] = issueDate #存入商品发布者的ID owner_id = LoginUser.objects.get(id=extends['uid']) condition['owner_id'] = extends['uid'] issuer['uid'] = owner_id #存入图片名 if extends['imgName']: condition['imagefile'] = extends['imgName'] #弹出id id = condition.pop('id') if id: #更新商品表操作,全更新,首先将值为空的字段弹出去 for co in condition.keys(): if not condition[co]: condition.pop(co) u1 = GoodsissueGoods.objects.filter(id=id).update(**condition) #更新商品发布者表操作,部分更新 goodsId = GoodsissueGoods.objects.get(id=id) u2 = GoodsissueIssuer.objects.filter(goods_id=goodsId) u2.issueDate = issueDate if u1 or u2: return 1 else: return -1 else: #新增商品表操作 u3 = GoodsissueGoods(**condition) u3.save() #新增商品发布者表操作 goodsId = GoodsissueGoods.objects.get(owner_id=issuer['uid'], name=condition['name']).id issuer['goods_id'] = goodsId u4 = GoodsissueIssuer(**issuer) u4.issuedate = issueDate u4.save() if u3: return 2 else: return -2
def user_register(date): condition = fun.warp_data(date) #change start if LoginUser.objects.filter(email=condition['email']): return -2 if LoginUser.objects.filter(name=condition['name']): return -3 #change end if condition['passwd'] != condition['repasswd']: return 0 del condition['repasswd'] passwd = fun.mk_md5(condition['passwd']) condition['passwd'] = passwd #数据库的存储 u = LoginUser(**condition) u.save() if u.name: return 1 else: return -1