Ignore:
Timestamp:
04/19/23 21:19:08 (19 months ago)
Author:
Gjoko Kostadinov <gjoko.kostadinov@…>
Branches:
master
Children:
950fa0d
Parents:
9050790
Message:

Add admin functionality and business admin functionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/edu/gjoko/schedlr/services/BusinessService.java

    r9050790 r8bcd64c  
    33import edu.gjoko.schedlr.entity.Business;
    44import edu.gjoko.schedlr.entity.ServiceType;
     5import edu.gjoko.schedlr.entity.Stakeholder;
    56import edu.gjoko.schedlr.entity.StakeholderType;
    67import edu.gjoko.schedlr.repositories.BusinessRepository;
    78import edu.gjoko.schedlr.repositories.ServiceTypeRepository;
    89import lombok.AllArgsConstructor;
     10import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
    911import org.springframework.stereotype.Service;
    1012
    1113import java.util.List;
    1214
    13 import static edu.gjoko.schedlr.entity.BusinessStatus.ACTIVE;
    1415import static edu.gjoko.schedlr.entity.BusinessStatus.NEW;
    1516
     
    2021    private final BusinessRepository businessRepository;
    2122    private final ServiceTypeRepository serviceTypeRepository;
     23    private BCryptPasswordEncoder bCryptPasswordEncoder;
    2224
    2325    public void saveBusiness(Business business) {
    2426        saveNewServiceTypes(business);
    2527        business.getOwner().setStakeholderType(StakeholderType.BUSINESS_OWNER);
     28        business.getOwner().setPassword(bCryptPasswordEncoder.encode(business.getOwner().getPassword()));
    2629        business.setBusinessStatus(NEW);
    2730        businessRepository.save(business);
     
    5255    }
    5356
     57    public Business findByOwner(Long ownerId) {
     58        var owner = new Stakeholder();
     59        owner.setId(ownerId);
     60        return businessRepository.findBusinessByOwner(owner);
     61    }
    5462}
Note: See TracChangeset for help on using the changeset viewer.