Ejemplo n.º 1
0
def add_collection():
    collection = Collection()
    user = User()
    question = Question()
    # 获取请求中的参数
    username = request.form.get("username")
    idq = request.form.get("idq")
    # 获取用户id
    idu = user.find_by_username(username)[0].id

    res = collection.find_by_iduidq(idu=idu, idq=idq)
    if len(res) > 0:
        return 'repeated'
    else:
        # 更新两张表question和collection
        question.add_collect_count(idq=idq)  # 问题表收藏数+1
        collection.add(idu=idu, idq=idq)
        return 'success'
Ejemplo n.º 2
0
def addcc():
    question = Question()
    idq = request.args.get("idq")
    question.add_collect_count(idq=idq)
    return 'add-success'