提交 | 用户 | 时间
|
3e61b6
|
1 |
package com.iailab.module.model.matlab.service.impl; |
D |
2 |
|
|
3 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
4 |
import com.iailab.framework.common.util.object.ConvertUtils; |
|
5 |
import com.iailab.module.model.matlab.dao.MlModelMethodDao; |
|
6 |
import com.iailab.module.model.matlab.dto.MlModelMethodDTO; |
|
7 |
import com.iailab.module.model.matlab.entity.MlModelMethodEntity; |
|
8 |
import com.iailab.module.model.matlab.entity.MlModelMethodSettingEntity; |
|
9 |
import com.iailab.module.model.matlab.service.MlModelMethodService; |
|
10 |
import com.iailab.module.model.matlab.service.MlModelMethodSettingService; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.stereotype.Service; |
|
13 |
import org.springframework.util.CollectionUtils; |
|
14 |
|
|
15 |
import java.util.*; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* |
|
20 |
* @author Dzd |
|
21 |
* @since 1.0.0 2025-02-08 |
|
22 |
*/ |
|
23 |
@Service |
|
24 |
public class MlModelMethodServiceImpl extends BaseServiceImpl<MlModelMethodDao, MlModelMethodEntity> implements MlModelMethodService { |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private MlModelMethodSettingService mlModelMethodSettingService; |
|
28 |
@Override |
|
29 |
public void insertList(List<MlModelMethodDTO> list, String modelId) { |
|
30 |
List<MlModelMethodEntity> methodEntities = new ArrayList<>(); |
|
31 |
List<MlModelMethodSettingEntity> settingEntities = new ArrayList<>(); |
|
32 |
for (int i = 0; i < list.size(); i++) { |
|
33 |
MlModelMethodEntity entity = ConvertUtils.sourceToTarget(list.get(i), MlModelMethodEntity.class); |
|
34 |
String methodId = UUID.randomUUID().toString(); |
|
35 |
entity.setId(methodId); |
|
36 |
entity.setMlModelId(modelId); |
|
37 |
entity.setSort(i); |
|
38 |
methodEntities.add(entity); |
|
39 |
if (!CollectionUtils.isEmpty(list.get(i).getMethodSettings())) { |
|
40 |
List<MlModelMethodSettingEntity> settingEntityList = ConvertUtils.sourceToTarget(list.get(i).getMethodSettings(), MlModelMethodSettingEntity.class); |
|
41 |
for (int j = 0; j < settingEntityList.size(); j++) { |
|
42 |
MlModelMethodSettingEntity mlModelMethodSettingEntity = settingEntityList.get(j); |
|
43 |
mlModelMethodSettingEntity.setId(UUID.randomUUID().toString()); |
|
44 |
mlModelMethodSettingEntity.setMlModelMethodId(methodId); |
|
45 |
mlModelMethodSettingEntity.setSort(j); |
|
46 |
settingEntities.add(mlModelMethodSettingEntity); |
|
47 |
} |
|
48 |
} |
|
49 |
} |
|
50 |
baseDao.insert(methodEntities); |
|
51 |
mlModelMethodSettingService.insertList(settingEntities); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void deleteModelMethod(String modelId) { |
|
56 |
Map<String,Object> map = new HashMap<>(); |
|
57 |
map.put("ml_model_id", modelId); |
|
58 |
baseDao.deleteByMap(map); |
|
59 |
} |
|
60 |
} |