Ejemplo n.º 1
0
def addItem(name, email):
    u = User(name=name, email=email)
    try:
        db_session.add(u)
        db_session.commit()
    except Exception, e:
        return 'wrong(key repeat)'
Ejemplo n.º 2
0
def register(name, pwd, uuid=None, device=None):
    # user_id = ticks%10000*100000*1000+1*1000
    today = datetime.datetime.now()
    # 00000 000 000

    first = int(time.time()) / 1000000 % 1000

    second = int(time.time()) / 1000 % 1000

    third = int(time.time()) % 1000

    times = first * 10000000 + second * 10000 + third * 10 - 3950000000 + int(
        random.uniform(0, 9))

    print "second", time.time(
    ), id, times, 'first:', first, 'second', second, 'third', third

    # user_id为十位
    u = User(name=name, pwd=pwd, user_id=str(times))
    u.uuid = uuid
    u.device = device

    # print 'uuid',uuid
    u.last_time = today
    try:
        db_session.add(u)
        db_session.commit()
        return u
    except Exception, e:
        print "用户名 重复", e
        return None
Ejemplo n.º 3
0
def userinfo(name, uuid, device):
    today = datetime.datetime.now()
    info = Userbehaviour(today, name, uuid, device)
    try:
        db_session.add(info)
        db_session.commit()
        return status_code.trueCode
    except Exception, e:
        print "userinfo", e
Ejemplo n.º 4
0
def feedback(user_id, content):
    today = datetime.datetime.now()
    feed = FeedBack(today, content, user_id)
    try:
        db_session.add(feed)
        db_session.commit()
        return status_code.trueCode
    except Exception, e:
        print "feedback", e
        return status_code.query_feedback_failure
Ejemplo n.º 5
0
def addOrder(deal_Prce, goods_name):
    user_id = 1
    order = Order(user_id=user_id,
                  deal_time=datetime.datetime.now(),
                  deal_Prce=deal_Prce,
                  goods_name=goods_name)
    try:
        db_session.add(order)
        db_session.commit()
    except Exception, e:
        return 0
Ejemplo n.º 6
0
def add(name, pwd):
    # encryption = encryptionWithString('hello')
    # print 'random:',random_generator
    # print decryptionWithString(encryption,random_generator)

    # signature = signatureWithString('text')
    # print 'verification:',verificationSignature('text1',signature)
    u = sqlmodel.User(name=name, pwd=pwd)
    try:
        db_session.add(u)
        db_session.commit()
    except Exception, e:
        return 'wrong(key repeat)'
Ejemplo n.º 7
0
def transformpoint(sponsor, received, point):
    spo = User.query.filter(User.user_id == sponsor).first()
    if spo:
        rec = User.query.filter(User.name == received).first()

        if rec and spo.points > float(point):
            spo.points = spo.points - float(point)
            rec.points = rec.points + float(point)
            try:
                db_session.add(spo)
                db_session.add(rec)
                db_session.commit()
                return status_code.trueCode
            except Exception, e:
                print status_code.query_points_transform_failuret
        else:
            return status_code.query_points_transform_received_failuret
Ejemplo n.º 8
0
# 登录接口
#
def login(name, pwd, uuid=None, device=None):
    try:
        u = User.query.filter(User.name == name).first()
    except Exception, e:
        return 'there isnot %s' % name

    if u:
        if u.pwd == pwd:
            # points = User.query.filter(User.i==name).first()
            u.last_time = datetime.datetime.now()
            u.uuid = uuid
            u.device = device
            db_session.add(u)
            db_session.commit()
            return u
    else:
        return False

    ###########################    更新积分接口    #############################################
    #


    # 如果paras = 0 表示查询当前积分
    # 如果paras != 0 表示更改当前积分
def update_points(userid, positive_points, negative_points):
    if int(positive_points) == 0 and int(negative_points) == 0:
        try:
            u = User.query.filter(User.user_id == userid).first()