liding
2 天以前 388bd216d4eb70b367ada95118d1087b45f07ae3
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
62
63
64
65
66
67
68
package com.ruoyi.basic.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.CoalPlanDto;
import com.ruoyi.basic.entity.CoalPlan;
import com.ruoyi.basic.mapper.CoalPlanMapper;
import com.ruoyi.basic.service.CoalPlanService;
import com.ruoyi.common.utils.bean.BeanUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Objects;
 
/**
 * <p>
 * 煤质信息表,记录煤炭质量检测相关数据 服务实现类
 * </p>
 *
 * @author ruoyi
 * @since 2025-06-09
 */
@Service
@RequiredArgsConstructor
public class CoalPlanServiceImpl extends ServiceImpl<CoalPlanMapper, CoalPlan> implements CoalPlanService {
 
    private final CoalPlanMapper coalPlanMapper;
 
    @Override
    public IPage<CoalPlan> selectCoalFieldList(Page page, CoalPlanDto coalPlanDto) {
        LambdaQueryWrapper<CoalPlan> queryWrapper = new LambdaQueryWrapper<>();
        return coalPlanMapper.selectPage(page,queryWrapper);
    }
 
    @Override
    public int addOrEditCoalPlan(CoalPlanDto coalPlanDto) {
        CoalPlan coalPlan = new CoalPlan();
        BeanUtils.copyProperties(coalPlanDto, coalPlan);
        if (Objects.isNull(coalPlanDto.getId())) {
            return coalPlanMapper.insert(coalPlan);
        } else {
            return coalPlanMapper.updateById(coalPlan);
        }
    }
 
    @Override
    public int delCoalPlanByIds(Long[] ids) {
        // 检查参数
        if (ids == null || ids.length == 0) {
            return 0;
        }
        // 构造更新条件
        UpdateWrapper<CoalPlan> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", ids)
                .set("deleted", 1);  // 设置 deleted 为 1 表示已删除
        // 执行批量逻辑删除
        return coalPlanMapper.update(null, updateWrapper);
    }
 
    @Override
    public List<CoalPlan> selectAllList() {
        return coalPlanMapper.selectList(null);
    }
}