package com.iailab.module.model.mpk.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.model.mpk.dao.ModelMethodDao; import com.iailab.module.model.mpk.dto.ModelMethodDTO; import com.iailab.module.model.mpk.entity.ModelMethodEntity; import com.iailab.module.model.mpk.service.MethodSettingService; import com.iailab.module.model.mpk.service.ModelMethodService; import com.iailab.module.model.mpk.service.SettingSelectService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; /** * @description: * @author: dzd * @date: 2024/9/9 10:51 **/ @Slf4j @Service public class ModelMethodServiceImpl extends BaseServiceImpl implements ModelMethodService { @Autowired private MethodSettingService methodSettingService; @Override public void deleteByMap(Map map) { baseDao.delete(getWrapper(map)); } private QueryWrapper getWrapper(Map params) { String mpkFileId = (String) params.get("mpkFileId"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(mpkFileId), "mpk_file_id", mpkFileId); return wrapper; } @Override public void insertList(List list, String fileId) { for (int i = 0; i < list.size(); i++) { ModelMethodEntity entity = ConvertUtils.sourceToTarget(list.get(i), ModelMethodEntity.class); entity.setId(UUID.randomUUID().toString()); entity.setMpkFileId(fileId); entity.setSort(i); baseDao.insert(entity); if (!CollectionUtils.isEmpty(list.get(i).getMethodSettings())) { methodSettingService.insertList(list.get(i).getMethodSettings(), entity.getId()); } } } @Override public void deleteModelMethod(String mpkId) { Map map = new HashMap<>(); map.put("mpk_file_id", mpkId); baseDao.deleteByMap(map); } }