From 064457406bda554e713aea8bada1bb066be42b8e Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期六, 23 九月 2023 12:39:29 +0800
Subject: [PATCH] 9-23 去鵷雏管理端验证

---
 standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java
index 98351a8..763408e 100644
--- a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java
+++ b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java
@@ -1,5 +1,6 @@
 package com.yuanchu.limslaboratory.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yuanchu.limslaboratory.mapper.MaterialMapper;
 import com.yuanchu.limslaboratory.mapper.ProductModelMapper;
@@ -27,13 +28,11 @@
     @Resource
     ProductModelMapper productModelMapper;
 
-    @Resource
-    MaterialMapper materialMapper;
 
     //閫夋嫨鏍峰搧
     @Override
     public List<String> selectmater() {
-        return materialMapper.selectmater();
+        return productModelMapper.selectmater();
     }
 
     //娣诲姞鏍囧噯-->閫夋嫨椤圭洰鍒嗙粍
@@ -45,19 +44,24 @@
     //娣诲姞鏍囧噯
     @Override
     public void addproductModel(ProductModelDto productModelDto) {
-        ProductModel productModel = new ProductModel();
-        BeanUtils.copyProperties(productModelDto,productModel);
-        productModelMapper.insert(productModel);
-        //娣诲姞鐗╂枡浜у搧搴�
-        Material material = new Material();
-        material.setName(productModelDto.getName()).setCode(MyUtil.getTimeSixNumberCode("CP","CP"));
-        materialMapper.insert(material);
+        if (ObjectUtils.isEmpty(productModelDto.getFather())) {
+            ProductModel productModel = ProductModel.builder()
+                    .name(productModelDto.getName())
+                    .material(productModelDto.getMaterial())
+                    .unit(productModelDto.getUnit())
+                    .build();
+            productModelMapper.insert(productModel);
+        } else {
+            ProductModel productModel = new ProductModel();
+            BeanUtils.copyProperties(productModelDto, productModel);
+            productModelMapper.insert(productModel);
+        }
     }
 
     //鏌ヨ鏍囧噯妯$増鍒楄〃
     @Override
     public List<Map<String, Object>> selectproductModel(String name, String father, String material) {
-        return productModelMapper.selectproductModel(name,father,material);
+        return productModelMapper.selectproductModel(name, father, material);
     }
 
     //鏍规嵁id鏌ヨ璇︽儏
@@ -65,7 +69,7 @@
     public ProductModelDto selectproductModelById(Integer id) {
         ProductModel productModel = productModelMapper.selectById(id);
         ProductModelDto productModelDto = new ProductModelDto();
-        BeanUtils.copyProperties(productModel,productModelDto);
+        BeanUtils.copyProperties(productModel, productModelDto);
         return productModelDto;
     }
 
@@ -73,7 +77,7 @@
     @Override
     public void writeproductModel(Integer id, ProductModelDto productModelDto) {
         ProductModel productModel = new ProductModel();
-        BeanUtils.copyProperties(productModelDto,productModel);
+        BeanUtils.copyProperties(productModelDto, productModel);
         productModel.setId(id);
         productModelMapper.updateById(productModel);
     }

--
Gitblit v1.9.3