From 691b4e362cfad3c81b58994b53d6094cc856e3b7 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Sun, 16 Mar 2025 18:54:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E5=86=99=E7=9C=9F?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E4=BA=A7=E5=93=81=E7=9A=84=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heritage/constant/FileConstant.java | 7 +- .../book/PhotoProductsController.java | 5 + .../controller/file/FileController.java | 116 +----------------- .../controller/good/CategoryController.java | 13 ++ .../controller/good/FestivalController.java | 9 +- .../controller/good/GoodController.java | 42 ++++++- .../order/AdvanceOrderController.java | 13 ++ .../controller/order/OrderController.java | 65 ++++++++++ .../order/PendingServiceGoodController.java | 4 +- .../controller/user/UserController.java | 35 ++---- .../good/impl/CartExperienceServiceImpl.java | 3 + .../good/impl/CartRecordServiceImpl.java | 3 + 12 files changed, 173 insertions(+), 142 deletions(-) diff --git a/src/main/java/com/cultural/heritage/constant/FileConstant.java b/src/main/java/com/cultural/heritage/constant/FileConstant.java index 02fa61f..5467e5b 100644 --- a/src/main/java/com/cultural/heritage/constant/FileConstant.java +++ b/src/main/java/com/cultural/heritage/constant/FileConstant.java @@ -5,11 +5,6 @@ public interface FileConstant { /** * 服务器访问地址 */ - String SERVER_HOST = "/static/img"; + String SERVER_HOST = "http://123.249.108.160:8888/api/file/downloadFile?objectKey="; - - /** - * 服务器上传路径 - */ - String SERVER_UPLOAD_DIR = "D:\\匠承非遗文件上传\\img"; } diff --git a/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java b/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java index a605eb4..b362add 100644 --- a/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java +++ b/src/main/java/com/cultural/heritage/controller/book/PhotoProductsController.java @@ -10,6 +10,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; @@ -287,6 +288,8 @@ public class PhotoProductsController { PhotoProductsVO photoProductsVO = new PhotoProductsVO(); BeanUtils.copyProperties(photoProducts, photoProductsVO); + // TODO + photoProductsVO.setIntroImg(FileConstant.SERVER_HOST + photoProducts.getIntroImg()); photoProductsVO.setBookingDateVOList(bookingDateVOList); photoProductsVOList.add(photoProductsVO); } @@ -396,6 +399,8 @@ public class PhotoProductsController { // 封装成BookingPhotoProductsVO列表 PhotoProductsVO photoProductsVO = new PhotoProductsVO(); BeanUtils.copyProperties(photoProducts, photoProductsVO); + // TODO + photoProductsVO.setIntroImg(FileConstant.SERVER_HOST + photoProductsVO.getIntroImg()); photoProductsVO.setBookingDateVOList(bookingDateVOList); return ResultUtils.success(photoProductsVO); diff --git a/src/main/java/com/cultural/heritage/controller/file/FileController.java b/src/main/java/com/cultural/heritage/controller/file/FileController.java index a891384..8703859 100644 --- a/src/main/java/com/cultural/heritage/controller/file/FileController.java +++ b/src/main/java/com/cultural/heritage/controller/file/FileController.java @@ -36,114 +36,7 @@ public class FileController { @Resource private IHweiYunOBSService iHweiYunOBSService; -// -// /** -// * 未登录的情况下的文件上传 -// * -// * @param multipartFile 文件上传参数 -// * @param uploadFileRequest 文件业务类型请求体 -// * @return 图片可访问地址 -// */ -// @PostMapping("/upload/server/not_login") -// @Operation(summary = "(未使用)未登录情况下的文件上传", description = "参数:(文档上是false,但biz是必传的),文件对象(multipartFile), 业务类型(biz),权限:所有人,方法名:uploadServerFileNotLogin") -// private BaseResponse uploadServerFileNotLogin(@RequestPart("file") MultipartFile multipartFile, UploadFileRequest uploadFileRequest) { -// // 获取业务名称 -// String biz = uploadFileRequest.getBiz(); -// FileUploadBizEnum fileUploadBizEnum = FileUploadBizEnum.getEnumByValue(biz); -// if (fileUploadBizEnum == null) { -// throw new BusinessException(ErrorCode.PARAMS_ERROR, "业务名称错误"); -// } -// // 校验文件 -// validFile(multipartFile, fileUploadBizEnum); -// // 文件目录:根据业务、用户来划分 -// String uuid = RandomStringUtils.randomAlphabetic(8); -// String filename = uuid + "-" + multipartFile.getOriginalFilename(); -// String filepath = String.format("/%s/%s/%s", fileUploadBizEnum.getValue(), 0, filename); -// -// // 判断目录是否存在 -// File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath); -// if (!file.exists()) { -// // 创建目录 -// boolean mkdirs = file.mkdirs(); -// if (!mkdirs) { -// throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败"); -// } -// } -// // 返回可访问地址 -// String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); -// return ResultUtils.success(url); -// } -// -// -// @PostMapping("/upload/server") -// @Operation(summary = "已登录情况下的文件上传", description = "参数:(文档上是false,但biz是必传的),文件对象(multipartFile), 业务类型(biz),权限:所有人,方法名:uploadServerFile") -// public BaseResponse uploadServerFile(@RequestPart("file") MultipartFile multipartFile, UploadFileRequest uploadFileRequest, HttpServletRequest request) { -// // 获取业务名称 -// String biz = uploadFileRequest.getBiz(); -// FileUploadBizEnum fileUploadBizEnum = FileUploadBizEnum.getEnumByValue(biz); -// if (fileUploadBizEnum == null) { -// throw new BusinessException(ErrorCode.PARAMS_ERROR, "业务名称错误"); -// } -// // 校验文件 -// validFile(multipartFile, fileUploadBizEnum); -// // 校验用户是否登录 -// User loginUser = userService.getLoginUser(request); -// if (loginUser == null) { -// throw new BusinessException(ErrorCode.NOT_LOGIN_ERROR, "未登录"); -// } -// // 文件目录:根据业务、用户来划分 -// String uuid = RandomStringUtils.randomAlphabetic(8); -// String filename = uuid + "-" + multipartFile.getOriginalFilename(); -// String filepath = String.format("/%s/%s/%s", fileUploadBizEnum.getValue(), loginUser.getId(), filename); -// -// // 判断目录是否存在 -// File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath); -// if (!file.exists()) { -// // 创建目录 -// boolean mkdirs = file.mkdirs(); -// if (!mkdirs) { -// throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败"); -// } -// } -// // 返回可访问地址 -// String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); -// return ResultUtils.success(url); -// } -// -// -// @PostMapping("/upload/single") -// @Operation(summary = "单独文件上传", description = "参数:file,文件对象(multipartFile),权限:所有人,方法名:uploadServerFile") -// public Object uploadSingleServerFile(@RequestPart("file") MultipartFile multipartFile, HttpServletRequest request) { -//// -// // 校验文件 -// validFile(multipartFile, null); -// // 文件目录:根据业务、用户来划分 -// String uuid = RandomStringUtils.randomAlphabetic(8); -// String filename = uuid + "-" + multipartFile.getOriginalFilename(); -// String filepath = String.format("/%s/%s/%s", "single", "yt", filename); -// -// // 判断目录是否存在 -// File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath); -// if (!file.exists()) { -// // 创建目录 -// boolean mkdirs = file.mkdirs(); -// if (!mkdirs) { -// throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败"); -// } -// } -// // 返回可访问地址 -// String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); -// -// Map data = new HashMap<>(); -// data.put("url", url); -// -// // 创建最终地响应对象 -// Map response = new HashMap<>(); -// response.put("errno", 0); -// response.put("data", data); -// Gson gson = new Gson(); -// return gson.fromJson(gson.toJson(response), Object.class); -// } + /** @@ -153,7 +46,7 @@ public class FileController { * @return PutObjectResult */ @PostMapping("/uploadFile") - @Operation(summary = "Web端文件上传", description = "参数:文件对象(multipartFile), 业务类型(biz),权限:所有人,方法名:uploadFile") + @Operation(summary = "Web端文件上传", description = "参数:文件对象(multipartFile), 业务类型(biz),权限:管理员,方法名:uploadFile") public BaseResponse uploadFile(@RequestPart("file") MultipartFile multipartFile, UploadFileRequest uploadFileRequest, HttpServletRequest request) { // 校验用户是否登录 User loginUser = userService.getLoginUser(request); @@ -164,7 +57,7 @@ public class FileController { iHweiYunOBSService.fileUpload(multipartFile, filePath); - return ResultUtils.success(filePath, "上传成功,返回给前端filePath,前端需存储"); + return ResultUtils.success(filePath, "上传成功"); } @@ -174,6 +67,7 @@ public class FileController { * @param objectKey 具体的文件名(含存储路径) */ @GetMapping("downloadFile") + @Operation(summary = "文件下载", description = "参数:文件对象(具体的文件名(含存储路径)),权限:所有人,方法名:downloadFile") public void downloadFile(@RequestParam String objectKey, HttpServletResponse response) { iHweiYunOBSService.downloadFile(objectKey, response); } @@ -232,6 +126,6 @@ public class FileController { // 文件目录:根据业务、用户来划分 String uuid = RandomStringUtils.randomAlphabetic(8); String filename = uuid + "-" + multipartFile.getOriginalFilename(); - return String.format("/%s/%s", fileUploadBizEnum.getValue(), filename); + return String.format("%s/%s", fileUploadBizEnum.getValue(), filename); } } diff --git a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java index 5f5365e..c1cc59b 100644 --- a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java @@ -7,6 +7,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; @@ -192,6 +193,10 @@ public class CategoryController { public BaseResponse> listCategoryOnWeb(HttpServletRequest request) { userService.getLoginUser(request); List list = categoryService.list(); + // TODO + for (Category category : list) { + category.setTypeUrl(FileConstant.SERVER_HOST + category.getTypeUrl()); + } return ResultUtils.success(list); } @@ -210,6 +215,10 @@ public class CategoryController { List goodList = commonService.findByFieldEqTargetField("isShelves", 1, goodService); // 获取所有存在上架商品的商品类别 List categoryList = commonService.findByFieldInTargetField(goodList, categoryService, Good::getType, "typeName"); + // TODO + for (Category category : categoryList) { + category.setTypeUrl(FileConstant.SERVER_HOST + category.getTypeUrl()); + } return ResultUtils.success(categoryList); } @@ -238,6 +247,10 @@ public class CategoryController { queryWrapper.eq("isShelves", 1); queryWrapper.orderByDesc("id"); List goodList = goodService.list(queryWrapper); + // TODO + for (Good good : goodList) { + good.setGoodImg(FileConstant.SERVER_HOST + good.getGoodImg()); + } Map> map = new HashMap<>(); map.put(id, goodList); return ResultUtils.success(map); diff --git a/src/main/java/com/cultural/heritage/controller/good/FestivalController.java b/src/main/java/com/cultural/heritage/controller/good/FestivalController.java index ba7f1f5..68daa96 100644 --- a/src/main/java/com/cultural/heritage/controller/good/FestivalController.java +++ b/src/main/java/com/cultural/heritage/controller/good/FestivalController.java @@ -5,6 +5,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.model.entity.Festival; @@ -72,7 +73,9 @@ public class FestivalController { // 遍历查找匹配的节日 for (Festival festival : festivalList) { if (festival.getName().equals(festivalName)) { - return ResultUtils.success(festival.getUrl()); // 返回对应的 URL + // TODO + String wholeFilePath = FileConstant.SERVER_HOST + festival.getUrl(); + return ResultUtils.success(wholeFilePath); // 返回对应的 URL } } throw new BusinessException(ErrorCode.OPERATION_ERROR, "该节日项不存在"); @@ -89,6 +92,10 @@ public class FestivalController { @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> getFestivalList() { List festivalList = redisTemplate.opsForList().range(FESTIVAL_KEY, 0, -1); + // TODO + for (Festival festival : festivalList) { + festival.setUrl(FileConstant.SERVER_HOST + festival.getUrl()); + } return ResultUtils.success(festivalList); } diff --git a/src/main/java/com/cultural/heritage/controller/good/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java index c0a3033..b00c90d 100644 --- a/src/main/java/com/cultural/heritage/controller/good/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java @@ -12,6 +12,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; @@ -409,6 +410,15 @@ public class GoodController { QueryWrapper goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest, false); Page page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper); List records = page.getRecords(); + // TODO + for (Good good : records) { + String[] goodImgArr = good.getGoodImg().split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + good.setGoodImg(joinImg); + } List goodPageVOS = commonService.convertList(records, GoodPageVO.class); Page goodPageVOPage = new Page<>(); goodPageVOPage.setRecords(goodPageVOS); @@ -459,8 +469,15 @@ public class GoodController { Long id = getByIdRequest.getId(); Good good = goodService.getById(id); ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "商品不存在"); + // TODO + String[] goodImgArr = good.getGoodImg().split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + good.setGoodImg(joinImg); + good.setRichText(DecoderUtils.decodeText(good.getRichText())); - System.out.println(good.getRichText()); GoodPageVO goodPageVO = new GoodPageVO(); BeanUtils.copyProperties(good, goodPageVO); return ResultUtils.success(goodPageVO); @@ -489,6 +506,10 @@ public class GoodController { QueryWrapper goodQueryWrapper = goodService.getGoodQueryWrapper(goodQueryRequest, true); Page page = goodService.page(new Page<>(current, pageSize), goodQueryWrapper); List records = page.getRecords(); + // TODO + for (Good good : records) { + good.setGoodImg(FileConstant.SERVER_HOST + good.getGoodImg()); + } // 获取联表(预约日期表, 预约时间段表)查询结果 List appointmentDateTimePeriodVOS = appointmentDateService.queryAppointmentDateDetail(); @@ -583,6 +604,8 @@ public class GoodController { Long id = commonRequest.getId(); Good good = goodService.getById(id); ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR, "商品不存在"); + // TODO + good.setGoodImg(FileConstant.SERVER_HOST + good.getGoodImg()); ServiceGoodVO serviceGoodVO = new ServiceGoodVO(); BeanUtils.copyProperties(good, serviceGoodVO); Long goodVOId = serviceGoodVO.getId(); @@ -683,6 +706,10 @@ public class GoodController { conditionMap.put("isGoodType", 0); List goodList = commonService.findByFieldEqTargetFields(conditionMap, goodService); goodList = goodList.stream().filter(good -> good.getName().contains(keyword)).toList(); + // TODO + for (Good good : goodList) { + good.setGoodImg(FileConstant.SERVER_HOST + good.getGoodImg()); + } List serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class); return ResultUtils.success(serviceGoodCardVOS); } @@ -718,6 +745,15 @@ public class GoodController { } return false; }).toList(); + for (Good good : goodList) { + // TODO + String[] goodImgArr = good.getGoodImg().split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + good.setGoodImg(joinImg); + } List serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class); return ResultUtils.success(serviceGoodCardVOS); } @@ -740,6 +776,10 @@ public class GoodController { map.put("isGoodType", 0); map.put("isShelves", 1); List goodList = commonService.findByFieldEqTargetFields(map, goodService); + // TODO + for (Good good : goodList) { + good.setGoodImg(FileConstant.SERVER_HOST + good.getGoodImg()); + } List serviceGoodCardVOS = commonService.convertList(goodList, ServiceGoodCardVO.class); return ResultUtils.success(serviceGoodCardVOS); } diff --git a/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java b/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java index a79b01b..712eb8e 100644 --- a/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/AdvanceOrderController.java @@ -9,6 +9,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; @@ -211,6 +212,12 @@ public class AdvanceOrderController { // 封装成写真预约订单VO List records = page.getRecords(); List advanceOrderVOS = commonService.convertList(records, AdvanceOrderVO.class); + // TODO + for (AdvanceOrderVO advanceOrderVO : advanceOrderVOS) { + PhotoProductsSnapshot photoProductsSnapshot = advanceOrderVO.getPhotoProductsSnapshot(); + photoProductsSnapshot.setIntroImg(FileConstant.SERVER_HOST + photoProductsSnapshot.getIntroImg()); + advanceOrderVO.setPhotoProductsSnapshot(photoProductsSnapshot); + } Page voPage = new Page<>(); voPage.setRecords(advanceOrderVOS); voPage.setTotal(page.getTotal()); @@ -235,6 +242,12 @@ public class AdvanceOrderController { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("userId", userId); List advanceOrderList = advanceOrderService.list(queryWrapper); + // TODO + for (AdvanceOrder advanceOrder : advanceOrderList) { + PhotoProductsSnapshot photoProductsSnapshot = advanceOrder.getPhotoProductsSnapshot(); + photoProductsSnapshot.setIntroImg(FileConstant.SERVER_HOST + photoProductsSnapshot.getIntroImg()); + advanceOrder.setPhotoProductsSnapshot(photoProductsSnapshot); + } // 封装成写真预约订单VO List advanceOrderVOS = commonService.convertList(advanceOrderList, AdvanceOrderVO.class); Collections.reverse(advanceOrderVOS); diff --git a/src/main/java/com/cultural/heritage/controller/order/OrderController.java b/src/main/java/com/cultural/heritage/controller/order/OrderController.java index 3bdd7de..2b04556 100644 --- a/src/main/java/com/cultural/heritage/controller/order/OrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/OrderController.java @@ -7,6 +7,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; @@ -255,6 +256,28 @@ public class OrderController { orderVO.setOrderItemList(orderItemsTempList); } + // TODO + for (OrderVO orderVO : orderVOS) { + boolean isGeneral = orderService.isGeneralGood(orderVO.getOrderType()); + List orderItemList = orderVO.getOrderItemList(); + for (OrderItems orderItems : orderItemList) { + GoodSnapshot goodSnapshot = orderItems.getGoodSnapshot(); + String goodImg = goodSnapshot.getGoodImg(); + if (isGeneral) { + String[] goodImgArr = goodImg.split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + goodSnapshot.setGoodImg(joinImg); + } else { + goodSnapshot.setGoodImg(FileConstant.SERVER_HOST + goodSnapshot.getGoodImg()); + } + orderItems.setGoodSnapshot(goodSnapshot); + } + orderVO.setOrderItemList(orderItemList); + } + Page orderVOPage = new Page<>(); orderVOPage.setRecords(orderVOS); @@ -309,6 +332,28 @@ public class OrderController { orderVO.setOrderItemList(orderItemsList); return orderVO; }).toList(); + + // TODO + for (OrderVO orderVO : orderVOS) { + boolean isGeneral = orderService.isGeneralGood(orderVO.getOrderType()); + List orderItemList = orderVO.getOrderItemList(); + for (OrderItems orderItems : orderItemList) { + GoodSnapshot goodSnapshot = orderItems.getGoodSnapshot(); + String goodImg = goodSnapshot.getGoodImg(); + if (isGeneral) { + String[] goodImgArr = goodImg.split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + goodSnapshot.setGoodImg(joinImg); + } else { + goodSnapshot.setGoodImg(FileConstant.SERVER_HOST + goodSnapshot.getGoodImg()); + } + orderItems.setGoodSnapshot(goodSnapshot); + } + orderVO.setOrderItemList(orderItemList); + } return ResultUtils.success(orderVOS); } @@ -356,6 +401,26 @@ public class OrderController { BeanUtils.copyProperties(order, orderVO); List orderItemsList = commonService.findByFieldEqTargetField("orderId", orderId, orderItemService); orderVO.setOrderItemList(orderItemsList); + // TODO + boolean isGeneral = orderService.isGeneralGood(orderVO.getOrderType()); + List orderItemList = orderVO.getOrderItemList(); + for (OrderItems orderItems : orderItemList) { + GoodSnapshot goodSnapshot = orderItems.getGoodSnapshot(); + String goodImg = goodSnapshot.getGoodImg(); + if (isGeneral) { + String[] goodImgArr = goodImg.split(";"); + for (int i = 0; i < goodImgArr.length; i++) { + goodImgArr[i] = FileConstant.SERVER_HOST + goodImgArr[i]; + } + String joinImg = String.join(";", goodImgArr); + goodSnapshot.setGoodImg(joinImg); + } else { + goodSnapshot.setGoodImg(FileConstant.SERVER_HOST + goodSnapshot.getGoodImg()); + } + orderItems.setGoodSnapshot(goodSnapshot); + } + orderVO.setOrderItemList(orderItemList); + return ResultUtils.success(orderVO); } diff --git a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java index 6652724..523fec4 100644 --- a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java +++ b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java @@ -7,6 +7,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; @@ -79,7 +80,6 @@ public class PendingServiceGoodController { List pendingServiceGoodList = pendingServiceGoodService.list(queryWrapper); // 获取服务类待处理订单 List pendingServiceOrderList = commonService.findByFieldInTargetField(pendingServiceGoodList, pendingServiceOrderService, PendingServiceGood::getId, "pendingId"); - // 封装成服务类待处理订单VO List pendingServiceOrderVOS = commonService.convertList(pendingServiceOrderList, PendingServiceOrderVO.class); // 封装map集合(键:服务类商品待处理id,值:待处理服务类订单列表) @@ -96,6 +96,8 @@ public class PendingServiceGoodController { List pendingServiceGoodVOList = new ArrayList<>(); for (PendingServiceGood pendingServiceGood : pendingServiceGoodList) { + // TODO + pendingServiceGood.setGoodImg(FileConstant.SERVER_HOST + pendingServiceGood.getGoodImg()); PendingServiceGoodVO pendingServiceGoodVO = new PendingServiceGoodVO(); BeanUtils.copyProperties(pendingServiceGood, pendingServiceGoodVO); Long goodId = pendingServiceGood.getId(); diff --git a/src/main/java/com/cultural/heritage/controller/user/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java index 473860e..846f0c7 100644 --- a/src/main/java/com/cultural/heritage/controller/user/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -10,6 +10,7 @@ import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.config.WxOpenConfig; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; @@ -263,24 +264,6 @@ public class UserController { - /** - * 根据 id 获取用户 - * @param id - * @return 用户信息 - */ - @GetMapping("/get") - @Operation(summary = "(未使用)Web端管理员根据id获取用户信息", description = "参数:用户id, 权限:管理员(admin, boss), 方法名:getUserById") - @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) - public BaseResponse getUserById(long id) { - if (id <= 0) { - throw new BusinessException(ErrorCode.PARAMS_ERROR); - } - User user = userService.getById(id); - ThrowUtils.throwIf(user == null, ErrorCode.NOT_FOUND_ERROR); - return ResultUtils.success(user); - } - - /** * 获取用户数量 */ @@ -309,6 +292,12 @@ public class UserController { long pageSize = userQueryRequest.getPageSize(); QueryWrapper queryWrapper = userService.getQueryWrapper(userQueryRequest); Page page = userService.page(new Page<>(current, pageSize), queryWrapper); + List userList = page.getRecords(); + // TODO + for (User user : userList) { + user.setUserAvatar(FileConstant.SERVER_HOST + user.getUserAvatar()); + } + page.setRecords(userList); return ResultUtils.success(page); } @@ -329,14 +318,16 @@ public class UserController { } long current = userQueryRequest.getCurrent(); long pageSize = userQueryRequest.getPageSize(); -// ThrowUtils.throwIf(size > 20, ErrorCode.PARAMS_ERROR); QueryWrapper queryWrapper = userService.getQueryWrapper(userQueryRequest); Page userPage = userService.page(new Page<>(current, pageSize), queryWrapper); Page userVOPage = new Page<>(current, pageSize, userPage.getTotal()); - List userVO = userService.getUserVO(userPage.getRecords()); - - userVOPage.setRecords(userVO); + List userVOS = userService.getUserVO(userPage.getRecords()); + // TODO + for (UserVO userVO : userVOS) { + userVO.setUserAvatar(FileConstant.SERVER_HOST + userVO); + } + userVOPage.setRecords(userVOS); return ResultUtils.success(userVOPage); } diff --git a/src/main/java/com/cultural/heritage/service/good/impl/CartExperienceServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/CartExperienceServiceImpl.java index 9515bd3..f088fd5 100644 --- a/src/main/java/com/cultural/heritage/service/good/impl/CartExperienceServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/good/impl/CartExperienceServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.cultural.heritage.common.ErrorCode; +import com.cultural.heritage.constant.FileConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.mapper.CartExperienceMapper; @@ -134,6 +135,8 @@ public class CartExperienceServiceImpl extends ServiceImpl