|
|
@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.seecoder.BlueWhale.Exception.BlueWhaleException;
|
|
|
-import com.seecoder.BlueWhale.Mapper.StoreMapper;
|
|
|
+import com.seecoder.BlueWhale.Repository.StoreRepository;
|
|
|
import com.seecoder.BlueWhale.PO.Store;
|
|
|
import com.seecoder.BlueWhale.Service.StoreService;
|
|
|
import com.seecoder.BlueWhale.VO.StoreVO;
|
|
|
@@ -16,24 +16,24 @@ import com.seecoder.BlueWhale.VO.StoreVO;
|
|
|
public class StoreServiceImpl implements StoreService {
|
|
|
|
|
|
@Autowired
|
|
|
- StoreMapper storeMapper;
|
|
|
+ StoreRepository storeRepository;
|
|
|
|
|
|
@Override
|
|
|
public Boolean create(StoreVO storeVO) {
|
|
|
- Store store = storeMapper.findByName(storeVO.getName());
|
|
|
+ Store store = storeRepository.findByName(storeVO.getName());
|
|
|
if (store != null) {
|
|
|
throw BlueWhaleException.nameAlreadyExists();
|
|
|
}
|
|
|
Store newStore = storeVO.toPO();
|
|
|
newStore.setRating(0.0);
|
|
|
newStore.setNumber(0);
|
|
|
- storeMapper.save(newStore);
|
|
|
+ storeRepository.save(newStore);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public StoreVO getStore(Integer id) {
|
|
|
- Store store = storeMapper.findById(id).orElse(null);
|
|
|
+ Store store = storeRepository.findById(id).orElse(null);
|
|
|
if (store == null) {
|
|
|
throw BlueWhaleException.storeNotExists();
|
|
|
}
|
|
|
@@ -42,7 +42,7 @@ public class StoreServiceImpl implements StoreService {
|
|
|
|
|
|
@Override
|
|
|
public List<StoreVO> getAllStores() {
|
|
|
- return storeMapper.findAll().stream().map(Store::toVO).collect(Collectors.toList());
|
|
|
+ return storeRepository.findAll().stream().map(Store::toVO).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
}
|