aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/service/UserService.java
blob: c23bf89c9fe856a483727a071e47bd1fd4684356 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.ufund.api.ufundapi.service;

import java.io.IOException;

import com.ufund.api.ufundapi.model.User;
import com.ufund.api.ufundapi.persistence.UserAuthDAO;
import com.ufund.api.ufundapi.persistence.UserDAO;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

@Component
public class UserService {

    private final UserDAO userDAO;

    /**
     * Create a user controller to receive REST signals
     *
     * @param userDao The Data Access Object
     */
    public UserService(UserDAO userDao, AuthService authService) {
        this.userDAO = userDao;
    }

    public User createUser(String username, String password) throws IOException {
        User user = User.create(username, password);
        return userDAO.addUser(user);
    }

    public User getUser(String username) throws IOException, IllegalAccessException {
        return userDAO.getUser(username);
    }

    public User updateUser(User user, String name) throws IllegalAccessException, IOException {
        return userDAO.updateUser(user, name);
    }

    public Boolean deleteUser(String username) throws IllegalAccessException, IOException {
        return userDAO.deleteUser(username);
    }
    
}