コード例 #1
0
class UserInsertService(Resource):
    def __init__(self, **kwargs):
        self.user_handler = UserDataHandler(kwargs['database_connector'])
        self.translator = UserTranslator()

    def put(self):
        user_json = request.json
        user = self.translator.translate_json_to_user(user_json)
        print(user)
        self.user_handler.register_user(user)
コード例 #2
0
class UserModifyService(Resource):
    def __init__(self, **kwargs):
       self.user_handler = UserDataHandler(kwargs['database_connector'])
       self.translator = UserTranslator()

    def post(self):
        user_json = request.json
        user = self.translator.translate_json_to_user(user_json)
        return self.user_handler.update_user(user)
コード例 #3
0
class UserListService(Resource):
    def __init__(self, **kwargs):
        self.user_handler = UserDataHandler(kwargs['database_connector'])
        self.translator = UserTranslator()

    def get(self, user_id):
        jsonsList = json.dumps(self.user_handler.retrieve(user_id),
                               default=self.translator.object_dict)
        return json.loads(jsonsList)
コード例 #4
0
 def __init__(self, **kwargs):
     self.user_handler = UserDataHandler(kwargs['database_connector'])
コード例 #5
0
class UserDeleteService(Resource):
    def __init__(self, **kwargs):
        self.user_handler = UserDataHandler(kwargs['database_connector'])

    def delete(self, user_id):
        return self.user_handler.delete(user_id)