From 6acd97f643c5c3dc3a90a4c0f902b3c30fe9c2c0 Mon Sep 17 00:00:00 2001 From: siontion Date: Tue, 16 Jan 2024 12:31:02 +0800 Subject: [PATCH] Storage_NOT_EXISTS Storage_NOT_EXISTS --- .../service/storage/StorageServiceImpl.java | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java index 4393d948..40dd17e8 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java @@ -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 getStoragePage(StoragePageReqVO pageReqVO) { - return storageMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file +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 getStoragePage(StoragePageReqVO pageReqVO) { + return storageMapper.selectPage(pageReqVO); + } + +}