郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
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
package com.gk.firework.Service.ServiceImpl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.firework.Domain.ContractFile;
import com.gk.firework.Domain.Exception.BusinessException;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Mapper.ContractFileMapper;
import com.gk.firework.Service.ContractFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service("contractFileService")
public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, ContractFile> implements ContractFileService {
 
    @Autowired
    private ContractFileMapper contractFileMapper;
 
    @Override
    public ContractFile selectByOrderCode(String ordercode) {
        if (StringUtils.isBlank(ordercode)) {
            throw new BusinessException("单号出现问题");
        }
        LambdaQueryWrapper<ContractFile> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ContractFile::getValidflag, true).eq(ContractFile::getOrdercode,ordercode);
        return contractFileMapper.selectOne(queryWrapper) ;
    }
 
    @Override
    public void deleteAll(String ordercode) {
        if (StringUtils.isBlank(ordercode)) {
            throw new BusinessException("单号出现问题");
        }
        LambdaUpdateWrapper<ContractFile> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(ContractFile::getValidflag, false)
                .eq(ContractFile::getOrdercode, ordercode);
        this.update(updateWrapper);
    }
}