|
@@ -0,0 +1,71 @@
|
|
|
+package org.dromara.InventoryManagement.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.InventoryManagement.domain.Supplier;
|
|
|
+import org.dromara.InventoryManagement.domain.bo.SupplierBo;
|
|
|
+import org.dromara.InventoryManagement.domain.vo.SupplierVo;
|
|
|
+import org.dromara.InventoryManagement.mapper.SupplierMapper;
|
|
|
+import org.dromara.InventoryManagement.service.SupplierService;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.OrderNumberGenerator;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class SupplierServiceImpl implements SupplierService {
|
|
|
+
|
|
|
+ private final SupplierMapper supplierMapper;
|
|
|
+ private final OrderNumberGenerator generator = OrderNumberGenerator.getInstance();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询供应商
|
|
|
+ * @param supplierBo 供应商BO对象
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 分页结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<SupplierVo> selectPageSupplierList(SupplierBo supplierBo, PageQuery pageQuery) {
|
|
|
+ QueryWrapper<Supplier> qw = new QueryWrapper<>();
|
|
|
+ qw.like(StringUtils.isNotBlank(supplierBo.getCode()),"code", supplierBo.getCode());
|
|
|
+ Page<SupplierVo> page = supplierMapper.selectVoPage(pageQuery.build(), qw);
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增供应商
|
|
|
+ * @param supplierBo 供应商BO对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertSupplier(SupplierBo supplierBo) {
|
|
|
+ supplierBo.setCode(generator.generateOrderNumber("SP"));
|
|
|
+ return supplierMapper.insert(MapstructUtils.convert(supplierBo, Supplier.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改供应商
|
|
|
+ * @param supplierBo 供应商BO对象
|
|
|
+ * @return 影响行数
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateSupplier(SupplierBo supplierBo) {
|
|
|
+ return supplierMapper.updateById(MapstructUtils.convert(supplierBo, Supplier.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除供应商
|
|
|
+ * @param supplierIds 供应商ID
|
|
|
+ * @return 影响行数
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteSupplierById(Long[] supplierIds) {
|
|
|
+ return supplierMapper.deleteByIds(Arrays.asList(supplierIds));
|
|
|
+ }
|
|
|
+}
|