package com.yuanchu.limslaboratory.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yuanchu.limslaboratory.pojo.Classify;
import com.yuanchu.limslaboratory.mapper.ClassifyMapper;
import com.yuanchu.limslaboratory.service.ClassifyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
*
* 服务实现类
*
*
* @author 江苏鵷雏网络科技有限公司
* @since 2023-07-20
*/
@Service
public class ClassifyServiceImpl extends ServiceImpl implements ClassifyService {
@Resource
private ClassifyMapper classifyMapper;
@Override
public Integer addClassifyInformation(Classify classify) {
if (ObjectUtils.isEmpty(classify.getFatherName())){
classify.setFatherName(classify.getSonName());
classify.setSonName(null);
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Classify::getFatherName, classify.getFatherName());
wrapper.isNull(Classify::getSonName);
wrapper.eq(Classify::getState, 1);
Classify classify1 = classifyMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(classify1)){
return classifyMapper.insert(classify);
}
return 2;
}
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Classify::getFatherName, classify.getFatherName());
wrapper.eq(Classify::getSonName, classify.getSonName());
wrapper.eq(Classify::getState, 1);
Classify classify1 = classifyMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(classify1)){
return classifyMapper.insert(classify);
} else {
return 3;
}
}
@Override
public List