diff --git a/src/main/java/com/gaotao/modules/manufacturer/controller/ManufacturerInformationController.java b/src/main/java/com/gaotao/modules/manufacturer/controller/ManufacturerInformationController.java index d946ffd..16c24ae 100644 --- a/src/main/java/com/gaotao/modules/manufacturer/controller/ManufacturerInformationController.java +++ b/src/main/java/com/gaotao/modules/manufacturer/controller/ManufacturerInformationController.java @@ -7,6 +7,8 @@ import com.gaotao.modules.manufacturer.service.ManufacturerInformationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RestController @RequestMapping("manufacturerInformation") public class ManufacturerInformationController { @@ -22,7 +24,6 @@ public class ManufacturerInformationController { * @return: com.gaotao.common.utils.R **/ @PostMapping(value="/manufacturerInformationSearch") - @ResponseBody public R manufacturerInformationSearch(@RequestBody ManufacturerInformationData data) { PageUtils page = manufacturerInformationService.manufacturerInformationSearch(data); return R.ok().put("page", page); @@ -37,7 +38,6 @@ public class ManufacturerInformationController { * @return: com.gaotao.common.utils.R **/ @PostMapping(value="/manufacturerInformationSave") - @ResponseBody public R manufacturerInformationSave(@RequestBody ManufacturerInformationData data){ manufacturerInformationService.manufacturerInformationSave(data); return R.ok(); @@ -51,7 +51,6 @@ public class ManufacturerInformationController { * @return: com.gaotao.common.utils.R **/ @PostMapping(value="/manufacturerInformationEdit") - @ResponseBody public R manufacturerInformationEdit(@RequestBody ManufacturerInformationData data){ manufacturerInformationService.manufacturerInformationEdit(data); return R.ok(); @@ -65,12 +64,17 @@ public class ManufacturerInformationController { * @return: com.gaotao.common.utils.R **/ @PostMapping(value="/manufacturerInformationDelete") - @ResponseBody public R manufacturerInformationDelete(@RequestBody ManufacturerInformationData data){ manufacturerInformationService.manufacturerInformationDelete(data); return R.ok(); } + + @PostMapping + public R queryManufacturerInformation(@RequestBody ManufacturerInformationData data){ + List list = manufacturerInformationService.queryManufacturerInformation(data); + return R.ok().put("rows",list); + } } diff --git a/src/main/java/com/gaotao/modules/manufacturer/service/ManufacturerInformationService.java b/src/main/java/com/gaotao/modules/manufacturer/service/ManufacturerInformationService.java index 72fabee..7c7f492 100644 --- a/src/main/java/com/gaotao/modules/manufacturer/service/ManufacturerInformationService.java +++ b/src/main/java/com/gaotao/modules/manufacturer/service/ManufacturerInformationService.java @@ -1,10 +1,13 @@ package com.gaotao.modules.manufacturer.service; +import com.baomidou.mybatisplus.extension.service.IService; import com.gaotao.common.utils.PageUtils; import com.gaotao.modules.manufacturer.data.ManufacturerInformationData; -public interface ManufacturerInformationService { +import java.util.List; + +public interface ManufacturerInformationService extends IService { PageUtils manufacturerInformationSearch(ManufacturerInformationData data); @@ -13,4 +16,6 @@ public interface ManufacturerInformationService { void manufacturerInformationEdit(ManufacturerInformationData data); void manufacturerInformationDelete(ManufacturerInformationData data); + + List queryManufacturerInformation(ManufacturerInformationData data); } diff --git a/src/main/java/com/gaotao/modules/manufacturer/service/impl/ManufacturerInformationServiceImpl.java b/src/main/java/com/gaotao/modules/manufacturer/service/impl/ManufacturerInformationServiceImpl.java index b4616ae..2eca0d3 100644 --- a/src/main/java/com/gaotao/modules/manufacturer/service/impl/ManufacturerInformationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/manufacturer/service/impl/ManufacturerInformationServiceImpl.java @@ -10,63 +10,73 @@ import com.gaotao.modules.manufacturer.mapper.ManufacturerInformationMapper; import com.gaotao.modules.manufacturer.service.ManufacturerInformationService; import com.gaotao.modules.part.entity.ExternalPartManufacturer; import com.gaotao.modules.part.mapper.ExternalPartManufacturerMapper; +import com.gaotao.modules.part.service.ExternalPartManufacturerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.List; @Service public class ManufacturerInformationServiceImpl extends ServiceImpl implements ManufacturerInformationService { @Autowired - private ManufacturerInformationMapper manufacturerInformationMapper; - - @Autowired - private ExternalPartManufacturerMapper externalPartManufacturerMapper; + private ExternalPartManufacturerService externalPartManufacturerService; @Override public PageUtils manufacturerInformationSearch(ManufacturerInformationData data) { - IPage resultList = this.manufacturerInformationMapper.manufacturerInformationSearch(new Page(data.getPage(), data.getLimit()), data); + IPage resultList = baseMapper.manufacturerInformationSearch(new Page(data.getPage(), data.getLimit()), data); return new PageUtils(resultList); } @Override public void manufacturerInformationSave(ManufacturerInformationData data) { // 校验 - HashMap map = new HashMap<>(); - map.put("site", data.getSite()); - map.put("manufacturer_no", data.getManufacturerNo()); - int count = manufacturerInformationMapper.selectByMap(map).size(); + Integer count = lambdaQuery() + .eq(ManufacturerInformationData::getSite, data.getSite()) + .eq(ManufacturerInformationData::getManufacturerNo, data.getManufacturerNo()).count(); if (count > 0) { throw new RuntimeException("The manufacturer no already exists!"); } data.setCreateDate(new Date()); - manufacturerInformationMapper.insert(data); + baseMapper.insert(data); } @Override public void manufacturerInformationEdit(ManufacturerInformationData data) { // 校验 是否存在相同数据并根据id排除自己 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("site", data.getSite()).eq("manufacturer_no", data.getManufacturerNo()).ne("id", data.getId()); - int count = manufacturerInformationMapper.selectCount(queryWrapper); + Integer count = lambdaQuery() + .eq(ManufacturerInformationData::getSite, data.getSite()) + .eq(ManufacturerInformationData::getManufacturerNo, data.getManufacturerNo()) + .ne(ManufacturerInformationData::getManufacturerNo, data.getManufacturerNo()) + .count(); if (count > 0) { throw new RuntimeException("The manufacturer no already exists!"); } data.setUpdateDate(new Date()); - manufacturerInformationMapper.updateById(data); + baseMapper.updateById(data); } @Override public void manufacturerInformationDelete(ManufacturerInformationData data) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("site", data.getSite()).eq("manufacturer_no", data.getManufacturerNo()); - Integer count = externalPartManufacturerMapper.selectCount(queryWrapper); + Integer count = externalPartManufacturerService.lambdaQuery() + .eq(ExternalPartManufacturer::getSite, data.getSite()) + .eq(ExternalPartManufacturer::getManufacturerNo, data.getManufacturerNo()) + .count(); if (count > 0) { throw new RuntimeException("This manufacturer has been referenced and cannot be removed!"); } - manufacturerInformationMapper.deleteById(data); + baseMapper.deleteById(data); + } + + @Override + public List queryManufacturerInformation(ManufacturerInformationData data) { + return lambdaQuery() + .eq(ManufacturerInformationData::getSite, data.getSite()) + .eq(ManufacturerInformationData::getManufacturerNo, data.getManufacturerNo()) + .list(); } }