buhuazhen
4 天以前 b36dfcb807af748dabdbc76a134b0667196563f6
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
package com.ruoyi.projectManagement.service.impl.handle;
 
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.projectManagement.dto.ContractInfoDto;
import com.ruoyi.projectManagement.mapper.ContractInfoMapper;
import com.ruoyi.projectManagement.pojo.ContractInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
 
/**
 * @author buhuazhen
 * @date 2026/3/9
 * @email 3038525872@qq.com
 */
@Component
@Transactional(rollbackFor = Exception.class,readOnly = true)
public class ContractInfoHandleService{
 
    @Autowired
    private ContractInfoMapper contractInfoMapper;
 
    @Transactional(rollbackFor = Exception.class)
    public void save(@Nullable Long id, @NotNull ContractInfoDto contractInfoDto) {
        ContractInfo contractInfo = BeanUtil.copyProperties(contractInfoDto, ContractInfo.class);
        contractInfo.setProjectManagementInfoId(id);
        if (contractInfoDto.getId() == null) {
            contractInfoMapper.insert(contractInfo);
        } else {
            contractInfoMapper.updateById(contractInfo);
        }
    }
 
    public ContractInfoDto getByInfoId(@NotNull Long id) {
        LambdaQueryWrapper<ContractInfo> queryWrapper = new LambdaQueryWrapper<ContractInfo>();
        queryWrapper.eq(ContractInfo::getProjectManagementInfoId, id);
        queryWrapper.eq(ContractInfo::getIsDelete, 0);
        queryWrapper.last("limit 1");
        ContractInfo contractInfo = contractInfoMapper.selectOne(queryWrapper);
        return BeanUtil.copyProperties(contractInfo, ContractInfoDto.class);
    }
 
}