Browse Source

20241122

print/logistic/save
qiezi 1 year ago
parent
commit
663f2e9342
  1. 12
      src/main/java/com/gaotao/modules/manufacturer/controller/ManufacturerInformationController.java
  2. 7
      src/main/java/com/gaotao/modules/manufacturer/service/ManufacturerInformationService.java
  3. 46
      src/main/java/com/gaotao/modules/manufacturer/service/impl/ManufacturerInformationServiceImpl.java

12
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<ManufacturerInformationData> list = manufacturerInformationService.queryManufacturerInformation(data);
return R.ok().put("rows",list);
}
}

7
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<ManufacturerInformationData> {
PageUtils manufacturerInformationSearch(ManufacturerInformationData data);
@ -13,4 +16,6 @@ public interface ManufacturerInformationService {
void manufacturerInformationEdit(ManufacturerInformationData data);
void manufacturerInformationDelete(ManufacturerInformationData data);
List<ManufacturerInformationData> queryManufacturerInformation(ManufacturerInformationData data);
}

46
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<ManufacturerInformationMapper, ManufacturerInformationData> implements ManufacturerInformationService {
@Autowired
private ManufacturerInformationMapper manufacturerInformationMapper;
@Autowired
private ExternalPartManufacturerMapper externalPartManufacturerMapper;
private ExternalPartManufacturerService externalPartManufacturerService;
@Override
public PageUtils manufacturerInformationSearch(ManufacturerInformationData data) {
IPage<ManufacturerInformationData> resultList = this.manufacturerInformationMapper.manufacturerInformationSearch(new Page<ManufacturerInformationData>(data.getPage(), data.getLimit()), data);
IPage<ManufacturerInformationData> resultList = baseMapper.manufacturerInformationSearch(new Page<ManufacturerInformationData>(data.getPage(), data.getLimit()), data);
return new PageUtils(resultList);
}
@Override
public void manufacturerInformationSave(ManufacturerInformationData data) {
// 校验
HashMap<String, Object> 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<ManufacturerInformationData> 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<ExternalPartManufacturer> 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<ManufacturerInformationData> queryManufacturerInformation(ManufacturerInformationData data) {
return lambdaQuery()
.eq(ManufacturerInformationData::getSite, data.getSite())
.eq(ManufacturerInformationData::getManufacturerNo, data.getManufacturerNo())
.list();
}
}
Loading…
Cancel
Save