Пример #1
0
def api_GetRecordList():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    c = b.get('cid')
    if not c:
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    return jsonify(Controller.debt_list(id, c))
Пример #2
0
def api_DelDebt():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    did = b.get('id')
    if not did:
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.delete_one_debt(id, did)
    return jsonify(res)
Пример #3
0
def api_DelCard():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    cid = b.get('id')
    if not cid:
        res = {'err': 1, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.delete_one_card(id, cid)
    return jsonify(res)
Пример #4
0
def api_DelLoan():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    cid = b.get('cid')
    if not cid:
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.delete_loan(id, cid)
    return jsonify(res)
Пример #5
0
def api_DelIncome():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    iid = b.get('id')
    if iid is None:
        res = {'err': 1, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.delete_one_income(id, iid)
    return jsonify(res)
Пример #6
0
def api_AddIncome():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    n = b.get('num')
    d = b.get('date')
    if not all([n, d]):
        res = {'stutas': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.add_one_income(id, n, d)
    return jsonify(res)
Пример #7
0
def api_AddAnswer():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    d = b.get('id')
    a = b.get('ans')
    if not all([a, d]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.ans_one_answer(d, a)
    return jsonify(res)
Пример #8
0
def load_user_from_request(request):
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    api_key = b.get('token')
    if api_key:
        user = Controller.verify_token(api_key)
        if user:
            g.current_user = user
            g.token_used = True
            return user
    JS_CODE = b.get('code')
    openid = get_openid(JS_CODE).get('openid')
    if openid is None:
        return
    user = Controller.find_user_by_apikey(openid)
    if user is None:
        user = Controller.log_on_user(openid)
    g.current_user = user
    g.token_used = False
    return user
Пример #9
0
def api_AddExchange():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    s = b.get('cid')
    n = b.get('num')
    d = b.get('date')
    o = b.get('oid')
    p = b.get('repaytype')
    if not all([s, n, d, p]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    if p == 1:
        res = Controller.quick_repay_by_card(id, s, n, d, o)
    elif p == 2:
        res = Controller.quick_repay_by_cash(id, s, n, d)
    elif p == 3:
        res = Controller.quick_repay_by_income(id, s, n, d, o)
    else:
        res = {'msg': '该类型还款方式暂未实现', 'status': 2}
    return jsonify(res)
Пример #10
0
def api_AddDebt():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    s = b.get('cid')
    n = b.get('num')
    d = b.get('date')
    if not all([s, n, d]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.add_one_debt(id, s, n, d)
    return jsonify(res)
Пример #11
0
def api_AddLoan():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    s = b.get('cid')
    n = b.get('num')
    ts = b.get('begin')
    tn = b.get('end')
    if not all([s, n, ts, tn]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.add_loan(id, s, n, ts, tn)
    return jsonify(res)
Пример #12
0
def api_AddReport():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    a = b.get('is_advice')
    p = b.get('pageAdr')
    c = b.get('content')
    n = b.get('userName')
    if a is None:
        a = False
    if not all([p, c]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.add_one_report(id, a, p, c, n)
    return jsonify(res)
Пример #13
0
def api_AddCard():
    id = g.current_user.id
    b = json.loads(str(request.get_data(), encoding="utf-8"))
    s = b.get('name')
    a = b.get('acdate')
    p = b.get('padate')
    n = b.get('num')
    c = b.get('isCredit')
    if c == None:
        c = 1
    if not all([s, a, p, n]):
        res = {'status': 2, 'msg': '参数不完整'}
        return jsonify(res)
    res = Controller.add_one_card(id, s, a, p, n, c)
    return jsonify(res)
Пример #14
0
def api_GetReportList():
    return jsonify(
        Controller.report_list(g.current_user.id,
                               g.current_user.is_administrator()))
Пример #15
0
def api_GetIncomeList():
    return jsonify(Controller.income_list(g.current_user.id))
Пример #16
0
def api_GetCardList():
    return jsonify(Controller.card_list(g.current_user.id))
Пример #17
0
def api_GetLoanList():
    return jsonify(Controller.loan_list(g.current_user.id))
Пример #18
0
def api_GetPlan():
    return jsonify(Controller.show_plan(g.current_user.id))
Пример #19
0
def outer_logic(f):
    MyApi.general_logic(MyApi.login_word, MyApi.login_program, f)
Пример #20
0
def inner_logic(uid):
    if uid == 0:
        return
    MyApi.general_logic(MyApi.record_word, MyApi.record_program, uid)
Пример #21
0
def api_GetDebtList():
    return jsonify(Controller.cal_debt_current(g.current_user.id))