|
@@ -0,0 +1,90 @@
|
|
|
+package org.dromara.commodityManagement.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.commodityManagement.domain.Craft;
|
|
|
+import org.dromara.commodityManagement.domain.bo.CraftBo;
|
|
|
+import org.dromara.commodityManagement.domain.vo.CraftVo;
|
|
|
+import org.dromara.commodityManagement.mapper.CraftMapper;
|
|
|
+import org.dromara.commodityManagement.service.CraftService;
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class CraftServiceImpl implements CraftService {
|
|
|
+ private final CraftMapper craftMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询工艺对象分页查询工艺数据
|
|
|
+ *
|
|
|
+ * @param craftBo 工艺Bo对象
|
|
|
+ * @param pageQuery 查询条件
|
|
|
+ * @return 分页结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<CraftVo> selectPageCraftList(CraftBo craftBo, PageQuery pageQuery) {
|
|
|
+ QueryWrapper<Craft> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(craftBo.getGoodsTypeExtendName()), "goods_type_extend_name", craftBo.getGoodsTypeExtendName());
|
|
|
+ Page<CraftVo> page = craftMapper.selectVoPage(pageQuery.build(), queryWrapper);
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增工艺
|
|
|
+ *
|
|
|
+ * @param craftBo CraftBo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertCraft(CraftBo craftBo) {
|
|
|
+ Craft craft = MapstructUtils.convert(craftBo, Craft.class);
|
|
|
+ validEntityBeforeSave(craft);
|
|
|
+ return craftMapper.insert(craft);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改工艺
|
|
|
+ *
|
|
|
+ * @param craftBo CraftBo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateCraft(CraftBo craftBo) {
|
|
|
+ Craft craft = MapstructUtils.convert(craftBo, Craft.class);
|
|
|
+ validEntityBeforeSave(craft);
|
|
|
+ QueryWrapper<Craft> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("id", craft.getId());
|
|
|
+ return craftMapper.updateById(craft);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除工艺
|
|
|
+ *
|
|
|
+ * @param craftIds CraftIds
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteCraftByIds(Long[] craftIds) {
|
|
|
+ return craftMapper.deleteByIds(Arrays.asList(craftIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前检验
|
|
|
+ *
|
|
|
+ * @param entity 实体对象
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(Craft entity) {
|
|
|
+ if (!StringUtils.isNotEmpty(entity.getGoodsTypeExtendName())) {
|
|
|
+ throw new ServiceException("名称不能为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|