|
@@ -7,6 +7,7 @@ import com.museum.common.constant.TypeCode;
|
|
import com.museum.common.util.Result;
|
|
import com.museum.common.util.Result;
|
|
import com.museum.domain.entity.PartEntity;
|
|
import com.museum.domain.entity.PartEntity;
|
|
import com.museum.domain.entity.FileEntity;
|
|
import com.museum.domain.entity.FileEntity;
|
|
|
|
+import com.museum.domain.entity.TypeEntity;
|
|
import com.museum.domain.request.NavRequest;
|
|
import com.museum.domain.request.NavRequest;
|
|
import com.museum.domain.request.PartRequest;
|
|
import com.museum.domain.request.PartRequest;
|
|
import com.museum.domain.response.PartResponse;
|
|
import com.museum.domain.response.PartResponse;
|
|
@@ -17,7 +18,6 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -65,6 +66,9 @@ public class PartController extends BaseController {
|
|
if (id == null) {
|
|
if (id == null) {
|
|
entity = new PartEntity();
|
|
entity = new PartEntity();
|
|
BeanUtils.copyProperties(param, entity);
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
partService.save(entity);
|
|
partService.save(entity);
|
|
|
|
|
|
|
|
|
|
@@ -90,26 +94,33 @@ public class PartController extends BaseController {
|
|
@GetMapping("detail/{id}")
|
|
@GetMapping("detail/{id}")
|
|
public Result detail(@PathVariable Long id) {
|
|
public Result detail(@PathVariable Long id) {
|
|
PartEntity entity = partService.findById(id);
|
|
PartEntity entity = partService.findById(id);
|
|
-
|
|
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
log.error("对象不存在: {}", id);
|
|
log.error("对象不存在: {}", id);
|
|
return Result.failure("对象不存在");
|
|
return Result.failure("对象不存在");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ PartResponse partResponse = new PartResponse();
|
|
|
|
+ BeanUtils.copyProperties(entity, partResponse);
|
|
|
|
+
|
|
|
|
+ TypeEntity typeEntity = typeService.findById(entity.getTypeId());
|
|
|
|
+ String typeName = typeEntity != null ? typeEntity.getName() : "";
|
|
|
|
+ partResponse.setTypeName(typeName);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 查找文件
|
|
// 查找文件
|
|
-// List<FileEntity> files = fileService.findByFkIdAndType(id, TypeCode.MODEL_PART);
|
|
|
|
|
|
+ String fileIds = entity.getFileIds();
|
|
|
|
+ List<FileEntity> files = (fileIds != null) ? fileService.findByIds(fileIds) : new ArrayList<>();
|
|
|
|
|
|
- List<FileEntity> files = fileService.findByIds(entity.getFileIds());
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
- resultMap.put("part", entity);
|
|
|
|
|
|
+ resultMap.put("part", partResponse);
|
|
resultMap.put("file", files);
|
|
resultMap.put("file", files);
|
|
|
|
|
|
return Result.success(resultMap);
|
|
return Result.success(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 是否要删除文件?再考虑
|
|
|
|
- */
|
|
|
|
|
|
+
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParam(name = "ids", value = "部件id,多个id用逗号隔开,如: 1,2,3", required = true)
|
|
@ApiImplicitParam(name = "ids", value = "部件id,多个id用逗号隔开,如: 1,2,3", required = true)
|
|
})
|
|
})
|