Пример #1
0
def get_user_info():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        user_id = json_data.get('user_id', None)
        if user_id is None:
            return bad('user id is None')
        user = UserManagementSystem.get_user_info(user_id)
        identity = json_data.get('identity', None)

        if identity is not None:
            if identity != user.identity:
                return bad('wrong identity')
        else:
            identity = user.identity

        data = UserManagementSystem.get_indentity_info(user_id, identity)
        if data is None:
            return bad('nothing found')

        data.update(user.info_basic_dict())
        print(data)
        return ok(json.dumps(data))
    return bad('error')
Пример #2
0
def get_users():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        page = json_data.get('page', None)
        user_type = json_data.get('user_type', None)

        if page is None or user_type is None:
            return bad('key error')

        record_num = UserManagementSystem.get_user_count(user_type)

        if page > record_num // 100 + 1:
            return bad('out of user size')

        data = UserManagementSystem.get_users(user_type=user_type, page=page)
        print(data)

        return ok(json.dumps(data))
    return bad('error')
Пример #3
0
def get_company_count():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        type_ = json_data.get('type', None)
        if type_ not in ['company', 'college']:
            return bad('wrong type')

        return ok(json.dumps(UserManagementSystem.get_company_count(type_)))
    else:
        return bad('use POST')
Пример #4
0
def low_credit_count():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        credit = json_data.get('credit', None)

        if not isinstance(credit, int):
            return bad('bad credit')

        return ok(json.dumps({'count': UserManagementSystem.low_credit_count(credit)}))
    else:
        return bad('use POST')
Пример #5
0
    def audit_user(user_id, identity, audit):
        """
        state_prove : U W F S
        :param user_id:  user id
        :param identity: 'S' or 'C'
        :param audit: True or False
        :return:
        """
        user = UserManagementSystem.get_user_info(user_id)
        if user.isprove != "W":
            return "this use is not in the waiting list"

        if identity not in ["S", "C"]:
            return "identity is wrong or None"

        user = UserManagementSystem.get_indentity_info(user_id, identity)

        if user is None:
            return "cannot fount this user in %s" % identity

        if user["state_prove"] != "W":
            return "this user is not in the %s waiting list" % identity

        return UserManagementSystem.audit_user(user_id, identity, audit)
Пример #6
0
    def audit_user(user_id, identity, audit):
        """
        state_prove : U W F S
        :param user_id:  user id
        :param identity: 'S' or 'C'
        :param audit: True or False
        :return:
        """
        user = UMS.get_user_info(user_id)
        if user.isprove != 'W':
            return 'this use is not in the waiting list'

        if identity not in ['S', 'C']:
            return 'identity is wrong or None'

        user = UMS.get_indentity_info(user_id, identity)

        if user is None:
            return 'cannot fount this user in %s' % identity

        if user['state_prove'] != 'W':
            return 'this user is not in the %s waiting list' % identity

        return UMS.audit_user(user_id, identity, audit)
Пример #7
0
def get_user_count():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        user_type = json_data.get('user_type', None)
        if user_type is None:
            return bad('key error')

        record_num = UserManagementSystem.get_user_count(user_type)

        print('record_num', record_num)

        return ok(json.dumps({'count': record_num}))
    return bad('please user POST!')
Пример #8
0
def specific_user_count():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode('utf-8'))
        print('data', json_data)

        gender = json_data.get('gender', None)
        identity = json_data.get('identity', None)

        if gender not in ['W', 'M'] or identity not in ['S', 'C']:
            return bad('bad gender/identity')

        record_num = UserManagementSystem.specific_user_count(gender, identity)

        print('record_num', record_num)

        if record_num[0]:
            return ok(json.dumps({'count': record_num[1]}))
        else:
            return bad(json.dumps(record_num[1]))
    else:
        return bad('use POST')
Пример #9
0
import connexion
import six

from swagger_server.models.balance import Balance  # noqa: E501
from swagger_server.models.error_response import ErrorResponse  # noqa: E501
from swagger_server.models.iden_info import IdenInfo  # noqa: E501
from swagger_server.models.iden_info_with_credit import IdenInfoWithCredit  # noqa: E501
from swagger_server.models.login_code import LoginCode  # noqa: E501
from swagger_server.models.prove_state import ProveState  # noqa: E501
from swagger_server.models.user_info import UserInfo  # noqa: E501
from swagger_server.models.user_info_without_id import UserInfoWithoutId  # noqa: E501
from swagger_server import util
from swagger_server.modules.userManagementSystem import ManagementSystem
from swagger_server.modules.accessControlSystem import AccessControlSystem as accessControlSystem

user_manager = ManagementSystem()
access_control = accessControlSystem()

login_response = (ErrorResponse(message="login"), 400)

@access_control.login_required(login_response)
def user_info_put(body):  # noqa: E501
    """User modify his basic info.

     # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: UserInfo
    """