XiaoRuby
2023-07-17 0042c9bee29a876a754e4d542bfba956822e7844
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.yuanchu.limslaboratory.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuanchu.limslaboratory.pojo.SerialNumber;
import com.yuanchu.limslaboratory.mapper.SerialNumberMapper;
import com.yuanchu.limslaboratory.service.SerialNumberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.limslaboratory.service.StandardsService;
import com.yuanchu.limslaboratory.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-07-11
 */
@Service
public class SerialNumberServiceImpl extends ServiceImpl<SerialNumberMapper, SerialNumber> implements SerialNumberService {
 
    @Resource
    private SerialNumberMapper serialNumberMapper;
 
    @Autowired
    private UserService userService;
 
    @Autowired
    private StandardsService standardsService;
 
    @Override
    public Integer addSerialNumberInformation(SerialNumber serialNumber) {
        Boolean userIsNull = userService.userIsNull(serialNumber.getUserId());
        if (userIsNull){
            Boolean standardsIsNull = standardsService.standardsIsNull(serialNumber.getStandardsId());
            if (!ObjectUtils.isEmpty(standardsIsNull)){
                return serialNumberMapper.insert(serialNumber);
            }
        }
        return 0;
    }
 
 
    @Override
    public List<Map<String, Object>> listSerialNumberInformation(String idOrNameOfSerialNumber, String standardsId) {
        LambdaQueryWrapper<SerialNumber> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SerialNumber::getStandardsId, standardsId);
        wrapper.like(SerialNumber::getId, idOrNameOfSerialNumber);
        wrapper.or().like(SerialNumber::getName, idOrNameOfSerialNumber);
        wrapper.select(SerialNumber::getId, SerialNumber::getName);
        return serialNumberMapper.selectMaps(wrapper);
    }
}