Пример #1
0
def createCat():
    hier = request.form["hier"]
    parent_id = request.form["parent_id"]
    name = request.form["name"]
    status = int(request.form["status"])
    uid = int(request.cookies.get("uid"))

    db = Pysql()

    res = db.insert(sql="""
        insert into category (parent_id,name,status,created_time,created_user,updated_time,updated_user) values
        (%s,%s,%s,now(),%s,now(),%s);
    """,
                    params=(parent_id, name, status, uid, uid))

    if res["success"] == True:
        return jsonify(success=True)
    else:
        return jsonify(success=False, reason="Internal Wrong!")
Пример #2
0
def createProduct():
    name = request.form["name"]
    category_id = int(request.form["category_id"])
    price = float(request.form["price"])
    stock = int(request.form["stock"])
    status = int(request.form["status"])
    uid = int(request.cookies.get("uid"))

    db = Pysql()

    res = db.insert(sql="""
        insert into product (category_id,name,price,stock,status,created_time,created_user,updated_time,updated_user) values
        (%s,%s,%s,%s,%s,now(),%s,now(),%s);
    """,
                    params=(category_id, name, price, stock, status, uid, uid))

    if res["success"] == True:
        return jsonify(success=True)
    else:
        return jsonify(success=False, reason="Internal Wrong!")
Пример #3
0
            `payment` decimal(20,2) default null,
            `postage` int(10) default null,
            `status` int(10) default null,
            `payment_time` datetime default null,
            `send_time` datetime default null,
            `close_time` datetime default null,
            `created_time` datetime default null,
            `updated_time` datetime default null,
            primary key (`id`),
            unique key `order_no_index`(`order_no`) using btree
        ) engine=InnoDB default charset=utf8;
    """)

    db.insert(sql="""
        insert into user (username,password,role) values
        (%s,%s,%s);
    """,
              params=("pangzilong", "pangzilong", 0))

    db.insert(sql="""
        insert into `order` (order_no,user_id,payment,status,created_time,updated_time) values
        (%s,%s,%s,%s,now(),now());
    """,
              params=(123456, 2, 19.8, 10))

    db.insert(sql="""
        insert into `order` (order_no,user_id,payment,status,created_time,updated_time) values
        (%s,%s,%s,%s,now(),now());
    """,
              params=(234567, 2, 20.4, 10))