From 8dcf105e052d001906c23ae615a227fcd15673a7 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Thu, 31 Oct 2024 19:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + .../heritage/aop/AuthInterceptor.java | 2 +- .../heritage/config/HweiOBSConfig.java | 70 +++++++ .../heritage/constant/FileConstant.java | 15 ++ .../controller/address/AddressController.java | 121 +++++++++++ .../controller/file/FileController.java | 122 +++++++++++ .../CategoryController.java | 55 ++++- .../{operategood => good}/GoodController.java | 18 +- .../{userinfo => user}/UserController.java | 18 +- .../heritage/mapper/AddressMapper.java | 8 + .../model/dto/address/AddressAddRequest.java | 48 +++++ .../dto/address/AddressUpdateRequest.java | 53 +++++ .../model/dto/file/UploadFileRequest.java | 19 ++ .../model/dto/good/GoodUpdateRequest.java | 7 + .../heritage/model/entity/Address.java | 63 ++++++ .../model/enums/FileUploadBizEnum.java | 58 ++++++ .../service/address/AddressService.java | 8 + .../address/impl/AddressServiceImpl.java | 12 ++ .../service/file/IHweiYunOBSService.java | 42 ++++ .../file/impl/HweiYunOBSServiceImpl.java | 190 ++++++++++++++++++ .../service/good/CategoryService.java | 22 ++ .../{operategood => good}/GoodService.java | 10 +- .../good/impl/CategoryServiceImpl.java | 43 ++++ .../impl/GoodServiceImpl.java | 27 ++- .../service/operategood/CategoryService.java | 9 - .../operategood/impl/CategoryServiceImpl.java | 11 - .../{userinfo => user}/UserService.java | 2 +- .../impl/UserServiceImpl.java | 5 +- src/main/resources/application.yml | 18 +- src/main/resources/mapper/AddressMapper.xml | 7 + 30 files changed, 1017 insertions(+), 67 deletions(-) create mode 100644 src/main/java/com/cultural/heritage/config/HweiOBSConfig.java create mode 100644 src/main/java/com/cultural/heritage/constant/FileConstant.java create mode 100644 src/main/java/com/cultural/heritage/controller/address/AddressController.java create mode 100644 src/main/java/com/cultural/heritage/controller/file/FileController.java rename src/main/java/com/cultural/heritage/controller/{operategood => good}/CategoryController.java (58%) rename src/main/java/com/cultural/heritage/controller/{operategood => good}/GoodController.java (90%) rename src/main/java/com/cultural/heritage/controller/{userinfo => user}/UserController.java (95%) create mode 100644 src/main/java/com/cultural/heritage/mapper/AddressMapper.java create mode 100644 src/main/java/com/cultural/heritage/model/dto/address/AddressAddRequest.java create mode 100644 src/main/java/com/cultural/heritage/model/dto/address/AddressUpdateRequest.java create mode 100644 src/main/java/com/cultural/heritage/model/dto/file/UploadFileRequest.java create mode 100644 src/main/java/com/cultural/heritage/model/entity/Address.java create mode 100644 src/main/java/com/cultural/heritage/model/enums/FileUploadBizEnum.java create mode 100644 src/main/java/com/cultural/heritage/service/address/AddressService.java create mode 100644 src/main/java/com/cultural/heritage/service/address/impl/AddressServiceImpl.java create mode 100644 src/main/java/com/cultural/heritage/service/file/IHweiYunOBSService.java create mode 100644 src/main/java/com/cultural/heritage/service/file/impl/HweiYunOBSServiceImpl.java create mode 100644 src/main/java/com/cultural/heritage/service/good/CategoryService.java rename src/main/java/com/cultural/heritage/service/{operategood => good}/GoodService.java (69%) create mode 100644 src/main/java/com/cultural/heritage/service/good/impl/CategoryServiceImpl.java rename src/main/java/com/cultural/heritage/service/{operategood => good}/impl/GoodServiceImpl.java (74%) delete mode 100644 src/main/java/com/cultural/heritage/service/operategood/CategoryService.java delete mode 100644 src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java rename src/main/java/com/cultural/heritage/service/{userinfo => user}/UserService.java (95%) rename src/main/java/com/cultural/heritage/service/{userinfo => user}/impl/UserServiceImpl.java (97%) create mode 100644 src/main/resources/mapper/AddressMapper.xml diff --git a/pom.xml b/pom.xml index de6c7a6..c875b77 100644 --- a/pom.xml +++ b/pom.xml @@ -142,6 +142,7 @@ 1.6.2 + cn.hutool hutool-all diff --git a/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java b/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java index 1dc384e..6541263 100644 --- a/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java +++ b/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java @@ -6,7 +6,7 @@ import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.enums.UserRoleEnum; -import com.cultural.heritage.service.userinfo.UserService; +import com.cultural.heritage.service.user.UserService; import io.micrometer.common.util.StringUtils; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; diff --git a/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java b/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java new file mode 100644 index 0000000..ae4a740 --- /dev/null +++ b/src/main/java/com/cultural/heritage/config/HweiOBSConfig.java @@ -0,0 +1,70 @@ +package com.cultural.heritage.config; + +import com.obs.services.ObsClient; +import com.obs.services.exception.ObsException; +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Data +@Configuration +public class HweiOBSConfig { + + + /** + * 访问密钥AK + */ + @Value("${hwyun.obs.accessKey}") + private String accessKey; + + /** + * 访问密钥SK + */ + @Value("${hwyun.obs.securityKey}") + private String securityKey; + + /** + * 终端节点 + */ + @Value("${hwyun.obs.endPoint}") + private String endPoint; + + /** + * 桶 + */ + @Value("${hwyun.obs.bucketName}") + private String bucketName; + + /** + * @Description 获取OBS客户端实例 + * @return: com.obs.services.ObsClient + */ + public ObsClient getInstance() { + return new ObsClient(accessKey, securityKey, endPoint); + } + + /** + * @Description 销毁OBS客户端实例 + * @param: obsClient + */ + public void destroy(ObsClient obsClient){ + try { + obsClient.close(); + } catch (ObsException e) { + } catch (Exception e) { + } + } + + /** + * @Description 微服务文件存放路径 + * @return: java.lang.String + */ + public static String getObjectKey() { + // 项目或者服务名称 + 日期存储方式 + return "Hwei" + "/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date() )+ "/"; + } +} + diff --git a/src/main/java/com/cultural/heritage/constant/FileConstant.java b/src/main/java/com/cultural/heritage/constant/FileConstant.java new file mode 100644 index 0000000..02fa61f --- /dev/null +++ b/src/main/java/com/cultural/heritage/constant/FileConstant.java @@ -0,0 +1,15 @@ +package com.cultural.heritage.constant; + +public interface FileConstant { + + /** + * 服务器访问地址 + */ + String SERVER_HOST = "/static/img"; + + + /** + * 服务器上传路径 + */ + String SERVER_UPLOAD_DIR = "D:\\匠承非遗文件上传\\img"; +} diff --git a/src/main/java/com/cultural/heritage/controller/address/AddressController.java b/src/main/java/com/cultural/heritage/controller/address/AddressController.java new file mode 100644 index 0000000..a462f14 --- /dev/null +++ b/src/main/java/com/cultural/heritage/controller/address/AddressController.java @@ -0,0 +1,121 @@ +package com.cultural.heritage.controller.address; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.cultural.heritage.common.BaseResponse; +import com.cultural.heritage.common.ErrorCode; +import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.exception.BusinessException; +import com.cultural.heritage.exception.ThrowUtils; +import com.cultural.heritage.model.dto.CommonRequest; +import com.cultural.heritage.model.dto.address.AddressAddRequest; +import com.cultural.heritage.model.dto.address.AddressUpdateRequest; +import com.cultural.heritage.model.entity.Address; +import com.cultural.heritage.service.address.AddressService; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/address") +@Slf4j +@Tag(name = "地址接口") +public class AddressController { + + + @Resource + private AddressService addressService; + + + /** + * 添加地址信息 + * @param addressAddRequest 地址添加请求体 + * @return 是否添加成功 + */ + @PostMapping("/add") + public BaseResponse addAddress(@RequestBody AddressAddRequest addressAddRequest) { + if (addressAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Address address = new Address(); + BeanUtils.copyProperties(addressAddRequest, address); + boolean save = addressService.save(address); + if (!save) { + throw new BusinessException(ErrorCode.OPERATION_ERROR); + } + return ResultUtils.success(true); + } + + + + /** + * 删除地址信息 + * @param deleteRequest 地址删除请求体 + * @return 是否成功删除 + */ + @PostMapping("/delete") + public BaseResponse delAddress(@RequestBody CommonRequest deleteRequest) { + if (deleteRequest == null || deleteRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long id = deleteRequest.getId(); + boolean result = addressService.removeById(id); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + + + + /** + * 更新地址信息 + * @param addressUpdateRequest 地址更新请求体 + * @return 是否更新成功 + */ + @PostMapping("/update") + public BaseResponse updateAddress(@RequestBody AddressUpdateRequest addressUpdateRequest) { + if (addressUpdateRequest == null || addressUpdateRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Address address = new Address(); + BeanUtils.copyProperties(addressUpdateRequest, address); + System.out.println(address); + boolean result = addressService.updateById(address); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + + + + /** + * 查询用户地址信息 + * @param addressQueryRequest 地址查询请求体 + * @return 用户地址列表 + */ + @PostMapping("/list") + public BaseResponse> listAddress(@RequestBody CommonRequest addressQueryRequest) { + if (addressQueryRequest == null || addressQueryRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long id = addressQueryRequest.getId(); + QueryWrapper
addressQueryWrapper = new QueryWrapper<>(); + addressQueryWrapper.eq("userId", id); + List
list = addressService.list(addressQueryWrapper); + if (CollectionUtils.isEmpty(list)) { + list = new ArrayList<>(); + } + return ResultUtils.success(list); + } + + + +} diff --git a/src/main/java/com/cultural/heritage/controller/file/FileController.java b/src/main/java/com/cultural/heritage/controller/file/FileController.java new file mode 100644 index 0000000..4892f58 --- /dev/null +++ b/src/main/java/com/cultural/heritage/controller/file/FileController.java @@ -0,0 +1,122 @@ +package com.cultural.heritage.controller.file; + +import cn.hutool.core.io.FileUtil; +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.exception.BusinessException; +import com.cultural.heritage.model.dto.file.UploadFileRequest; +import com.cultural.heritage.model.entity.User; +import com.cultural.heritage.model.enums.FileUploadBizEnum; +import com.cultural.heritage.service.file.IHweiYunOBSService; +import com.cultural.heritage.service.user.UserService; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Random; + +@RestController +@RequestMapping("/file") +@Slf4j +@Tag(name = "文件上传接口") +public class FileController { + + + @Resource + private UserService userService; + + + @Resource + private IHweiYunOBSService iHweiYunOBSService; + + + /** + * 未登录的情况下的文件上传 + * @param multipartFile 文件上传参数 + * @param uploadFileRequest 文件业务类型请求体 + * @return 图片可访问地址 + */ + @PostMapping("/upload/server/not_login") + 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", fileUploadBizEnum.getValue(), 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 test = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); + return ResultUtils.success(test); + } + + + @PostMapping("/upload/server") + public BaseResponse uploadServerFile(@RequestPart 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 s = uuid + "-" + multipartFile.getOriginalFilename(); + return null; + } + + + /** + * 校验文件 + * + * @param multipartFile 文件 + * @param fileUploadBizEnum 业务类型 + */ + private void validFile(MultipartFile multipartFile, FileUploadBizEnum fileUploadBizEnum) { + //文件大小 + long fileSize = multipartFile.getSize(); + //文件后缀 + String fileSuffix = FileUtil.getSuffix(multipartFile.getOriginalFilename()); + final long LIMIT = 512 * 1024L; + if (fileSize > LIMIT) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件大小不能超过512K"); + } + if (!Arrays.asList("jpeg", "jpg", "svg", "png", "webp").contains(fileSuffix)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件类型错误"); + } + } + + +} diff --git a/src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java similarity index 58% rename from src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java rename to src/main/java/com/cultural/heritage/controller/good/CategoryController.java index fa447c1..9bbeeb3 100644 --- a/src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java @@ -1,7 +1,6 @@ -package com.cultural.heritage.controller.operategood; +package com.cultural.heritage.controller.good; -import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; @@ -10,17 +9,22 @@ import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.category.CategoryAddRequest; import com.cultural.heritage.model.entity.Category; -import com.cultural.heritage.service.operategood.CategoryService; +import com.cultural.heritage.model.entity.Good; +import com.cultural.heritage.service.good.CategoryService; +import com.cultural.heritage.service.good.GoodService; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/category") @@ -32,6 +36,12 @@ public class CategoryController { private CategoryService categoryService; + + @Resource + private GoodService goodService; + + + /** * 添加商品类别 * @param categoryAddRequest 类别添加请求体 @@ -42,6 +52,11 @@ public class CategoryController { if (categoryAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); } + String typeName = categoryAddRequest.getTypeName(); + List typeNameList = categoryService.getTypeNameList(); + if (typeNameList.contains(typeName)) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "已存在该类别"); + } Category category = new Category(); BeanUtils.copyProperties(categoryAddRequest, category); boolean save = categoryService.save(category); @@ -59,7 +74,7 @@ public class CategoryController { */ @PostMapping("/delete") public BaseResponse deleteCategory(@RequestBody CommonRequest deleteCategoryRequest) { - if (deleteCategoryRequest == null) { + if (deleteCategoryRequest == null || deleteCategoryRequest.getId() == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); } Long id = deleteCategoryRequest.getId(); @@ -77,9 +92,14 @@ public class CategoryController { */ @PostMapping("/update") public BaseResponse updateCategory(@RequestBody Category category) { - if (category == null) { + if (category == null || category.getId() == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); } + String typeName = category.getTypeName(); + List typeNameList = categoryService.getTypeNameList(); + if (typeNameList.contains(typeName)) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "已存在该类别"); + } boolean result = categoryService.updateById(category); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); return ResultUtils.success(true, "类别更新成功"); @@ -87,14 +107,27 @@ public class CategoryController { /** - * 查询商品类别 - * @return 类别列表 + * 根据类别查询商品列表 + * @param categoryQueryRequest 类别查询请求体 + * @return 当前类别的商品列表 */ - @PostMapping("/list") - public BaseResponse> listCategory() { - List list = categoryService.list(); - return ResultUtils.success(list); + @PostMapping("/list/type") + public BaseResponse>> listGoodByCategory(@RequestBody CommonRequest categoryQueryRequest) { + if (categoryQueryRequest == null || categoryQueryRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long id = categoryQueryRequest.getId(); + Category category = categoryService.getCategoryById(id); + String typeName = category.getTypeName(); + if (StringUtils.isBlank(typeName)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + List goodList = goodService.getGoodListByTypeName(typeName); + Map> map = new HashMap<>(); + map.put(category, goodList); + return ResultUtils.success(map); } + } diff --git a/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java similarity index 90% rename from src/main/java/com/cultural/heritage/controller/operategood/GoodController.java rename to src/main/java/com/cultural/heritage/controller/good/GoodController.java index c391d14..c7503a7 100644 --- a/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java @@ -1,13 +1,11 @@ -package com.cultural.heritage.controller.operategood; +package com.cultural.heritage.controller.good; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -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.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonDelBatchRequest; @@ -16,15 +14,13 @@ import com.cultural.heritage.model.dto.good.GoodAddRequest; import com.cultural.heritage.model.dto.good.GoodQueryRequest; import com.cultural.heritage.model.dto.good.GoodUpdateRequest; import com.cultural.heritage.model.entity.Good; -import com.cultural.heritage.service.operategood.GoodService; +import com.cultural.heritage.service.good.CategoryService; +import com.cultural.heritage.service.good.GoodService; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -42,6 +38,10 @@ public class GoodController { private GoodService goodService; + @Resource + private CategoryService categoryService; + + /** * 添加商品 * @param goodAddRequest 商品添加请求体 @@ -118,6 +118,7 @@ public class GoodController { + /** * 批量删除商品 * @param commonDelBatchRequest 批量删除请求体 @@ -134,5 +135,4 @@ public class GoodController { - } diff --git a/src/main/java/com/cultural/heritage/controller/userinfo/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java similarity index 95% rename from src/main/java/com/cultural/heritage/controller/userinfo/UserController.java rename to src/main/java/com/cultural/heritage/controller/user/UserController.java index aceb999..8ade3f8 100644 --- a/src/main/java/com/cultural/heritage/controller/userinfo/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -1,4 +1,4 @@ -package com.cultural.heritage.controller.userinfo; +package com.cultural.heritage.controller.user; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,14 +12,13 @@ import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.user.*; import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.vo.UserVO; -import com.cultural.heritage.service.userinfo.UserService; +import com.cultural.heritage.service.user.UserService; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; -import org.springframework.data.redis.core.RedisTemplate; import org.springframework.util.DigestUtils; import org.springframework.web.bind.annotation.*; @@ -42,19 +41,6 @@ public class UserController { private UserService userService; -// @GetMapping("/test") -// public String test(){ -// return "匠承非遗"; -// } - - -// -// @GetMapping("/list") -// public BaseResponse> listUser(){ -// return ResultUtils.success(userService.list()); -// } - - /** * 用户登录 * @param userLoginRequest 用户登录请求体 diff --git a/src/main/java/com/cultural/heritage/mapper/AddressMapper.java b/src/main/java/com/cultural/heritage/mapper/AddressMapper.java new file mode 100644 index 0000000..c249e82 --- /dev/null +++ b/src/main/java/com/cultural/heritage/mapper/AddressMapper.java @@ -0,0 +1,8 @@ +package com.cultural.heritage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.cultural.heritage.model.entity.Address; + +public interface AddressMapper extends BaseMapper
{ + +} diff --git a/src/main/java/com/cultural/heritage/model/dto/address/AddressAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/address/AddressAddRequest.java new file mode 100644 index 0000000..7ffabaa --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/dto/address/AddressAddRequest.java @@ -0,0 +1,48 @@ +package com.cultural.heritage.model.dto.address; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class AddressAddRequest implements Serializable { + + + /** + * 联系人 + */ + private String name; + + + /** + * 手机号 + */ + private String phone; + + + /** + * 地区 + */ + private String region; + + + /** + * 详细地址 + */ + private String detailAddress; + + + /** + * 用户id + */ + private Long userId; + + /** + * 是否为默认地址 + */ + private Integer isDefault; + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/dto/address/AddressUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/address/AddressUpdateRequest.java new file mode 100644 index 0000000..7f72468 --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/dto/address/AddressUpdateRequest.java @@ -0,0 +1,53 @@ +package com.cultural.heritage.model.dto.address; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class AddressUpdateRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 联系人 + */ + private String name; + + + /** + * 手机号 + */ + private String phone; + + + /** + * 地区 + */ + private String region; + + + /** + * 详细地址 + */ + private String detailAddress; + + + /** + * 用户id + */ + private Long userId; + + /** + * 是否为默认地址 + */ + private Integer isDefault; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/dto/file/UploadFileRequest.java b/src/main/java/com/cultural/heritage/model/dto/file/UploadFileRequest.java new file mode 100644 index 0000000..da7737d --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/dto/file/UploadFileRequest.java @@ -0,0 +1,19 @@ +package com.cultural.heritage.model.dto.file; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class UploadFileRequest implements Serializable { + + /** + * 业务 + */ + private String biz; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java index a3a8235..64cdef3 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java @@ -63,6 +63,13 @@ public class GoodUpdateRequest implements Serializable { */ private Integer festivalOrder; + + /** + * 是否上架 + */ + private Integer isShelves; + + @TableField(exist = false) private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/cultural/heritage/model/entity/Address.java b/src/main/java/com/cultural/heritage/model/entity/Address.java new file mode 100644 index 0000000..989e840 --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/entity/Address.java @@ -0,0 +1,63 @@ +package com.cultural.heritage.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class Address implements Serializable { + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + + /** + * 联系人 + */ + private String name; + + + /** + * 手机号 + */ + private String phone; + + + /** + * 地区 + */ + private String region; + + + /** + * 详细地址 + */ + private String detailAddress; + + + /** + * 用户id + */ + private Long userId; + + /** + * 是否删除 + */ + private Integer isDelete; + + + /** + * 是否为默认地址 + */ + private Integer isDefault; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/enums/FileUploadBizEnum.java b/src/main/java/com/cultural/heritage/model/enums/FileUploadBizEnum.java new file mode 100644 index 0000000..ca37a61 --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/enums/FileUploadBizEnum.java @@ -0,0 +1,58 @@ +package com.cultural.heritage.model.enums; + +import lombok.Getter; +import org.springframework.util.ObjectUtils; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 文件上传业务类型枚举 + */ + +@Getter +public enum FileUploadBizEnum { + + USER_AVATAR("头像", "user_avatar"), + + GOOD_IMAGE("商品", "good"), + + SYSTEM_IMAGE("系统", "system"), + + TEST_IMAGE("测试", "test"); + + private final String text; + + private final String value; + + FileUploadBizEnum(String text, String value) { + this.text = text; + this.value = value; + } + + + /** + * 获取值列表 + */ + public static List getValues() { + return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList()); + } + + /** + * 根据 value 获取枚举 + */ + public static FileUploadBizEnum getEnumByValue(String value) { + if (ObjectUtils.isEmpty(value)) { + return null; + } + for (FileUploadBizEnum anEnum : FileUploadBizEnum.values()) { + if (anEnum.value.equals(value)) { + return anEnum; + } + } + return null; + } + +} diff --git a/src/main/java/com/cultural/heritage/service/address/AddressService.java b/src/main/java/com/cultural/heritage/service/address/AddressService.java new file mode 100644 index 0000000..442068e --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/address/AddressService.java @@ -0,0 +1,8 @@ +package com.cultural.heritage.service.address; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.cultural.heritage.model.entity.Address; + +public interface AddressService extends IService
{ + +} diff --git a/src/main/java/com/cultural/heritage/service/address/impl/AddressServiceImpl.java b/src/main/java/com/cultural/heritage/service/address/impl/AddressServiceImpl.java new file mode 100644 index 0000000..681c3fe --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/address/impl/AddressServiceImpl.java @@ -0,0 +1,12 @@ +package com.cultural.heritage.service.address.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.cultural.heritage.mapper.AddressMapper; +import com.cultural.heritage.model.entity.Address; +import com.cultural.heritage.service.address.AddressService; +import org.springframework.stereotype.Service; + +@Service +public class AddressServiceImpl extends ServiceImpl implements AddressService { + +} diff --git a/src/main/java/com/cultural/heritage/service/file/IHweiYunOBSService.java b/src/main/java/com/cultural/heritage/service/file/IHweiYunOBSService.java new file mode 100644 index 0000000..f13014e --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/file/IHweiYunOBSService.java @@ -0,0 +1,42 @@ +package com.cultural.heritage.service.file; + +import org.springframework.web.multipart.MultipartFile; + +/** + * 华为云OBS服务接口 + */ +public interface IHweiYunOBSService { + + /** + * @Description 删除文件 + * @param: objectKey 文件名 + * @return: boolean 执行结果 + */ +// boolean delete(String objectKey); +// boolean deleteFileByPath(String objectKey); + + /** + * @Description 批量删除文件 + * @param: objectKeys 文件名集合 + * @return: boolean 执行结果 + */ +// boolean delete(List objectKeys); + + /** + * @Description 上传文件 + * @param: uploadFile 上传文件 + * @param: objectKey 文件名称 + * @return: java.lang.String url访问路径 + */ + String fileUpload(MultipartFile uploadFile, String objectKey); + +// String uploadFileByte(byte data[], String objectKey); +// String uploadFile(File file); +// +// /** +// * @Description 文件下载 +// * @param: objectKey +// * @return: java.io.InputStream +// */ +// InputStream fileDownload(String objectKey); +} diff --git a/src/main/java/com/cultural/heritage/service/file/impl/HweiYunOBSServiceImpl.java b/src/main/java/com/cultural/heritage/service/file/impl/HweiYunOBSServiceImpl.java new file mode 100644 index 0000000..9508fe2 --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/file/impl/HweiYunOBSServiceImpl.java @@ -0,0 +1,190 @@ +package com.cultural.heritage.service.file.impl; + +import com.cultural.heritage.config.HweiOBSConfig; +import com.cultural.heritage.service.file.IHweiYunOBSService; +import com.obs.services.ObsClient; +import com.obs.services.exception.ObsException; +import com.obs.services.model.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.InputStream; + + +/** + * 华为云OBS服务业务层 + */ + +@Service +@Slf4j +public class HweiYunOBSServiceImpl implements IHweiYunOBSService { + + + @Autowired + private HweiOBSConfig hweiOBSConfig; + +// @Override +// public boolean delete(String objectKey) { +// ObsClient obsClient = null; +// try { +// // 创建ObsClient实例 +// obsClient = hweiOBSConfig.getInstance(); +// // obs删除 +// obsClient.deleteObject(hweiOBSConfig.getBucketName(), objectKey); +// } catch (ObsException e) { +// } finally { +// hweiOBSConfig.destroy(obsClient); +// } +// return true; +// } + +// @Override +// public boolean deleteFileByPath(String path) { +// //path:https://wwwbak.obs.ap-southeast-1.myhuaweicloud.com/uploadFiles/xiehui/yongjiu/fujian/wode.jpg +// ObsClient obsClient = null; +// try { +// // 创建ObsClient实例 +// obsClient = hweiOBSConfig.getInstance(); +// +// String file_http_url = PropertiesUtil.readValue("file_http_url"); +// +// File file = new File(path); +// String key = file.getName();//wode.jpg +// +// //realPath : uploadFiles/xiehui/yongjiu/fujian +// String realPath = path.replace(file_http_url, ""); +// realPath = realPath.substring(0, realPath.lastIndexOf('/')); +// +// // obs删除 +// obsClient.deleteObject(hweiOBSConfig.getBucketName(), realPath + "/" + key); +// } catch (ObsException e) { +// } finally { +// hweiOBSConfig.destroy(obsClient); +// } +// return false; +// } + +// @Override +// public boolean delete(List objectKeys) { +// ObsClient obsClient = null; +// try { +// obsClient = hweiOBSConfig.getInstance(); +// DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(hweiOBSConfig.getBucketName()); +// objectKeys.forEach(x -> deleteObjectsRequest.addKeyAndVersion(x)); +// // 批量删除请求 +// obsClient.deleteObjects(deleteObjectsRequest); +// return true; +// } catch (ObsException e) { +// } finally { +// hweiOBSConfig.destroy(obsClient); +// } +// return false; +// } + + @Override + public String fileUpload(MultipartFile uploadFile, String objectKey) { + ObsClient obsClient = null; + try { + String bucketName = hweiOBSConfig.getBucketName(); + obsClient = hweiOBSConfig.getInstance(); + // 判断桶是否存在 + boolean exists = obsClient.headBucket(bucketName); + if (!exists) { + // 若不存在,则创建桶 + HeaderResponse response = obsClient.createBucket(bucketName); + } + InputStream inputStream = uploadFile.getInputStream(); + long available = inputStream.available(); + PutObjectRequest request = new PutObjectRequest(bucketName, objectKey, inputStream); + + ObjectMetadata objectMetadata = new ObjectMetadata(); + objectMetadata.setContentLength(available); + request.setMetadata(objectMetadata); + // 设置对象访问权限为公共读 + request.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ); + PutObjectResult result = obsClient.putObject(request); + // 读取该已上传对象的URL + return result.getObjectUrl(); + } catch (ObsException e) { + } catch (IOException e) { + } finally { + hweiOBSConfig.destroy(obsClient); + } + return null; + } + +// @Override +// public String uploadFileByte(byte[] data, String fileName) { +// try { +// ObsClient obsClient = null; +// String bucketName = hweiOBSConfig.getBucketName(); +// obsClient = hweiOBSConfig.getInstance(); +// // 判断桶是否存在 +// boolean exists = obsClient.headBucket(bucketName); +// if (!exists) { +// // 若不存在,则创建桶 +// HeaderResponse response = obsClient.createBucket(bucketName); +// } +// +// String file_http_url = PropertiesUtil.readValue("file_http_url"); +// +// //转为File +// InputStream inputStream = new ByteArrayInputStream(data); +// String prefix = fileName.substring(fileName.lastIndexOf(".") + 1);//后缀 +// String uuid = UUID.randomUUID().toString().replace("-", "");//customer_YYYYMMDDHHMM +// fileName = uuid + "." + prefix; //文件全路径 +// obsClient.putObject(bucketName, fileName.substring(0, fileName.lastIndexOf("/")) + "/" + fileName, inputStream); +// return file_http_url + fileName; +// } catch (ObsException e) { +// } +// return null; +// } + +// @Override +// public String uploadFile(File file) { +// ObsClient obsClient = null; +// try { +// String bucketName = hweiOBSConfig.getBucketName(); +// obsClient = hweiOBSConfig.getInstance(); +// // 判断桶是否存在 +// boolean exists = obsClient.headBucket(bucketName); +// if (!exists) { +// // 若不存在,则创建桶 +// HeaderResponse response = obsClient.createBucket(bucketName); +// } +// +// String file_http_url = PropertiesUtil.readValue("file_http_url"); +// +// //转为File +// String filename = file.getName(); +// String prefix = filename.substring(filename.lastIndexOf(".") + 1);//后缀 +// String uuid = UUID.randomUUID().toString().replace("-", "");//customer_YYYYMMDDHHMM +// String fileName = uuid + "." + prefix; //文件全路径 +// obsClient.putObject(bucketName, fileName.substring(0, fileName.lastIndexOf("/")) + "/" + fileName, file); +// return file_http_url + fileName; +// } catch (Exception e) { +// } finally { +// hweiOBSConfig.destroy(obsClient); +// } +// return null; +// } + +// @Override +// public InputStream fileDownload(String objectKey) { +// ObsClient obsClient = null; +// try { +// String bucketName = hweiOBSConfig.getBucketName(); +// obsClient = hweiOBSConfig.getInstance(); +// ObsObject obsObject = obsClient.getObject(bucketName, objectKey); +// return obsObject.getObjectContent(); +// } catch (ObsException e) { +// } finally { +// hweiOBSConfig.destroy(obsClient); +// } +// return null; +// } +} + diff --git a/src/main/java/com/cultural/heritage/service/good/CategoryService.java b/src/main/java/com/cultural/heritage/service/good/CategoryService.java new file mode 100644 index 0000000..b0c61cb --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/good/CategoryService.java @@ -0,0 +1,22 @@ +package com.cultural.heritage.service.good; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.cultural.heritage.model.entity.Category; + +import java.util.List; + + +public interface CategoryService extends IService { + + /** + * 获取类别名列表 + */ + + List getTypeNameList(); + + /** + * 根据id获取类别 + */ + Category getCategoryById(Long id); + +} diff --git a/src/main/java/com/cultural/heritage/service/operategood/GoodService.java b/src/main/java/com/cultural/heritage/service/good/GoodService.java similarity index 69% rename from src/main/java/com/cultural/heritage/service/operategood/GoodService.java rename to src/main/java/com/cultural/heritage/service/good/GoodService.java index 77ca689..a8a9a25 100644 --- a/src/main/java/com/cultural/heritage/service/operategood/GoodService.java +++ b/src/main/java/com/cultural/heritage/service/good/GoodService.java @@ -1,14 +1,22 @@ -package com.cultural.heritage.service.operategood; +package com.cultural.heritage.service.good; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.cultural.heritage.model.dto.good.GoodQueryRequest; import com.cultural.heritage.model.entity.Good; +import java.util.List; + public interface GoodService extends IService { /** * 获取查询条件 */ QueryWrapper getGoodQueryWrapper(GoodQueryRequest goodQueryRequest); + + + /** + * 根据商品类名查询商品列表 + */ + List getGoodListByTypeName(String typeName); } diff --git a/src/main/java/com/cultural/heritage/service/good/impl/CategoryServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/CategoryServiceImpl.java new file mode 100644 index 0000000..898255f --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/good/impl/CategoryServiceImpl.java @@ -0,0 +1,43 @@ +package com.cultural.heritage.service.good.impl; + +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.exception.BusinessException; +import com.cultural.heritage.mapper.CategoryMapper; +import com.cultural.heritage.model.entity.Category; +import com.cultural.heritage.service.good.CategoryService; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CategoryServiceImpl extends ServiceImpl implements CategoryService { + + /** + * 获取类别名列表 + */ + @Override + public List getTypeNameList() { + List list = this.list(); + List collect = list.stream().map(Category::getTypeName).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + return new ArrayList<>(); + } + return collect; + } + + @Override + public Category getCategoryById(Long id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", id); + Category category = this.baseMapper.selectOne(queryWrapper); + if (category == null) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); + } + return category; + } +} diff --git a/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java similarity index 74% rename from src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java rename to src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java index f3492fc..726f995 100644 --- a/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java @@ -1,4 +1,4 @@ -package com.cultural.heritage.service.operategood.impl; +package com.cultural.heritage.service.good.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -8,15 +8,21 @@ import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.mapper.GoodMapper; import com.cultural.heritage.model.dto.good.GoodQueryRequest; import com.cultural.heritage.model.entity.Good; -import com.cultural.heritage.model.entity.User; -import com.cultural.heritage.service.operategood.GoodService; +import com.cultural.heritage.service.good.GoodService; import com.cultural.heritage.utils.SqlUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; @Service public class GoodServiceImpl extends ServiceImpl implements GoodService { + /** + * 商品查询条件 + */ @Override public QueryWrapper getGoodQueryWrapper(GoodQueryRequest goodQueryRequest) { if (goodQueryRequest == null) { @@ -41,4 +47,19 @@ public class GoodServiceImpl extends ServiceImpl implements Go return queryWrapper; } + + /** + * 根据商品类名查询商品列表 + */ + @Override + public List getGoodListByTypeName(String typeName) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("type", typeName); + List list = this.list(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list; + } + } diff --git a/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java b/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java deleted file mode 100644 index 25e0250..0000000 --- a/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.cultural.heritage.service.operategood; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.cultural.heritage.model.entity.Category; - - -public interface CategoryService extends IService { - -} diff --git a/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java b/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java deleted file mode 100644 index ff6cef5..0000000 --- a/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.cultural.heritage.service.operategood.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.cultural.heritage.mapper.CategoryMapper; -import com.cultural.heritage.model.entity.Category; -import com.cultural.heritage.service.operategood.CategoryService; -import org.springframework.stereotype.Service; - -@Service -public class CategoryServiceImpl extends ServiceImpl implements CategoryService { -} diff --git a/src/main/java/com/cultural/heritage/service/userinfo/UserService.java b/src/main/java/com/cultural/heritage/service/user/UserService.java similarity index 95% rename from src/main/java/com/cultural/heritage/service/userinfo/UserService.java rename to src/main/java/com/cultural/heritage/service/user/UserService.java index 13a04cc..89a99a7 100644 --- a/src/main/java/com/cultural/heritage/service/userinfo/UserService.java +++ b/src/main/java/com/cultural/heritage/service/user/UserService.java @@ -1,4 +1,4 @@ -package com.cultural.heritage.service.userinfo; +package com.cultural.heritage.service.user; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; diff --git a/src/main/java/com/cultural/heritage/service/userinfo/impl/UserServiceImpl.java b/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java similarity index 97% rename from src/main/java/com/cultural/heritage/service/userinfo/impl/UserServiceImpl.java rename to src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java index 5949d28..3578d49 100644 --- a/src/main/java/com/cultural/heritage/service/userinfo/impl/UserServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java @@ -1,4 +1,4 @@ -package com.cultural.heritage.service.userinfo.impl; +package com.cultural.heritage.service.user.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -10,7 +10,7 @@ import com.cultural.heritage.model.dto.user.UserQueryRequest; import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.enums.UserRoleEnum; import com.cultural.heritage.model.vo.UserVO; -import com.cultural.heritage.service.userinfo.UserService; +import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.utils.SqlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; @@ -97,7 +97,6 @@ public class UserServiceImpl extends ServiceImpl implements Us if (currentUser == null || currentUser.getId() == null) { throw new BusinessException(ErrorCode.NOT_LOGIN_ERROR); } - //根据id进行查询 Long userId = currentUser.getId(); currentUser = this.getById(userId); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9f28e7c..8378262 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,9 +9,13 @@ spring: port: 6379 host: localhost database: 0 + servlet: + multipart: + max-file-size: 10MB - +springdoc: + default-flat-param-object: true server: @@ -27,6 +31,16 @@ mybatis-plus: mapper-locations: classpath:mapper/*.xml configuration: map-underscore-to-camel-case: false + global-config: + db-config: + logic-delete-field: isDelete #全局逻辑删除的实体字段名 + logic-delete-value: 1 #逻辑已删除值(默认为1) + logic-not-delete-value: 0 #逻辑未删除值(默认为0) - +hwyun: + obs: + accessKey: TEA5FAYCZDUSCEJP8NKX + securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec + endPoint: obs.cn-north-4.myhuaweicloud.com + bucketName: carbon2 diff --git a/src/main/resources/mapper/AddressMapper.xml b/src/main/resources/mapper/AddressMapper.xml new file mode 100644 index 0000000..44665be --- /dev/null +++ b/src/main/resources/mapper/AddressMapper.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file