Esempio n. 1
0
def collects():
    # 收藏商品或店铺
    req_data = request.get_json()
    token = req_data.get('token')
    if check_token(token):
        user_id = get_token_user_id(token)
        clt_id = req_data.get('clt_id')
        type_id = req_data.get('type_id')
        if (clt_id and type_id) is not None:
            dao = BaseDao()
            save_data = {
                'user_id': user_id,
                'clt_id': clt_id,
                'type_id': type_id
            }
            result = dao.save('u_clt', **save_data)
            if result:
                return jsonify({'code': 200, 'msg': '收藏成功!'})
            else:
                return jsonify({'code': 400, 'msg': '查询数据库失败!'})
        elif clt_id is not None and type_id is None:  # 取消收藏
            if clt_id:
                dao = GoodsDao()
                delet = dao.del_collect(clt_id)
                if delet:
                    return jsonify({'code': 200, 'msg': '该收藏信息已删除!'})
                else:
                    return jsonify({'code': 400, 'msg': '删除失败!'})
            else:
                return jsonify({'code': 400, 'msg': '未接收到需要删除的ID!'})
        else:
            return jsonify({'code': 400, 'msg': '请上传商铺或商品ID和type类型!'})
    else:
        return jsonify({'code': 400, 'msg': 'token验证失败!'})
Esempio n. 2
0
def patient_message():
    try:
        req_data = {}
        token = request.args.get('token')  # 获取form中的token
        req_data['p_user_id'] = get_token_user_id(token)  # 通过token获取id
        req_data['p_name'] = request.form.get('p_name')  # 患者姓名
        req_data['p_ID_number'] = request.form.get('p_ID_number')  # 身份证号
        req_data['p_sex'] = request.form.get('p_sex')  # 性别
        req_data['date_birth'] = request.form.get('date_birth')  # 出生日期
        req_data['p_weight'] = request.form.get('p_weight')  # 体重
        req_data['is_allergy'] = request.form.get('is_allergy')  # 过敏史
        req_data['medical_history'] = request.form.get(
            'medical_history')  # 过往病史
        req_data['is_normal_liver'] = request.form.get('is_normal_liver')  # 肝功
        req_data['is_normal_kidney'] = request.form.get(
            'is_normal_kidney')  # 肾功
        req_data['is_pregnancy_preparation'] = request.form.get(
            'is_pregnancy_preparation')  # 是否备孕
        patient_dao = BaseDao()
        patient_dao.save('patient', **req_data)
        return jsonify({'code': 200, 'msg': '添加患者信息成功'})
    except:
        return jsonify({'code': 400, 'msg': '暂无数据'})
Esempio n. 3
0
def update_address():
    # 修改地址
    req_data = request.get_json()
    token = req_data.get('token')
    add_id = req_data.get('address', None)
    re_str = req_data.get('strs', None)
    print(re_str, add_id)
    if check_token(token):
        user_id = get_token_user_id(token)

        if add_id is not None and re_str is None:  # 删除
            dao = BaseDao()
            dao.delete('u_address', 'user_address', add_id)
            return jsonify({'code': 200, 'msg': '该地址已删除!'})
        elif (add_id and re_str) is not None:  # 修改
            dao = AddDao()
            dao.update('u_address', 'user_address', re_str, 'user_address',
                       add_id)
            check_data = dao.check_address(user_id)
            user_data = UserDao().get_profile(user_id)
            if all((check_data, user_data)):
                data = {
                    'addressList': [{
                        "receivePersonName":
                        user_data[0]['user_name'],
                        "receiveAddress":
                        check_data[0]['user_address'],
                        "receiveTEL":
                        user_data[0]['tel']
                    }]
                }
                return jsonify({'code': 200, 'msg': '地址修改成功!', 'data': data})
            else:
                return jsonify({'code': 400, 'msg': '数据库查询失败!'})

        elif re_str is not None and add_id is None:  # 添加
            print(re_str)
            dao = AddDao()
            save_add = dao.save(
                'u_address', **{
                    "user_id": user_id,
                    "user_address": re_str,
                    "is_default": 0
                })
            if save_add:
                check_data = dao.check_address(user_id)
                user_data = UserDao().get_profile(user_id)
                if all((check_data, user_data)):
                    data = {
                        'addressList': [{
                            "receivePersonName":
                            user_data[0]['user_name'],
                            "receiveAddress":
                            check_data[0]['user_address'],
                            "receiveTEL":
                            user_data[0]['tel']
                        }]
                    }
                    return jsonify({
                        'code': 200,
                        'msg': '地址添加成功!',
                        'data': data
                    })
                else:
                    return jsonify({'code': 400, 'msg': '数据库查询失败!'})
            else:
                return jsonify({'code': 400, 'msg': '地址添加失败!'})
        else:
            return jsonify({'code': 400, 'msg': '数据上传有误!'})
    else:
        return jsonify({'code': 400, 'msg': 'token验证失败!'})