|
@@ -0,0 +1,64 @@
|
|
|
+package org.dromara.commodityManagement.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.commodityManagement.domain.Oem;
|
|
|
+import org.dromara.commodityManagement.domain.bo.OemBo;
|
|
|
+import org.dromara.commodityManagement.domain.vo.OemVo;
|
|
|
+import org.dromara.commodityManagement.mapper.OemMapper;
|
|
|
+import org.dromara.commodityManagement.service.OemService;
|
|
|
+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;
|
|
|
+
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class OemSeviceImpl implements OemService {
|
|
|
+ private final OemMapper oemMapper;
|
|
|
+ /**
|
|
|
+ * 查询花型号列表
|
|
|
+ * @param oem 花型号Bo对象
|
|
|
+ * @param pageQuery 查询条件
|
|
|
+ * @return 分页结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<OemVo> selectPageOemList(OemBo oem, PageQuery pageQuery) {
|
|
|
+ QueryWrapper<Oem> lqw =new QueryWrapper<>();
|
|
|
+ lqw.eq(StringUtils.isNotBlank(oem.getName()), "name", oem.getName());
|
|
|
+ Page<OemVo> page = oemMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public int insertOem(OemBo oemBo) {
|
|
|
+ Oem oem = MapstructUtils.convert(oemBo, Oem.class);
|
|
|
+ validEntityBeforeSave(oem);
|
|
|
+ return oemMapper.insert(oem);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public int updateOem(OemBo oemBo) {
|
|
|
+ Oem oem = MapstructUtils.convert(oemBo, Oem.class);
|
|
|
+ validEntityBeforeSave(oem);
|
|
|
+ QueryWrapper<Oem> lqw =new QueryWrapper<>();
|
|
|
+ lqw.eq("id", oem.getId());
|
|
|
+ return oemMapper.updateById(oem);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public int deleteOemById(int oemId) {
|
|
|
+ return oemMapper.deleteById(oemId);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 保存前检验
|
|
|
+ * @param entity 实体对象
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(Oem entity) {
|
|
|
+ if(!StringUtils.isNotEmpty(entity.getName())){
|
|
|
+ throw new ServiceException("名称不能为空!");
|
|
|
+ } else if (!StringUtils.isNotBlank(entity.getImage())) {
|
|
|
+ throw new ServiceException("图片不能为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|