潘志宝
2024-09-09 9cfbabe0cbe096cfd1343d5bd6540bc47e01836a
提交 | 用户 | 时间
bbc1ee 1 package com.iailab.module.model.mcs.sche.service.impl;
2
3 import com.iailab.framework.common.service.impl.BaseServiceImpl;
4 import com.iailab.framework.common.util.object.BeanUtils;
5 import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import com.iailab.module.model.mcs.sche.dao.StScheduleModelSettingDao;
7 import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity;
8 import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
9 import com.iailab.module.model.mcs.sche.vo.StScheduleModelSettingSaveReqVO;
10 import org.springframework.stereotype.Service;
11 import org.springframework.util.CollectionUtils;
12
13 import java.util.List;
14 import java.util.UUID;
15
16 /**
17  * @author PanZhibao
18  * @Description
19  * @createTime 2024年09月06日
20  */
21 @Service
22 public class StScheduleModelSettingServiceImpl extends BaseServiceImpl<StScheduleModelSettingDao, StScheduleModelSettingEntity>
23         implements StScheduleModelSettingService {
24
25     @Override
26     public List<StScheduleModelSettingEntity> getByModelId(String modelId) {
27         return baseDao.selectList(
28                 new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
29                         .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
30                         .orderByAsc(StScheduleModelSettingEntity::getSort)
31         );
32     }
33
34     @Override
35     public void deleteByModelId(String modelId) {
36         baseDao.delete(new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
37                 .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
38         );
39     }
40
41     @Override
42     public void saveList(String modelId, List<StScheduleModelSettingSaveReqVO> saveList) {
43         deleteByModelId(modelId);
44         if (CollectionUtils.isEmpty(saveList)) {
45             return;
46         }
47         saveList.forEach(item -> {
48             StScheduleModelSettingEntity entity = BeanUtils.toBean(item, StScheduleModelSettingEntity.class);
49             entity.setId(UUID.randomUUID().toString());
50             baseDao.insert(entity);
51         });
52     }
53 }