From 707828bdc0759cb0ee749206f55e2da64f7304c1 Mon Sep 17 00:00:00 2001 From: liuxm <liuxm_a@163.com> Date: 星期二, 21 五月 2024 13:57:55 +0800 Subject: [PATCH] 文件id返回时设置为String,以防丢失精度 --- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 4 ++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java | 1 + pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java | 1 + pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java | 15 ++++++++++++++- pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductFile.java | 5 +++++ 5 files changed, 25 insertions(+), 1 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java index feadcae..df63134 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java @@ -47,6 +47,7 @@ /** * 鍏稿瀷鍥剧墖 */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) public Long image; @TableField(exist = false) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductFile.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductFile.java index e913451..9d6f9aa 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductFile.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductFile.java @@ -1,5 +1,7 @@ package com.dy.pmsGlobal.pojoPlt; +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -22,17 +24,20 @@ /** * */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) @TableId(type = IdType.AUTO) private Long id; /** * 浜у搧瀹炰綋缂栧彿 */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) public Long proId; /** * 鏂囦欢缂栧彿 */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) public Long fileId; /** diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java index 8683fc2..2cf57ff 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductParams.java @@ -26,6 +26,7 @@ /** * 浜у搧瀹炰綋缂栧彿 */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) public Long proId; /** diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java index 28c3c7e..48ca437 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java @@ -14,13 +14,26 @@ import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.http.ContentDisposition; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.StreamUtils; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * 浜у搧绠$悊 @@ -134,7 +147,7 @@ try{ PltProduct pro=proSv.selectById(id); - return BaseResponseUtils.buildSuccess(JSON.toJSON(pro)); + return BaseResponseUtils.buildSuccess(pro); }catch (Exception e){ log.error("鏍规嵁ID鏌ヨ浜у搧寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()); diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java index 0ee58f1..1078260 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java @@ -12,6 +12,7 @@ import com.dy.pmsGlobal.pojoOth.OthFile; import com.dy.pmsGlobal.pojoPlt.PltProduct; import com.dy.pmsGlobal.pojoPlt.PltProductFile; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -224,4 +225,7 @@ } + public void downloadDoc(HttpServletResponse response) { + PltProduct pro=dao.selectByPrimaryKey(Long.valueOf(1)); + } } -- Gitblit v1.8.0