|
|
@ -2,14 +2,11 @@ package com.luoo.user.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.user.dao.StoreDao;
|
|
|
|
import com.luoo.user.dao.StoreDao;
|
|
|
|
import com.luoo.user.dto.store.StoreUpdateDto;
|
|
|
|
import com.luoo.user.dto.store.StoreUpdateDto;
|
|
|
|
import com.luoo.user.mapstruct.StoreMapper;
|
|
|
|
|
|
|
|
import com.luoo.user.pojo.Store;
|
|
|
|
import com.luoo.user.pojo.Store;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import util.IdWorker;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -25,11 +22,9 @@ public class StoreService {
|
|
|
|
|
|
|
|
|
|
|
|
private final StoreDao storeDao;
|
|
|
|
private final StoreDao storeDao;
|
|
|
|
|
|
|
|
|
|
|
|
private final StoreMapper storeMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StoreService(StoreDao storeDao, StoreMapper storeMapper) {
|
|
|
|
public StoreService(StoreDao storeDao) {
|
|
|
|
this.storeDao = storeDao;
|
|
|
|
this.storeDao = storeDao;
|
|
|
|
this.storeMapper = storeMapper;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 增删改查
|
|
|
|
// 增删改查
|
|
|
@ -49,7 +44,7 @@ public class StoreService {
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void update(StoreUpdateDto storeUpdateDto) {
|
|
|
|
public void update(StoreUpdateDto storeUpdateDto) {
|
|
|
|
Store oldStore = storeDao.findById(storeUpdateDto.getId()).orElseThrow(() -> new RuntimeException("Store not found"));
|
|
|
|
Store oldStore = storeDao.findById(storeUpdateDto.getId()).orElseThrow(() -> new RuntimeException("Store not found"));
|
|
|
|
storeMapper.updateStoreFromDto(storeUpdateDto, oldStore);
|
|
|
|
BeanUtils.copyProperties(storeUpdateDto, oldStore);
|
|
|
|
storeDao.save(oldStore);
|
|
|
|
storeDao.save(oldStore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public Store getOne(String id) {
|
|
|
|
public Store getOne(String id) {
|
|
|
|