潘志宝
2024-09-09 bbc1eeba9c29032add5175f2739782fd204de715
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
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.StScheduleModelSettingDao;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
import com.iailab.module.model.mcs.sche.vo.StScheduleModelSettingSaveReqVO;
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 StScheduleModelSettingServiceImpl extends BaseServiceImpl<StScheduleModelSettingDao, StScheduleModelSettingEntity>
        implements StScheduleModelSettingService {
 
    @Override
    public List<StScheduleModelSettingEntity> getByModelId(String modelId) {
        return baseDao.selectList(
                new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
                        .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
                        .orderByAsc(StScheduleModelSettingEntity::getSort)
        );
    }
 
    @Override
    public void deleteByModelId(String modelId) {
        baseDao.delete(new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
                .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
        );
    }
 
    @Override
    public void saveList(String modelId, List<StScheduleModelSettingSaveReqVO> saveList) {
        deleteByModelId(modelId);
        if (CollectionUtils.isEmpty(saveList)) {
            return;
        }
        saveList.forEach(item -> {
            StScheduleModelSettingEntity entity = BeanUtils.toBean(item, StScheduleModelSettingEntity.class);
            entity.setId(UUID.randomUUID().toString());
            baseDao.insert(entity);
        });
    }
}