潘志宝
2024-12-03 51c1c2c9fa28fb1765dd6e81c70b78566792aebe
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
package com.iailab.module.model.mcs.sche.service.impl;
 
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.module.model.mcs.sche.dao.StScheduleModelParamDao;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
import com.iailab.module.model.mcs.sche.vo.StScheduleModelParamSaveReqVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
import java.util.UUID;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月06日
 */
@Service
public class StScheduleModelParamServiceImpl extends BaseServiceImpl<StScheduleModelParamDao, StScheduleModelParamEntity>
        implements StScheduleModelParamService {
 
    @Override
    public List<StScheduleModelParamEntity> getByModelId(String modelId) {
        return baseDao.selectList(
                new LambdaQueryWrapperX<StScheduleModelParamEntity>()
                        .likeIfPresent(StScheduleModelParamEntity::getModelid, modelId)
                        .orderByAsc(StScheduleModelParamEntity::getModelparamportorder)
                        .orderByAsc(StScheduleModelParamEntity::getModelparamorder)
        );
    }
 
    @Override
    public void deleteByModelId(String modelId) {
        baseDao.delete(new LambdaQueryWrapperX<StScheduleModelParamEntity>()
                .likeIfPresent(StScheduleModelParamEntity::getModelid, modelId)
        );
    }
 
    @Override
    public void saveList(String modelId, List<StScheduleModelParamSaveReqVO> saveList) {
        deleteByModelId(modelId);
        if (CollectionUtils.isEmpty(saveList)) {
            return;
        }
        saveList.forEach(item -> {
            StScheduleModelParamEntity entity = BeanUtils.toBean(item, StScheduleModelParamEntity.class);
            entity.setId(UUID.randomUUID().toString());
            entity.setModelid(modelId);
            baseDao.insert(entity);
        });
    }
}