package service;

import JDBC.UserJDBC;
import pojo.IcCard;
import pojo.ParkingSpot;
import pojo.User;
import pojo.Vehicle;

import java.util.List;
import java.util.Map;

public class UserService {
    UserJDBC db = new UserJDBC();
    public List<User> getAllUser() throws Exception {
        return db.selectAllUser();
    }

    public List<User> getUserByNPA(String name, int parking_spot_id, String address) throws Exception {
        return db.selectUserByNPA(name,parking_spot_id, address);
    }

    public List<User> OrderUserByUserId() throws Exception {
        return db.SortUserByUserId();
    }

    public List<User> OrderUserByParkId() throws Exception {
        return db.SortUserByParkId();
    }

    public List<User> OrderUserByName() throws Exception {
        return db.SortUserByName();
    }

    public Map<String, Integer> CntUserBytotalUser() throws Exception {
        return db.CntUserByTotalUser();
    }

    public Map<String, Integer> CntUserByGender() throws Exception {
        return db.CntUserByGender();
    }

    public Map<String, Integer> CntUserByUserType() throws Exception {
        return db.CntUserByUserType();
    }

    public List<Vehicle> selectCarByUserId(int user_id) throws Exception {
        return db.selectCarByUserId(user_id);
    }

    public List<ParkingSpot> selectParkByParkId(int parkingSpotId) throws Exception {
        return db.selectParkByParkId(parkingSpotId);
    }

    public List<IcCard> selectICByUserId(int userId) throws Exception {
        return db.selectICByUserId(userId);
    }


    public List<User> updateUser(int userId, String name, String telephone, String userType, int parkingSpotId, String address, String gender) throws Exception {
        return db.updateUser(userId,name,telephone,userType,parkingSpotId,address,gender);
    }

    public List<User> deleteUser(int userId) throws Exception {
        return db.deleteUserById(userId);
    }

    public User getUserbyId(int id) throws Exception {
        return db.getUserById(id);
    }
    public int updateUser(User user) throws Exception {
        return db.update_user_Info(user);
    }
}


