Exemplo n.º 1
0
    def del_data():
        if 'whereJson' in req.form:
            try:
                dict_where = json.loads(req.form['whereJson'])
                if len(dict_where) != 1:
                    return make_response('whereJson错误')
            except:
                return make_response('whereJson错误')
        else:
            return make_response('whereJson错误')

        result = mysqldb.del_data(table_name, dict_where)
        # print(result)

        if result:
            # 操作记录
            content = 'whereJson=' + re.sub(
                r'\"', "'", json.dumps(dict_where, ensure_ascii=False))
            dict_record = {
                'username': dict_login['username'],
                'dbName': table_name,
                'action': '删除',
                'content': content,
                'os': dict_login['os'],
                'px': dict_login['px'],
                'ip': req.remote_addr,
                'time': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
            }
            mysqldb.set_record(dict_record)

            return make_response('操作成功')
        else:
            return make_response('操作失败')
Exemplo n.º 2
0
    def delete_data_fn(self, dict_where):
        result = mysqldb.del_data(self.table_name, dict_where)
        # print(result)

        if result:
            # 操作记录
            content = 'whereJson=' + re.sub(r'\"', "'", json.dumps(dict_where, ensure_ascii=False))
            dict_record = {'username': self.dict_login['username'], 'dbName': self.table_name, 'action': '删除', 'content': content,
                           'os': self.dict_login['os'], 'px': self.dict_login['px'], 'ip': self.req.remote_addr,
                           'time': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}
            mysqldb.set_record(dict_record)

            return make_response('操作成功')
        else:
            return make_response('操作失败')
Exemplo n.º 3
0
    def del_data():
        if 'whereJson' in req.form:
            try:
                dict_where = json.loads(req.form['whereJson'])
                if len(dict_where) != 1:
                    return make_response('whereJson错误')
            except:
                return make_response('whereJson错误')
        else:
            return make_response('whereJson错误')

        result = mysqldb.del_data(table_name, dict_where)
        # print(result)

        if result:
            return make_response('操作成功')
        else:
            return make_response('操作失败')
Exemplo n.º 4
0
    def del_data():
        if 'whereJson' in req.form:
            try:
                dict_where = json.loads(req.form['whereJson'])
                if not dict_where['url']:
                    return make_response('whereJson错误')
            except:
                return make_response('whereJson错误')
        else:
            return make_response('whereJson错误')

        result = mysqldb.del_data(table_name, dict_where)
        # print(result)

        if result:
            for url in dict_where['url']:
                file_path = os.path.normpath(
                    os.path.dirname(os.path.dirname(__file__)) + url)
                if os.path.exists(file_path):
                    os.remove(file_path)
                else:
                    pass

            # 操作记录
            content = 'whereJson=' + re.sub(
                r'\"', "'", json.dumps(dict_where, ensure_ascii=False))
            dict_record = {
                'username': dict_login['username'],
                'dbName': table_name,
                'action': '删除文件',
                'content': content,
                'os': dict_login['os'],
                'px': dict_login['px'],
                'ip': req.remote_addr,
                'time': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
            }
            mysqldb.set_record(dict_record)

            return make_response('操作成功')
        else:
            return make_response('操作失败')