package com.iailab.module.model.mpk.service.impl; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.model.mpk.dao.MethodSettingDao; import com.iailab.module.model.mpk.dto.MethodSettingDTO; import com.iailab.module.model.mpk.entity.MethodSettingEntity; import com.iailab.module.model.mpk.service.MethodSettingService; 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.List; import java.util.UUID; /** * @description: * @author: dzd * @date: 2024/9/14 15:12 **/ @Slf4j @Service public class MethodSettingServiceImpl extends BaseServiceImpl implements MethodSettingService { @Autowired private SettingSelectService settingSelectService; @Override public void insertList(List list, String MethodId) { List entityList = ConvertUtils.sourceToTarget(list, MethodSettingEntity.class); for(int i = 0; i < entityList.size(); i++){ MethodSettingEntity entity = entityList.get(i); if (StringUtils.isNotBlank(entity.getValue())){ // 去掉空格 entity.setValue(entity.getValue().trim().replace("\\s+", "")); } entity.setId(UUID.randomUUID().toString()); entity.setMethodId(MethodId); entity.setSort(i); baseDao.insert(entity); if (!CollectionUtils.isEmpty(list.get(i).getSettingSelects())) { settingSelectService.insertList(list.get(i).getSettingSelects(), entity.getId()); } } } }