|
@ -35,11 +35,11 @@ import com.epmet.entity.IcExportTemplateEntity; |
|
|
import com.epmet.service.IcExportTemplateConfigService; |
|
|
import com.epmet.service.IcExportTemplateConfigService; |
|
|
import com.epmet.service.IcExportTemplateService; |
|
|
import com.epmet.service.IcExportTemplateService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -177,9 +177,19 @@ public class IcExportTemplateServiceImpl extends BaseServiceImpl<IcExportTemplat |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void delete(String[] ids) { |
|
|
public void delete(String userId, String[] ids) { |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
List<String> idList = Arrays.asList(ids); |
|
|
|
|
|
idList.forEach(id -> { |
|
|
|
|
|
IcExportTemplateEntity entity = baseDao.selectById(id); |
|
|
|
|
|
if (!userId.equals(entity.getCreatedBy())) { |
|
|
|
|
|
throw new EpmetException("只能删除自己创建的模板"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
baseDao.deleteBatchIds(idList); |
|
|
|
|
|
idList.forEach(id -> { |
|
|
|
|
|
icExportTemplateConfigService.deleteByTempId(id); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -250,7 +260,21 @@ public class IcExportTemplateServiceImpl extends BaseServiceImpl<IcExportTemplat |
|
|
wrapper.eq(IcExportTemplateEntity::getFormCode, formDTO.getFormCode()); |
|
|
wrapper.eq(IcExportTemplateEntity::getFormCode, formDTO.getFormCode()); |
|
|
wrapper.orderByAsc(IcExportTemplateEntity::getSort); |
|
|
wrapper.orderByAsc(IcExportTemplateEntity::getSort); |
|
|
List<IcExportTemplateEntity> list = baseDao.selectList(wrapper); |
|
|
List<IcExportTemplateEntity> list = baseDao.selectList(wrapper); |
|
|
return ConvertUtils.sourceToTarget(list, IcExportTemplateDTO.class); |
|
|
List<IcExportTemplateDTO> result = new ArrayList<>(); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
|
result = list.stream().map(item -> { |
|
|
|
|
|
IcExportTemplateDTO dto = new IcExportTemplateDTO(); |
|
|
|
|
|
dto.setId(item.getId()); |
|
|
|
|
|
dto.setName(item.getName()); |
|
|
|
|
|
if (tokenDto.getUserId().equals(item.getCreatedBy())) { |
|
|
|
|
|
dto.setIsSelf(NumConstant.ONE); |
|
|
|
|
|
} else { |
|
|
|
|
|
dto.setIsSelf(NumConstant.ZERO); |
|
|
|
|
|
} |
|
|
|
|
|
return dto; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|