parent
d6ea63ec54
commit
03ecc489a4
@ -1,74 +1,74 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.storage;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.storage.StorageMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 入/出库 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StorageServiceImpl implements StorageService {
|
||||
|
||||
@Resource
|
||||
private StorageMapper storageMapper;
|
||||
|
||||
@Override
|
||||
public Long createStorage(StorageSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
StorageDO storage = BeanUtils.toBean(createReqVO, StorageDO.class);
|
||||
storageMapper.insert(storage);
|
||||
// 返回
|
||||
return storage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStorage(StorageSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStorageExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StorageDO updateObj = BeanUtils.toBean(updateReqVO, StorageDO.class);
|
||||
storageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStorage(Long id) {
|
||||
// 校验存在
|
||||
validateStorageExists(id);
|
||||
// 删除
|
||||
storageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateStorageExists(Long id) {
|
||||
if (storageMapper.selectById(id) == null) {
|
||||
throw exception(Storage_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageDO getStorage(Long id) {
|
||||
return storageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StorageDO> getStoragePage(StoragePageReqVO pageReqVO) {
|
||||
return storageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
package com.chanko.yunxi.mes.module.heli.service.storage;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.storage.StorageMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 入/出库 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StorageServiceImpl implements StorageService {
|
||||
|
||||
@Resource
|
||||
private StorageMapper storageMapper;
|
||||
|
||||
@Override
|
||||
public Long createStorage(StorageSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
StorageDO storage = BeanUtils.toBean(createReqVO, StorageDO.class);
|
||||
storageMapper.insert(storage);
|
||||
// 返回
|
||||
return storage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStorage(StorageSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStorageExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StorageDO updateObj = BeanUtils.toBean(updateReqVO, StorageDO.class);
|
||||
storageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStorage(Long id) {
|
||||
// 校验存在
|
||||
validateStorageExists(id);
|
||||
// 删除
|
||||
storageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateStorageExists(Long id) {
|
||||
if (storageMapper.selectById(id) == null) {
|
||||
throw exception(STORAGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageDO getStorage(Long id) {
|
||||
return storageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StorageDO> getStoragePage(StoragePageReqVO pageReqVO) {
|
||||
return storageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue