|
@@ -10,6 +10,7 @@ import cn.cslg.report.web.ServiceCode;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -30,39 +31,35 @@ import java.util.List;
|
|
@Slf4j
|
|
@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(Constants.REPORT_API + "/product")
|
|
@RequestMapping(Constants.REPORT_API + "/product")
|
|
|
|
+@RequiredArgsConstructor
|
|
public class ProductController {
|
|
public class ProductController {
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private ProductServiceImpl productService;
|
|
private ProductServiceImpl productService;
|
|
|
|
|
|
@Operation(summary = "新增产品")
|
|
@Operation(summary = "新增产品")
|
|
@PostMapping("/addProduct")
|
|
@PostMapping("/addProduct")
|
|
- public String addProduct(String jsons, List<MultipartFile> files) {
|
|
|
|
|
|
+ public JsonResult addProduct(String jsons, List<MultipartFile> files) {
|
|
log.info("开始处理【新增产品】的请求,参数为:{}, {}", jsons, files);
|
|
log.info("开始处理【新增产品】的请求,参数为:{}, {}", jsons, files);
|
|
if (jsons != null) {
|
|
if (jsons != null) {
|
|
ProductDTO productDTO = JSONObject.parseObject(jsons, ProductDTO.class);
|
|
ProductDTO productDTO = JSONObject.parseObject(jsons, ProductDTO.class);
|
|
productService.addProduct(productDTO, files);
|
|
productService.addProduct(productDTO, files);
|
|
- return Response.success("产品新增成功");
|
|
|
|
|
|
+ return JsonResult.ok("产品新增成功");
|
|
} else {
|
|
} else {
|
|
- return Response.error("产品信息不能为空");
|
|
|
|
|
|
+ return JsonResult.fail("产品信息不能为空");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Operation(summary = "根据报告id查询产品数据信息")
|
|
@Operation(summary = "根据报告id查询产品数据信息")
|
|
@GetMapping("/getProduct")
|
|
@GetMapping("/getProduct")
|
|
- public String getProduct(Integer reportId) {
|
|
|
|
|
|
+ public JsonResult getProduct(Integer reportId) {
|
|
log.info("开始处理【根据报告id查询产品数据信息】的请求,参数为:{}", reportId);
|
|
log.info("开始处理【根据报告id查询产品数据信息】的请求,参数为:{}", reportId);
|
|
if (reportId != null) {
|
|
if (reportId != null) {
|
|
ProductStandardVO queryResult = productService.getProduct(reportId);
|
|
ProductStandardVO queryResult = productService.getProduct(reportId);
|
|
if (queryResult == null) {
|
|
if (queryResult == null) {
|
|
- //return JsonResult.fail(ServiceCode.ERROR_NOT_FOUND, "产品不存在");
|
|
|
|
- return Response.error("报告id对应产品不存在");
|
|
|
|
|
|
+ return JsonResult.fail("产品不存在");
|
|
}
|
|
}
|
|
- //return JsonResult.ok(queryResult);
|
|
|
|
- return Response.success(queryResult);
|
|
|
|
|
|
+ return JsonResult.ok(queryResult);
|
|
} else {
|
|
} else {
|
|
- //return JsonResult.fail(ServiceCode.ERROR_BAD_REQUEST, "报告id不能为空");
|
|
|
|
- return Response.error("报告id不能为空");
|
|
|
|
|
|
+ return JsonResult.fail("报告id不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|