def del_vip_person(req): """ 会员删除(单个/批量删除) :param req: :return: """ id_list= req.POST.copy()['checkData'] # print (id_list) sql = 'DELETE FROM vms.person WHERE id IN (%s)'%(id_list) db = Mysql() exist = db.getAll("select * from vip_order where person_id in (%s) and order_status = 0"%(id_list)) if not exist: count = (db.delete(sql)) db.dispose() if count == len(id_list.split(",")): resp = { "code": 0, "msg": "success" } else: resp = { "code": 1, "msg": "internal_exceptions" } else: resp = { "code": 2, "msg": "person exist order" } return HttpResponse(json.dumps(resp), content_type="application/json")
def manager_logout(req): """ 管理者账号退出登录 :param req: :return: """ token = req.GET.get('access_token') db = Mysql() result = db.getAll("select * from t_token where token = '%s'"%token) if result: if db.delete("DELETE FROM t_token where token = '%s'"%token): resp = { "code": 0 , "msg": "退出成功" , "data": { } } else: resp = { "code": 1 , "msg": "数据库异常,退出失败" , "data": { } } else: resp = { "code": 1 , "msg": "退出失败" , "data": { } } return HttpResponse(json.dumps(resp), content_type="application/json")
def __deco(request, *para, **kw): if debug: print("JWT debug状态,未校验!") return func(request, *para, **kw) else: token = '' db = Mysql() if request.method == 'GET': token = request.GET.get('access_token') elif request.method == 'POST': token = request.POST.get('access_token') else: print('尚未处理的请求类型') if token is not None: try: payload = jwt.decode(token, 'mothanty', algorithms=['HS256']) except Exception as e: db.delete("DELETE FROM t_token WHERE token='%s'" % token) print(e) resp = { "code": 1001, "msg": "", "count": 0, "data": [] } return HttpResponse(json.dumps(resp), content_type="application/json") result = db.getAll( "select * from t_token where token = '%s' and DATE_SUB(now(), INTERVAL 1 HOUR)<time" % token) if payload: if result: db.update("UPDATE t_token set time = now() WHERE token ='%s'" % token) print (func.__name__ + '方法token校验--成功') return func(request, *para, **kw) print (func.__name__ + '方法token校验--失败') db.delete("DELETE FROM t_token WHERE token='%s'" % token) resp = { "code": 1001, "msg": "", "count": 0, "data": [] } return HttpResponse(json.dumps(resp), content_type="application/json")
def wx_del_love(req): """ 微信小程序删除收藏 :param req: :return: """ openid = req.POST['openid'] good_id = req.POST['id'] db = Mysql() sql = "delete from person_love where good_id=%s and openid = '%s' " % ( good_id, openid) print(sql) result = db.delete(sql) print(result) resp = {"code": 0, "msg": "success", "data": ''} return HttpResponse(json.dumps(resp), content_type="application/json")
def del_server(req): """ 服务删除(单个/批量删除) :param req: :return: """ id_list = req.POST.copy()['checkData'] logger.debug("删除数据的ID:" + str(id_list)) sql = 'DELETE FROM server WHERE id IN (%s)' % (id_list) db = Mysql() count = (db.delete(sql)) db.dispose() if count == len(id_list.split(",")): resp = {"code": 0, "msg": "success"} else: resp = {"code": 1, "msg": "internal_exceptions"} return HttpResponse(json.dumps(resp), content_type="application/json")
def del_server(req): """ 分类删除(单个/批量删除) :param req: :return: """ id_list = req.POST.copy()['checkData'] logger.debug("删除分类的ID:" + str(id_list)) db = Mysql() sql1 = 'SELECT * FROM good WHERE good_category_id in (%s)' % (id_list) result = db.getAll(sql1) if result: resp = {"code": 2, "msg": "exsit_good_in_this_category"} else: sql = 'DELETE FROM good_category WHERE id IN (%s)' % (id_list) count = (db.delete(sql)) db.dispose() if count == len(id_list.split(",")): resp = {"code": 0, "msg": "success"} else: resp = {"code": 1, "msg": "internal_exceptions"} return HttpResponse(json.dumps(resp), content_type="application/json")