/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.sxkj.gd.workorder.wrapper; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.utils.BeanUtil; import org.sxkj.gd.workorder.dto.GdTaskResultDTO; import org.sxkj.gd.workorder.entity.GdTaskResultEntity; import org.sxkj.gd.workorder.vo.GdTaskResultVO; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * 成果表 包装类,返回视图层所需的字段 * * @author lw * @since 2026-01-14 */ public class GdTaskResultWrapper extends BaseEntityWrapper { public static GdTaskResultWrapper build() { return new GdTaskResultWrapper(); } @Override public GdTaskResultVO entityVO(GdTaskResultEntity gdTaskResult) { return Objects.requireNonNull(BeanUtil.copy(gdTaskResult, GdTaskResultVO.class)); } /** * 将DTO列表转换为Entity列表 * * @param gdTaskResultDTOList DTO列表 * @return Entity列表 */ public List listEntity(List gdTaskResultDTOList) { return gdTaskResultDTOList.stream() .map(this::convertDtoToEntity) .collect(Collectors.toList()); } /** * 将单个DTO转换为Entity * * @param dto DTO对象 * @return Entity对象 */ private GdTaskResultEntity convertDtoToEntity(GdTaskResultDTO dto) { GdTaskResultEntity entity = BeanUtil.copy(dto, GdTaskResultEntity.class); if (dto.getAttachmentType() != null) { entity.setAttachmentType(dto.getAttachmentType()); } else if (dto.getDateType() != null) { entity.setAttachmentType(dto.getDateType()); } return entity; } /** * 将文件类型字符串转换为附件类型编码 * * @param fileType 文件类型字符串(图片/视频/照片) * @return 附件类型编码:0-图片,1-视频,2-其他 */ private Integer convertFileTypeToAttachmentType(String fileType) { if (fileType == null) { return 2; } switch (fileType.trim()) { case "图片": case "照片": return 0; case "视频": return 1; default: return 2; } } }