UserService.java 7.06 KiB
package com.tarento.retail.service;
import java.util.List;
import java.util.Set;
import org.springframework.web.multipart.MultipartFile;
import com.tarento.retail.dto.CountryDto;
import com.tarento.retail.dto.MasterRoleDto;
import com.tarento.retail.dto.UserCountryDto;
import com.tarento.retail.dto.UserDto;
import com.tarento.retail.dto.UserMasterRoleCountryOrgDto;
import com.tarento.retail.dto.UserRoleDto;
import com.tarento.retail.model.Action;
import com.tarento.retail.model.Country;
import com.tarento.retail.model.InstituteCourses;
import com.tarento.retail.model.KeyValue;
import com.tarento.retail.model.Role;
import com.tarento.retail.model.SearchRequest;
import com.tarento.retail.model.User;
import com.tarento.retail.model.UserAuthentication;
import com.tarento.retail.model.UserDeviceToken;
import com.tarento.retail.model.UserProfile;
public interface UserService {
	/**
	 * This method receives the List of Role IDs from the controller and passes the
	 * same to DAO to fetch the List of Actions allowed and configured for the Role
	 * ID
	 * @param roleID
	 * @return
	public List<Action> findAllActionsByRoleID(List<Integer> roleID);
	/**
	 * This method receives the User high level object. This is passed to DAO after
	 * Password encryption to save the same into Database
	 * @param user
	 * @return
	User save(User user);
	/**
	 * This method receives the existing User object to update the details in the
	 * Database for the respective User
	 * @param user
	 * @return
	User update(User user);
	/**
	 * This method receives the User Authentication Details on every login to save
	 * the Auth Token for the sake of further validations while accessing other
	 * features in the application
	 * @param user
	 * @return
	UserAuthentication save(UserAuthentication user);
	/**
	 * This method supports pagination and fetches the User Profiles for the
	 * respective search criteria Search can happen based on Page Number, Number of
	 * Records, Active status of the user Keyword to search the user and also based
	 * on the Roles Assigned to the User
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
* @param pageNumber * @param numberOfRecords * @param active * @param keyword * @param roles * @return */ List<UserProfile> findAll(Integer pageNumber, Integer numberOfRecords, Boolean active, String keyword, List<Long> roles, String countryCode, Long orgId); /** * This method receives the String Username to fetch the respective User record * from the Database * * @param username * @return */ User findOne(String username); UserDto findUserRolesActions(String username); /** * This method receives the Long ID to fetch the respective User Profile from * the database * * @param id * @return */ UserProfile findById(Long id, Long orgId); /** * This method receives the list of Users IDs and passes the same to Data layer * to get and fetch the User Profiles for that User ID List * * @param userIdList * @return */ List<UserProfile> findListOfUsers(List<Long> userIdList); /** * This method receives the User ID and find the corresponding roles for the * User ID and lists out the Roles as a response * * @param userId * @return */ public List<Role> findAllRolesByUser(Long userId, String orgId, String username); /** * This method receives the User ID and then fetches the Role ID for the same * With the help of Role ID, it fetches the corresponding Actions which are * allowed and mapped. As a result, this responds Action object * * @param userId * @return */ public Set<Action> findAllActionsByUser(Long userId, String orgId); /** * This method carries the Phone Number and fetches the corresponding User high * level object for the Phone Number * * @param phoneNo * @return */ User findMobile(String phoneNo); /** * This method receives the User Role Object. For a User ID and each Role ID in * the list, this method creates a mapping so that User Role Mapping is added
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
* * @param userRole * @return */ Boolean mapUserToRole(UserRoleDto userRole); /** * This method receives the User Profile which contains the secondary details of * the User. Method is invoked internally on creating User * * @param profile * @return */ UserProfile saveUserProfile(UserProfile profile); /** * This method receives an already existing User Profile object which is passed * on to Data Layer Method ensures that the update is successful. * * @param profile * @return */ UserProfile updateUserProfile(UserProfile profile); /** * This method receives the User Profile object which carries the Profile Image * Updates the same and responds with the same object * * @param profile * @return */ UserProfile updateUserProfileImage(UserProfile profile); Long checkUserNameExists(String emailId, String phoneNo); Boolean uploadFile(MultipartFile file, long userId); Long getNumberOfUsers(Long role, Boolean active); Long getNumberOfRoles(); List<Country> getCountryList(); List<Country> getCountryListForUser(Long userId); Boolean mapUserToCountry(UserCountryDto userCountry); Boolean invalidateToken(String authToken); Boolean findUserByToken(String authToken); Boolean checkUserTokenExists(Long userId, String deviceToken); Boolean updateUserDeviceToken(Long userId, String deviceToken, String deviceId, Long authTokenRef); /** * This method receives the list of Users IDs and passes the same to Data layer * to get and fetch the User Device Tokens which are registered by Mobile * Application * * @param userIdList * @return */ List<UserDeviceToken> getDeviceTokenForUsers(List<Long> userIdList); Long fetchAuthTokenReference(String authToken); Boolean hasAccess(List<Role> roles);
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
Boolean createCountry(CountryDto countryDto); Boolean updateCountry(CountryDto countryDto); public List<Country> getCountryListForOrg(Long orgId); public Boolean checkCountryAlreadyExists(String code, Long orgId); Boolean deleteUserToRole(UserRoleDto userRole); Boolean deleteCountryForOrg(CountryDto countryDto); Boolean deleteUser(UserDto userDto); List<UserDto> getUsersByMasterRole(String roleCode, Long orgId); Boolean mapUserMasterRoleCountryOrg(UserMasterRoleCountryOrgDto userMasterRoleCountryOrgDto); List<MasterRoleDto> getMasterRoleByOrgDomainId(Long orgDomainId); UserProfile getUserProfile(String username); Boolean requestOTP(String email); Boolean validateUserOTP(String username, String otp); public List<UserProfile> findAll(SearchRequest searchRequest); List<KeyValue> getNumberOfUsersAndRoles(); public Boolean setUserPin(int pin, Long userId); public Boolean validateUserPin(String username, int pin); public Boolean deleteDeviceToken(Long userId, String deviceId); public Boolean updateDeviceAuthRef(Long userId, String deviceToken, Long authId); InstituteCourses getInstituteCourses(Long profileId, String course, String degree); Boolean saveInstituteCourse(InstituteCourses instituteCourses); Boolean softDeleteUser(UserDto userDto); List<InstituteCourses> findAllInstituteCourses(Long userId); User getUserByEmailId(String emailId); }