Exemplo n.º 1
0
def get_all_user():
    """
    查询所有用户
    :return:
    """
    try:
        user_infos = user_service.get_user_infos()
    except Exception as e:
        return ResponseUtil.error_response(data=[], msg=str(e))
    return ResponseUtil.success_response(data=user_infos, msg='success')
Exemplo n.º 2
0
def get_msg():
    """
    显示站内信
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        res = email_service.get_all_msgs(user_id)
    except Exception as e:
        return ResponseUtil.error_response(data=[], msg=str(e))
    return ResponseUtil.success_response(data=res, msg='success')
Exemplo n.º 3
0
def get_user_info():
    """
    获取当前登陆用户的信息
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        user_info = user_service.get_user_info(user_id)
    except Exception as e:
        return ResponseUtil.error_response(data={}, msg=str(e))
    return ResponseUtil.success_response(data=user_info, msg='success')
Exemplo n.º 4
0
def logout():
    """
    用户注销
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        user_service.logout(user_id)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 5
0
def get_all_experiment_pass():
    """
    得到实验
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        experiment_infos = experiment_service.get_all_experiments_pass(user_id)
    except Exception as e:
        return ResponseUtil.error_response(data=[], msg=str(e))
    return ResponseUtil.success_response(data=experiment_infos, msg='success')
Exemplo n.º 6
0
def get_all_orders():
    """
    查询所有订单信息
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        res = order_service.get_all_orders(user_id)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success', data=res)
Exemplo n.º 7
0
def join_experiment():
    """
    参加实验, 学生可选
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        eid = request.args.get('eid')
        experiment_service.join_experiment(user_id, int(eid))
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 8
0
def register():
    """
    注册接口
    :return:
    """
    form = RegisterForm.from_json(formdata=request.json, meta={'locales': ['zh_CN', 'zh']})
    try:
        validate_form(form)
        user_service.user_register(form.data)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 9
0
def get_logistics():
    """
    根据寄件人电话号/快递编号查询物流信息
    :return: 
    """
    order_number = request.args.get('order_number', '')
    if not order_number:
        return ResponseUtil.error_response(msg='寄件人电话号和订单号必填一项')
    try:
        res = logistics_service.get_logistics_by_phone_and_order_number(
            order_number)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(data=res, msg='success')
Exemplo n.º 10
0
def update_status():
    """
    删除用户
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    username = request.args.get('username')
    if not username:
        raise Exception('相关参数不能为空')
    try:
        user_service.delete_user(user_id, username)
    except Exception as e:
        return ResponseUtil.error_response(data={}, msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 11
0
def add_experiment():
    """
    录入实验
    :return:
    """
    form = ExperimentAdd.from_json(formdata=request.json,
                                   meta={'locales': ['zh_CN', 'zh']})
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        validate_form(form)
        experiment_service.add_experiment(form.data, user_id)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 12
0
def send_msg():
    """
    发送消息/公告
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        eid = request.args.get('eid')
        content = request.args.get('content')
        if not content:
            raise Exception('相关参数不能为空')
        email_service.send_msg_v1(user_id, eid, content)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='发送成功')
Exemplo n.º 13
0
def get_order_cost():
    """
    根据寄件人地址, 收件人地址, 物品重量获得价格
    :return:
    """
    form = GetOrderCost(request.args, meta={'locales': ['zh_CN', 'zh']})
    try:
        validate_form(form)
        send_pos, receive_pos, goods_weight = form.data.get('send_pos'), form.data.get('receive_pos'), \
                                              form.data.get('goods_weight')
        res = order_service.get_order_cost_by_pos(send_pos, receive_pos,
                                                  float(goods_weight))
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success', data=res)
Exemplo n.º 14
0
def do_order():
    """
    下单接口
    @:param username, password
    :return:
    {"msg": "34e3f953ee814a66a62b2cc2c02b1968", "code": 0, "data": null}
    """
    form = DoOrderForm.from_json(formdata=request.json,
                                 meta={'locales': ['zh_CN', 'zh']})
    try:
        validate_form(form)
        order_service.generate_order(form.data)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 15
0
def register():
    """
    注册接口
    @:param
    {"username":"******","password":"******"}
    :return:
    """
    form = RegisterForm.from_json(formdata=request.json,
                                  meta={'locales': ['zh_CN', 'zh']})
    try:
        validate_form(form)
        user_service.user_register(form.data)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 16
0
def update_status():
    """
    修改实验状态  审批/拒绝
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    try:
        eid = request.args.get('eid')
        status = request.args.get('status')
        if not eid or not status:
            return ResponseUtil.error_response(msg="缺少相关参数")
        experiment_service.update_experiment(user_id, eid, int(status))
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')
Exemplo n.º 17
0
def get_all_user_info():
    """
    得到所有用户信息
    status:查询普通用户/快递员
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    identity_type = request.args.get('identity_type')
    if not identity_type:
        return ResponseUtil.error_response('请填写查询类型')
    try:
        user_infos = user_service.get_all_user_infos(user_id, identity_type)
    except Exception as e:
        return ResponseUtil.error_response(data={}, msg=str(e))
    return ResponseUtil.success_response(data=user_infos, msg='success')
Exemplo n.º 18
0
def make_employee_to_deliver():
    """
    指派快递员去派件
    :return:
    """
    user_id = request.cookies.get('login_token').split('-')[0]
    employee_name = request.args.get('employee_name')
    order_number = request.args.get('order_number')
    if not employee_name or not order_number:
        return ResponseUtil.error_response(msg='相关参数不能为空')
    try:
        logistics_service.make_employee_to_deliver(user_id, employee_name,
                                                   order_number)
    except Exception as e:
        return ResponseUtil.error_response(msg=str(e))
    return ResponseUtil.success_response(msg='success')