Class CommissionService
- java.lang.Object
-
- edu.cnm.deepdive.albuquirky.service.CommissionService
-
@Service public class CommissionService extends Object
This class handles all of the business logic for getting, putting, posting, and deleting items from theCommissionon behalf of theCommissionServiceclass, using methods from theCommissionRepositoryinterface.
-
-
Constructor Summary
Constructors Constructor Description CommissionService(CommissionRepository commissionRepository, ProfileRepository profileRepository)Constructor for the instances ofCommissionRepositoryandProfileRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Commission>get(long id)Method to return a commission that matches a specific ID.List<Commission>getByCommissioner(Profile commissioner)Method to return a list ofCommissionby the commissioning party, ordered by timestamp.List<Commission>getBySeller(Profile seller)Method to return a list of (@link Commission} by the commissioned party, ordered by timestamp.List<Commission>getWaitlist(Profile seller)Method to return a truncated list ofCommissionrepresenting the user's waitlist.Commissionremove(Commission commission, Profile profile)Method to delete a commission if the user is either the commissioner or the seller.Commissionsave(Commission commission)Method to save an entireCommission.Commissionsave(Commission commission, Profile profile)Method to save the seller and commissioner on aCommission.
-
-
-
Constructor Detail
-
CommissionService
@Autowired public CommissionService(CommissionRepository commissionRepository, ProfileRepository profileRepository)
Constructor for the instances ofCommissionRepositoryandProfileRepository.- Parameters:
commissionRepository- An instance ofCommissionRepositoryto be initialized.profileRepository- An instance ofProfileRepositoryto be initialized.
-
-
Method Detail
-
save
public Commission save(Commission commission)
Method to save an entireCommission.- Parameters:
commission- An instance ofCommissionto be saved.
-
save
public Commission save(Commission commission, Profile profile)
Method to save the seller and commissioner on aCommission.- Parameters:
commission- An instance ofCommission.profile- An instance ofProfilerepresenting the commissioned party.
-
remove
public Commission remove(Commission commission, Profile profile)
Method to delete a commission if the user is either the commissioner or the seller.- Parameters:
commission- TheCommissionto be deleted.profile- The {@link {Profile} of the user attempting to delete the commission.- Returns:
- The Commission being deleted.
-
get
public Optional<Commission> get(long id)
Method to return a commission that matches a specific ID.- Parameters:
id- The ID of theCommissionbeing requested.- Returns:
- An
Optionalcontaining the matchingCommission.
-
getBySeller
public List<Commission> getBySeller(Profile seller)
Method to return a list of (@link Commission} by the commissioned party, ordered by timestamp.- Parameters:
seller- An instance ofProfilerepresenting the commissioned party.
-
getWaitlist
public List<Commission> getWaitlist(Profile seller)
Method to return a truncated list ofCommissionrepresenting the user's waitlist.- Parameters:
seller- An instance ofProfilerepresenting the commissioned party.
-
getByCommissioner
public List<Commission> getByCommissioner(Profile commissioner)
Method to return a list ofCommissionby the commissioning party, ordered by timestamp.- Parameters:
commissioner- An instance ofProfilerepresenting the commissioning party.
-
-