From c761a849913392c77a874bc456cc18de5a6d258a Mon Sep 17 00:00:00 2001 From: tsukiyalo <2450026988@qq.com> Date: Fri, 18 Oct 2024 15:31:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- school_lend_back_end/.gitignore | 33 ++ school_lend_back_end/pom.xml | 136 +++++++ school_lend_back_end/sql/create_table.sql | 237 +++++++++++ .../UserCenterApplication.java | 15 + .../annotation/AuthCheck.java | 21 + .../annotation/SystemLog.java | 19 + .../aop/AuthInterceptor.java | 75 ++++ .../aop/SystemLogInterceptor.java | 67 +++ .../common/BaseResponse.java | 49 +++ .../common/ErrorCode.java | 48 +++ .../common/ResultUtils.java | 68 ++++ .../config/AliPayNotifyHandler.java | 42 ++ .../config/AlipayClients.java | 39 ++ .../config/CorsConfig.java | 28 ++ .../config/JsonConfig.java | 28 ++ .../config/Knife4jConfig.java | 53 +++ .../config/MyBatisPlusConfig.java | 27 ++ .../contant/CommonConstant.java | 18 + .../contant/FileConstant.java | 24 ++ .../contant/RegexConstant.java | 32 ++ .../contant/SystemLogConstant.java | 37 ++ .../contant/UserConstant.java | 44 ++ .../controller/AlipayController.java | 338 ++++++++++++++++ .../controller/BusinessController.java | 221 ++++++++++ .../controller/CartController.java | 196 +++++++++ .../controller/CategoryController.java | 118 ++++++ .../controller/DishesController.java | 207 ++++++++++ .../controller/DishesGroupController.java | 156 +++++++ .../controller/FileController.java | 147 +++++++ .../controller/OrdersController.java | 327 +++++++++++++++ .../controller/OssController.java | 41 ++ .../controller/SpecificationsController.java | 149 +++++++ .../controller/SystemInfoController.java | 77 ++++ .../controller/SystemLogController.java | 86 ++++ .../controller/UserController.java | 381 ++++++++++++++++++ .../exception/BusinessException.java | 49 +++ .../exception/GlobalExceptionHandler.java | 30 ++ .../exception/ThrowUtils.java | 44 ++ .../mapper/AttributeMapper.java | 15 + .../mapper/BusinessAuthMapper.java | 18 + .../mapper/BusinessMapper.java | 18 + .../mapper/CartMapper.java | 18 + .../mapper/CategoryMapper.java | 18 + .../mapper/DishesGroupMapper.java | 15 + .../mapper/DishesMapper.java | 19 + .../mapper/OrderDetailsMapper.java | 18 + .../mapper/OrdersMapper.java | 18 + .../mapper/SpecificationsDishesMapper.java | 18 + .../mapper/SpecificationsMapper.java | 18 + .../mapper/SysteminfoMapper.java | 18 + .../mapper/SystemlogMapper.java | 18 + .../mapper/UserMapper.java | 21 + .../model/domain/Attribute.java | 59 +++ .../model/domain/Business.java | 106 +++++ .../model/domain/BusinessAuth.java | 72 ++++ .../model/domain/Cart.java | 80 ++++ .../model/domain/Category.java | 46 +++ .../model/domain/Dishes.java | 83 ++++ .../model/domain/DishesGroup.java | 57 +++ .../model/domain/OrderDetails.java | 73 ++++ .../model/domain/Orders.java | 97 +++++ .../model/domain/Specifications.java | 52 +++ .../model/domain/SpecificationsDishes.java | 53 +++ .../model/domain/Systeminfo.java | 41 ++ .../model/domain/Systemlog.java | 46 +++ .../model/domain/User.java | 96 +++++ .../model/dto/CommonRequest.java | 20 + .../model/dto/Dishes/DishesAddRequest.java | 61 +++ .../model/dto/Dishes/DishesDeleteRequest.java | 18 + .../model/dto/Dishes/DishesQueryRequest.java | 33 ++ .../model/dto/Dishes/DishesUpdateRequest.java | 64 +++ .../DishesGroup/DishesGroupAddRequest.java | 23 ++ .../DishesGroup/DishesGroupDeleteRequest.java | 18 + .../DishesGroup/DishesGroupQueryRequest.java | 18 + .../DishesGroup/DishesGroupUpdateRequest.java | 28 ++ .../model/dto/PageRequest.java | 33 ++ .../dto/attribute/AttributeAddRequest.java | 29 ++ .../dto/attribute/AttributeUpdateRequest.java | 31 ++ .../dto/business/BusinessAddRequest.java | 98 +++++ .../dto/business/BusinessQueryRequest.java | 61 +++ .../dto/business/BusinessUpdateMyRequest.java | 66 +++ .../dto/business/BusinessUpdateRequest.java | 83 ++++ .../model/dto/cart/CartAddRequest.java | 36 ++ .../model/dto/cart/CartDeleteRequest.java | 21 + .../model/dto/cart/CartQueryRequest.java | 21 + .../model/dto/cart/CartUpdateRequest.java | 42 ++ .../dto/category/CategoryAddRequest.java | 23 ++ .../dto/category/CategoryDeleteRequest.java | 18 + .../dto/category/CategoryUpdateRequest.java | 30 ++ .../model/dto/file/UploadFileRequest.java | 19 + .../model/dto/log/LogQueryRequest.java | 47 +++ .../model/dto/order/MyOrderQueryRequest.java | 44 ++ .../model/dto/order/OrderAddRequest.java | 63 +++ .../model/dto/order/OrderCountRequest.java | 48 +++ .../dto/order/OrderDetailAddRequest.java | 33 ++ .../model/dto/order/OrderQueryRequest.java | 58 +++ .../SpecificationsAddRequest.java | 25 ++ .../SpecificationsMyQueryRequest.java | 21 + .../SpecificationsQueryRequest.java | 21 + .../SpecificationsUpdateRequest.java | 30 ++ .../model/dto/system/SystemAddRequest.java | 23 ++ .../model/dto/system/SystemDeleteRequest.java | 18 + .../model/dto/system/SystemQueryRequest.java | 18 + .../model/dto/user/UserAddRequest.java | 45 +++ .../model/dto/user/UserDeleteRequest.java | 21 + .../model/dto/user/UserLoginRequest.java | 25 ++ .../model/dto/user/UserQueryRequest.java | 46 +++ .../model/dto/user/UserRegisterRequest.java | 30 ++ .../model/dto/user/UserSearchRequest.java | 67 +++ .../model/dto/user/UserUpdateMyRequest.java | 42 ++ .../dto/user/UserUpdatePasswordRequest.java | 25 ++ .../model/dto/user/UserUpdateRequest.java | 69 ++++ .../model/enums/FileUploadBizEnum.java | 53 +++ .../model/enums/UserRoleEnum.java | 51 +++ .../model/vo/AttributeVO.java | 28 ++ .../model/vo/BusinessAdminVO.java | 119 ++++++ .../model/vo/BusinessLogVO.java | 43 ++ .../model/vo/BusinessVO.java | 89 ++++ .../school_send_back_end/model/vo/CartVO.java | 55 +++ .../model/vo/DishesGroupVO.java | 21 + .../model/vo/DishesVO.java | 40 ++ .../model/vo/LoginUserVO.java | 60 +++ .../model/vo/OrderDetailsVO.java | 69 ++++ .../model/vo/OrdersVO.java | 105 +++++ .../model/vo/SpecificationsVO.java | 29 ++ .../service/AttributeService.java | 37 ++ .../service/BusinessAuthService.java | 22 + .../service/BusinessService.java | 55 +++ .../service/CartService.java | 39 ++ .../service/CategoryService.java | 17 + .../service/DishesGroupService.java | 34 ++ .../service/DishesService.java | 51 +++ .../service/OrderDetailsService.java | 34 ++ .../service/OrdersService.java | 44 ++ .../service/OssService.java | 17 + .../service/SpecificationsDishesService.java | 35 ++ .../service/SpecificationsService.java | 36 ++ .../service/SysteminfoService.java | 13 + .../service/SystemlogService.java | 20 + .../service/UserService.java | 93 +++++ .../service/impl/AttributeServiceImpl.java | 136 +++++++ .../service/impl/BusinessAuthServiceImpl.java | 54 +++ .../service/impl/BusinessServiceImpl.java | 204 ++++++++++ .../service/impl/CartServiceImpl.java | 138 +++++++ .../service/impl/CategoryServiceImpl.java | 46 +++ .../service/impl/DishesGroupServiceImpl.java | 137 +++++++ .../service/impl/DishesServiceImpl.java | 169 ++++++++ .../service/impl/OrderDetailsServiceImpl.java | 82 ++++ .../service/impl/OrdersServiceImpl.java | 163 ++++++++ .../service/impl/OssServiceImpl.java | 78 ++++ .../impl/SpecificationsDishesServiceImpl.java | 85 ++++ .../impl/SpecificationsServiceImpl.java | 101 +++++ .../service/impl/SysteminfoServiceImpl.java | 22 + .../service/impl/SystemlogServiceImpl.java | 45 +++ .../service/impl/UserServiceImpl.java | 362 +++++++++++++++++ .../utils/AlipayUtils.java | 36 ++ .../utils/ConstantPropertiesUtil.java | 35 ++ .../utils/RandomNumberGenerator.java | 14 + .../utils/RegexUtils.java | 60 +++ .../school_send_back_end/utils/SqlUtils.java | 27 ++ .../src/main/resources/application.yml | 53 +++ .../main/resources/mapper/AttributeMapper.xml | 22 + .../resources/mapper/BusinessAuthMapper.xml | 26 ++ .../main/resources/mapper/BusinessMapper.xml | 33 ++ .../src/main/resources/mapper/CartMapper.xml | 27 ++ .../main/resources/mapper/CategoryMapper.xml | 19 + .../resources/mapper/DishesGroupMapper.xml | 21 + .../main/resources/mapper/DishesMapper.xml | 28 ++ .../resources/mapper/OrderDetailsMapper.xml | 26 ++ .../main/resources/mapper/OrdersMapper.xml | 33 ++ .../mapper/SpecificationsDishesMapper.xml | 20 + .../resources/mapper/SpecificationsMapper.xml | 20 + .../resources/mapper/SysteminfoMapper.xml | 18 + .../main/resources/mapper/SystemlogMapper.xml | 19 + .../src/main/resources/mapper/UserMapper.xml | 36 ++ .../src/main/resources/static/index.html | 6 + .../UserCenterApplicationTests.java | 13 + .../controller/UserControllerTest.java | 27 ++ .../dto/business/BusinessAddRequest.java | 4 + .../service/UserServiceTest.java | 55 +++ 180 files changed, 10440 insertions(+) create mode 100644 school_lend_back_end/.gitignore create mode 100644 school_lend_back_end/pom.xml create mode 100644 school_lend_back_end/sql/create_table.sql create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/UserCenterApplication.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/AuthCheck.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/SystemLog.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/AuthInterceptor.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/SystemLogInterceptor.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/BaseResponse.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ErrorCode.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ResultUtils.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AliPayNotifyHandler.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AlipayClients.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/CorsConfig.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/JsonConfig.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/Knife4jConfig.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/MyBatisPlusConfig.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/CommonConstant.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/FileConstant.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/RegexConstant.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/SystemLogConstant.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/UserConstant.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/AlipayController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/BusinessController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CartController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CategoryController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesGroupController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/FileController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OrdersController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OssController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SpecificationsController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemInfoController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemLogController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/UserController.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/BusinessException.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/GlobalExceptionHandler.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/ThrowUtils.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/AttributeMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessAuthMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CartMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CategoryMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesGroupMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrderDetailsMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrdersMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsDishesMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SysteminfoMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SystemlogMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/UserMapper.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Attribute.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Business.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/BusinessAuth.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Cart.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Category.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Dishes.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/DishesGroup.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/OrderDetails.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Orders.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Specifications.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/SpecificationsDishes.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systeminfo.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systemlog.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/User.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/CommonRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/PageRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateMyRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/file/UploadFileRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/log/LogQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/MyOrderQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderCountRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderDetailAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsMyQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserAddRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserDeleteRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserLoginRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserQueryRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserRegisterRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserSearchRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateMyRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdatePasswordRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateRequest.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/FileUploadBizEnum.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/UserRoleEnum.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/AttributeVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessAdminVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessLogVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/CartVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesGroupVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/LoginUserVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrderDetailsVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrdersVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/SpecificationsVO.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/AttributeService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessAuthService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CartService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CategoryService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesGroupService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrderDetailsService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrdersService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OssService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsDishesService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SysteminfoService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SystemlogService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/UserService.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/AttributeServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessAuthServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CartServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CategoryServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesGroupServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrderDetailsServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrdersServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OssServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsDishesServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SysteminfoServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SystemlogServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/UserServiceImpl.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/AlipayUtils.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/ConstantPropertiesUtil.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RandomNumberGenerator.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RegexUtils.java create mode 100644 school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/SqlUtils.java create mode 100644 school_lend_back_end/src/main/resources/application.yml create mode 100644 school_lend_back_end/src/main/resources/mapper/AttributeMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/BusinessAuthMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/BusinessMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/CartMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/CategoryMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/DishesGroupMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/DishesMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/OrderDetailsMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/OrdersMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/SpecificationsDishesMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/SpecificationsMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/SysteminfoMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/SystemlogMapper.xml create mode 100644 school_lend_back_end/src/main/resources/mapper/UserMapper.xml create mode 100644 school_lend_back_end/src/main/resources/static/index.html create mode 100644 school_lend_back_end/src/test/java/com/bsz/school_send_back_end/UserCenterApplicationTests.java create mode 100644 school_lend_back_end/src/test/java/com/bsz/school_send_back_end/controller/UserControllerTest.java create mode 100644 school_lend_back_end/src/test/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java create mode 100644 school_lend_back_end/src/test/java/com/bsz/school_send_back_end/service/UserServiceTest.java diff --git a/school_lend_back_end/.gitignore b/school_lend_back_end/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/school_lend_back_end/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/school_lend_back_end/pom.xml b/school_lend_back_end/pom.xml new file mode 100644 index 0000000..677ef1d --- /dev/null +++ b/school_lend_back_end/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.4 + + + com.bsz + school_send_back_end + 0.0.1-SNAPSHOT + school_send_back_end + school_send_back_end + + 21 + + + + org.springframework.boot + spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.2 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.1 + + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + com.alipay.sdk + alipay-sdk-java + 4.38.0.ALL + + + cn.hutool + hutool-all + 5.8.16 + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.aliyun.oss + aliyun-sdk-oss + 3.15.1 + + + + joda-time + joda-time + 2.10.1 + + + + + com.github.xiaoymin + knife4j-spring-boot-starter + 3.0.3 + + + + junit + junit + 4.13.2 + test + + + org.aspectj + aspectjtools + 1.9.21 + + + org.projectlombok + lombok + 1.18.30 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.6.4 + + + + org.projectlombok + lombok + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + + + + + + diff --git a/school_lend_back_end/sql/create_table.sql b/school_lend_back_end/sql/create_table.sql new file mode 100644 index 0000000..dd2a774 --- /dev/null +++ b/school_lend_back_end/sql/create_table.sql @@ -0,0 +1,237 @@ +create database school_send; + +use school_send; + +create table user +( + username varchar(256) null comment '用户昵称', + id bigint auto_increment comment 'id' + primary key, + unionId varchar(256) null comment '支付宝开放平台id', + openId varchar(256) null comment 'openId', + userAccount varchar(256) null comment '账号', + avatarUrl varchar(256) null comment '用户头像', + gender tinyint null comment '性别', + userPassword varchar(512) not null comment '密码', + phone varchar(128) null comment '电话', + email varchar(512) null comment '邮箱', + userStatus int default 0 not null comment '状态 0 -正常', + createTime datetime default CURRENT_TIMESTAMP null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP, + isDelete tinyint default 0 not null comment '是否删除', + userRole varchar(256) default 'user' not null comment 'user-普通用户,business-商家,admin-管理员', + index idx_openId (openId) +) comment '用户' collate = utf8mb4_unicode_ci; + +-- 商家表 +create table if not exists business +( + id bigint auto_increment comment 'id' primary key, + userId bigint not null comment '用户id', + businessName varchar(512) not null comment '门店名称', + businessAvatar varchar(1024) not null comment '门店头像', + businessPhone varchar(64) not null comment '门店手机号', + address varchar(512) not null comment '店铺详细地址', + businessProfile varchar(512) null comment '门店简介', + businessImages varchar(1024) null comment '商家相册', + categoryId bigint null comment '分类id', + startBusiness varchar(64) not null comment '开始营业时间', + endBusiness varchar(64) not null comment '结束营业时间', + state tinyint default 0 not null comment '状态:0审核中,1启用,2禁用', + storeStatus tinyint default 0 not null comment '店铺状态:0休业,1营业', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (id), + index idx_userId (userId) +) comment '商家' collate = utf8mb4_unicode_ci; + +-- 商家认证表 +create table if not exists business_auth +( + id bigint auto_increment comment 'id' primary key, + businessId bigint not null comment '店铺id', + shopkeeper varchar(64) not null comment '店主名', + license varchar(1024) not null comment '营业执照', + frontIdCard varchar(1024) not null comment '身份证正面', + backIdCard varchar(1024) not null comment '身份证反面', + bankCard varchar(64) not null comment '银行卡号', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (businessId) +) comment '商家认证' collate = utf8mb4_unicode_ci; + +-- 系统 +-- 分类表 +create table if not exists category +( + id bigint auto_increment comment 'id' primary key, + name varchar(256) not null comment '分类名', + image varchar(512) not null comment '分类图片', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + index idx_categoryId (id) +) comment '分类表' collate = utf8mb4_unicode_ci; + +-- 系统信息表 +create table if not exists systemInfo +( + id bigint auto_increment comment 'id' primary key, + type tinyint not null comment '类型:0公告,1轮播图', + content varchar(256) not null comment '功能内容', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间' +) comment '系统信息' collate = utf8mb4_unicode_ci; + +-- 操作日志表 +create table if not exists systemLog +( + id bigint auto_increment comment 'id' primary key, + userId bigint not null comment '用户id', + content varchar(256) not null comment '操作内容', + ip varchar(64) not null comment 'ip地址', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + index idx_businessId (userId) +) comment '系统信息' collate = utf8mb4_unicode_ci; + +-- 菜品 +-- 菜品分组表 +create table if not exists dishes_group +( + id bigint auto_increment comment 'id' primary key, + businessId bigint not null comment '商家id', + groupName varchar(128) not null comment '菜品分组名称', + isTopping tinyint default 0 not null comment '是否置顶:0不置顶,1置顶', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (businessId) +) comment '菜品分组表' collate = utf8mb4_unicode_ci; + +-- 菜品表 +create table if not exists dishes +( + id bigint auto_increment comment 'id' primary key, + businessId bigint not null comment '商家id', + dishesGroupId bigint not null comment '菜品分组id', + dishesName varchar(128) not null comment '菜品名称', + dishesImage varchar(1024) null comment '菜品图片', + dishesPrice double not null comment '菜品价格', + packPrice double not null comment '打包费', + inventoryStatus int not null comment '库存数量', + status varchar(20) default '上架' not null comment '菜品状态:上架,下架', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (businessId) +) comment '菜品表' collate = utf8mb4_unicode_ci; + +-- 菜品和规格的中间表 +create table if not exists specifications_dishes +( + id bigint auto_increment comment 'id' primary key, + dishesId bigint not null comment '菜品id', + specificationsId bigint not null comment '规格id', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_dishesId (dishesId), + index idx_specificationsId (specificationsId) +) comment '菜品和规格的中间表' collate = utf8mb4_unicode_ci; + +-- 规格表 +create table if not exists specifications +( + id bigint auto_increment comment 'id' primary key, + businessId bigint not null comment '商家id', + specificationsName varchar(128) not null comment '规格名称', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (businessId) +) comment '规格表' collate = utf8mb4_unicode_ci; + +-- 属性表 +create table if not exists attribute +( + id bigint auto_increment comment 'id' primary key, + businessId bigint not null comment '商家id', + specificationsId bigint not null comment '规格id', + attributeName varchar(128) not null comment '属性名称', + attributeStatus tinyint default 0 not null comment '属性状态:0在售,1停售', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + index idx_businessId (businessId) +) comment '属性表' collate = utf8mb4_unicode_ci; + +-- 订单 +-- 订单表 +create table if not exists orders +( + id bigint auto_increment comment 'id' primary key, + pickupCode varchar(64) null comment '取餐码', + userName varchar(256) not null comment '姓名', + phone varchar(64) not null comment '手机号', + userId bigint not null comment '下单用户id', + businessId bigint not null comment '商家id', + totalPrice decimal(10, 2) not null comment '订单实际总价', + pickupMethod tinyint not null comment '取餐方式(0堂食 1自提)', + payMethod tinyint not null comment '支付方式:0微信支付', + pickupTime datetime null comment '取餐时间', + notes varchar(128) null comment '备注', + state tinyint default 0 not null comment '订单状态:0未支付 1已完成 2已退款 3已取消', + createTime datetime default CURRENT_TIMESTAMP not null comment '下单时间', + updateTime datetime default CURRENT_TIMESTAMP not null comment '支付时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_businessId (businessId), + index idx_stateId (state) +) comment '订单表' collate = utf8mb4_unicode_ci; + +-- 订单详情表 +create table if not exists order_details +( + id bigint auto_increment comment 'id' primary key, + orderId bigint not null comment '关联的订单id', + dishesId bigint not null comment '关联的菜品id', + quantity int not null comment '购买数量', + price decimal(10, 2) not null comment '单价', + subtotal decimal(10, 2) not null comment '小计(单价 * 数量)', + attributeNames varchar(512) null comment '规格属性列表', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + isDelete tinyint default 0 not null comment '是否删除', + index idx_orderId (orderId) +) comment '订单详情表' collate = utf8mb4_unicode_ci; +-- 购物车表 +create table if not exists cart +( + id bigint auto_increment comment 'id' primary key, + userId bigint not null comment '用户id', + businessId bigint not null comment '商家id', + createTime datetime default CURRENT_TIMESTAMP not null comment '加入购物车时间', + updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', + dishesId bigint null comment '菜品id', + quantity int default 1 not null comment '商品数量', + price decimal(10, 2) not null comment '当前选择规格的价格', + subtotal decimal(10, 2) as ((`price` * `quantity`)) stored comment '小计(单价 * 数量)', + selectedOptions varchar(512) default '' not null comment '已选规格属性列表', + isDelete tinyint default 0 not null comment '是否删除', + index idx_userId (userId), + index idx_businessId (businessId) +) comment '购物车表' collate = utf8mb4_unicode_ci; + + +create table demo( + id int auto_increment primary key , + name varchar(30) comment '姓名', + detail varchar(256) comment '详情' +); + +-- 系统信息表 +create table if not exists systemInfo +( + id bigint auto_increment comment 'id' primary key, + type tinyint not null comment '类型:0公告,1轮播图', + content varchar(256) not null comment '功能内容', + createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间' +) comment '系统信息' collate = utf8mb4_unicode_ci; \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/UserCenterApplication.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/UserCenterApplication.java new file mode 100644 index 0000000..28c5330 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/UserCenterApplication.java @@ -0,0 +1,15 @@ +package com.bsz.school_send_back_end; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@MapperScan("com.bsz.school_send_back_end.mapper") +@SpringBootApplication +public class UserCenterApplication { + + public static void main(String[] args) { + SpringApplication.run(UserCenterApplication.class, args); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/AuthCheck.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/AuthCheck.java new file mode 100644 index 0000000..793da80 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/AuthCheck.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 权限校验 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AuthCheck { + + /** + * 必须有某个角色 + * @return + */ + String mustRole() default ""; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/SystemLog.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/SystemLog.java new file mode 100644 index 0000000..892175e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/annotation/SystemLog.java @@ -0,0 +1,19 @@ +package com.bsz.school_send_back_end.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 系统日志 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface SystemLog { + + /** + * 操作步骤 + */ + String executeStep() default ""; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/AuthInterceptor.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/AuthInterceptor.java new file mode 100644 index 0000000..4095d48 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/AuthInterceptor.java @@ -0,0 +1,75 @@ +package com.bsz.school_send_back_end.aop; + +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.enums.UserRoleEnum; +import com.bsz.school_send_back_end.service.UserService; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +/** + * 权限校验 AOP + */ +@Aspect +@Component +public class AuthInterceptor { + + @Resource + private UserService userService; + + /** + * 执行拦截 + */ + @Around("@annotation(authCheck)") + public Object doInterceptor(ProceedingJoinPoint joinPoint, AuthCheck authCheck) throws Throwable { + String mustRole = authCheck.mustRole(); + RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); + HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); + // 当前登录用户 + User loginUser = userService.getLoginUser(request); + // 必须有该权限才通过 + UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValue(mustRole); + + String userRole = loginUser.getUserRole(); + // 如果被封号,直接拒绝 + if (UserRoleEnum.BAN.equals(UserRoleEnum.getEnumByValue(userRole))) { + throw new BusinessException(ErrorCode.NO_AUTH); + } + + // 必须有Boss权限 + if (UserRoleEnum.BOSS.equals(mustUserRoleEnum)) { + if (!mustRole.equals(userRole)) { + throw new BusinessException(ErrorCode.NO_AUTH); + } + } + + // 必须有管理员权限 + if (UserRoleEnum.ADMIN.equals(mustUserRoleEnum)) { + if (!mustRole.equals(userRole) && !UserConstant.BOSS_ROLE.equals(userRole)) { + throw new BusinessException(ErrorCode.NO_AUTH); + } + } + // 必须有商家或管理员权限 + if (UserRoleEnum.BUSINESS.equals(mustUserRoleEnum)) { + if (!mustRole.equals(userRole) + && !UserConstant.ADMIN_ROLE.equals(userRole) + &&!UserConstant.BOSS_ROLE.equals(userRole)) { + throw new BusinessException(ErrorCode.NO_AUTH); + } + } + + // 通过权限校验,放行 + return joinPoint.proceed(); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/SystemLogInterceptor.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/SystemLogInterceptor.java new file mode 100644 index 0000000..b61663a --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/aop/SystemLogInterceptor.java @@ -0,0 +1,67 @@ +package com.bsz.school_send_back_end.aop; + + +import com.bsz.school_send_back_end.annotation.SystemLog; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Systemlog; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.service.SystemlogService; +import com.bsz.school_send_back_end.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +/** + * 日志AOP + */ +@Slf4j +@Aspect +@Component +public class SystemLogInterceptor { + + @Resource + private UserService userService; + + @Resource + private SystemlogService systemlogService; + + /** + * 执行拦截 + */ + @Around("@annotation(systemLog)") + public Object doInterceptor(ProceedingJoinPoint joinPoint, SystemLog systemLog) throws Throwable { + // 获取执行操作 + String executeStep = systemLog.executeStep(); + ThrowUtils.throwIf(StringUtils.isEmpty(executeStep), ErrorCode.PARAMS_ERROR); + //获取请求 + RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); + HttpServletRequest httpServletRequest = ((ServletRequestAttributes) requestAttributes).getRequest(); + //获取登录用户 + User loginUser = userService.getLoginUser(httpServletRequest); + //写入系统日志 + Systemlog systemlog = new Systemlog(); + systemlog.setUserId(loginUser.getId()); + systemlog.setContent(executeStep); + systemlog.setIp(httpServletRequest.getRemoteHost()); + boolean save = systemlogService.save(systemlog); + if (!save) { + log.error("操作日志写入失败,执行操作:" + executeStep); + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "操作日志写入失败"); + } + + // 放行 + return joinPoint.proceed(); + } + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/BaseResponse.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/BaseResponse.java new file mode 100644 index 0000000..74fe95e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/BaseResponse.java @@ -0,0 +1,49 @@ +package com.bsz.school_send_back_end.common; + +import lombok.Data; + +import java.io.Serializable; + +/** + *通用返回类 + * + * @author bsz + */ +@Data +public class BaseResponse implements Serializable { + /** + * 状态码 + */ + private int code; + /** + * 数据 + */ + private T data; + /** + * 消息 + */ + private String message; + /** + * 描述 + */ + private String description; + + public BaseResponse(int code, T data, String message, String description) { + this.code = code; + this.data = data; + this.message = message; + this.description = description; + } + + public BaseResponse(int code, T data, String message) { + this(code, data, message, ""); + } + + public BaseResponse(int code, T data) { + this(code, data, "", ""); + } + + public BaseResponse(ErrorCode errorCode) { + this(errorCode.getCode(), null , errorCode.getMessage(), errorCode.getDescription()); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ErrorCode.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ErrorCode.java new file mode 100644 index 0000000..7a82eac --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ErrorCode.java @@ -0,0 +1,48 @@ +package com.bsz.school_send_back_end.common; + + +/** + * 错误码 + */ +public enum ErrorCode { + + SUCCESS(0, "ok", ""), + PARAMS_ERROR(40000, "请求参数错误", ""), + NULL_ERROR(40001, "请求数据为空", ""), + NOT_LOGIN(40100, "未登录", ""), + NO_AUTH(40101, "无权限", ""), + NOT_FOUND_ERROR(40400,"请求数据不存在",""), + SYSTEM_ERROR(50000, "系统内部异常", ""), + OPERATION_ERROR(50001, "操作失败", ""); + + /** + * 状态码 + */ + private final int code; + /** + * 状态码信息 + */ + private final String message; + /** + * 状态码的详细描述 + */ + private final String description; + + ErrorCode(int code, String message, String description) { + this.code = code; + this.message = message; + this.description = description; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public String getDescription() { + return description; + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ResultUtils.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ResultUtils.java new file mode 100644 index 0000000..2c7b69b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/common/ResultUtils.java @@ -0,0 +1,68 @@ +package com.bsz.school_send_back_end.common; + +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; + +/** + * 返回工具类 + */ +public class ResultUtils { + /** + * 成功 + * + * @param data + * @param + * @return + */ + public static BaseResponse success(T data) { + return new BaseResponse<>(0, data, "ok"); + } + + public static BaseResponse success(T data, String message) { + return new BaseResponse<>(0, data, message); + } + + /** + * 失败 + * + * @param errorCode + * @return + */ + public static BaseResponse error(ErrorCode errorCode) { + return new BaseResponse<>(errorCode); + } + + /** + * 失败 + * + * @param code + * @param message + * @param description + * @return + */ + public static BaseResponse error(int code, String message, String description) { + return new BaseResponse(code, null, message, description); + } + + /** + * 失败 + * + * @param errorCode + * @return + */ + public static BaseResponse error(ErrorCode errorCode, String message, String description) { + return new BaseResponse(errorCode.getCode(), null, message, description); + } + + + /** + * 失败 + * + * @param errorCode + * @return + */ + public static BaseResponse error(ErrorCode errorCode, String description) { + return new BaseResponse(errorCode.getCode(), errorCode.getMessage(), description); + } + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AliPayNotifyHandler.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AliPayNotifyHandler.java new file mode 100644 index 0000000..c2e2559 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AliPayNotifyHandler.java @@ -0,0 +1,42 @@ +package com.bsz.school_send_back_end.config; + +import com.alipay.api.internal.util.AlipaySignature; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +@Configuration +public class AliPayNotifyHandler { + + public void aliPayNotifyUrl(HttpServletRequest request) { + // 将 HttpServletRequest 的参数转换为 Map + Map params = new HashMap<>(); + Enumeration parameterNames = request.getParameterNames(); + + while (parameterNames.hasMoreElements()) { + String paramName = parameterNames.nextElement(); + params.put(paramName, request.getParameter(paramName)); + } + + // 之后可以使用 params 进行业务处理 + // 例如: + String alipayrsaPublicKey = "MIIBIjANBgKGhKiG9WOBAOEFAAOCAQ8AMIIBCgKCAOEAUQWP3y7DHD0Z+/K+TcGlki0/acP8"; + try { + // 验证签名 + boolean flag = AlipaySignature.rsaCheckV1(params, alipayrsaPublicKey, "UTF-8", "RSA2"); + + if (flag && "TRADE_SUCCESS".equals(params.get("trade_status"))) { + // 业务处理 + System.out.println("success"); + } else { + System.out.println("fail"); + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("fail"); + } + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AlipayClients.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AlipayClients.java new file mode 100644 index 0000000..08584c1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/AlipayClients.java @@ -0,0 +1,39 @@ +package com.bsz.school_send_back_end.config; + + +import com.alipay.api.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; + +public class AlipayClients { + //appid + public String appId = "2021004151684053"; + //私钥 + //上:沙箱公钥 下:支付宝公钥 + public String PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3JKMG3clg/1MqewlIK/koEhiQiSLagckb/2/Dyvg+rJ2snGiAgzNvhvvc1GdVC+Xnn/P+U+2tAytyuvbOuhmGgNZjeObczJXpo/0D6LBdYDrg4PVMDxpStCxLUpaShHbc/l/IquaorBwd94UJxIPAbUQkUBCbo94mGbhDX+yU4FQ6k1yeUtn03jvZ3AY0BEHpenCxWKgr5S/CUAYEitMbi/r7extBy6f4FCR120NM7VaNEK1xpHbGHo6rDpyiAOR1lWFuiqOJ1hv14UL/SfOLlzvUZiiPysIxdNjycZyiyRvFRHP3n8GBAaJDm9vVHwDfgQ5s3Ig2ggBeYXkFHZqWwIDAQAB"; +// public String PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjqGlEXMznr4XlQ3hvbZnQmfj0iJ2MAmPmpNyXMuQhuMK2xx8t9HozL+YzZ8l/4ksgtzGCHx0NiObsYe6Tt0EogfBqXjPTst21AjrT1TPKOxSfv6WuqNLNuY5o/i8ev0OLAGg8YUD2PL1GXSIrUMqjUuCFYQ7iFgEtcN54GVh4XG7Qj6wpN8CCTwmG4R4vHk4Al0ydE2yf0Efj49EgIi+Oq8EkXPSgdWpcS+UaEyuFVr3R5am36MHp+rXkOm6NluVJFBD/JHsOjB/Wt0EGd2HSyhR7n0hjFpNfVodughLL53/zG+nZ7+mM25s2S7Qh4iirxTedeqXlvBMXffxLSQrtQIDAQAB"; + //公钥appPrivateKey + //上:沙箱私钥 下:支付宝私钥 + public String appPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCc1rWOaCHl7KnDDMctWIgFJqerq9ZU8QsxSA+wQC4nrTfoQVSVZn8fDNosilCHda7yv910A9aJYqZKx0+NOXY9YvMbKYifWtO8TtzAQ9Q0EQXce85gnVQ3yn9evE1MVwfmMIiXJ2jx/dmGrxuADrLcsNB/U4xsusKcNQaA76vALtAYTnKwOODaDt5Qd2OC25PRcGtKupKIbir/f62tNquBkCX+Z5URBpy0rZY2hCu30v3uPv8I3OlpxegFwNDHpKMIY3+wjQtqsogQTn20E5wzeV3VNabNxbORq6B6nh8mvxlo9q14XvmMJDPUoWiJgyUUpaAPZFWSpRCrLvWQY/klAgMBAAECggEAZJ/Ahig7L2gClriZBXfadOuTAapS7dZkpu6j2iGjOyOATgu0N9I11vcI9zCab/5KC0abzzYzK5vWMv3jBSmLueDFNnUUSaEdXaB/Mv+RowIU75ujEgt+n/jUdTR8p3DjCYWz7L6FL1T9fdLU4vkLOlpauoYg/xVnjI7cqFacq8SWr3jiGj/I31O18y02/eDiyAb5RMlSlNGnzvDuRwJ3h2Sn1u7znbMCi6CydG3hx+I0GE2iJqVPymc1f0T0vm7Jy3l/zL84oNKLTgPCqG9k+eriC7RaMkbvPQFjWCDCuWxgYM2pi1L9ZDG+FkReTFsZw6r/TWc4sl2xtj3GDSrHYQKBgQD1NwFBMQwsUQ/aJP63R0gILWSFR0+yQ314vfRRVKoZTujbQr7RBAzgQff97DirINIxXCBeV0zifpc2IaAPaY29YjDnQU+xGqIO91EWPjMkQ6XUvGGesKnKDYkA5yBMyD3/BH8BwJruidW2DwtC2rGTW1hatkXNtYccEI79/00UOQKBgQCjvKIySZdRolOYUfSPHHipOygWClFy1DlI54XDnj0gRBoOrFkeqrXr+G8dYeXP6UnMqLWX8V3RuEJB8klwKGLkMtUWdqMQUFM5yvjuX2d1Y9R2ESw0ch70B/6aItMVv6aN4GjGwCJWD1XD54IpWxtAKJsUxbDiN+343cVqSQQETQKBgQDq9JBcMa3TTLyerbHuVPt88lmNpr2DNk2kAoZ142S0qTpO1M5XIcVgn3UKNWw69FDSgM529rkxkFA8ys0910q7erkW7Cp6rOU459onMOP5zGO5yeLTlbyqYHu0hMEbMQbOMjWrrSwGgcVnE1Ub8sYRRoYLLPkHWPcjee45C4WEaQKBgHkUUeDb+JD+d9DIsg9uH3ANdcwunyJJ+36E7q7EgjEtCxPUsSZzWIoBsbFJppbDzbYRABA3BYjDOAPqNhJBWzeiu16cJmM28wRmqwQi+q+dPgx9EHJL/cW5b7XtkKihi3mY/AIVLI71UhfHR8JrQ9CC9oM62V2/vDNvU8AP9G91AoGANdvRubukeWgvWryBTaPuUTpjkP1mOuJuHiHEW5/XePsURwS6gGP/qJ9bSbhYhQ6iDaMOQ8vahfYM3Q4jvDxgcKS/N1fxFTohcN4bVdvekq62YdTNqcGhNzaxMNboFZYt2dPeDm8PRRMP+abddrS2NqgVSOC3Ru5Kh9iRIs2LOgE="; +// public String appPrivateKey ="MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCOoaURczOevheVDeG9tmdCZ+PSInYwCY+ak3Jcy5CG4wrbHHy30ejMv5jNnyX/iSyC3MYIfHQ2I5uxh7pO3QSiB8GpeM9Oy3bUCOtPVM8o7FJ+/pa6o0s25jmj+Lx6/Q4sAaDxhQPY8vUZdIitQyqNS4IVhDuIWAS1w3ngZWHhcbtCPrCk3wIJPCYbhHi8eTgCXTJ0TbJ/QR+Pj0SAiL46rwSRc9KB1alxL5RoTK4VWvdHlqbfowen6teQ6bo2W5UkUEP8kew6MH9a3QQZ3YdLKFHufSGMWk19Wh26CEsvnf/Mb6dnv6YzbmzZLtCHiKKvFN516peW8Exd9/EtJCu1AgMBAAECggEAPghReVhoL/cu3HXQIylsmXYDoIW6b0QJP8o25+Lk9bVTKF6oY24Y2MvPkkZQSWYIhNWuD0zJYi50bW7BecEoXawP7zwKtZNKGAfVB4i0HHFDo9XoCj4w3SyeDxGEL91VR5Bhxgj61mU8chi7xNc8b31SkzcSiUb2rXLZ091kB58/xtzQk2nZAhKhwms7gbX7qxm8+TWLRK9g4vWmsGVqbgFNj/sutqBURSeU/pHmW9PMqgcWvx6AwWWi+VgBUSoIgMnX7r7s6ZlgeDIgioii3JdCcr1nq39sVYPwFpwIe7a1DOCB58B+v2un1XoThC7ZNEcbwP5oYpUdFhSoxClrNQKBgQDJc/A1nz2yYiLUHUMJn2DhyTrOnCSclmowuzJVkyuo5gQPfZ3dTmjdPkM/fg09J3+zi3UCSwZd6dGMzJVHWooMniSiomZ/rY+o9SVTAJOjxt29N8jFN92b3fB43hbAWyBOuy4NMZMcr+4cADuqRHz2pKAeaALiZdpTbrTCzVXtqwKBgQC1QGS0sv8VU9fyBCyrYU4kQh8Fcvz0g6ObgUnHZi6UIL+Cy0/3JIGeIyvB/n47RF1wLUz4wykwW70e1qlMz7w21HM+DB8fVuzbO7SmQI3gDo024kQkWWGUhe3/w9ztzLF9ezleSN6wnrPeDbeMV+pURbsxIXA9xg7DYpZZ76ksHwKBgHQnF/oi7bTbpo88q/lxXq/wkaqtFuL+Sw378UKsD4Fb1j2ERTBj1Ey0aJvENyfqjVPddcKztWESvtL65pt0laI+0IrBLm4xiWJ2rmWUMIw+zn0aG/Wyh2Emb0+RZfbU0+TxQdUzn0nsGlMkw0IiKRcgxn2hpQAaj+6JJ0omkIPvAoGAZ2eGTKT17Cf6QgNprJiF6R+j7QruD11uoJABFHZSSoXoXGk7hMbZ/+sW0sUrJQrat93QVPeabxFXctmKmtzFBw7rdFGcC9gepvCIHnUju9jxbYdm0sn/ZqmF323RhAVMmUcMsqKmEWNpQFzZA4NAl7V0lxH5o/RzhbqgBk05WYcCgYEAny/umQs7+NYgwL/FztMJVljfQsGY81mhgrQyPhmg/7NiWmLodJtwQgSj3UitDVtUGhZRnuidO8P1XW0sUyDwc8xMLb+0qVxX4gMpM4J1B0UaIp+oPg7hCXeFGxkWQl8bPY0RFa3GOfT2/D63NpXqYw8Fe1lZWoIMz+PBdx0YN90="; + //应用证书 + private String appCertPath; + //支付宝证书 + private String alipayCertPath; + //支付宝根证书 + private String alipayRootCertPath; + //回调地址 + private String notify; + //字符集 签名 + private String gateway = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"; + + + // 公私钥模式 + @Bean + public AlipayClient alipayClient() throws AlipayApiException { + AlipayClient client = new DefaultAlipayClient(this.gateway, this.appId, this.appPrivateKey, AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8, PublicKey, AlipayConstants.SIGN_TYPE_RSA2); + return client; + } + +} + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/CorsConfig.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/CorsConfig.java new file mode 100644 index 0000000..c9c2bec --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/CorsConfig.java @@ -0,0 +1,28 @@ +package com.bsz.school_send_back_end.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 全局跨域配置 + * + * + * @author bsz + */ +@Configuration +public class CorsConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(CorsRegistry registry) { + // 覆盖所有请求 + registry.addMapping("/**") + // 允许发送 Cookie + .allowCredentials(true) + // 放行哪些域名(必须用 patterns,否则 * 会和 allowCredentials 冲突) + .allowedOriginPatterns("*") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .exposedHeaders("*"); + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/JsonConfig.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/JsonConfig.java new file mode 100644 index 0000000..29d4503 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/JsonConfig.java @@ -0,0 +1,28 @@ +package com.bsz.school_send_back_end.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.boot.jackson.JsonComponent; +import org.springframework.context.annotation.Bean; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +/** + * Spring MVC Json 配置 + */ +@JsonComponent +public class JsonConfig { + + /** + * 添加 Long 转 json 精度丢失的配置 + */ + @Bean + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + SimpleModule module = new SimpleModule(); + module.addSerializer(Long.class, ToStringSerializer.instance); + module.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(module); + return objectMapper; + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/Knife4jConfig.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/Knife4jConfig.java new file mode 100644 index 0000000..e6d275f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/Knife4jConfig.java @@ -0,0 +1,53 @@ +package com.bsz.school_send_back_end.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * @author bsz + * Knife4j 接口文档配置 + * + * http://localhost:8080/api/doc.html#/home 接口文档地址 + */ +@Configuration +@EnableSwagger2 +@Profile({"dev", "test"}) //版本控制访问 +public class Knife4jConfig { + @Bean + public Docket defaultApi2() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + // 指定 Controller 扫描包路径 + .apis(RequestHandlerSelectors.basePackage("com.bsz.school_send_back_end.controller")) + .paths(PathSelectors.any()) + .build(); + } + /** + * 自定义接口文档信息 + * @return 接口文档 + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + // 接口文档的标题 + .title("校快送接口平台管理") + // 接口文档的描述信息 + .description("校快送的接口文档,进行测试") + // 提供服务的是谁?可以填写你自己的地址因为是你自己提供的服务 + .termsOfServiceUrl("https://gitee.com/shir23zxc/school_lend_back-end") + .contact(new Contact("bsz", "https://account.bilibili.com/account/face/upload?spm_id_from=333.999.0.0", "1113832400@qq.com")) + // 版本 + .version("1.0") + // 构建 + .build(); + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/MyBatisPlusConfig.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..450f301 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/config/MyBatisPlusConfig.java @@ -0,0 +1,27 @@ +package com.bsz.school_send_back_end.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * MyBatis Plus 配置 + */ +@Configuration +@MapperScan("com.bsz.school_send_back_end.mapper") +public class MyBatisPlusConfig { + + /** + * 拦截器配置 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 分页插件 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/CommonConstant.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/CommonConstant.java new file mode 100644 index 0000000..284fe81 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/CommonConstant.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.contant; + +/** + * 通用常量 + */ +public interface CommonConstant { + + /** + * 升序 + */ + String SORT_ORDER_ASC = "ascend"; + + /** + * 降序 + */ + String SORT_ORDER_DESC = " descend"; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/FileConstant.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/FileConstant.java new file mode 100644 index 0000000..19cc1b3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/FileConstant.java @@ -0,0 +1,24 @@ +package com.bsz.school_send_back_end.contant; + +/** + * 文件常量 + */ +@SuppressWarnings("all") +public interface FileConstant { + + /** + * COS 访问地址 + */ + String COS_HOST = "xxxxxxxxxxxxxxxxxxxx"; + + /** + * 服务器访问地址 + */ + String SERVER_HOST = "http://39.101.78.35/images"; + + /** + * 服务器上传路径 + */ + String SERVER_UPLOAD_DIR = "/www/wwwroot/images"; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/RegexConstant.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/RegexConstant.java new file mode 100644 index 0000000..19dd907 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/RegexConstant.java @@ -0,0 +1,32 @@ +package com.bsz.school_send_back_end.contant; + +/** + * 正则表达式常量 + */ +@SuppressWarnings("all") +public interface RegexConstant { + /** + * 手机号正则 + */ + String PHONE_REGEX = "^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$"; + + /** + * 邮箱正则 + */ + String EMAIL_REGEX = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"; + + /** + * 18位身份证号正则 + */ + String ID_CARD_REGEX = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9xX]$"; + + /** + * 验证码正则, 6位数字或字母 + */ + String VERIFY_CODE_REGEX = "^[a-zA-Z\\d]{6}$"; + + /** + * 密码正则。4~32位的字母、数字、下划线 + */ + String PASSWORD_REGEX = "^\\w{4,32}$"; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/SystemLogConstant.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/SystemLogConstant.java new file mode 100644 index 0000000..53e0c41 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/SystemLogConstant.java @@ -0,0 +1,37 @@ +package com.bsz.school_send_back_end.contant; + +/** + * 系统日志通用常量 + */ +public interface SystemLogConstant { + + /** + * 添加菜品 + */ + String ADD_DISHES = "添加菜品"; + + /** + * 删除菜品 + */ + String DELETE_DISHES = "删除菜品"; + + /** + * 修改菜品 + */ + String UPDATE_DISHES = "修改菜品"; + + /** + * 删除菜品分组 + */ + String ADD_DISHES_GROUP = "添加菜品分组"; + + /** + * 删除菜品分组 + */ + String DELETE_DISHES_GROUP = "删除菜品分组"; + + /** + * 修改菜品分组 + */ + String UPDATE_DISHES_GROUP = "修改菜品分组"; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/UserConstant.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/UserConstant.java new file mode 100644 index 0000000..adf801d --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/contant/UserConstant.java @@ -0,0 +1,44 @@ +package com.bsz.school_send_back_end.contant; + +/** + * 用户常量 + */ +public interface UserConstant { + + /** + * 用户登录态键 + */ + String USER_LOGIN_STATE = "userLoginState"; + + /** + * 盐值 + */ + String USER_SALT = "bsz"; + + // ------- 权限 -------- + + /** + * 默认角色 + */ + String DEFAULT_ROLE = "user"; + + /** + * 商家角色 + */ + String BUSINESS_ROLE = "business"; + + /** + * 管理员角色 + */ + String ADMIN_ROLE = "admin"; + + /** + * Boss + */ + String BOSS_ROLE = "boss"; + + /** + * 被封号 + */ + String BAN_ROLE = "ban"; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/AlipayController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/AlipayController.java new file mode 100644 index 0000000..71a27cd --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/AlipayController.java @@ -0,0 +1,338 @@ +package com.bsz.school_send_back_end.controller; + +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.AlipayConfig; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeCloseModel; +import com.alipay.api.domain.AlipayTradeCreateModel; +import com.alipay.api.domain.AlipayTradeQueryModel; +import com.alipay.api.domain.AlipayTradeRefundModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.*; +import com.alipay.api.response.*; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.config.AlipayClients; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.mapper.UserMapper; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.utils.RandomNumberGenerator; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.*; + +@RestController +@RequestMapping("/Alipay") +public class AlipayController { + + + @Value("${alipay.appId}") + public String appId; + + @Value("${alipay.appPrivateKey}") + public String appPrivateKey; + + @Value("${alipay.alipayPublicKey}") + public String PublicKey; + + @Resource + private UserMapper userMapper; + + @Resource + private RandomNumberGenerator randomNumberGenerator; + + private static String authToken; + + public static final String NOURL = "http://39.101.78.35:6271/Alipay/notifyUrl"; + + /** + * 解析code获取open_id和token + * @return aaa + * @throws AlipayApiException 支付宝api异常 + */ + @GetMapping("/parseCode") + public BaseResponse login(String authcode, HttpServletRequest req) throws AlipayApiException { + String privateKey = appPrivateKey; + String alipayPublicKey = PublicKey; + AlipayConfig alipayConfig = new AlipayConfig(); + //沙箱网关 + alipayConfig.setServerUrl("https://openapi-sandbox.dl.alipaydev.com/gateway.do"); + //支付宝网关 + alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); + alipayConfig.setAppId(appId); + alipayConfig.setPrivateKey(privateKey); + alipayConfig.setFormat("json"); + alipayConfig.setAlipayPublicKey(alipayPublicKey); + alipayConfig.setCharset("UTF-8"); + alipayConfig.setSignType("RSA2"); + AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); + AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); + request.setCode(authcode); + request.setGrantType("authorization_code"); + AlipaySystemOauthTokenResponse response = alipayClient.execute(request); +// System.out.println(response.getBody());打印所有响应 + authToken = response.getAccessToken(); + if (!response.isSuccess()) { + return ResultUtils.error(ErrorCode.PARAMS_ERROR); + } + AlipayUserInfoShareRequest request1 = new AlipayUserInfoShareRequest(); + AlipayUserInfoShareResponse response1 = alipayClient.execute(request1, authToken); + + User oid = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getOpenId, response.getOpenId())); + if (response1.isSuccess()) { + if (oid == null) { + User user = new User(); + user.setOpenId(response.getOpenId()); + user.setUsername(StringUtils.isAnyBlank(response1.getNickName()) ? "随机名字" + randomNumberGenerator.generateRandomNumber() : response1.getNickName()); + user.setUserPassword("123456"); + user.setAvatarUrl(StringUtils.isAnyBlank(response1.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response1.getAvatar()); + userMapper.insert(user); + req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE,user); + return ResultUtils.success(user,"注册成功"); + } + req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE,oid); + return ResultUtils.success(oid,"登录成功"); + } + req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE,oid); + return ResultUtils.success(oid,"登录成功"); + } + +// @GetMapping("/login") +// public BaseResponse getMessage() throws AlipayApiException { +// AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, appPrivateKey, "json", "GBK", PublicKey, "RSA2"); +// AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); +// AlipayUserInfoShareResponse response = alipayClient.execute(request, authToken); +// User oid = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getOpenId, response.getOpenId())); +// if (response.isSuccess()) { +// if (oid == null) { +// User user = new User(); +// user.setOpenId(response.getOpenId()); +// user.setUsername(StringUtils.isAnyBlank(response.getNickName()) ? "随机名字" + randomNumberGenerator.generateRandomNumber() : response.getNickName()); +// user.setUserPassword("123456"); +// user.setAvatarUrl(StringUtils.isAnyBlank(response.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response.getAvatar()); +// userMapper.insert(user); +// return ResultUtils.success(user,"注册成功"); +// } +// return ResultUtils.success(oid,"登录成功"); +// } +// return ResultUtils.error(ErrorCode.PARAMS_ERROR); +// +// } + + + @GetMapping("/test/parseCode") + public BaseResponse test_login(String authcode, HttpServletRequest req) throws AlipayApiException { + AlipayClients clients = new AlipayClients(); + AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); + request.setCode(authcode); + request.setGrantType("authorization_code"); + AlipaySystemOauthTokenResponse response = clients.alipayClient().execute(request); +// System.out.println(response.getBody());打印所有响应 + authToken = response.getAccessToken(); + if (!response.isSuccess()) { + return ResultUtils.error(ErrorCode.PARAMS_ERROR); + } + AlipayUserInfoShareRequest request1 = new AlipayUserInfoShareRequest(); + AlipayUserInfoShareResponse response1 = clients.alipayClient().execute(request1, authToken); + User oid = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getOpenId, response.getOpenId())); + if (response.isSuccess()) { + if (oid == null) { + User user = new User(); + user.setOpenId(response.getOpenId()); + user.setUsername(StringUtils.isAnyBlank(response1.getNickName()) ? "随机名字" + randomNumberGenerator.generateRandomNumber() : response1.getNickName()); + user.setUserPassword("123456"); + user.setAvatarUrl(StringUtils.isAnyBlank(response1.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response1.getAvatar()); + userMapper.insert(user); + req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE,oid); + return ResultUtils.success(user,"注册成功"); + } + req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE,oid); + return ResultUtils.success(oid,"登录成功"); + } + return ResultUtils.error(ErrorCode.PARAMS_ERROR); + } + +/* @GetMapping("/test/login") + public BaseResponse test_getMessage() throws AlipayApiException { + AlipayClients clients = new AlipayClients(); + AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); + AlipayUserInfoShareResponse response = clients.alipayClient().execute(request, authToken); + User oid = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getOpenId, response.getOpenId())); + if (response.isSuccess()) { + if (oid == null) { + User user = new User(); + user.setOpenId(response.getOpenId()); + user.setUsername(StringUtils.isAnyBlank(response.getNickName()) ? "随机名字" + randomNumberGenerator.generateRandomNumber() : response.getNickName()); + user.setUserPassword("123456"); + user.setAvatarUrl(StringUtils.isAnyBlank(response.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response.getAvatar()); + userMapper.insert(user); + return ResultUtils.success(user,"注册成功"); + } + return ResultUtils.success(oid,"登录成功"); + } + return ResultUtils.error(ErrorCode.PARAMS_ERROR); + }*/ + + @GetMapping("/trade") + public BaseResponse AlipayTradeCreate() throws AlipayApiException { + //创建客户端 + AlipayClients clients = new AlipayClients(); + //AlipayClient client = clients.alipayClient(); + //创建交易请求 + AlipayTradeCreateRequest request = new AlipayTradeCreateRequest(); + //创建实体类 + AlipayTradeCreateModel model = new AlipayTradeCreateModel(); + + //请求参数 沙箱内部参数 + //TODO 后续传入 数据库中菜品 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String datePart = dateFormat.format(new Date()); + + // 生成随机部分,确保其长度为9位 + Random random = new Random(); + String randomPart = String.format("%09d", random.nextInt(1000000000)); // 生成一个0到8位的随机数,补足到9位 + + // 拼接日期和随机部分,并赋值给String a + String a = datePart + randomPart; + System.out.println(a); + model.setOutTradeNo(a); + model.setTotalAmount("88.88"); + model.setSubject("Iphone6 16G"); + model.setProductCode("JSAPI_PAY"); + model.setSellerId("2088721035350152"); + model.setBuyerId("2088722035366541"); + model.setOpAppId("2021004151684053"); + + ///回调地址 + request.setNotifyUrl("http://39.101.78.35:6271/Alipay/notifyUrl"); + request.setBizModel(model); + String tradeNo = ""; + try { + AlipayTradeCreateResponse response = clients.alipayClient().execute(request); + String trade_no = response.getTradeNo(); + tradeNo = trade_no; + } catch (AlipayApiException e) { + e.printStackTrace(); + } + return ResultUtils.success(tradeNo); + } + + @GetMapping("/test/close") + public String closeOrder(String orderNo) throws AlipayApiException { + + AlipayClients clients = new AlipayClients(); + AlipayTradeCloseRequest request = new AlipayTradeCloseRequest(); + AlipayTradeCloseModel model = new AlipayTradeCloseModel(); + + //model.setTradeNo(); 这是订单项 + //订单项可能会有多个支付单 + model.setOutTradeNo(orderNo); + + request.setBizModel(model); + request.setNotifyUrl(NOURL); + AlipayTradeCloseResponse response = clients.alipayClient().execute(request); + + //这里应该写进日志 + + + return ""; + } + + @GetMapping("/test/refund") + public String test_refund(String orderNo) throws AlipayApiException { + AlipayClients clients = new AlipayClients(); + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + AlipayTradeRefundModel model = new AlipayTradeRefundModel(); + + model.setOutTradeNo(orderNo); + model.setRefundAmount("1"); + //退款请求单号 要求唯一 需改 + model.setOutRequestNo("123"); + + request.setBizModel(model); + request.setNotifyUrl(NOURL); + AlipayTradeRefundResponse response = clients.alipayClient().execute(request); + + return ""; + } + + @GetMapping("/test/query") + public String test_query (String orderNo) throws AlipayApiException { + AlipayClients clients = new AlipayClients(); + AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); + AlipayTradeQueryModel model = new AlipayTradeQueryModel(); + + model.setOutTradeNo(orderNo); + + request.setBizModel(model); + request.setNotifyUrl(NOURL); + + AlipayTradeQueryResponse response = clients.alipayClient().execute(request); + String body = response.getBody(); + return body; + } + + @PostMapping("/notifyUrl") + public void aliPayNotifyUrl(HttpServletRequest request, HttpServletResponse response) { + + // 将 HttpServletRequest 的参数转换为 Map + Map params = new HashMap<>();Map requestParams = request.getParameterMap(); + for(String name : requestParams.keySet()) { + params.put(name, request.getParameter(name)); + } + + String resultInfo = "buyer_id=208****42&total_amount=0.01&body=***试&trade_no=20190329**941025940236¬ify_time=2019-03-29 19:42:04&subject=**电脑网站支付&sign_type=RSA2&charset=UTF-8&auth_app_id=201****222¬ify_type=trade_status_sync&invoice_amount=0.01&out_trade_no=20190329ygyg45484544100003&trade_status=TRADE_SUCCESS&gmt_payment=2019-03-29 19:42:03&version=1.0&point_amount=0.00&sign=LDDUIGQmc+1qNtk3oyoAKVeMUKTngdX3ZjVeZOK0EjiPDJ/+Nk+0WSqcE6J7/5xb96Z/vP0yY3pVhZUiFVJ1G45/ys/HAleHh+EERZ1lkCkule1sSyaGFTKQGKx4uHpTyqIgRB1bouf19RPbSx1EkA0VkCarSy9G/OEG5Qmg8UdL2dRulMhlbOHS7tdMJJycDA8vOspOUMeQmk/H6IK9R2Kou5hN2T3KR1GWLYFK+z1jeZhQB3q52lZynO0OFjSzU4aQUBMW5QskQppBYd/ghtY/2YP+2H6YVGNgVmaheZMQ3PVTBALEV+8rZa91salH9DkKN2UCYGvNSNDT1VGCTQ==&gmt_create=2019-03-29 19:42:00&buyer_pay_amount=0.01&receipt_amount=0.01&fund_bill_list=[{\"amount\":\"0.01\",\"fundChannel\":\"PCREDIT\"}]&seller_id=208****5&app_id=2014100***22¬ify_id=20190329002221942040**8"; + //编码格式 + String charset="utf-8"; + //支付宝公钥 + String alipaypublicKey=""; + //签名方式 + String sign_type="RSA2"; + //对待签名字符串数据通过&进行拆分 + String [] temp = resultInfo.split("&"); + LinkedHashMap map = new LinkedHashMap(); + //把拆分数据放在map集合内 + for (int i = 0; i < temp.length; i++) { + String[] arr = temp[i].split("=", 2); //通过"="号分割成2个数据 + String[] tempAagin = new String[arr.length]; //再开辟一个数组用来接收分割后的数据 + for (int j = 0; j < arr.length; j++) { + tempAagin[j] = arr[j]; + } + map.put(tempAagin[0], tempAagin[1]); + } + System.out.println(map); + + + String alipayrsaPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3JKMG3clg/1MqewlIK/koEhiQiSLagckb/2/Dyvg+rJ2snGiAgzNvhvvc1GdVC+Xnn/P+U+2tAytyuvbOuhmGgNZjeObczJXpo/0D6LBdYDrg4PVMDxpStCxLUpaShHbc/l/IquaorBwd94UJxIPAbUQkUBCbo94mGbhDX+yU4FQ6k1yeUtn03jvZ3AY0BEHpenCxWKgr5S/CUAYEitMbi/r7extBy6f4FCR120NM7VaNEK1xpHbGHo6rDpyiAOR1lWFuiqOJ1hv14UL/SfOLlzvUZiiPysIxdNjycZyiyRvFRHP3n8GBAaJDm9vVHwDfgQ5s3Ig2ggBeYXkFHZqWwIDAQAB"; + try { + //验签方法 + boolean signVerified = AlipaySignature.rsaCheckV1(params,PublicKey,charset,sign_type); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer = response.getWriter(); + if (signVerified && "TRADE_SUCCESS".equals(params.get("trade_status"))) { + // 业务处理 + writer.println("success"); + } else { + writer.println("fail"); + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/BusinessController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/BusinessController.java new file mode 100644 index 0000000..c329144 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/BusinessController.java @@ -0,0 +1,221 @@ +package com.bsz.school_send_back_end.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.business.BusinessAddRequest; +import com.bsz.school_send_back_end.model.dto.business.BusinessQueryRequest; +import com.bsz.school_send_back_end.model.dto.business.BusinessUpdateMyRequest; +import com.bsz.school_send_back_end.model.dto.business.BusinessUpdateRequest; +import com.bsz.school_send_back_end.model.vo.BusinessAdminVO; +import com.bsz.school_send_back_end.model.vo.BusinessVO; +import com.bsz.school_send_back_end.service.BusinessAuthService; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.util.DigestUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import java.util.List; + +import static com.bsz.school_send_back_end.contant.UserConstant.USER_SALT; + +/** + * 商家接口 + */ +@Slf4j +@RestController +@RequestMapping("/business") +public class BusinessController { + + @Resource + private BusinessService businessService; + + @Resource + private BusinessAuthService businessAuthService; + + @Resource + private UserService userService; + + @PostMapping("/add") + public BaseResponse addBusiness(@RequestBody BusinessAddRequest businessAddRequest) { + + ThrowUtils.throwIf(businessAddRequest == null,ErrorCode.PARAMS_ERROR); + + User user = new User(); + BeanUtils.copyProperties(businessAddRequest, user); + Business business = new Business(); + BeanUtils.copyProperties(businessAddRequest, business); + BusinessAuth businessAuth = new BusinessAuth(); + BeanUtils.copyProperties(businessAddRequest, businessAuth); + + //对每个应该校验的业务进行校验 + businessService.validUser(user, true); + businessService.validBusiness(business, true); + businessService.validBusinessAuth(businessAuth, true); + + //加密 + String encryptPassword = DigestUtils.md5DigestAsHex((USER_SALT + user.getUserPassword()).getBytes()); + user.setUserPassword(encryptPassword); + + //更改用户权限为商家 + user.setUserRole("business"); + + //往user表中补充商家信息 + user.setUsername(business.getBusinessName()); + user.setAvatarUrl(business.getBusinessAvatar()); + user.setPhone(business.getBusinessPhone()); + + //插入到表中 + businessService.addBusiness(user, business, businessAuth); + + return ResultUtils.success(business.getId(),"添加商家成功"); + + } + + /** + * 管理员更新商家 + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updateBusiness (@RequestBody BusinessUpdateRequest businessUpdateRequest) { + if (businessUpdateRequest == null || businessUpdateRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "传入参数为空"); + } + + Business business = new Business(); + + BeanUtils.copyProperties(businessUpdateRequest, business); + //更新不添加 只需要判断修改符不符合逻辑 + businessService.validBusiness(business, false); + + boolean updateById = businessService.updateById(business); + + ThrowUtils.throwIf(!updateById, ErrorCode.OPERATION_ERROR); + + return ResultUtils.success(true); + } + + /** + * 商家更新个人信息 + */ + @PostMapping("/update/my") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + public BaseResponse updateMyBusiness (@RequestBody BusinessUpdateMyRequest businessUpdateMyRequest, HttpServletRequest request) { + + if (businessUpdateMyRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + // 获取当前登录商家信息 + Business loginBusiness = businessService.getLoginBusiness(request); + ThrowUtils.throwIf(loginBusiness == null, ErrorCode.NOT_FOUND_ERROR); + Business business = new Business(); + business.setId(loginBusiness.getId()); + business.setUserId(loginBusiness.getUserId()); + BeanUtils.copyProperties(businessUpdateMyRequest, business); + // 校验 + businessService.validBusiness(business, false); + // 修改商家信息 + boolean updateBusiness = businessService.updateById(business); + ThrowUtils.throwIf(!updateBusiness, ErrorCode.OPERATION_ERROR, "修改商家信息失败"); + // 修改用户信息 + User loginUser = userService.getById(loginBusiness.getUserId()); + if (StringUtils.isNotBlank(business.getBusinessName())) { + loginUser.setUsername(business.getBusinessName()); + } + if (StringUtils.isNotBlank(business.getBusinessPhone())) { + loginUser.setPhone(business.getBusinessPhone()); + } + boolean updateUser = userService.updateById(loginUser); + ThrowUtils.throwIf(!updateUser, ErrorCode.OPERATION_ERROR, "修改用户信息失败"); + return ResultUtils.success(true); + } + + /** + * 根据id查询 + */ + @GetMapping("/getById") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse getBusinessById(long id) { + if (id <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Business business = businessService.getById(id); + + ThrowUtils.throwIf(business == null , ErrorCode.NULL_ERROR); + + BusinessAdminVO businessAdminVO = businessAuthService.getBusinessAdminVO(business); + + return ResultUtils.success(businessAdminVO); + } + + /** + * 根据当前登录用户获取商家信息 + */ + @PostMapping("/get/current") + public BaseResponse getByBusiness (HttpServletRequest request) { + Business loginBusiness = businessService.getLoginBusiness(request); + BusinessVO businessVO = businessService.getBusinessVO(loginBusiness); + return ResultUtils.success(businessVO); + } + /** + * 查询所有商家 + */ + @PostMapping("/list") + public BaseResponse> listBusinessAll(){ + List businessList = businessService.list(); + return new BaseResponse<>(0,businessList,"查询成功"); + } + + + /** + * 分页查询 + */ + @PostMapping("/list/page") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse> listBusinessByPage (@RequestBody BusinessQueryRequest businessQueryRequest) { + Page businessPage = businessService.page(new Page<>(businessQueryRequest.getCurrent(), businessQueryRequest.getPageSize()), + businessService.getQueryWrapper(businessQueryRequest)); + return ResultUtils.success(businessPage); + + } + + /** + * 分页获取商家列表(用户视图) + */ + @PostMapping("/list/page/vo") + public BaseResponse> listBusinessVOByPage(@RequestBody BusinessQueryRequest businessQueryRequest) { + long current = businessQueryRequest.getCurrent(); + long size = businessQueryRequest.getPageSize(); + + ThrowUtils.throwIf(size > 20, ErrorCode.PARAMS_ERROR); + QueryWrapper queryWrapper = businessService.getQueryWrapper(businessQueryRequest); + // 只显示正常营业商家 + queryWrapper.eq("state", 1); + Page businessPage = businessService.page(new Page<>(current, size), queryWrapper); + Page businessVOPage = new Page<>(current, size, businessPage.getTotal()); + List businessVOList = businessService.getBusinessVO(businessPage.getRecords()); + businessVOPage.setRecords(businessVOList); + return ResultUtils.success(businessVOPage); + } + + + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CartController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CartController.java new file mode 100644 index 0000000..02caace --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CartController.java @@ -0,0 +1,196 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Cart; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.cart.CartAddRequest; +import com.bsz.school_send_back_end.model.dto.cart.CartDeleteRequest; +import com.bsz.school_send_back_end.model.dto.cart.CartQueryRequest; +import com.bsz.school_send_back_end.model.dto.cart.CartUpdateRequest; +import com.bsz.school_send_back_end.model.vo.CartVO; +import com.bsz.school_send_back_end.service.CartService; +import com.bsz.school_send_back_end.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +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 javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@Slf4j +@RequestMapping("/cart") +public class CartController { + + @Resource + private CartService cartService; + + @Resource + private UserService userService; + + /** + * 添加剂购物车 + * @param cartAddRequest 添加请求 + * @param request 网络请求 + * @return 购物车id + */ + @PostMapping("/add") + @Transactional(rollbackFor = Exception.class) + public BaseResponse addCart (@RequestBody CartAddRequest cartAddRequest, HttpServletRequest request) { + if (cartAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + //校验 + cartService.validCart(cartAddRequest); + //添加菜品到购物车 + Long cart = cartService.addCart(cartAddRequest, request); + return ResultUtils.success(cart); + } + + /** + * 更新购物车 + * @param cartUpdateRequest 更新请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/update") + @Transactional(rollbackFor = Exception.class) + public BaseResponse updateCart (@RequestBody CartUpdateRequest cartUpdateRequest, HttpServletRequest request){ + if (cartUpdateRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + //校验 + CartAddRequest cartAddRequest = new CartAddRequest(); + BeanUtils.copyProperties(cartUpdateRequest,cartAddRequest); + cartService.validCart(cartAddRequest); + + Boolean cart = cartService.updateCart(cartUpdateRequest, request); + return ResultUtils.success(cart); + } + + /** + * 删除购物车 + * @param cartDeleteRequest 删除请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/delete") + @Transactional(rollbackFor = Exception.class) + public BaseResponse deleteCart (@RequestBody CartDeleteRequest cartDeleteRequest, HttpServletRequest request) { + if (cartDeleteRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Long id = cartDeleteRequest.getId(); + Boolean cart = cartService.deleteCart(id, request); + ThrowUtils.throwIf(!cart, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + /** + * 根据商户id获取购物车脱敏列表 + * @param cartQueryRequest 商户id + * @param request 网络请求 + * @return 脱敏列表 + */ + @PostMapping("/selectByBusinessId") + public BaseResponse> selectByBusinessId (@RequestBody CartQueryRequest cartQueryRequest, HttpServletRequest request) { + if (cartQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Long businessId = cartQueryRequest.getId(); + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Cart::getBusinessId, businessId); + queryWrapper.eq(Cart::getUserId, userId); + List cartList = cartService.list(queryWrapper); + List cartVOList = this.getCartVOList(cartList); + return ResultUtils.success(cartVOList); + } + + /** + * 根据用户查找购物车列表 + * @param request 网络请求 + * @return 脱敏列表 + */ + @PostMapping("/selectByUserId") + public BaseResponse> selectByUserId (HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Cart::getUserId, userId); + + List cartList = cartService.list(wrapper); + List cartVOList = this.getCartVOList(cartList); + return ResultUtils.success(cartVOList); + } + + /** + * 清空商家内的购物车 + * @param cartQueryRequest 商家id + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/empty/business") + public BaseResponse emptyBusinessCart(@RequestBody CartQueryRequest cartQueryRequest, HttpServletRequest request) { + if (cartQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Long businessId = cartQueryRequest.getId(); + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Cart::getBusinessId, businessId); + queryWrapper.eq(Cart::getUserId, userId); + boolean remove = cartService.remove(queryWrapper); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + + return ResultUtils.success(true); + } + + /** + * 清空用户购物车 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/empty/user") + public BaseResponse emptyUserCart(HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Cart::getUserId, userId); + boolean remove = cartService.remove(queryWrapper); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + + return ResultUtils.success(true); + } + + private List getCartVOList(List cartList) { + if (CollectionUtils.isEmpty(cartList)) { + return new ArrayList<>(); + } + + return cartList.stream().map(item ->{ + CartVO cartVO = new CartVO(); + BeanUtils.copyProperties(item, cartVO); + return cartVO; + }).collect(Collectors.toList()); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CategoryController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CategoryController.java new file mode 100644 index 0000000..6b42784 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/CategoryController.java @@ -0,0 +1,118 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Category; +import com.bsz.school_send_back_end.model.dto.category.CategoryAddRequest; +import com.bsz.school_send_back_end.model.dto.category.CategoryDeleteRequest; +import com.bsz.school_send_back_end.model.dto.category.CategoryUpdateRequest; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.CategoryService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@Slf4j +@RestController +@RequestMapping("/category") +public class CategoryController { + + @Resource + private CategoryService categoryService; + + @Resource + private BusinessService businessService; + + /** + * 添加类别 + * @param categoryAddRequest 添加请求体 + * @return 是否成功 + */ + @PostMapping("/add") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse addCategory (@RequestBody CategoryAddRequest categoryAddRequest) { + if (categoryAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Category category = new Category(); + BeanUtils.copyProperties(categoryAddRequest, category); + categoryService.validCategory(category, true); + boolean save = categoryService.save(category); + ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR); + Long id = category.getId(); + return ResultUtils.success(id,"添加成功"); + } + + /** + * 修改类别 + * @param categoryUpdateRequest 修改请求体 + * @return 返回修改后类别 + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updateCategory (@RequestBody CategoryUpdateRequest categoryUpdateRequest) { + if (categoryUpdateRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Category category = new Category(); + BeanUtils.copyProperties(categoryUpdateRequest, category); + categoryService.validCategory(category, false); + boolean update = categoryService.updateById(category); + ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "操作失败"); + + return new BaseResponse<>(0,category,"修改成功"); + } + + /** + * 根据id删除 + * @param categoryDeleteRequest 删除请求体 + * @return 是否成功 + */ + @PostMapping("/delete") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse deleteCategory (@RequestBody CategoryDeleteRequest categoryDeleteRequest) { + if (categoryDeleteRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Business::getCategoryId, categoryDeleteRequest.getId()); + long count = businessService.count(wrapper); + ThrowUtils.throwIf(count > 0, ErrorCode.OPERATION_ERROR, "该分类下拥有商家"); + boolean remove = categoryService.removeById(categoryDeleteRequest.getId()); + return ResultUtils.success(remove); + } + + /** + * 根据id查询分类 + */ + @GetMapping("/getById") + public BaseResponse getCategoryById (long id) { + if (id <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Category category = categoryService.getById(id); + ThrowUtils.throwIf(category == null, ErrorCode.NOT_FOUND_ERROR); + return ResultUtils.success(category); + } + + /** + * 查询类别 + */ + @GetMapping("/list") + public BaseResponse> listCategoryAll() { + List categoryList = categoryService.list(); + return ResultUtils.success(categoryList); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesController.java new file mode 100644 index 0000000..5690a8e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesController.java @@ -0,0 +1,207 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.annotation.SystemLog; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.SystemLogConstant; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesAddRequest; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesDeleteRequest; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesQueryRequest; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesUpdateRequest; +import com.bsz.school_send_back_end.model.vo.DishesVO; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.DishesService; +import com.bsz.school_send_back_end.service.SpecificationsDishesService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@Slf4j +@RestController +@RequestMapping("/dishes") +public class DishesController { + @Resource + private DishesService dishesService; + + @Resource + private BusinessService businessService; + + @Resource + private SpecificationsDishesService specificationsDishesService; + + /** + *添加菜品 + * @param dishesAddRequest 添加菜品请求体 + * @return 是否成功 + */ + @PostMapping("/add") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @Transactional(rollbackFor = Exception.class) + @SystemLog(executeStep = SystemLogConstant.ADD_DISHES) + public BaseResponse addDishes (@RequestBody DishesAddRequest dishesAddRequest, HttpServletRequest request) { + if (dishesAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Dishes dishes = new Dishes(); + BeanUtils.copyProperties(dishesAddRequest,dishes); + //校验 + dishesService.validDishes(dishes,false); + //添加商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + dishes.setBusinessId(businessId); + //保存菜品信息 + Long dishesId = dishesService.addDishes(dishes); + //中间表中添加数据 + List specificationsIds = dishesAddRequest.getSpecificationsIds(); + specificationsDishesService.add(dishesId,specificationsIds); + return ResultUtils.success(true); + } + + /** + * 删除菜品 + * @param dishesDeleteRequest 删除请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/delete") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @Transactional(rollbackFor = Exception.class) + @SystemLog(executeStep = SystemLogConstant.DELETE_DISHES) + public BaseResponse deleteDishes(@RequestBody DishesDeleteRequest dishesDeleteRequest,HttpServletRequest request) { + if (dishesDeleteRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long dishesId = dishesDeleteRequest.getId(); + //获取商家id + Business business = businessService.getLoginBusiness(request); + Long businessId = business.getId(); + //校验菜品是不是当前登录商家的 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Dishes::getId, dishesId); + wrapper.eq(Dishes::getBusinessId, businessId); + Dishes dishes = dishesService.getOne(wrapper); + ThrowUtils.throwIf(dishes == null, ErrorCode.OPERATION_ERROR, "当前商家无权限删除该菜品"); + //删除菜品 + boolean dishesRemove = dishesService.removeById(dishesId); + ThrowUtils.throwIf(!dishesRemove, ErrorCode.OPERATION_ERROR); + //删除中间表信息 + specificationsDishesService.deleteByDishesId(dishesId); + return ResultUtils.success(true); + } + + /** + * 更新菜品 + * @param dishesUpdateRequest 更新请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @Transactional(rollbackFor = Exception.class) + @SystemLog(executeStep = SystemLogConstant.UPDATE_DISHES) + public BaseResponse updateDishes (@RequestBody DishesUpdateRequest dishesUpdateRequest, HttpServletRequest request) { + if (dishesUpdateRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Dishes dishes = new Dishes(); + BeanUtils.copyProperties(dishesUpdateRequest, dishes); + //校验 + dishesService.validDishes(dishes, true); + //添加商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + dishes.setBusinessId(businessId); + //更新菜品 + Boolean updateDishes = dishesService.updateDishes(dishes); + ThrowUtils.throwIf(!updateDishes, ErrorCode.OPERATION_ERROR); + //更新中间表的信息 + Long dishesId = dishes.getId(); + List specificationsIds = dishesUpdateRequest.getSpecificationsIds(); + return ResultUtils.success(specificationsDishesService.updateByDishesId(dishesId, specificationsIds)); + } + + /** + * 更新菜品状态 + * @param dishesUpdateRequest 菜品请求体 + * @param request 前端请求 + * @return 是否成功 + */ + @PostMapping("/update/status") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @SystemLog(executeStep = SystemLogConstant.UPDATE_DISHES) + public BaseResponse updateDishesStatus (@RequestBody DishesUpdateRequest dishesUpdateRequest, HttpServletRequest request) { + Long id = dishesUpdateRequest.getId(); + String status = dishesUpdateRequest.getStatus(); + if (id == null || StringUtils.isBlank(status)) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "请补全参数"); + } + //获取商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + //更新状态 + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(Dishes::getId, id); + wrapper.eq(Dishes::getBusinessId, businessId); + wrapper.set(Dishes::getStatus, status); + return ResultUtils.success(dishesService.update(wrapper)); + } + + /** + *获取菜品脱敏列表 + * @param dishesQueryRequest 查询请求体 + * @return 脱敏列表 + */ + @PostMapping("/list/dishes") + public BaseResponse> dishesList(@RequestBody DishesQueryRequest dishesQueryRequest) { + Long businessId = dishesQueryRequest.getBusinessId(); + if (businessId == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + //获取查询条件 + QueryWrapper wrapper = dishesService.getWrapper(dishesQueryRequest); + //根据查询条件该商家的所有菜品 + List list = dishesService.list(wrapper); + //获取菜品脱敏列表 + return ResultUtils.success(list); + } + + /** + *获取菜品脱敏列表 + * @param dishesQueryRequest 查询请求体 + * @return 分页列表 + */ + @PostMapping("/list/page/dishesVO") + public BaseResponse> dishesVOPage(@RequestBody DishesQueryRequest dishesQueryRequest) { + long current = dishesQueryRequest.getCurrent(); + long pageSize = dishesQueryRequest.getPageSize(); + //获取查询条件 + QueryWrapper wrapper = dishesService.getWrapper(dishesQueryRequest); + //获取商家多有菜品 + Page dishesPage = dishesService.page(new Page<>(current, pageSize), wrapper); + //获取脱敏信息列表 + List dishesList = dishesPage.getRecords(); + long total = dishesPage.getTotal(); + List dishesVOList = dishesService.getDishesVOList(dishesList); + Page dishesVOPage = new Page<>(current, pageSize, total); + dishesVOPage.setRecords(dishesVOList); + return ResultUtils.success(dishesVOPage); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesGroupController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesGroupController.java new file mode 100644 index 0000000..7430931 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/DishesGroupController.java @@ -0,0 +1,156 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.annotation.SystemLog; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.SystemLogConstant; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.domain.DishesGroup; +import com.bsz.school_send_back_end.model.dto.DishesGroup.DishesGroupAddRequest; +import com.bsz.school_send_back_end.model.dto.DishesGroup.DishesGroupDeleteRequest; +import com.bsz.school_send_back_end.model.dto.DishesGroup.DishesGroupQueryRequest; +import com.bsz.school_send_back_end.model.dto.DishesGroup.DishesGroupUpdateRequest; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.DishesGroupService; +import com.bsz.school_send_back_end.service.DishesService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +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 javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@Slf4j +@RestController +@RequestMapping("/dishesGroup") +public class DishesGroupController { + @Resource + private BusinessService businessService; + + @Resource + private DishesGroupService dishesGroupService; + + @Resource + private DishesService dishesService; + + /** + * 添加菜品分组 + * @param dishesGroupAddRequest 添加请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/add") + @Transactional(rollbackFor = Exception.class) + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @SystemLog(executeStep = SystemLogConstant.ADD_DISHES_GROUP) + public BaseResponse addDishesGroup(@RequestBody DishesGroupAddRequest dishesGroupAddRequest, HttpServletRequest request) { + if (dishesGroupAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + + DishesGroup dishesGroup = new DishesGroup(); + BeanUtils.copyProperties(dishesGroupAddRequest,dishesGroup); + //校验请求体 + dishesGroupService.validDishesGroup(dishesGroup,false); + //添加分组 + Boolean result = dishesGroupService.addDishesGroup(dishesGroup, request); + ThrowUtils.throwIf(!result,ErrorCode.OPERATION_ERROR); + + return ResultUtils.success(true); + } + + /** + * 删除菜品分组 + * @param dishesGroupDeleteRequest 删除请求 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/delete") + @Transactional(rollbackFor = Exception.class) + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @SystemLog(executeStep = SystemLogConstant.DELETE_DISHES_GROUP) + public BaseResponse deleteDishesGroup (@RequestBody DishesGroupDeleteRequest dishesGroupDeleteRequest, HttpServletRequest request) { + if (dishesGroupDeleteRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long id = dishesGroupDeleteRequest.getId(); + //获取商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + + // 校验分组是否为当前商家的分组 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id",id); + queryWrapper.eq("businessId",businessId); + DishesGroup dishesGroup = dishesGroupService.getOne(queryWrapper); + ThrowUtils.throwIf(dishesGroup == null,ErrorCode.OPERATION_ERROR,"当前商家无权删除该分组"); + //删除分组 + boolean byId = dishesGroupService.removeById(id); + ThrowUtils.throwIf(!byId,ErrorCode.OPERATION_ERROR); + //检查分组下是否有菜品 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Dishes::getDishesGroupId, id); + long count = dishesService.count(wrapper); + ThrowUtils.throwIf(count > 0, ErrorCode.OPERATION_ERROR, "该分组下还有菜品"); + //删除该分组的菜品以及中检表 + dishesService.removeByDishesGroupId(id); + return ResultUtils.success(true); + } + + /** + * 更行菜品分组 + * @param dishesGroupUpdateRequest 更新请求 + * @param request 网轮廓请求 + * @return 是否成功 + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @SystemLog(executeStep = SystemLogConstant.UPDATE_DISHES_GROUP) + public BaseResponse updateDishesGroup (@RequestBody DishesGroupUpdateRequest dishesGroupUpdateRequest,HttpServletRequest request){ + if (dishesGroupUpdateRequest == null) { + throw new BusinessException(ErrorCode.OPERATION_ERROR); + } + DishesGroup dishesGroup = new DishesGroup(); + BeanUtils.copyProperties(dishesGroupUpdateRequest,dishesGroup); + //校验 + dishesGroupService.validDishesGroup(dishesGroup,true); + //更新菜品分组信息 + Boolean result = dishesGroupService.updateDishesGroupById(dishesGroup, request); + ThrowUtils.throwIf(!result,ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + /** + * 查询菜品分组脱敏列表 + * @param dishesGroupQueryRequest 菜品分组请求体 + * @return 脱敏列表 + */ + @PostMapping("/list/dishesGroup") + public BaseResponse> dishesGroupList (@RequestBody DishesGroupQueryRequest dishesGroupQueryRequest){ + //获取商家id + Long businessId = dishesGroupQueryRequest.getBusinessId(); + Business business = businessService.getById(businessId); + if (business == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"该商家不存在"); + } + //查询商家菜品分组信息 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessId",businessId); + List list = dishesGroupService.list(queryWrapper); + // 获取菜品分组脱敏列表 + return ResultUtils.success(list); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/FileController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/FileController.java new file mode 100644 index 0000000..0cb0822 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/FileController.java @@ -0,0 +1,147 @@ +package com.bsz.school_send_back_end.controller; + +import cn.hutool.core.io.FileUtil; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.FileConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.file.UploadFileRequest; +import com.bsz.school_send_back_end.model.enums.FileUploadBizEnum; +import com.bsz.school_send_back_end.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; + +/** + * 文件上传 + */ +@Slf4j +@RestController +@RequestMapping("/file") +public class FileController { + + @Resource + private UserService userService; + @PostMapping("/upload/server/not_login") + public BaseResponse uploadServerNotLogin (@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); + try { + //判断目录是否存在 + File file = new File(FileConstant.SERVER_UPLOAD_DIR, filePath); + log.info("filepath:{}",file); + if (!file.exists()) { + boolean mkdirs = file.mkdirs(); + if (!mkdirs) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR,"创建目录失败"); + } + } + multipartFile.transferTo(new File(FileConstant.SERVER_UPLOAD_DIR, filePath)); + // 返回可访问地址 + return ResultUtils.success(FileConstant.SERVER_HOST + filePath); + } + catch (IOException e) { + log.error("file upload error, filePath = " + filePath, e);http://39.101.78.35/images + throw new BusinessException(ErrorCode.SYSTEM_ERROR,"上传失败"); + } + + } + + @PostMapping("/upload/server") + 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_FOUND_ERROR, "未登录"); + } + // 文件目录:根据业务、用户来划分 + String uuid = RandomStringUtils.randomAlphabetic(8); + String fileName = uuid + "-" + multipartFile.getOriginalFilename(); + String filePath = String.format("/%s/%s/%s", fileUploadBizEnum.getValue(), loginUser.getId(), fileName); + try { + File file = new File(FileConstant.SERVER_UPLOAD_DIR, filePath); + if (!file.exists()) { + //创建目录 + boolean mkdirs = file.mkdirs(); + + if (!mkdirs) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败"); + } + } + multipartFile.transferTo(new File(FileConstant.SERVER_UPLOAD_DIR,filePath)); + //返回可访问的地址 + return ResultUtils.success(FileConstant.SERVER_HOST + filePath); + } + catch (IOException e) { + log.error("file upload error, filepath = " + filePath, e); + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "上传失败"); + } + } + + /** + * 校验文件 + */ + private void validfile(MultipartFile multipartFile, FileUploadBizEnum fileUploadBizEnum) { + //文件大小 + long fileSize = multipartFile.getSize(); + //文件后缀 + String fileSuffix = FileUtil.getSuffix(multipartFile.getOriginalFilename()); + final long TWO_M = 2*1024*1024L; + if (FileUploadBizEnum.USER_AVATAR.equals(fileUploadBizEnum)) { + if (fileSize > TWO_M) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件大小不能超过 2M"); + } + if (!Arrays.asList("jpeg", "jpg", "svg", "png", "webp").contains(fileSuffix)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件类型错误"); + } + } + } + + +} + + + + + + + + + + + + + + + + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OrdersController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OrdersController.java new file mode 100644 index 0000000..07fb422 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OrdersController.java @@ -0,0 +1,327 @@ +package com.bsz.school_send_back_end.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.CommonConstant; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.*; +import com.bsz.school_send_back_end.model.dto.CommonRequest; +import com.bsz.school_send_back_end.model.dto.order.*; +import com.bsz.school_send_back_end.model.vo.OrdersVO; +import com.bsz.school_send_back_end.service.*; +import com.bsz.school_send_back_end.utils.SqlUtils; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 订单相关接口 + **/ +@Slf4j +@RestController +@Tag(name = "订单接口") +@RequestMapping("/orders") +public class OrdersController { + + @Resource + private UserService userService; + + @Resource + private DishesService dishesService; + + @Resource + private OrdersService ordersService; + + @Resource + private BusinessService businessService; + + @Resource + private OrderDetailsService orderDetailsService; + + /** + * 创建订单 + * + * @return 订单id + */ + @PostMapping("/add") + public BaseResponse addOrders(@RequestBody OrderAddRequest orderAddRequest, HttpServletRequest request) { + if (orderAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + // 提取订单 + Orders orders = new Orders(); + User loginUser = userService.getLoginUser(request); + BeanUtils.copyProperties(orderAddRequest, orders); + orders.setUserId(loginUser.getId()); + ordersService.validOrder(orders); + // 提取订单详情 + List detailAddRequest = orderAddRequest.getOrderDetailAddRequest(); + List orderDetailsList = detailAddRequest.stream().map(item -> { + OrderDetails orderDetails = new OrderDetails(); + BeanUtils.copyProperties(item, orderDetails); + orderDetailsService.validOrderDetail(orderDetails); + Long dishesId = orderDetails.getDishesId(); + // 根据菜品设置价格 + Dishes dishes = dishesService.getById(dishesId); + BigDecimal dishesPrice = BigDecimal.valueOf(dishes.getDishesPrice()); + orderDetails.setPrice(dishesPrice); + double subtotal = dishes.getDishesPrice() * orderDetails.getQuantity(); + orderDetails.setSubtotal(BigDecimal.valueOf(subtotal)); + return orderDetails; + }).toList(); + // 创建订单 + long orderId = ordersService.addOrder(orders, orderDetailsList); + return ResultUtils.success(orderId, "订单创建成功"); + } + + /** + * 取消订单 + */ + @PostMapping("/cancel") + public BaseResponse cancelOrder(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { + Long orderId = commonRequest.getId(); + if (orderId == null || orderId <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + // 校验订单 + Orders orders = ordersService.getById(orderId); + ThrowUtils.throwIf(orders == null, ErrorCode.NOT_FOUND_ERROR); + ThrowUtils.throwIf(orders.getState() != 0, ErrorCode.OPERATION_ERROR, "订单状态错误"); + // 判断是否为自己的订单 + User loginUser = userService.getLoginUser(request); + if (!orders.getUserId().equals(loginUser.getId())) { + throw new BusinessException(ErrorCode.NO_AUTH); + } + // 修改订单状态 + orders.setState(3); + boolean update = ordersService.updateById(orders); + ThrowUtils.throwIf(!update, ErrorCode.SYSTEM_ERROR); + return ResultUtils.success(true); + } + + /** + * 根据 id 获取订单信息(仅管理员) + */ + @GetMapping("/get") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse getOrderVOById(long id) { + if (id <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Orders orders = ordersService.getById(id); + ThrowUtils.throwIf(orders == null, ErrorCode.NOT_FOUND_ERROR); + return ResultUtils.success(ordersService.getOrdersVO(orders)); + } + + /** + * 分页获取订单列表(管理员) + */ + @PostMapping("/list/page") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse> listOrdersByPage(@RequestBody OrderQueryRequest orderQueryRequest) { + long current = orderQueryRequest.getCurrent(); + long size = orderQueryRequest.getPageSize(); + Page ordersPage = ordersService.page(new Page<>(current, size), + ordersService.getQueryWrapper(orderQueryRequest)); + return ResultUtils.success(ordersPage); + } + + /** + * 获取我的订单 + */ + @PostMapping("/my/page") + public BaseResponse> getMyOrders(@RequestBody MyOrderQueryRequest myOrderQueryRequest, HttpServletRequest request) { + if (myOrderQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + long current = myOrderQueryRequest.getCurrent(); + long size = myOrderQueryRequest.getPageSize(); + User loginUser = userService.getLoginUser(request); + OrderQueryRequest orderQueryRequest = new OrderQueryRequest(); + BeanUtils.copyProperties(myOrderQueryRequest, orderQueryRequest); + QueryWrapper queryWrapper = ordersService.getQueryWrapper(orderQueryRequest); + if (loginUser.getUserRole().equals(UserConstant.BUSINESS_ROLE)) { + // 商家获取订单 + Business loginBusiness = businessService.getLoginBusiness(request); + queryWrapper.eq("businessId", loginBusiness.getId()); + } else { + // 用户获取订单 + queryWrapper.eq("userId", loginUser.getId()); + } + Page ordersPage = ordersService.page(new Page<>(current, size), + queryWrapper); + Page ordersVOPage = new Page<>(current, size, ordersPage.getTotal()); + List ordersVOList = ordersService.getOrdersVO(ordersPage.getRecords()); + ordersVOPage.setRecords(ordersVOList); + return ResultUtils.success(ordersVOPage); + } + + /** + * 订单统计 + */ + @PostMapping("/count") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + public BaseResponse ordersCount(@RequestBody OrderCountRequest orderCountRequest) { + String type = orderCountRequest.getType(); + Integer state = orderCountRequest.getState(); + Long businessId = orderCountRequest.getBusinessId(); + String startTime = orderCountRequest.getStartTime(); + String endTime = orderCountRequest.getEndTime(); + ThrowUtils.throwIf(StringUtils.isBlank(type), ErrorCode.PARAMS_ERROR); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(state != null, "state", state); + queryWrapper.eq(businessId != null, "businessId", businessId); + return getStringBaseResponse(type, startTime, endTime, queryWrapper); + } + + /** + * 订单金额统计 + */ + @PostMapping("/count/money") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + public BaseResponse> ordersCountMoney(@RequestBody OrderCountRequest orderCountRequest) { + // 获取查询类型 + String type = orderCountRequest.getType(); + ThrowUtils.throwIf(StringUtils.isBlank(type), ErrorCode.PARAMS_ERROR); + OrderQueryRequest orderQueryRequest = new OrderQueryRequest(); + BeanUtils.copyProperties(orderCountRequest, orderQueryRequest); + List moneyCountList = new ArrayList<>(); + if (type.equals("week")) { + LocalDate today = LocalDate.now(); + DateTimeFormatter startFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00"); + DateTimeFormatter endFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 23:59:59"); + // 遍历查询7天数据,放入数组 + for (int i = 0; i <= 6; i++) { + LocalDate date = today.minusDays(i); + orderQueryRequest.setStartTime(date.format(startFormatter)); + orderQueryRequest.setEndTime(date.format(endFormatter)); + QueryWrapper queryWrapper = ordersService.getQueryWrapper(orderQueryRequest); + List ordertList = ordersService.list(queryWrapper); + BigDecimal money = new BigDecimal("0"); + for (Orders order : ordertList) { + money = money.add(order.getTotalPrice()); + } + moneyCountList.add(money); + } + } else { + QueryWrapper queryWrapper = ordersService.getQueryWrapper(orderQueryRequest); + List ordertList = ordersService.list(queryWrapper); + BigDecimal money = new BigDecimal("0"); + for (Orders order : ordertList) { + money = money.add(order.getTotalPrice()); + } + moneyCountList.add(money); + } + return ResultUtils.success(moneyCountList); + } + + /** + * 订单数量统计 + */ + @PostMapping("/count/number") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + public BaseResponse> ordersCountNumber(@RequestBody OrderCountRequest orderCountRequest) { + // 获取查询类型 + String type = orderCountRequest.getType(); + ThrowUtils.throwIf(StringUtils.isBlank(type), ErrorCode.PARAMS_ERROR); + OrderQueryRequest orderQueryRequest = new OrderQueryRequest(); + BeanUtils.copyProperties(orderCountRequest, orderQueryRequest); + List numberCountList = new ArrayList<>(); + if (type.equals("week")) { + LocalDate today = LocalDate.now(); + DateTimeFormatter startFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00"); + DateTimeFormatter endFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 23:59:59"); + // 遍历查询7天数据,放入数组 + for (int i = 0; i <= 6; i++) { + LocalDate date = today.minusDays(i); + orderQueryRequest.setStartTime(date.format(startFormatter)); + orderQueryRequest.setEndTime(date.format(endFormatter)); + QueryWrapper queryWrapper = ordersService.getQueryWrapper(orderQueryRequest); + long count = ordersService.count(queryWrapper ); + numberCountList.add(count); + } + } else { + QueryWrapper queryWrapper = ordersService.getQueryWrapper(orderQueryRequest); + long count = ordersService.count(queryWrapper); + numberCountList.add(count); + } + return ResultUtils.success(numberCountList); + } + + /** + * 订单统计(web端) + */ + @PostMapping("/count/web") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + public BaseResponse ordersCountByWeb(@RequestBody OrderCountRequest orderCountRequest) { + String type = orderCountRequest.getType(); + Integer state = orderCountRequest.getState(); + String businessName = orderCountRequest.getBusinessName(); + Long businessState = orderCountRequest.getBusinessState(); + String startTime = orderCountRequest.getStartTime(); + String endTime = orderCountRequest.getEndTime(); + Long categoryId = orderCountRequest.getCategoryId(); + List businessIdList = new ArrayList<>(); + ThrowUtils.throwIf(StringUtils.isBlank(type), ErrorCode.PARAMS_ERROR); + if (categoryId != null || businessName != null || businessState != null) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(businessName), "businessName", businessName); + wrapper.eq(businessState != null, "state", businessState); + wrapper.eq(categoryId != null, "categoryId", categoryId); + List businessList = businessService.list(wrapper); + if (CollectionUtils.isEmpty(businessList)) { + return ResultUtils.success("0"); + } + businessIdList = businessList.stream().map(Business::getId).collect(Collectors.toList()); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(state != null, "state", state); + queryWrapper.in(!CollectionUtils.isEmpty(businessIdList), "businessId", businessIdList); + return getStringBaseResponse(type, startTime, endTime, queryWrapper); + } + + + private BaseResponse getStringBaseResponse(String type, String startTime, String endTime, QueryWrapper queryWrapper) { + queryWrapper.ge(StringUtils.isNotBlank(startTime), "createTime", startTime); + queryWrapper.le(StringUtils.isNotBlank(endTime), "createTime", endTime); + if (type.equals("money")) { + List ordertList = ordersService.list(queryWrapper); + BigDecimal money = new BigDecimal("0"); + for (Orders order : ordertList) { + money = money.add(order.getTotalPrice()); + } + String strMoney = String.valueOf(money); + return ResultUtils.success(strMoney); + } else if (type.equals("number")) { + long count = ordersService.count(queryWrapper); + String strNumber = String.valueOf(count); + return ResultUtils.success(strNumber); + } else { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "type不正确"); + } + } +} + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OssController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OssController.java new file mode 100644 index 0000000..b78e04a --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/OssController.java @@ -0,0 +1,41 @@ +package com.bsz.school_send_back_end.controller; + + +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.service.OssService; + +import com.bsz.school_send_back_end.common.ResultUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +@Api(tags = "阿里云文件管理") +@RestController +@RequestMapping("/fileOss") +public class OssController { + + @Resource + private OssService ossService; + + /** + * 上传头像 + * + * @param file + * @return + */ + @ApiOperation(value = "文件上传") + @PostMapping("/upload") + public BaseResponse uploadOssFile(@RequestParam(required = false) MultipartFile file) { + //获取上传的文件 + if (file.isEmpty()) { + return null; + } + //返回上传到oss的路径 + String url = ossService.uploadFileAvatar(file); + //返回r对象 + return ResultUtils.success(url); + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SpecificationsController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SpecificationsController.java new file mode 100644 index 0000000..ab9b3a4 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SpecificationsController.java @@ -0,0 +1,149 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Specifications; +import com.bsz.school_send_back_end.model.domain.SpecificationsDishes; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import com.bsz.school_send_back_end.model.dto.specifications.SpecificationsAddRequest; +import com.bsz.school_send_back_end.model.dto.specifications.SpecificationsMyQueryRequest; +import com.bsz.school_send_back_end.model.dto.specifications.SpecificationsQueryRequest; +import com.bsz.school_send_back_end.model.dto.specifications.SpecificationsUpdateRequest; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; +import com.bsz.school_send_back_end.service.AttributeService; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.SpecificationsDishesService; +import com.bsz.school_send_back_end.service.SpecificationsService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +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 javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@Slf4j +@RestController +@Tag(name = "规格接口") +@RequestMapping("/specifications") +public class SpecificationsController { + + @Resource + private SpecificationsService specificationsService; + + @Resource + private SpecificationsDishesService specificationsDishesService; + + @Resource + private BusinessService businessService; + + @Resource + private AttributeService attributeService; + + /** + * 添加规格 + * @param specificationsAddRequest 添加请求体 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/add") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @Transactional(rollbackFor = Exception.class) + public BaseResponse addSpecifications(@RequestBody SpecificationsAddRequest specificationsAddRequest, HttpServletRequest request){ + if (specificationsAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Specifications specifications = new Specifications(); + BeanUtils.copyProperties(specificationsAddRequest,specifications); + //校验请求体 + specificationsService.validSpecifications(specifications, false); + //添加规格和属性 + List attributeAddRequests = specificationsAddRequest.getAttributeAddRequests(); + Boolean aBoolean = specificationsService.addSpecifications(specifications, attributeAddRequests, request); + ThrowUtils.throwIf(!aBoolean, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + /**· + * 更新规格 + * @param specificationsUpdateRequest 更新请求体 + * @param request 网络请求 + * @return 是否成功 + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.BUSINESS_ROLE) + @Transactional(rollbackFor = Exception.class) + public BaseResponse updateSpecifications(@RequestBody SpecificationsUpdateRequest specificationsUpdateRequest, HttpServletRequest request) { + if (specificationsUpdateRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Specifications specifications = new Specifications(); + BeanUtils.copyProperties(specificationsUpdateRequest,specifications); + //校验 + specificationsService.validSpecifications(specifications,true); + + //更新规格和属性 + List attributeUpdateRequests = specificationsUpdateRequest.getAttributeUpdateRequests(); + Boolean aBoolean = specificationsService.updateSpecifications(specifications, attributeUpdateRequests, request); + ThrowUtils.throwIf(!aBoolean, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + /** + * 根据菜品id获取规格脱敏信息 + * @param specificationsMyQueryRequest 请求体 + * @return 脱敏列表 + */ + @PostMapping("/list/specificationsVOByDishesId") + public BaseResponse> specificationsVOByDishesId(@RequestBody SpecificationsMyQueryRequest specificationsMyQueryRequest) { + if (specificationsMyQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long dishesId = specificationsMyQueryRequest.getId(); + //根据id获取中间表数据 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dishesId",dishesId); + List list = specificationsDishesService.list(queryWrapper); + //根据中间表数据中的规格获取规格信息和属性 + return ResultUtils.success(specificationsDishesService.getSpecificationsAddAttribute(list)); + } + + /** + * 获取脱敏列表 + * @param specificationsQueryRequest 前端请求 + * @param request 网络请求 + * @return 脱敏列表 + */ + @PostMapping("/list/specificationsVO") + public BaseResponse> specificationsVOList(@RequestBody SpecificationsQueryRequest specificationsQueryRequest, HttpServletRequest request) { + //获取商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + //获取商家的规格表 + String specificationsName = specificationsQueryRequest.getSpecificationsName(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.like(StringUtils.isNotBlank(specificationsName), "specificationsName", specificationsName); + queryWrapper.eq("businessId",businessId); + List list = specificationsService.list(queryWrapper); + //对规格信息脱敏 + List specificationsVO = specificationsService.getSpecificationsVO(list); + //获取各规格的属性脱敏信息 + return ResultUtils.success(attributeService.getBySpecificationsVoId(specificationsVO)); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemInfoController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemInfoController.java new file mode 100644 index 0000000..18ca79b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemInfoController.java @@ -0,0 +1,77 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Systeminfo; +import com.bsz.school_send_back_end.model.dto.system.SystemAddRequest; +import com.bsz.school_send_back_end.model.dto.system.SystemDeleteRequest; +import com.bsz.school_send_back_end.model.dto.system.SystemQueryRequest; +import com.bsz.school_send_back_end.service.SysteminfoService; +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 javax.annotation.Resource; +import java.util.List; + +@RestController +@Slf4j +@RequestMapping("/system") +public class SystemInfoController { + + @Resource + private SysteminfoService systeminfoService; + + /** + * 添加功能 + */ + @PostMapping("/add") + public BaseResponse addInfo (@RequestBody SystemAddRequest systemAddRequest) { + if (systemAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Systeminfo systeminfo = new Systeminfo(); + BeanUtils.copyProperties(systemAddRequest, systeminfo); + ThrowUtils.throwIf(systeminfo.getContent() == null, ErrorCode.PARAMS_ERROR, "内容为空"); + boolean save = systeminfoService.save(systeminfo); + ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true, "添加成功"); + } + + /** + * 删除功能 + */ + @PostMapping("/delete") + public BaseResponse deleteInfo (@RequestBody SystemDeleteRequest deleteRequest) { + if (deleteRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + boolean remove = systeminfoService.removeById(deleteRequest.getId()); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "添加失败"); + return ResultUtils.success(true,"删除成功"); + } + + /** + *查询列表 + */ + @PostMapping("/list") + public BaseResponse> selectInfo (@RequestBody SystemQueryRequest common) { + if (common == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Systeminfo::getType, common.getType()); + List list = systeminfoService.list(queryWrapper); + + return ResultUtils.success(list,"查询成功"); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemLogController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemLogController.java new file mode 100644 index 0000000..ee3ffca --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/SystemLogController.java @@ -0,0 +1,86 @@ +package com.bsz.school_send_back_end.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Systemlog; +import com.bsz.school_send_back_end.model.dto.log.LogQueryRequest; +import com.bsz.school_send_back_end.model.vo.BusinessLogVO; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.SystemlogService; +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 javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/log") +@Slf4j +public class SystemLogController { + + @Resource + private BusinessService businessService; + + @Resource + private SystemlogService systemlogService; + /** + * 分页获取商家系统日志列表 + */ + @PostMapping("/business/logs") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse> getLogByPage(@RequestBody LogQueryRequest logQueryRequest) { + if (logQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + long current = logQueryRequest.getCurrent(); + long pageSize = logQueryRequest.getPageSize(); + + //根据手机号获取用户id + String businessPhone = logQueryRequest.getBusinessPhone(); + if (StringUtils.isNotBlank(businessPhone)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Business::getBusinessPhone, businessPhone); + Business business = businessService.getOne(wrapper); + if (business == null) { + logQueryRequest.setUserId((long) -1); + } + else { + logQueryRequest.setUserId(business.getUserId()); + } + } + Page systemlogPage = systemlogService.page(new Page<>(current, pageSize), + systemlogService.getQueryWrapper(logQueryRequest)); + List systemlogList = systemlogPage.getRecords(); + List businessLogVOList = systemlogList.stream().map(item -> { + BusinessLogVO businessLogVO = new BusinessLogVO(); + BeanUtils.copyProperties(item, businessLogVO); + //查询商家信息 + Long userId = item.getUserId(); + Business business = null; + if (userId != null && userId > -1) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userId", userId); + business = businessService.getOne(queryWrapper); + } + businessLogVO.setBusiness(business); + return businessLogVO; + }).collect(Collectors.toList()); + Page businessLogVOPage = new Page<>(current, pageSize, systemlogPage.getTotal()); + businessLogVOPage.setRecords(businessLogVOList); + return ResultUtils.success(businessLogVOPage); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/UserController.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/UserController.java new file mode 100644 index 0000000..c6c0860 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/controller/UserController.java @@ -0,0 +1,381 @@ +package com.bsz.school_send_back_end.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsz.school_send_back_end.annotation.AuthCheck; +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.contant.UserConstant; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.vo.LoginUserVO; +import com.bsz.school_send_back_end.model.dto.user.*; +import com.bsz.school_send_back_end.common.ResultUtils; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.mapper.UserMapper; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.service.UserService; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.util.DigestUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import static com.bsz.school_send_back_end.contant.UserConstant.*; + +/** + * 用户接口 + */ +@RestController +@RequestMapping("/user") +public class UserController { + + @Resource + private UserService userService; + + @Resource + private UserMapper userMapper; + + /** + * 用户注册请求接口 + * + * @param userRegisterRequest + * @return + */ + @PostMapping("/register") + public BaseResponse userRegister(@RequestBody UserRegisterRequest userRegisterRequest) { + if (userRegisterRequest == null){ + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + + String userAccount = userRegisterRequest.getUserAccount(); + String userPassword = userRegisterRequest.getUserPassword(); + String checkPassword = userRegisterRequest.getCheckPassword(); + + if (StringUtils.isAllBlank(userAccount, userPassword, checkPassword)) { + return ResultUtils.error(ErrorCode.PARAMS_ERROR); + } + + long result = userService.userRegister(userAccount, userPassword, checkPassword); + return ResultUtils.success(result); + } + + + /** + * 用户登录请求接口 + * + * @param userLoginRequest + * @param request 前端请求对象 + * @return + */ + @PostMapping("/login") + public BaseResponse userLogin(@RequestBody UserLoginRequest userLoginRequest, HttpServletRequest request) { + if (userLoginRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + + String userAccount = userLoginRequest.getUserAccount(); + String userPassword = userLoginRequest.getUserPassword(); + + if (StringUtils.isAllBlank(userAccount, userPassword)){ + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + + LoginUserVO loginUserVO = userService.userLogin(userAccount, userPassword, request); + return ResultUtils.success(loginUserVO); + } + + /* + @GetMapping("/search") + public BaseResponse> searchUsers( String username, HttpServletRequest request) { + if (!isAdmin(request)){ + throw new BusinessException(ErrorCode.NO_AUTH, "缺少管理员权限"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (StringUtils.isNotBlank(username)) { + queryWrapper.like("userAccount", username); + } + + List userList = userService.list(queryWrapper); + + List list = userList.stream().map(user -> userService.getSafetyUser(user)).collect(Collectors.toList()); + return ResultUtils.success(list); + }*/ + + /** + * 查询用户 + * + * @param searchRequest + * @param request + * @return + */ + @GetMapping("/search") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse> searchUsers(UserSearchRequest searchRequest, HttpServletRequest request) { + String username = searchRequest.getUsername(); + String userAccount = searchRequest.getUserAccount(); + Integer gender = searchRequest.getGender(); + String phone = searchRequest.getPhone(); + String email = searchRequest.getEmail(); + Integer userStatus = searchRequest.getUserStatus(); + String userRole = searchRequest.getUserRole(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + Date updateTime = searchRequest.getUpdateTime(); + Date createTime = searchRequest.getCreateTime(); + + //校验 + // username + if (StringUtils.isNotBlank(username)) { + queryWrapper.like("username", username); + } + // userAccount + if (StringUtils.isNotBlank(userAccount)) { + queryWrapper.like("userAccount", userAccount); + } + // gender + if (gender != null) { + queryWrapper.eq("gender", gender); + } + // phone + if (StringUtils.isNotBlank(phone)) { + queryWrapper.like("phone", phone); + } + // email + if (StringUtils.isNotBlank(email)) { + queryWrapper.like("email", email); + } + // userStatus + if (userStatus != null) { + queryWrapper.eq("userStatus", userStatus); + } + + //userRole + if (userRole != null) { + queryWrapper.eq("userRole", userRole); + } + + + if (updateTime != null) { + queryWrapper.like("updateTime", updateTime); + } + if (createTime != null) { + queryWrapper.like("createTime", createTime); + } + List userList = userService.list(queryWrapper); + List users = userList.stream().map(userService::getSafetyUser).collect(Collectors.toList()); + return ResultUtils.success(users); + } + + /** + * 用户注销的接口 + * + * @param request + * @return + */ + @PostMapping("/logout") + public BaseResponse userLogout(HttpServletRequest request) { + if (request == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + int logoutResult = userService.userLogout(request); + return ResultUtils.success(logoutResult); + } + + /** + * 获取当前的用户 + * @param request + * @return + */ + @GetMapping("/current") + public BaseResponse getCurrenUser(HttpServletRequest request) { + //获取登录态 + User user = userService.getLoginUser(request); + return ResultUtils.success(userService.getLoginUserVO(user)); + } + + /** + * 新增用户 + * + * @param userAddRequest + * @param request + * @return + */ + @PostMapping("/add") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse addUser(@RequestBody UserAddRequest userAddRequest, HttpServletRequest request) { + if (userAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + User user = new User(); + String userAccount = userAddRequest.getUserAccount(); + String userPassword = userAddRequest.getUserPassword(); + if (StringUtils.isAllEmpty(userAccount,userPassword)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"未输入账号和密码"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userAccount", userAccount); + Long count = userMapper.selectCount(queryWrapper); + if (count > 0){ + throw new BusinessException(ErrorCode.PARAMS_ERROR, "存在相同用户"); + } + + BeanUtils.copyProperties(userAddRequest, user); + String encryptPassword = DigestUtils.md5DigestAsHex((USER_SALT + userPassword).getBytes()); + user.setUserPassword(encryptPassword); + boolean result = userService.save(user); + if (!result) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "操作失败"); + } + return ResultUtils.success(user.getId()); + } + + /** + * 删除用户 + * + * @param deleteRequest + * @param request + * @return + */ + @PostMapping("delete") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse deleteUser(@RequestBody UserDeleteRequest deleteRequest, HttpServletRequest request) { + if (deleteRequest == null || deleteRequest.getId() <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + boolean removeUser = userService.removeById(deleteRequest.getId()); + return ResultUtils.success(removeUser); + } + /** + * 更新用户 + * + * @param userUpdateRequest + * @param request + * @return + */ + @PostMapping("/update") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updateUser(@RequestBody UserUpdateRequest userUpdateRequest , HttpServletRequest request) { + if (userUpdateRequest == null || userUpdateRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数错误"); + } + + + User user = new User(); + BeanUtils.copyProperties(userUpdateRequest, user); + boolean result = userService.updateById(user); + if (!result) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "未找到该用户"); + } + return ResultUtils.success(true); + } + + /** + * 根据 id 获取用户(仅管理员) + * + * @param id id + * @return 用户信息 + */ + @GetMapping("/getById") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse getUserById(long id, HttpServletRequest request) { + if (id <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + User user = userService.getById(id); + ThrowUtils.throwIf(user == null, ErrorCode.PARAMS_ERROR); + return ResultUtils.success(user); + } + + /** + * 分页获取用户列表(仅管理员) + * + * @return 用户列表 + */ + @PostMapping("/list/page") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse> listUserByPage(@RequestBody UserSearchRequest userSearchRequest, HttpServletRequest request) { + long current = userSearchRequest.getCurrent(); + long size = userSearchRequest.getPageSize(); + Page userPage = userService.page(new Page<>(current, size), + userService.getQueryWrapper(userSearchRequest)); + return ResultUtils.success(userPage); + } + + + /** + * 用户自己更新个人信息 + * + * @param userUpdateMyRequest + * @param request + * @return + */ + @PostMapping("/update/my") + @ApiOperation(value = "用户更新信息") + public BaseResponse updateMyUser(@RequestBody UserUpdateMyRequest userUpdateMyRequest, + HttpServletRequest request) { + if (userUpdateMyRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + User loginUser = userService.getLoginUser(request); + User user = new User(); + BeanUtils.copyProperties(userUpdateMyRequest, user); + user.setId(loginUser.getId()); + boolean result = userService.updateById(user); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + /** + * 修改密码 + * + * @param updatePasswordRequest + * @param request + * @return + */ + @PostMapping("/update/password") + @ApiOperation(value = "用户密码更改") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updateUserPassword(@RequestBody UserUpdatePasswordRequest updatePasswordRequest, + HttpServletRequest request) { + boolean updateUserPassword = userService.updateUserPassword(updatePasswordRequest, request); + if (updateUserPassword) { + return ResultUtils.success(true); + } else { + return ResultUtils.error(ErrorCode.OPERATION_ERROR); + } + } + + + +// /** +// * 用户登录(支付宝) +// */ +// /** +// * 用户登录(支付宝) +// */ +// @GetMapping("/login/alipay") +// public BaseResponse userLoginByAlipay(HttpServletRequest request, @RequestParam("authCode") String authCode) { +// AlipaySystemOauthTokenResponse oauthTokenResponse; +// try { +// // 获取access_token 和 openId +// oauthTokenResponse = Factory.Base.OAuth().getToken(authCode); +// String accessToken = oauthTokenResponse.getAccessToken(); +// // 获取用户信息 +// JSONObject userInfo = AlipayUtils.getUserInfo(accessToken); +// String openId = userInfo.getStr("open_id"); +// return ResultUtils.success(userService.userLoginByAlipay(openId, userInfo, request)); +// } catch (Exception e) { +// throw new BusinessException(ErrorCode.SYSTEM_ERROR, "登录失败,系统错误"); +// } +// } + + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/BusinessException.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/BusinessException.java new file mode 100644 index 0000000..c72a984 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/BusinessException.java @@ -0,0 +1,49 @@ +package com.bsz.school_send_back_end.exception; + + +import com.bsz.school_send_back_end.common.ErrorCode; + +/** + * 自定义异常类 + * + */ +public class BusinessException extends RuntimeException { + + /** + * 异常码 + */ + private final int code; + + /** + * 描述 + */ + private final String description; + + public BusinessException(String message, int code, String description) { + super(message); + this.code = code; + this.description = description; + } + + public BusinessException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.code = errorCode.getCode(); + this.description = errorCode.getDescription(); + } + + public BusinessException(ErrorCode errorCode, String description) { + super(errorCode.getMessage()); + this.code = errorCode.getCode(); + this.description = description; + } + + public int getCode() { + return code; + } + + + + public String getDescription() { + return description; + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/GlobalExceptionHandler.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..0965f8b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/GlobalExceptionHandler.java @@ -0,0 +1,30 @@ +package com.bsz.school_send_back_end.exception; + + +import com.bsz.school_send_back_end.common.BaseResponse; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.common.ResultUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * 全局异常处理器 + * + */ +@RestControllerAdvice +@Slf4j +public class GlobalExceptionHandler { + + @ExceptionHandler(BusinessException.class) + public BaseResponse businessExceptionHandler(BusinessException e) { + log.error("businessException: " + e.getMessage(), e); + return ResultUtils.error(e.getCode(), e.getMessage(), e.getDescription()); + } + + @ExceptionHandler(RuntimeException.class) + public BaseResponse runtimeExceptionHandler(RuntimeException e) { + log.error("runtimeException", e); + return ResultUtils.error(ErrorCode.SYSTEM_ERROR, e.getMessage(), ""); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/ThrowUtils.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/ThrowUtils.java new file mode 100644 index 0000000..65b901e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/exception/ThrowUtils.java @@ -0,0 +1,44 @@ +package com.bsz.school_send_back_end.exception; + + +import com.bsz.school_send_back_end.common.ErrorCode; + +/** + * 抛异常工具类 + */ +@SuppressWarnings("all") +public class ThrowUtils { + + /** + * 条件成立则抛异常 + * + * @param condition 条件 + * @param runtimeException 运行时异常 + */ + public static void throwIf(boolean condition, RuntimeException runtimeException) { + if (condition) { + throw runtimeException; + } + } + + /** + * 条件成立则抛异常 + * + * @param condition 条件 + * @param errorCode 自定义异常 + */ + public static void throwIf(boolean condition, ErrorCode errorCode) { + throwIf(condition, new BusinessException(errorCode)); + } + + /** + * 条件成立则抛异常 + * + * @param condition 条件 + * @param errorCode 自定义异常 + * @param message 报错信息 + */ + public static void throwIf(boolean condition, ErrorCode errorCode, String message) { + throwIf(condition, new BusinessException(errorCode, message)); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/AttributeMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/AttributeMapper.java new file mode 100644 index 0000000..639529c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/AttributeMapper.java @@ -0,0 +1,15 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Attribute; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author xy +*/ +public interface AttributeMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessAuthMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessAuthMapper.java new file mode 100644 index 0000000..5df56b5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessAuthMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Lenovo +* @description 针对表【business_auth(商家认证)】的数据库操作Mapper +* @createDate 2024-06-24 21:01:17 +* @Entity com.bsz.school_send_back_end.model.domain.BusinessAuth +*/ +public interface BusinessAuthMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessMapper.java new file mode 100644 index 0000000..88074ed --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/BusinessMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Business; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Lenovo +* @description 针对表【business(商家)】的数据库操作Mapper +* @createDate 2024-06-24 21:01:17 +* @Entity com.bsz.school_send_back_end.model.domain.Business +*/ +public interface BusinessMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CartMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CartMapper.java new file mode 100644 index 0000000..5fa912f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CartMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Cart; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author pc +* @description 针对表【cart(购物车表)】的数据库操作Mapper +* @createDate 2024-08-13 13:59:13 +* @Entity com.bsz.school_send_back_end.model.domain.Cart +*/ +public interface CartMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CategoryMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CategoryMapper.java new file mode 100644 index 0000000..55753f0 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/CategoryMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Category; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author pc +* @description 针对表【category(分类表)】的数据库操作Mapper +* @createDate 2024-09-01 18:09:04 +* @Entity com.bsz.school_send_back_end.model.domain.Category +*/ +public interface CategoryMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesGroupMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesGroupMapper.java new file mode 100644 index 0000000..b144659 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesGroupMapper.java @@ -0,0 +1,15 @@ +package com.bsz.school_send_back_end.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bsz.school_send_back_end.model.domain.DishesGroup; + +/** +* @author bsz +*/ +public interface DishesGroupMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesMapper.java new file mode 100644 index 0000000..d549412 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/DishesMapper.java @@ -0,0 +1,19 @@ +package com.bsz.school_send_back_end.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bsz.school_send_back_end.model.domain.Dishes; + +/** +* @author pc +* @description 针对表【dishes(菜品表)】的数据库操作Mapper +* @createDate 2024-06-29 17:23:31 +* @Entity com.bsz.school_send_back_end.model.domain.Dishes +*/ +public interface DishesMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrderDetailsMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrderDetailsMapper.java new file mode 100644 index 0000000..a14c736 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrderDetailsMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.OrderDetails; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Lenovo +* @description 针对表【order_details(订单详情表)】的数据库操作Mapper +* @createDate 2024-09-12 12:31:48 +* @Entity com.bsz.school_send_back_end.model.domain.OrderDetails +*/ +public interface OrderDetailsMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrdersMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrdersMapper.java new file mode 100644 index 0000000..0dc71ea --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/OrdersMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Orders; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Lenovo +* @description 针对表【orders(订单表)】的数据库操作Mapper +* @createDate 2024-09-12 12:31:49 +* @Entity com.bsz.school_send_back_end.model.domain.Orders +*/ +public interface OrdersMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsDishesMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsDishesMapper.java new file mode 100644 index 0000000..3816f8a --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsDishesMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.SpecificationsDishes; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author pc +* @description 针对表【specifications_dishes(菜品和规格的中间表)】的数据库操作Mapper +* @createDate 2024-06-29 21:18:25 +* @Entity generator.domain.SpecificationsDishes +*/ +public interface SpecificationsDishesMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsMapper.java new file mode 100644 index 0000000..8bdd725 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SpecificationsMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bsz.school_send_back_end.model.domain.Specifications; + +/** +* @author pc +* @description 针对表【specifications(规格表)】的数据库操作Mapper +* @createDate 2024-06-29 21:10:34 +* @Entity com.bsz.school_send_back_end.model.domain.Specifications +*/ +public interface SpecificationsMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SysteminfoMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SysteminfoMapper.java new file mode 100644 index 0000000..75b7f70 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SysteminfoMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Systeminfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author pc +* @description 针对表【systeminfo(系统信息)】的数据库操作Mapper +* @createDate 2024-09-23 19:16:42 +* @Entity com.bsz.school_send_back_end.model.domain.Systeminfo +*/ +public interface SysteminfoMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SystemlogMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SystemlogMapper.java new file mode 100644 index 0000000..aaae28c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/SystemlogMapper.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.mapper; + +import com.bsz.school_send_back_end.model.domain.Systemlog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author pc +* @description 针对表【systemlog(系统信息)】的数据库操作Mapper +* @createDate 2024-09-25 15:40:09 +* @Entity com.bsz.school_send_back_end.model.domain.Systemlog +*/ +public interface SystemlogMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/UserMapper.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/UserMapper.java new file mode 100644 index 0000000..d1e5f00 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/mapper/UserMapper.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bsz.school_send_back_end.model.domain.User; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +/** +* @author bsz +* @description 针对表【user(用户)】的数据库操作Mapper +* @createDate 2024-05-09 20:59:59 +* +*/ +@Mapper +public interface UserMapper extends BaseMapper { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Attribute.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Attribute.java new file mode 100644 index 0000000..722d7e5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Attribute.java @@ -0,0 +1,59 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 属性表 + * @TableName attribute + */ +@TableName(value ="attribute") +@Data +public class Attribute implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 规格id + */ + private Long specificationsId; + + /** + * 属性名称 + */ + private String attributeName; + + /** + * 属性状态:0在售,1停售 + */ + private Integer attributeStatus; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Business.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Business.java new file mode 100644 index 0000000..35fa7d3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Business.java @@ -0,0 +1,106 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 商家 + * + * @TableName business + */ +@TableName(value = "business") +@Data +public class Business implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 门店名称 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 门店手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; + + /** + * 状态:0禁用,1启用 + */ + private Integer state; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/BusinessAuth.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/BusinessAuth.java new file mode 100644 index 0000000..14903a1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/BusinessAuth.java @@ -0,0 +1,72 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 商家 + * @TableName business_auth + */ +@TableName(value ="business_auth") +@Data +public class BusinessAuth implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 店铺id + */ + private Long businessId; + + /** + * 店主名 + */ + private String shopkeeper; + + /** + * 营业执照 + */ + private String license; + + /** + * 身份证正面 + */ + private String frontIdCard; + + /** + * 身份证反面 + */ + private String backIdCard; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Cart.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Cart.java new file mode 100644 index 0000000..1fbba73 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Cart.java @@ -0,0 +1,80 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import lombok.Data; + +/** + * 购物车表 + * @TableName cart + */ +@TableName(value ="cart") +@Data +public class Cart implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 商家id + */ + private Long businessId; + + /** + * 加入购物车时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 菜品id + */ + private Long dishesId; + + /** + * 商品数量 + */ + private Integer quantity; + + /** + * 当前选择规格的价格 + */ + private BigDecimal price; + + /** + * 小计(单价 * 数量) + */ + private BigDecimal subtotal; + + /** + * 已选规格属性列表 + */ + private String selectedOptions; + + /** + * 是否删除 + */ + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Category.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Category.java new file mode 100644 index 0000000..1071624 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Category.java @@ -0,0 +1,46 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 分类表 + * @TableName category + */ +@TableName(value ="category") +@Data +public class Category implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 分类名 + */ + private String name; + + /** + * 分类图片 + */ + private String image; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Dishes.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Dishes.java new file mode 100644 index 0000000..1fac082 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Dishes.java @@ -0,0 +1,83 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 菜品表 + * @TableName dishes + */ +@TableName(value ="dishes") +@Data +public class Dishes implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组id + */ + private Long dishesGroupId; + + /** + * 菜品名称 + */ + private String dishesName; + + /** + * 菜品图片 + */ + private String dishesImage; + + /** + * 菜品价格 + */ + private Double dishesPrice; + + /** + * 打包费 + */ + private Double packPrice; + + /** + * 库存数量 + */ + private Integer inventoryStatus; + + /** + * 菜品状态:上架,下架 + */ + private String status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/DishesGroup.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/DishesGroup.java new file mode 100644 index 0000000..7dd8546 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/DishesGroup.java @@ -0,0 +1,57 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 菜品分组表 + * @TableName dishes_group + */ +@TableName(value ="dishes_group") +@Data +public class DishesGroup implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组名称 + */ + private String groupName; + + /** + * 是否置顶:0不置顶,1置顶 + */ + private Integer isTopping; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/OrderDetails.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/OrderDetails.java new file mode 100644 index 0000000..8afc45d --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/OrderDetails.java @@ -0,0 +1,73 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import lombok.Data; + +/** + * 订单详情表 + * @TableName order_details + */ +@TableName(value ="order_details") +@Data +public class OrderDetails implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 关联的订单id + */ + private Long orderId; + + /** + * 关联的菜品id + */ + private Long dishesId; + + /** + * 购买数量 + */ + private Integer quantity; + + /** + * 单价 + */ + private BigDecimal price; + + /** + * 小计(单价 * 数量) + */ + private BigDecimal subtotal; + + /** + * 规格属性列表 + */ + private String attributeNames; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间OrderDetailsServiceImpl + * OrdersServiceImpl + */ + private Date updateTime; + + /** + * 是否删除 + */ + private Integer isDelete; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Orders.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Orders.java new file mode 100644 index 0000000..74101cb --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Orders.java @@ -0,0 +1,97 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import lombok.Data; + +/** + * 订单表 + * @TableName orders + */ +@TableName(value ="orders") +@Data +public class Orders implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 取餐码 + */ + private String pickupCode; + + /** + * 姓名 + */ + private String userName; + + /** + * 手机号 + */ + private String phone; + + /** + * 下单用户id + */ + private Long userId; + + /** + * 商家id + */ + private Long businessId; + + /** + * 订单实际总价 + */ + private BigDecimal totalPrice; + + /** + * 取餐方式(0堂食 1自提) + */ + private Integer pickupMethod; + + /** + * 支付方式:0微信支付 + */ + private Integer payMethod; + + /** + * 取餐时间 + */ + private Date pickupTime; + + /** + * 备注 + */ + private String notes; + + /** + * 订单状态:0未支付 1已完成 2已退款 3已取消 + */ + private Integer state; + + /** + * 下单时间 + */ + private Date createTime; + + /** + * 支付时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + private Integer isDelete; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Specifications.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Specifications.java new file mode 100644 index 0000000..42247ea --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Specifications.java @@ -0,0 +1,52 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 规格表 + * @TableName specifications + */ +@Data +@TableName(value ="specifications") +public class Specifications implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 规格名称 + */ + private String specificationsName; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/SpecificationsDishes.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/SpecificationsDishes.java new file mode 100644 index 0000000..7b99859 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/SpecificationsDishes.java @@ -0,0 +1,53 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 菜品和规格的中间表 + * @TableName specifications_dishes + */ +@TableName(value ="specifications_dishes") +@Data +public class SpecificationsDishes implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 菜品id + */ + private Long dishesId; + + /** + * 规格id + */ + private Long specificationsId; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systeminfo.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systeminfo.java new file mode 100644 index 0000000..81667db --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systeminfo.java @@ -0,0 +1,41 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 系统信息 + * @TableName systeminfo + */ +@TableName(value ="systeminfo") +@Data +public class Systeminfo implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 类型:0公告,1轮播图 + */ + private Integer type; + + /** + * 功能内容 + */ + private String content; + + /** + * 创建时间 + */ + private Date createTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systemlog.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systemlog.java new file mode 100644 index 0000000..9ef90df --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/Systemlog.java @@ -0,0 +1,46 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 系统信息 + * @TableName systemlog + */ +@TableName(value ="systemlog") +@Data +public class Systemlog implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 操作内容 + */ + private String content; + + /** + * ip地址 + */ + private String ip; + + /** + * 创建时间 + */ + private Date createTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/User.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/User.java new file mode 100644 index 0000000..c7407d5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/domain/User.java @@ -0,0 +1,96 @@ +package com.bsz.school_send_back_end.model.domain; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 用户 + * @TableName user + */ +@TableName(value ="user") +@Data +public class User implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + + /** + * 支付宝开放平台id + */ + private String unionId; + + /** + * openId + */ + private String openId; + /** + * 用户昵称 + */ + private String username; + + /** + * 账号 + */ + private String userAccount; + + /** + * 用户头像 + */ + private String avatarUrl; + + /** + * 性别 + */ + private Integer gender; + + /** + * 密码 + */ + private String userPassword; + + /** + * 电话 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + /** + * 状态 0 -正常 + */ + private Integer userStatus; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * + */ + private Date updateTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + /** + * 用户角色 0 - 普通用户 1 - 管理员 2 - 商家 + */ + private String userRole; + + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/CommonRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/CommonRequest.java new file mode 100644 index 0000000..3f97f72 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/CommonRequest.java @@ -0,0 +1,20 @@ +package com.bsz.school_send_back_end.model.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 通用请求 + */ +@Data +@SuppressWarnings("all") +public class CommonRequest implements Serializable { + + /** + * id + */ + private Long id; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesAddRequest.java new file mode 100644 index 0000000..ceacf14 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesAddRequest.java @@ -0,0 +1,61 @@ +package com.bsz.school_send_back_end.model.dto.Dishes; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class DishesAddRequest implements Serializable { + + + + /** + * 该菜品的规格id列表 + */ + private List specificationsIds; + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组id + */ + private Long dishesGroupId; + + /** + * 菜品名称 + */ + private String dishesName; + + /** + * 菜品图片 + */ + private String dishesImage; + + /** + * 菜品价格 + */ + private Double dishesPrice; + + /** + * 打包费 + */ + private Double packPrice; + + /** + * 库存数量 + */ + private Integer inventoryStatus; + + /** + * 菜品状态:上架,下架 + */ + private String status; + + @Serial + private static final long serialVersionUID = 4275284130550579408L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesDeleteRequest.java new file mode 100644 index 0000000..b8a63c2 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesDeleteRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.Dishes; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = 3490090832442230078L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesQueryRequest.java new file mode 100644 index 0000000..3681b3f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesQueryRequest.java @@ -0,0 +1,33 @@ +package com.bsz.school_send_back_end.model.dto.Dishes; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesQueryRequest extends PageRequest implements Serializable { + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组id + */ + private Long dishesGroupId; + + /** + * 菜品名称 + */ + private String dishesName; + + /** + * 菜品状态:上架,下架 + */ + private String status; + @Serial + private static final long serialVersionUID = 7657901721509360225L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesUpdateRequest.java new file mode 100644 index 0000000..d483d6f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/Dishes/DishesUpdateRequest.java @@ -0,0 +1,64 @@ +package com.bsz.school_send_back_end.model.dto.Dishes; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class DishesUpdateRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 该菜品的规格id列表 + */ + private List specificationsIds; + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组id + */ + private Long dishesGroupId; + + /** + * 菜品名称 + */ + private String dishesName; + + /** + * 菜品图片 + */ + private String dishesImage; + + /** + * 菜品价格 + */ + private Double dishesPrice; + + /** + * 打包费 + */ + private Double packPrice; + + /** + * 库存数量 + */ + private Integer inventoryStatus; + + /** + * 菜品状态:上架,下架 + */ + private String status; + + @Serial + private static final long serialVersionUID = 692981642677866302L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupAddRequest.java new file mode 100644 index 0000000..9884be1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupAddRequest.java @@ -0,0 +1,23 @@ +package com.bsz.school_send_back_end.model.dto.DishesGroup; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesGroupAddRequest implements Serializable { + + /** + * 菜品分组名称 + */ + private String groupName; + + /** + * 是否置顶:0不置顶,1置顶 + */ + private Integer isTopping; + + @Serial + private static final long serialVersionUID = -3305541981600216983L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupDeleteRequest.java new file mode 100644 index 0000000..4bde669 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupDeleteRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.DishesGroup; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesGroupDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = 1451141219473984015L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupQueryRequest.java new file mode 100644 index 0000000..5a9dc15 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupQueryRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.DishesGroup; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesGroupQueryRequest implements Serializable { + + /** + * 商家id + */ + private Long businessId; + + @Serial + private static final long serialVersionUID = -5330731551871723003L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupUpdateRequest.java new file mode 100644 index 0000000..3c307b1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/DishesGroup/DishesGroupUpdateRequest.java @@ -0,0 +1,28 @@ +package com.bsz.school_send_back_end.model.dto.DishesGroup; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class DishesGroupUpdateRequest implements Serializable { + + + /** + * id + */ + private Long id; + /** + * 菜品分组名称 + */ + private String groupName; + + /** + * 是否置顶:0不置顶,1置顶 + */ + private Integer isTopping; + + @Serial + private static final long serialVersionUID = 96052001253631145L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/PageRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/PageRequest.java new file mode 100644 index 0000000..22f4768 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/PageRequest.java @@ -0,0 +1,33 @@ +package com.bsz.school_send_back_end.model.dto; + +import com.bsz.school_send_back_end.contant.CommonConstant; +import lombok.Data; + +/** + * 分页请求 + * + * @author bsz + */ +@Data +public class PageRequest { + + /** + * 当前页号 + */ + private long current = 1; + + /** + * 页面大小 + */ + private long pageSize = 10; + + /** + * 排序字段 + */ + private String sortField; + + /** + * 排序顺序(默认升序) + */ + private String sortOrder = CommonConstant.SORT_ORDER_ASC; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeAddRequest.java new file mode 100644 index 0000000..e327432 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeAddRequest.java @@ -0,0 +1,29 @@ +package com.bsz.school_send_back_end.model.dto.attribute; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 属性添加请求体 + * + * @author xy + */ +@Data +public class AttributeAddRequest implements Serializable { + + /** + * 属性名称 + */ + private String attributeName; + + /** + * 属性状态:0在售,1停售 + */ + private Integer attributeStatus; + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeUpdateRequest.java new file mode 100644 index 0000000..6ef65ee --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/attribute/AttributeUpdateRequest.java @@ -0,0 +1,31 @@ +package com.bsz.school_send_back_end.model.dto.attribute; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class AttributeUpdateRequest implements Serializable { + + /** + * 属性id + */ + private Long id; + + /** + * 属性名称 + */ + private String attributeName; + + /** + * 属性状态:0在售,1停售 + */ + private Integer attributeStatus; + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java new file mode 100644 index 0000000..6d9389c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java @@ -0,0 +1,98 @@ +package com.bsz.school_send_back_end.model.dto.business; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 商家添加请求 + * + * @TableName business + */ +@Data +public class BusinessAddRequest implements Serializable { + + @Serial + private static final long serialVersionUID = -923925091426442746L; + + /** + * 账号 + */ + private String userAccount; + + /** + * 密码 + */ + private String userPassword; + + /** + * 门店名 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 门店手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 店主名 + */ + private String shopkeeper; + + /** + * 营业执照 + */ + private String license; + + /** + * 身份证正面 + */ + private String frontIdCard; + + /** + * 身份证反面 + */ + private String backIdCard; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessQueryRequest.java new file mode 100644 index 0000000..21aa0bc --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessQueryRequest.java @@ -0,0 +1,61 @@ +package com.bsz.school_send_back_end.model.dto.business; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 商家查询请求体 + * + * @TableName business + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class BusinessQueryRequest extends PageRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 门店名称 + */ + private String businessName; + + /** + * 门店地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 状态:0禁用,1启用 + */ + private Integer state; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateMyRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateMyRequest.java new file mode 100644 index 0000000..ede1007 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateMyRequest.java @@ -0,0 +1,66 @@ +package com.bsz.school_send_back_end.model.dto.business; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 商家添加请求 + */ +@Data +public class BusinessUpdateMyRequest implements Serializable { + + /** + * 门店昵称 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateRequest.java new file mode 100644 index 0000000..145e1d3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/business/BusinessUpdateRequest.java @@ -0,0 +1,83 @@ +package com.bsz.school_send_back_end.model.dto.business; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 商家更新请求 + * + */ +@Data +public class BusinessUpdateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = -3591512809067116995L; + + /** + * id + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 门店昵称 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 门店手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; + + /** + * 状态:0禁用,1启用 + */ + private Integer state; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartAddRequest.java new file mode 100644 index 0000000..9cfcdc5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartAddRequest.java @@ -0,0 +1,36 @@ +package com.bsz.school_send_back_end.model.dto.cart; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class CartAddRequest implements Serializable { + + /** + * 商家id + */ + private Long businessId; + + /** + * 关联的菜品id + */ + private Long dishesId; + + /** + * 菜品数量 + */ + private Integer quantity; + + /** + * 已选规格属性列表 + */ + private String selectedOptions = ""; + + @Serial + private static final long serialVersionUID = 4086381861303093101L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartDeleteRequest.java new file mode 100644 index 0000000..55323c4 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartDeleteRequest.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.dto.cart; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class CartDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = 4086381861303093101L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartQueryRequest.java new file mode 100644 index 0000000..cda368e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartQueryRequest.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.dto.cart; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class CartQueryRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = 4086381861303093101L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartUpdateRequest.java new file mode 100644 index 0000000..ebc06a5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/cart/CartUpdateRequest.java @@ -0,0 +1,42 @@ +package com.bsz.school_send_back_end.model.dto.cart; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class CartUpdateRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 关联的菜品id + */ + private Long dishesId; + + /** + * 菜品数量 + */ + private Integer quantity; + + /** + * 是否加入有规格的菜品 + */ + private Boolean isSelectedOptions = false; + + /** + * 已选规格属性列表 + */ + private String selectedOptions = ""; + + @Serial + private static final long serialVersionUID = 4086381861303093101L; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryAddRequest.java new file mode 100644 index 0000000..94963d2 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryAddRequest.java @@ -0,0 +1,23 @@ +package com.bsz.school_send_back_end.model.dto.category; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class CategoryAddRequest implements Serializable { + + /** + * 分类名 + */ + private String name; + + /** + * 分类图片 + */ + private String image; + + @Serial + private static final long serialVersionUID = -8266948446201272634L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryDeleteRequest.java new file mode 100644 index 0000000..b3362d2 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryDeleteRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.category; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class CategoryDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = -8266948446201272634L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryUpdateRequest.java new file mode 100644 index 0000000..8b69250 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/category/CategoryUpdateRequest.java @@ -0,0 +1,30 @@ +package com.bsz.school_send_back_end.model.dto.category; + +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 CategoryUpdateRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 分类名 + */ + private String name; + + /** + * 分类图片 + */ + private String image; + + @Serial + private static final long serialVersionUID = -8266948446201272634L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/file/UploadFileRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/file/UploadFileRequest.java new file mode 100644 index 0000000..e582a7e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/file/UploadFileRequest.java @@ -0,0 +1,19 @@ +package com.bsz.school_send_back_end.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 = 5633491538829896175L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/log/LogQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/log/LogQueryRequest.java new file mode 100644 index 0000000..edd4378 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/log/LogQueryRequest.java @@ -0,0 +1,47 @@ +package com.bsz.school_send_back_end.model.dto.log; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + *系统信息查询请求 + */ +@Data +public class LogQueryRequest extends PageRequest implements Serializable{ + + /** + * 用户id + */ + private Long userId; + + /** + * 手机号 + */ + private String businessPhone; + + /** + * 操作内容 + */ + private String content; + + /** + * ip + */ + private String ip; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + + @Serial + private static final long serialVersionUID = 2952253938605974287L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/MyOrderQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/MyOrderQueryRequest.java new file mode 100644 index 0000000..0b9be4a --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/MyOrderQueryRequest.java @@ -0,0 +1,44 @@ +package com.bsz.school_send_back_end.model.dto.order; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 我的订单查询请求 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class MyOrderQueryRequest extends PageRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 取餐方式(0堂食 1自提) + */ + private Integer pickupMethod; + + /** + * 订单状态:0未支付 1已完成 2已取消 + */ + private Integer state; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderAddRequest.java new file mode 100644 index 0000000..180b579 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderAddRequest.java @@ -0,0 +1,63 @@ +package com.bsz.school_send_back_end.model.dto.order; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 订单创建请求 + */ +@Data +public class OrderAddRequest implements Serializable { + + /** + * 姓名 + */ + private String userName; + + /** + * 手机号 + */ + private String phone; + + /** + * 商家id + */ + private Long businessId; + + /** + * 订单实际总价 + */ + private BigDecimal totalPrice; + + /** + * 取餐方式(0堂食 1自提) + */ + private Integer pickupMethod; + + /** + * 支付方式 + */ + private Integer payMethod; + + /** + * 取餐时间 + */ + private String pickupTime; + + /** + * 备注 + */ + private String notes; + + /** + * 订单详情 + */ + private List orderDetailAddRequest; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderCountRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderCountRequest.java new file mode 100644 index 0000000..d6121a8 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderCountRequest.java @@ -0,0 +1,48 @@ +package com.bsz.school_send_back_end.model.dto.order; + +import lombok.Data; + +@Data +public class OrderCountRequest { + + /** + * 商家id + */ + private Long businessId; + + /** + * 商家名称 + */ + private String businessName; + + /** + * 商家状态 + */ + private Long businessState; + + /** + * 餐厅分类 + */ + private Long categoryId; + + /** + * 类型 + */ + private String type; + + /** + * 支付状态 + */ + private Integer state; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderDetailAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderDetailAddRequest.java new file mode 100644 index 0000000..c2d6b55 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderDetailAddRequest.java @@ -0,0 +1,33 @@ +package com.bsz.school_send_back_end.model.dto.order; + +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 订单详情创建请求 + */ +@Data +public class OrderDetailAddRequest implements Serializable { + + /** + * 关联的菜品id + */ + private Long dishesId; + + /** + * 购买数量 + */ + private Integer quantity; + + /** + * 规格属性列表 + */ + private String attributeNames; + + @Serial + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderQueryRequest.java new file mode 100644 index 0000000..ee79033 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/order/OrderQueryRequest.java @@ -0,0 +1,58 @@ +package com.bsz.school_send_back_end.model.dto.order; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 订单查询请求 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class OrderQueryRequest extends PageRequest implements Serializable { + /** + * id + */ + private Long id; + + /** + * 下单用户id + */ + private Long userId; + + /** + * 商家id + */ + private Long businessId; + + /** + * 取餐码 + */ + private String pickupCode; + + /** + * 取餐方式(0堂食 1自提) + */ + private Integer pickupMethod; + + /** + * 订单状态:0未支付 1已完成 2已取消 + */ + private Integer state; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsAddRequest.java new file mode 100644 index 0000000..9e0386c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsAddRequest.java @@ -0,0 +1,25 @@ +package com.bsz.school_send_back_end.model.dto.specifications; + +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class SpecificationsAddRequest implements Serializable { + + /** + * 规格名称 + */ + private String specificationsName; + + /** + * 属性请求体列表 + */ + private List attributeAddRequests; + + @Serial + private static final long serialVersionUID = -2573217224030065261L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsMyQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsMyQueryRequest.java new file mode 100644 index 0000000..d697de3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsMyQueryRequest.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.dto.specifications; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户删除请求 + * + * @author bsz + */ +@Data +public class SpecificationsMyQueryRequest implements Serializable { + + /** + * id + */ + private Long id; + + private static final long serialVersionUID = 1L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsQueryRequest.java new file mode 100644 index 0000000..1c0af6f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsQueryRequest.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.dto.specifications; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author ASUS + */ +@Data +public class SpecificationsQueryRequest implements Serializable { + + /** + * 规格名称 + */ + private String specificationsName; + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsUpdateRequest.java new file mode 100644 index 0000000..e673702 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/specifications/SpecificationsUpdateRequest.java @@ -0,0 +1,30 @@ +package com.bsz.school_send_back_end.model.dto.specifications; + +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class SpecificationsUpdateRequest implements Serializable { + + /** + * 规格id + */ + private Long id; + + /** + * 规格名称 + */ + private String specificationsName; + + /** + * 属性请求体列表 + */ + private List attributeUpdateRequests; + + @Serial + private static final long serialVersionUID = -2573217224030065261L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemAddRequest.java new file mode 100644 index 0000000..2ac1e5e --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemAddRequest.java @@ -0,0 +1,23 @@ +package com.bsz.school_send_back_end.model.dto.system; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class SystemAddRequest implements Serializable { + + /** + * 类型:0公告,1轮播图 + */ + private Integer type; + + /** + * 功能内容 + */ + private String content; + + @Serial + private static final long serialVersionUID = 8089646587314575974L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemDeleteRequest.java new file mode 100644 index 0000000..f9e0c03 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemDeleteRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.system; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class SystemDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + @Serial + private static final long serialVersionUID = 8089646587314575974L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemQueryRequest.java new file mode 100644 index 0000000..f7d0e46 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/system/SystemQueryRequest.java @@ -0,0 +1,18 @@ +package com.bsz.school_send_back_end.model.dto.system; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class SystemQueryRequest implements Serializable { + + /** + * type 0公告,1轮播图 + */ + private Integer type; + + @Serial + private static final long serialVersionUID = 8089646587314575974L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserAddRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserAddRequest.java new file mode 100644 index 0000000..c22f569 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserAddRequest.java @@ -0,0 +1,45 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * + * 用户创建请求 + * + * @author bsz + */ +@Data +public class UserAddRequest implements Serializable { + + @Serial + private static final long serialVersionUID = -8848430212953827391L; + + /** + * 用户昵称 + */ + private String username; + + /** + * 用户账号 + */ + private String userAccount; + + /** + * 用户密码 + */ + private String userPassword; + + /** + * 用户头像 + */ + private String avatarUrl; + + + + +} + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserDeleteRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserDeleteRequest.java new file mode 100644 index 0000000..928f7ce --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserDeleteRequest.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户删除请求 + * + * @author bsz + */ +@Data +public class UserDeleteRequest implements Serializable { + + /** + * id + */ + private Long id; + + private static final long serialVersionUID = 1L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserLoginRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserLoginRequest.java new file mode 100644 index 0000000..2e512c1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserLoginRequest.java @@ -0,0 +1,25 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import lombok.Data; +import java.io.Serializable; + +/** + * 用户登录请求体 + */ +@Data +public class UserLoginRequest implements Serializable { + + private static final long serialVersionUID = 3191241716373120793L; + + /** + * 用户账号 + */ + private String userAccount; + + /** + * 用户密码 + */ + private String userPassword; + +} + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserQueryRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserQueryRequest.java new file mode 100644 index 0000000..a8c77f1 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserQueryRequest.java @@ -0,0 +1,46 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 用户查询请求 + * @author 玄德 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class UserQueryRequest extends PageRequest implements Serializable { + + /** + * id + */ + private Long id; + + + /** + * openId + */ + private String openId; + + /** + * 用户昵称 + */ + private String username; + + /** + * 手机号 + */ + private String phone; + + /** + * 用户角色:user/admin/ban + */ + private String userRole; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserRegisterRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserRegisterRequest.java new file mode 100644 index 0000000..df6e9c5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserRegisterRequest.java @@ -0,0 +1,30 @@ +package com.bsz.school_send_back_end.model.dto.user; + + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户注册请求体参数 + * + */ +@Data +public class UserRegisterRequest implements Serializable { + /** + * 防止序列化出现冲突 + */ + private static final long serialVersionUID = 3553317334228624372L; + /** + * 用户账号 + */ + private String userAccount; + /** + * 用户密码 + */ + private String userPassword; + /** + * 校验密码 + */ + private String checkPassword; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserSearchRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserSearchRequest.java new file mode 100644 index 0000000..abcdb25 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserSearchRequest.java @@ -0,0 +1,67 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import com.bsz.school_send_back_end.model.dto.PageRequest; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 用户查询请求 +* +* @author bsz +*/ +@Data +public class UserSearchRequest extends PageRequest implements Serializable { + + /** + * 用户昵称 + */ + private String username; + + /** + * 账号 + */ + private String userAccount; + + + /** + * 性别 男 女 + */ + private Integer gender; + + + /** + * 电话 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + /** + * 状态 0-正常 1-注销 2-封号 + */ + private Integer userStatus; + + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * + */ + private String userRole; + + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateMyRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateMyRequest.java new file mode 100644 index 0000000..17a46f3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateMyRequest.java @@ -0,0 +1,42 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 用户更新个人信息请求 + * + */ +@Data +public class UserUpdateMyRequest implements Serializable { + + /** + * 用户名 + */ + private String username; + + + /** + * 用户头像 + */ + private String avatarUrl; + + /** + * 性别 男 女 + */ + private String gender; + + /** + * 电话 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdatePasswordRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdatePasswordRequest.java new file mode 100644 index 0000000..ffaacfa --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdatePasswordRequest.java @@ -0,0 +1,25 @@ +package com.bsz.school_send_back_end.model.dto.user; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Shier + * CreateTime 2023/5/11 12:24 + */ +@Data +public class UserUpdatePasswordRequest implements Serializable { + + private static final long serialVersionUID = -5996345129538944393L; + + /** + * 原密码 + */ + private String userPassword; + + /** + * 新密码 + */ + private String newPassword; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateRequest.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateRequest.java new file mode 100644 index 0000000..32ee9ad --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/dto/user/UserUpdateRequest.java @@ -0,0 +1,69 @@ +package com.bsz.school_send_back_end.model.dto.user; + + +import com.baomidou.mybatisplus.annotation.TableLogic; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户更新请求 + * + * @author bsz + */ +@Data +public class UserUpdateRequest implements Serializable { + + private Long id; + /** + * 用户昵称 + */ + private String username; + + /** + * 账号 + */ + private String userAccount; + + /** + * 密码 + */ + private String userPassword; + + /** + * 用户头像 + */ + private String avatarUrl; + + /** + * 性别 + */ + private Integer gender; + + /** + * 电话 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + /** + * 状态 0 - 正常 1 - 注销 2 - 封号 + */ + private Integer userStates; + + /** + * 更新时间 + */ + private Date updateTime; + + + /** + * 用户 or 管理员 + */ + private String userRole; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/FileUploadBizEnum.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/FileUploadBizEnum.java new file mode 100644 index 0000000..159fe3f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/FileUploadBizEnum.java @@ -0,0 +1,53 @@ +package com.bsz.school_send_back_end.model.enums; + +import lombok.Getter; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +public enum FileUploadBizEnum { + USER_AVATAR("头像", "user_avatar"), + + DISHES_IMAGE("菜品", "dishes"), + + CARD_IMAGE("证件", "card"), + + SYSTEM_IMAGE("系统", "system"); + + + 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 fileEnum : FileUploadBizEnum.values()) { + if (fileEnum.value.equals(value)) { + return fileEnum; + } + } + + return null; + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/UserRoleEnum.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/UserRoleEnum.java new file mode 100644 index 0000000..14640b8 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/enums/UserRoleEnum.java @@ -0,0 +1,51 @@ +package com.bsz.school_send_back_end.model.enums; + +import lombok.Getter; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 用户角色枚举 + */ +@Getter +public enum UserRoleEnum { + + USER("用户", "user"), + BUSINESS("商家", "business"), + ADMIN("管理员", "admin"), + BOSS("Boss", "boss"), + BAN("被封号", "ban"); + + private final String text; + private final String value; + + UserRoleEnum(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 UserRoleEnum getEnumByValue(String value) { + if (ObjectUtils.isEmpty(value)) { + return null; + } + for (UserRoleEnum anEnum : UserRoleEnum.values()) { + if (anEnum.value.equals(value)) { + return anEnum; + } + } + return null; + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/AttributeVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/AttributeVO.java new file mode 100644 index 0000000..64e6f3f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/AttributeVO.java @@ -0,0 +1,28 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class AttributeVO implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 属性名称 + */ + private String attributeName; + + /** + * 属性状态:0在售,1停售 + */ + private Integer attributeStatus; + + @Serial + private static final long serialVersionUID = 1542187317375164514L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessAdminVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessAdminVO.java new file mode 100644 index 0000000..93ee027 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessAdminVO.java @@ -0,0 +1,119 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 商家视图(管理员视角) + */ +@Data +public class BusinessAdminVO implements Serializable { + + + @Serial + private static final long serialVersionUID = 1250238798844609277L; + /** + * id + */ + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 用户id + */ + private Long userId; + + /** + * 门店名称 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 门店手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 店主名 + */ + private String shopkeeper; + + /** + * 营业执照 + */ + private String license; + + /** + * 身份证正面 + */ + private String frontIdCard; + + /** + * 身份证反面 + */ + private String backIdCard; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; + + /** + * 状态:0禁用,1启用 + */ + private Integer state; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + + /** + * 创建时间 + */ + private Date createTime; + + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessLogVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessLogVO.java new file mode 100644 index 0000000..1a15799 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessLogVO.java @@ -0,0 +1,43 @@ +package com.bsz.school_send_back_end.model.vo; + +import com.bsz.school_send_back_end.model.domain.Business; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 商家日志视图 + */ +@Data +public class BusinessLogVO implements Serializable { + + /** + * 用户id + */ + private Long userId; + + /** + * 商家信息 + */ + private Business business; + + /** + * 操作内容 + */ + private String content; + + /** + * ip地址 + */ + private String ip; + + /** + * 创建时间 + */ + private Date createTime; + + @Serial + private static final long serialVersionUID = 3150374624339085749L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessVO.java new file mode 100644 index 0000000..c102759 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/BusinessVO.java @@ -0,0 +1,89 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 商家视图 (用户视角) + * + * + */ +@Data +public class BusinessVO implements Serializable { + + @Serial + private static final long serialVersionUID = -3905934050752996111L; + /** + * id + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 门店名称 + */ + private String businessName; + + /** + * 门店头像 + */ + private String businessAvatar; + + /** + * 门店手机号 + */ + private String businessPhone; + + /** + * 店铺详细地址 + */ + private String address; + + /** + * 门店简介 + */ + private String businessProfile; + + /** + * 商家相册 + */ + private String businessImages; + + /** + * 开始营业时间 + */ + private String startBusiness; + + /** + * 结束营业时间 + */ + private String endBusiness; + + /** + * 月售 + */ + private Long monthlySales; + + /** + * 分类id + */ + private Long categoryId; + + /** + * 店铺状态:0休业,1营业 + */ + private Integer storeStatus; + + /** + * 创建时间 + */ + private Date createTime; + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/CartVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/CartVO.java new file mode 100644 index 0000000..b7a443f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/CartVO.java @@ -0,0 +1,55 @@ +package com.bsz.school_send_back_end.model.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 购物车表 + * @TableName cart + */ +@TableName(value ="cart") +@Data +public class CartVO implements Serializable { + /** + * id + */ + private Long id; + + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品id + */ + private Long dishesId; + + /** + * 商品数量 + */ + private Integer quantity; + + /** + * 当前选择规格的价格 + */ + private BigDecimal price; + + /** + * 小计(单价 * 数量) + */ + private BigDecimal subtotal; + + /** + * 已选规格属性列表 + */ + private String selectedOptions; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesGroupVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesGroupVO.java new file mode 100644 index 0000000..8a2c11b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesGroupVO.java @@ -0,0 +1,21 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +@Data +public class DishesGroupVO { + /** + * 商家id + */ + private Long businessId; + + /** + * 菜品分组名称 + */ + private String groupName; + + /** + * 是否置顶:0不置顶,1置顶 + */ + private Integer isTopping; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesVO.java new file mode 100644 index 0000000..33e5edf --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/DishesVO.java @@ -0,0 +1,40 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +@Data +public class DishesVO { + /** + * 菜品名称 + */ + private String dishesName; + + /** + * 菜品图片 + */ + private String dishesImage; + + /** + * 菜品价格 + */ + private Double dishesPrice; + + /** + * 打包费 + */ + private Double packPrice; + + /** + * 库存数量 + */ + private Integer inventoryStatus; + + /** + * 菜品状态:上架,下架 + */ + private String status; + /** + * 是否有规格(0:没有,1:有) + */ + private Integer isSpecification = 0; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/LoginUserVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/LoginUserVO.java new file mode 100644 index 0000000..009f8fe --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/LoginUserVO.java @@ -0,0 +1,60 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 已登录用户视图(脱敏) + * @author bsz + */ +@Data +public class LoginUserVO implements Serializable { + + + /** + * 用户 id + */ + private Long id; + + /** + * 用户昵称 + */ + private String username; + + /** + * 用户头像 + */ + private String avatarUrl; + + /** + * 性别 + */ + private Integer gender; + + /** + * 手机号 + */ + private String phone; + + /** + * 用户角色:user/admin + */ + private String userRole; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + @Serial + private static final long serialVersionUID = 6304492672093490894L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrderDetailsVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrderDetailsVO.java new file mode 100644 index 0000000..446c06b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrderDetailsVO.java @@ -0,0 +1,69 @@ +package com.bsz.school_send_back_end.model.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单详情表 + * + * @TableName order_details + */ +@TableName(value = "order_details") +@Data +public class OrderDetailsVO implements Serializable { + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 关联的订单id + */ + private Long orderId; + + /** + * 关联的菜品id + */ + private Long dishesId; + + /** + * 菜品信息 + */ + private DishesVO dishesVO; + + /** + * 购买数量 + */ + private Integer quantity; + + /** + * 单价 + */ + private BigDecimal price; + + /** + * 小计(单价 * 数量) + */ + private BigDecimal subtotal; + + /** + * 规格属性列表 + */ + private String attributeNames; + + /** + * 创建时间 + */ + private Date createTime; + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrdersVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrdersVO.java new file mode 100644 index 0000000..6cdc212 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/OrdersVO.java @@ -0,0 +1,105 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单视图 + */ +@Data +public class OrdersVO implements Serializable { + /** + * id + */ + private Long id; + + /** + * 取餐码 + */ + private String pickupCode; + + /** + * 姓名 + */ + private String userName; + + /** + * 手机号 + */ + private String phone; + + /** + * 下单用户id + */ + private Long userId; + + /** + * 商家id + */ + private Long businessId; + + /** + * 商家信息 + */ + private BusinessVO businessVO; + + /** + * 订单实际总价 + */ + private BigDecimal totalPrice; + + /** + * 取餐方式(0堂食 1自提) + */ + private Integer pickupMethod; + + /** + * 支付方式 + */ + private Integer payMethod; + + /** + * 取餐时间 + */ + private String pickupTime; + + /** + * 备注 + */ + private String notes; + + /** + * 订单状态:0未支付 1已完成 2已取消 + */ + private Integer state; + + /** + * 下单时间 + */ + private Date createTime; + + /** + * 支付时间 + */ + private Date updateTime; + + /** + * 商品数量 + */ + private Integer number; + + /** + * 订单详情 + */ + private List orderDetailsVOList; + + + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/SpecificationsVO.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/SpecificationsVO.java new file mode 100644 index 0000000..3c0d195 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/model/vo/SpecificationsVO.java @@ -0,0 +1,29 @@ +package com.bsz.school_send_back_end.model.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class SpecificationsVO implements Serializable { + + /** + * 规格id + */ + private Long id; + + /** + * 规格名称 + */ + private String specificationsName; + + /** + * 该规格的所有属性 + */ + private List attributeVOList; + + @Serial + private static final long serialVersionUID = 8473325711571994982L; +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/AttributeService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/AttributeService.java new file mode 100644 index 0000000..389c328 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/AttributeService.java @@ -0,0 +1,37 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Attribute; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; + +import java.util.List; + +/** +* @author xy +*/ +public interface AttributeService extends IService { + + /** + * 根据规格id获取属性脱敏列表 + */ + List getBySpecificationsVoId(List specificationsVOList); + + /** + * 添加规格的属性 + */ + Boolean addAttribute(List attributeAddRequest, Long businessId, Long specificationsId); + + /** + * 校验 + */ + void validAttribute(Attribute attribute); + + /** + * 更新规格的属性信息 + */ + Boolean updateAttribute(List attributeUpdateRequests, Long businessId, Long specificationsId); + + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessAuthService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessAuthService.java new file mode 100644 index 0000000..a35bbf7 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessAuthService.java @@ -0,0 +1,22 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.vo.BusinessAdminVO; + +import java.util.List; + +/** +* @author Lenovo +* @description 针对表【business_auth(商家认证)】的数据库操作Service +* @createDate 2024-06-24 21:01:17 +*/ +public interface BusinessAuthService extends IService { + + /** + * 获取脱敏的商家信息 + */ + BusinessAdminVO getBusinessAdminVO(Business business); + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessService.java new file mode 100644 index 0000000..0db0791 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/BusinessService.java @@ -0,0 +1,55 @@ +package com.bsz.school_send_back_end.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.bsz.school_send_back_end.model.domain.Business; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.bsz.school_send_back_end.model.domain.DishesGroup; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.business.BusinessQueryRequest; +import com.bsz.school_send_back_end.model.vo.BusinessVO; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** +* @author Lenovo +* @description 针对表【business(商家)】的数据库操作Service +* @createDate 2024-06-24 21:01:17 +*/ +public interface BusinessService extends IService { + + /** + * 添加商户和商家的账户以及填充认证信息 + * @param user + * @param business + * @param businessAuth + */ + void addBusiness(User user, Business business, BusinessAuth businessAuth); + + /** + *校验 + */ + void validUser(User user, boolean add); + + void validBusiness(Business business, boolean add); + + void validBusinessAuth(BusinessAuth businessAuth, boolean add); + + /** + * 获取查询条件 + */ + QueryWrapper getQueryWrapper(BusinessQueryRequest businessQueryRequest); + + BusinessVO getBusinessVO(Business business); + /** + * 获取脱敏的商家信息 + */ + List getBusinessVO(List businessList); + + + /** + * 获取当前登录商家 + */ + Business getLoginBusiness(HttpServletRequest request); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CartService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CartService.java new file mode 100644 index 0000000..0a70ec5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CartService.java @@ -0,0 +1,39 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Cart; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.dto.cart.CartAddRequest; +import com.bsz.school_send_back_end.model.dto.cart.CartUpdateRequest; +import com.bsz.school_send_back_end.model.vo.CartVO; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** +* @author pc +* @description 针对表【cart(购物车表)】的数据库操作Service +* @createDate 2024-08-13 13:59:13 +*/ +public interface CartService extends IService { + + /** + * 校验 + */ + void validCart(CartAddRequest cartAddRequest); + + /** + * 添加菜品 + */ + Long addCart (CartAddRequest cartAddRequest, HttpServletRequest request); + + /** + * 更新购物车菜品 + */ + Boolean updateCart(CartUpdateRequest cartUpdateRequest, HttpServletRequest request); + + /** + * 删除购物车菜品 + */ + Boolean deleteCart(Long cartId, HttpServletRequest request); + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CategoryService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CategoryService.java new file mode 100644 index 0000000..e8f0ffd --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/CategoryService.java @@ -0,0 +1,17 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Category; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author pc +* @description 针对表【category(分类表)】的数据库操作Service +* @createDate 2024-09-01 18:09:04 +*/ +public interface CategoryService extends IService { + /** + * 校验 + */ + void validCategory(Category category, boolean add); + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesGroupService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesGroupService.java new file mode 100644 index 0000000..d26870d --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesGroupService.java @@ -0,0 +1,34 @@ +package com.bsz.school_send_back_end.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.domain.DishesGroup; +import com.bsz.school_send_back_end.model.vo.DishesGroupVO; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** +* @author xy +*/ +public interface DishesGroupService extends IService { + + /** + * 校验菜品分组 + */ + void validDishesGroup(DishesGroup dishesGroup,boolean update); + + /** + * 添加菜品分组 + */ + Boolean addDishesGroup(DishesGroup dishesGroup, HttpServletRequest request); + + /** + * 获取菜品分组 + */ + List getDishGroupVOList(List dishesGroupList); + + /** + * 更新 + */ + Boolean updateDishesGroupById(DishesGroup dishesGroup, HttpServletRequest request); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesService.java new file mode 100644 index 0000000..d17a186 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/DishesService.java @@ -0,0 +1,51 @@ +package com.bsz.school_send_back_end.service; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesQueryRequest; +import com.bsz.school_send_back_end.model.vo.DishesVO; +import java.util.List; + +/** +* @author xy +*/ +public interface DishesService extends IService { + + /** + * 根据分组id删除菜品 + */ + void removeByDishesGroupId(Long dishesGroupId); + + /** + * 校验 + */ + void validDishes(Dishes dishes, Boolean update); + + /** + * 添加菜品 + */ + Long addDishes(Dishes dishes); + + /** + * 更新菜品 + */ + Boolean updateDishes(Dishes dishes); + + /** + * 获取菜品脱敏信信息 + */ + List getDishesVOList(List dishesList); + + /** + * 获取菜品脱敏信息 + */ + DishesVO getDishesVO(Dishes dishes); + + + /** + * 获取菜品查询条件 + */ + QueryWrapper getWrapper(DishesQueryRequest dishesQueryRequest); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrderDetailsService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrderDetailsService.java new file mode 100644 index 0000000..baca225 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrderDetailsService.java @@ -0,0 +1,34 @@ +package com.bsz.school_send_back_end.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.domain.OrderDetails; +import com.bsz.school_send_back_end.model.vo.OrderDetailsVO; + + +import java.util.List; + +/** + * @author 玄德 + * @description 针对表【order_details(订单详情表)】的数据库操作Service + * @createDate 2024-04-05 17:57:44 + */ +public interface OrderDetailsService extends IService { + + /** + * 校验订单菜品 + */ + void validOrderDetail(OrderDetails orderDetails); + + /** + * 获取订单详情视图信息 + */ + OrderDetailsVO getOrderDetailsVO(OrderDetails orderDetails); + + /** + * 获取订单详情视图信息 + */ + List getOrderDetailsVO(List orderDetailsList); + + + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrdersService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrdersService.java new file mode 100644 index 0000000..dceabbf --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OrdersService.java @@ -0,0 +1,44 @@ +package com.bsz.school_send_back_end.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.domain.OrderDetails; +import com.bsz.school_send_back_end.model.domain.Orders; +import com.bsz.school_send_back_end.model.dto.order.OrderQueryRequest; +import com.bsz.school_send_back_end.model.vo.OrdersVO; + + +import java.util.List; + +/** + * @author 玄德 + * @description 针对表【orders(订单表)】的数据库操作Service + * @createDate 2024-04-05 17:57:44 + */ +public interface OrdersService extends IService { + + /** + * 创建订单 + * + * @return 订单id + */ + long addOrder(Orders orders, List orderDetailsList); + + /** + * 校验订单 + */ + void validOrder(Orders orders); + + /** + * 获取订单视图信息 + */ + OrdersVO getOrdersVO(Orders orders); + + List getOrdersVO(List ordersList); + + /** + * 获取查询条件 + */ + QueryWrapper getQueryWrapper(OrderQueryRequest orderQueryRequest); + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OssService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OssService.java new file mode 100644 index 0000000..337f6ea --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/OssService.java @@ -0,0 +1,17 @@ +package com.bsz.school_send_back_end.service; + +import org.springframework.web.multipart.MultipartFile; + +/** + * @author Shier + */ +public interface OssService { + /** + * 上传头像到OSS + * + * @param file + * @return + */ + String uploadFileAvatar(MultipartFile file); + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsDishesService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsDishesService.java new file mode 100644 index 0000000..720598c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsDishesService.java @@ -0,0 +1,35 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.SpecificationsDishes; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; + +import java.util.List; + +/** +* @author pc +* @description 针对表【specifications_dishes(菜品和规格的中间表)】的数据库操作Service +* @createDate 2024-06-29 21:18:25 +*/ +public interface SpecificationsDishesService extends IService { + + /** + * 删除中间表信息 + */ + void deleteByDishesId(Long dishesId); + + /** + * 添加中间表信息 + */ + Boolean add(Long dishesId, List specificationsIds); + + /** + * 更新中间表信息 + */ + Boolean updateByDishesId(Long dishesId, List specificationsIds); + + /** + * 根据中间表数据中的规格id获取规格信息和属性 + */ + List getSpecificationsAddAttribute(List specificationsDishesList); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsService.java new file mode 100644 index 0000000..2894b99 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SpecificationsService.java @@ -0,0 +1,36 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Specifications; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** +* @author xy +*/ +public interface SpecificationsService extends IService { + + /** + * 校验 + */ + void validSpecifications(Specifications specifications, boolean add); + + /** + * 添加规格 + */ + Boolean addSpecifications(Specifications specifications, List attributeAddRequests, HttpServletRequest request); + + /** + * 更新规格 + */ + Boolean updateSpecifications(Specifications specifications, List attributeUpdateRequests, HttpServletRequest request); + + /** + * 获取规格脱敏列表 + */ + List getSpecificationsVO(List specificationsList); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SysteminfoService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SysteminfoService.java new file mode 100644 index 0000000..d5ab950 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SysteminfoService.java @@ -0,0 +1,13 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.Systeminfo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author pc +* @description 针对表【systeminfo(系统信息)】的数据库操作Service +* @createDate 2024-09-23 19:16:42 +*/ +public interface SysteminfoService extends IService { + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SystemlogService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SystemlogService.java new file mode 100644 index 0000000..ffefa2b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/SystemlogService.java @@ -0,0 +1,20 @@ +package com.bsz.school_send_back_end.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.bsz.school_send_back_end.model.domain.Systemlog; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.dto.log.LogQueryRequest; + +/** +* @author pc +* @description 针对表【systemlog(系统信息)】的数据库操作Service +* @createDate 2024-09-25 15:40:09 +*/ +public interface SystemlogService extends IService { + + /** + * 获取查询条件 + */ + QueryWrapper getQueryWrapper(LogQueryRequest logQueryRequest); + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/UserService.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/UserService.java new file mode 100644 index 0000000..a6c5b38 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/UserService.java @@ -0,0 +1,93 @@ +package com.bsz.school_send_back_end.service; + +import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsz.school_send_back_end.model.vo.LoginUserVO; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.user.UserSearchRequest; +import com.bsz.school_send_back_end.model.dto.user.UserUpdatePasswordRequest; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** +* @author bsz +* @description +* @createDate 2024-05-09 20:59:59 +*/ +@Service +public interface UserService extends IService { + + /** + * 用户注册 + * + * @param userAccount 登陆账号 + * @param userPassword 登录密码 + * @param checkPassword 校验密码 + * @return 新用户id + */ + long userRegister(String userAccount, String userPassword, String checkPassword); + + /** + * + * @param userAccount 登陆账号 + * @param userPassword 登陆密码 + * @param request 返回请求 + * @return 脱敏后的用户信息 + */ + + LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request); + + + /** + * 用户脱敏 + * + * @param originUser + * @return + */ + User getSafetyUser(User originUser); + + /** + * 用户注销 + * + * + * @param request + * @return 1 表示成功 + */ + int userLogout(HttpServletRequest request); + + /** + * 获取当前用户登录信息 + * + * @param request + * @return + */ + User getLoginUser(HttpServletRequest request); + + /** + * 修改密码 + * + * @param updatePasswordRequest + * @param request + */ + boolean updateUserPassword(UserUpdatePasswordRequest updatePasswordRequest, HttpServletRequest request); + + /** + * 分页条件 + * @param searchRequest + * @return + */ + QueryWrapper getQueryWrapper(UserSearchRequest searchRequest); + + /** + * 用户登录(支付宝) + * @param openId + * @param userInfo + * @param request + * @return 返回脱敏后的用户信息 + */ + LoginUserVO userLoginByAlipay(String openId, JSONObject userInfo, HttpServletRequest request); + + public LoginUserVO getLoginUserVO(User user); +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/AttributeServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/AttributeServiceImpl.java new file mode 100644 index 0000000..7ea31a5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/AttributeServiceImpl.java @@ -0,0 +1,136 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.AttributeMapper; +import com.bsz.school_send_back_end.model.domain.Attribute; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import com.bsz.school_send_back_end.model.vo.AttributeVO; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; +import com.bsz.school_send_back_end.service.AttributeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author xy +*/ +@Service +public class AttributeServiceImpl extends ServiceImpl + implements AttributeService { + + @Override + public List getBySpecificationsVoId(List specificationsVOList) { + if (CollectionUtils.isEmpty(specificationsVOList)) { + return specificationsVOList; + } + return specificationsVOList.stream().peek(item ->{ + Long specificationsId = item.getId(); + //根据规格id获取属性 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("specificationsId",specificationsId); + List attributeList = this.list(queryWrapper); + //获取属性脱敏信息 + List attributeVOList = getAttributeVOList(attributeList); + item.setAttributeVOList(attributeVOList); + }).collect(Collectors.toList()); + } + + @Override + public Boolean addAttribute(List attributeAddRequests, Long businessId, Long specificationsId) { + if (attributeAddRequests.isEmpty()) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + //保存每个规格属性 + for (AttributeAddRequest attributeAddRequest: attributeAddRequests) { + Attribute attribute = new Attribute(); + BeanUtils.copyProperties(attributeAddRequest, attribute); + //校验 + validAttribute(attribute); + //添加保存 + saveAttribute(businessId, specificationsId, attribute); + } + + return true; + } + + @Override + public void validAttribute(Attribute attribute) { + if (attribute == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + String attributeName = attribute.getAttributeName(); + Integer attributeStatus = attribute.getAttributeStatus(); + + if (attributeStatus == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请填写属性状态"); + } + + if (StringUtils.isBlank(attributeName)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请填写属性名称"); + } + } + + @Override + public Boolean updateAttribute(List attributeUpdateRequests, Long businessId, Long specificationsId) { + if (attributeUpdateRequests.isEmpty()) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"请补全属性参数"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("specificationsId",specificationsId); + boolean remove = this.remove(queryWrapper); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + //更新 + for (AttributeUpdateRequest attributeUpdateRequest : attributeUpdateRequests) { + Attribute attribute = new Attribute(); + BeanUtils.copyProperties(attributeUpdateRequest,attribute); + //校验 + validAttribute(attribute); + //更新 + saveAttribute(businessId,specificationsId,attribute); + } + + return true; + } + + /** + * 获取脱敏属性列表 + * @param attributes 为脱敏列表 + * @return 脱敏列表 + */ + private List getAttributeVOList (List attributes) { + if (CollectionUtils.isEmpty(attributes)) { + return new ArrayList<>(); + } + return attributes.stream().map(item -> { + AttributeVO attributeVO = new AttributeVO(); + BeanUtils.copyProperties(item,attributeVO); + return attributeVO; + }).collect(Collectors.toList()); + } + + /** + * 保存属性信息 + */ + private void saveAttribute(Long businessId, Long specificationsId, Attribute attribute) { + attribute.setBusinessId(businessId); + attribute.setSpecificationsId(specificationsId); + boolean result = this.save(attribute); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessAuthServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessAuthServiceImpl.java new file mode 100644 index 0000000..d89c8d5 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessAuthServiceImpl.java @@ -0,0 +1,54 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.bsz.school_send_back_end.model.vo.BusinessAdminVO; +import com.bsz.school_send_back_end.service.BusinessAuthService; +import com.bsz.school_send_back_end.mapper.BusinessAuthMapper; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +/** +* @author Lenovo +* @description 针对表【business_auth(商家认证)】的数据库操作Service实现 +* @createDate 2024-06-24 21:01:17 +*/ +@Service +public class BusinessAuthServiceImpl extends ServiceImpl + implements BusinessAuthService{ + + @Override + public BusinessAdminVO getBusinessAdminVO(Business business) { + if (business == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + BusinessAdminVO businessAdminVO = new BusinessAdminVO(); + + //关联认证信息 传入到视图中 + BusinessAuth businessAuth = new BusinessAuth(); + Long id = business.getId(); + if (id != null && id > 0) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessId", id); + businessAuth = this.getOne(queryWrapper); + } + + BeanUtils.copyProperties(business, businessAdminVO); + + if (businessAuth == null) { + throw new BusinessException(ErrorCode.NULL_ERROR); + } + + BeanUtils.copyProperties(businessAuth, businessAdminVO); + + return businessAdminVO; + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessServiceImpl.java new file mode 100644 index 0000000..7433cf0 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/BusinessServiceImpl.java @@ -0,0 +1,204 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.contant.CommonConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.BusinessAuth; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.business.BusinessQueryRequest; +import com.bsz.school_send_back_end.model.vo.BusinessVO; +import com.bsz.school_send_back_end.service.BusinessAuthService; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.mapper.BusinessMapper; +import com.bsz.school_send_back_end.service.UserService; +import com.bsz.school_send_back_end.utils.RegexUtils; +import com.bsz.school_send_back_end.utils.SqlUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author Lenovo +* @description 针对表【business(商家)】的数据库操作Service实现 +* @createDate 2024-06-24 21:01:17 +*/ +@Service +public class BusinessServiceImpl extends ServiceImpl + implements BusinessService{ + + @Resource + private UserService userService; + + + @Resource + private BusinessAuthService businessAuthService; + + @Override + @Transactional(rollbackFor = Exception.class) + public synchronized void addBusiness(User user, Business business, BusinessAuth businessAuth) { + boolean save = userService.save(user); + ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "创建商家失败"); + + //商家绑定user + business.setUserId(user.getId()); + boolean save1 = this.save(business); + ThrowUtils.throwIf(!save1, ErrorCode.OPERATION_ERROR, "绑定id失败"); + //添加认证信息 + businessAuth.setBusinessId(business.getId()); + boolean save2 = businessAuthService.save(businessAuth); + ThrowUtils.throwIf(!save1, ErrorCode.OPERATION_ERROR, "商家认证信息失败"); + + } + + @Override + public void validUser(User user, boolean add) { + ThrowUtils.throwIf(user == null , ErrorCode.NULL_ERROR); + + String userAccount = user.getUserAccount(); + String userPassword = user.getUserPassword(); + + if (add) { + ThrowUtils.throwIf(StringUtils.isAllBlank(userAccount, userPassword), ErrorCode.PARAMS_ERROR); + + if (userAccount.length() < 4) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户账号不符合要求"); + } + + if(userPassword.length() < 8) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户密码不符合要求"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userAccount", userAccount); + long count = userService.count(queryWrapper); + if (count > 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "账号重复"); + } + } + } + + @Override + public void validBusiness(Business business, boolean add) { + String businessName = business.getBusinessName(); + String businessAvatar = business.getBusinessAvatar(); + String businessPhone = business.getBusinessPhone(); + String address = business.getAddress(); + String startBusiness = business.getStartBusiness(); + String endBusiness = business.getEndBusiness(); + + //只在添加时严格校验 保证商家信息是全的 + if (add) { + if (StringUtils.isAnyBlank(businessName, businessAvatar, businessPhone, address, startBusiness, endBusiness)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "商家信息不全"); + } + } + + // 有参数可以校验参数 保证商家名字唯一 + if (StringUtils.isNotBlank(businessName)) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessName", businessName); + long count = this.count(queryWrapper); + ThrowUtils.throwIf(count > 0, ErrorCode.OPERATION_ERROR, "门店名称重复"); + } + + //校验手机号格式 + if (StringUtils.isNotBlank(businessPhone)) { + boolean phoneInvalid = RegexUtils.isPhoneInvalid(businessPhone); + ThrowUtils.throwIf(phoneInvalid, ErrorCode.PARAMS_ERROR, "手机号格式错误"); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessPhone", businessPhone); + long count = this.count(queryWrapper); + ThrowUtils.throwIf(count > 0 , ErrorCode.OPERATION_ERROR, "手机号重复"); + } + } + + @Override + public void validBusinessAuth(BusinessAuth businessAuth, boolean add) { + //只在添加时严格校验 保证商家认证信息是全的 + if (add) { + String shopkeeper = businessAuth.getShopkeeper(); + String license = businessAuth.getLicense(); + String frontIdCard = businessAuth.getFrontIdCard(); + String backIdCard = businessAuth.getBackIdCard(); + String bankCard = businessAuth.getBankCard(); + if (StringUtils.isAnyBlank(shopkeeper, license, frontIdCard, bankCard, backIdCard)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "商家认证信息不全"); + } + } + } + + @Override + public QueryWrapper getQueryWrapper(BusinessQueryRequest businessQueryRequest) { + + if (businessQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + + Long id = businessQueryRequest.getId(); + Long userId = businessQueryRequest.getUserId(); + Long categoryId = businessQueryRequest.getCategoryId(); + Integer state = businessQueryRequest.getState(); + Integer storeStatus = businessQueryRequest.getStoreStatus(); + String businessName = businessQueryRequest.getBusinessName(); + String address = businessQueryRequest.getAddress(); + String businessProfile = businessQueryRequest.getBusinessProfile(); + String sortField = businessQueryRequest.getSortField(); + String sortOrder = businessQueryRequest.getSortOrder(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(ObjectUtils.isNotEmpty(id), "id", id); + queryWrapper.eq(ObjectUtils.isNotEmpty(userId), "userId", userId); + queryWrapper.eq(ObjectUtils.isNotEmpty(categoryId), "categoryId", categoryId); + queryWrapper.eq(ObjectUtils.isNotEmpty(state), "state", state); + queryWrapper.eq(ObjectUtils.isNotEmpty(storeStatus), "storeStatus", storeStatus); + queryWrapper.like(StringUtils.isNotBlank(businessName), "businessName", businessName); + queryWrapper.like(StringUtils.isNotBlank(address), "address", address); + queryWrapper.like(StringUtils.isNotBlank(businessProfile), "businessProfile", businessProfile); + queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), + sortField); + return queryWrapper; + } + + @Override + public BusinessVO getBusinessVO(Business business) { + BusinessVO businessVO = new BusinessVO(); + if (business == null) { + return null; + } + BeanUtils.copyProperties(business,businessVO); + return businessVO; + } + + @Override + public List getBusinessVO(List businessList) { + if (CollectionUtils.isEmpty(businessList)) { + return new ArrayList<>(); + } + return businessList.stream().map(this::getBusinessVO).collect(Collectors.toList()); + } + + @Override + public Business getLoginBusiness(HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userId",loginUser.getId()); + Business business = this.baseMapper.selectOne(queryWrapper); + ThrowUtils.throwIf(business == null,ErrorCode.NOT_FOUND_ERROR,"当前用户没有关联商家"); + return business; + } + + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CartServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CartServiceImpl.java new file mode 100644 index 0000000..7ce837c --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CartServiceImpl.java @@ -0,0 +1,138 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Cart; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.cart.CartAddRequest; +import com.bsz.school_send_back_end.model.dto.cart.CartUpdateRequest; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.CartService; +import com.bsz.school_send_back_end.mapper.CartMapper; +import com.bsz.school_send_back_end.service.DishesService; +import com.bsz.school_send_back_end.service.UserService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; + +/** +* @author pc +*/ +@Service +public class CartServiceImpl extends ServiceImpl + implements CartService{ + + @Resource + private BusinessService businessService; + + @Resource + private DishesService dishesService; + + @Resource + private UserService userService; + + @Override + public void validCart(CartAddRequest cartAddRequest) { + if (cartAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + Long businessId = cartAddRequest.getBusinessId(); + Long dishesId = cartAddRequest.getDishesId(); + Integer quantity = cartAddRequest.getQuantity(); + + if (quantity == null || quantity < 1) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR,"菜品数量错误"); + } + + Business business = businessService.getById(businessId); + if (business == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"不存在改商家"); + } + + Dishes dishes = dishesService.getById(dishesId); + if (dishes == null || dishes.getStatus().equals("下架")){ + throw new BusinessException(ErrorCode.PARAMS_ERROR,"不存在改菜品"); + } + } + + @Override + public Long addCart(CartAddRequest cartAddRequest, HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + Long businessId = cartAddRequest.getBusinessId(); + Long dishesId = cartAddRequest.getDishesId(); + //计算菜品价格 + Dishes dishes = dishesService.getById(dishesId); + BigDecimal price = new BigDecimal(String.valueOf(dishes.getDishesPrice())); + //保存购物车菜品 + Cart cart = new Cart(); + cart.setBusinessId(businessId); + cart.setUserId(userId); + cart.setPrice(price); + cart.setDishesId(dishesId); + boolean save = this.save(cart); + ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR); + + return cart.getId(); + } + + @Override + public Boolean updateCart(CartUpdateRequest cartUpdateRequest, HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + Long dishesId = cartUpdateRequest.getDishesId(); + String selectedOptions = cartUpdateRequest.getSelectedOptions(); + Long id = cartUpdateRequest.getId(); + ThrowUtils.throwIf(id == null,ErrorCode.OPERATION_ERROR,"购物车id不存在"); + //检验该购物车是否为登录用户的 + Cart cartId =this.getById(id); + Long cartUserId = cartId.getUserId(); + if (userId.equals(cartUserId)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"无法操作该购物车"); + } + Dishes dishes = dishesService.getById(dishesId); + BigDecimal price = new BigDecimal(String.valueOf(dishes.getDishesPrice())); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Cart::getId, id); + Cart cart = this.getOne(wrapper); + Integer quantity = cartUpdateRequest.getQuantity(); + if (cartUpdateRequest.getIsSelectedOptions()) { + cart.setQuantity(cart.getQuantity() + quantity); + } else { + cart.setQuantity(quantity); + } + cart.setPrice(price); + cart.setSubtotal(null); + cart.setSelectedOptions(selectedOptions); + + return this.updateById(cart); + } + + @Override + public Boolean deleteCart(Long cartId, HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + Long userId = loginUser.getId(); + Cart cart = this.getById(cartId); + Long cartUserId = cart.getUserId(); + + if (!userId.equals(cartUserId)) { + throw new BusinessException(ErrorCode.OPERATION_ERROR, "该用户无权删除该购物车"); + } + boolean remove = this.removeById(cartId); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + + return true; + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CategoryServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CategoryServiceImpl.java new file mode 100644 index 0000000..882fc85 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/CategoryServiceImpl.java @@ -0,0 +1,46 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.model.domain.Category; +import com.bsz.school_send_back_end.service.CategoryService; +import com.bsz.school_send_back_end.mapper.CategoryMapper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** +* @author xy +*/ +@Service +public class CategoryServiceImpl extends ServiceImpl + implements CategoryService{ + + @Resource + private CategoryMapper categoryMapper; + + @Override + public void validCategory(Category category, boolean add) { + String name = category.getName(); + String image = category.getImage(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Category::getName, name); + if (add) { + ThrowUtils.throwIf(name == null, ErrorCode.PARAMS_ERROR, "请传入名称!"); + } + + if (StringUtils.isAnyBlank(image)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"请传入图片"); + } + Long count = categoryMapper.selectCount(wrapper); + ThrowUtils.throwIf(count > 0, ErrorCode.PARAMS_ERROR, "名称重复"); + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesGroupServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesGroupServiceImpl.java new file mode 100644 index 0000000..80e6e98 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesGroupServiceImpl.java @@ -0,0 +1,137 @@ +package com.bsz.school_send_back_end.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.DishesGroupMapper; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.DishesGroup; +import com.bsz.school_send_back_end.model.vo.DishesGroupVO; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.DishesGroupService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author Lenovo +* +*/ +@Service +public class DishesGroupServiceImpl extends ServiceImpl + implements DishesGroupService { + + @Resource + private BusinessService businessService; + + @Override + public void validDishesGroup(DishesGroup dishesGroup, boolean update) { + if (dishesGroup == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + String groupName = dishesGroup.getGroupName(); + Integer isTopping = dishesGroup.getIsTopping(); + Long dishesGroupId = dishesGroup.getId(); + + if (update) { + if (dishesGroupId == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"未填写分组id"); + } + } + + if (isTopping == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"请选择是否置顶"); + } + + if (StringUtils.isBlank(groupName)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR,"未填写分组名称"); + } + } + + @Override + public Boolean addDishesGroup(DishesGroup dishesGroup, HttpServletRequest request) { + String groupName = dishesGroup.getGroupName(); + Integer isTopping = dishesGroup.getIsTopping(); + + //获取商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + dishesGroup.setBusinessId(businessId); + + //判断更新的分组是否置顶,并将组内数据更改为非置顶 + changeTopping(businessId,isTopping); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessId",businessId); + queryWrapper.eq("groupName",groupName); + long count = this.count(queryWrapper); + if (count > 0) { + throw new BusinessException(ErrorCode.OPERATION_ERROR,"存在相同的分组"); + } + + return this.save(dishesGroup); + } + + + + @Override + public List getDishGroupVOList(List dishesGroupList) { + if (CollectionUtils.isEmpty(dishesGroupList)) { + return new ArrayList<>(); + } + + return dishesGroupList.stream().map(item -> { + DishesGroupVO dishesGroupVO = new DishesGroupVO(); + BeanUtils.copyProperties(item, dishesGroupVO); + return dishesGroupVO; + }).collect(Collectors.toList()); + } + + @Override + public Boolean updateDishesGroupById(DishesGroup dishesGroup, HttpServletRequest request) { + //获取当前商家id + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + Long dishesGroupId = dishesGroup.getId(); + String groupName = dishesGroup.getGroupName(); + Integer isTopping = dishesGroup.getIsTopping(); + //判断更新的分组是否置顶,并将组内数据更改为非置顶 + changeTopping(businessId,isTopping); + //更新分组信息 + UpdateWrapper wrapper = new UpdateWrapper<>(); + wrapper.eq("id",dishesGroupId); + wrapper.eq("businessId",businessId); + wrapper.set("groupName",groupName); + wrapper.set("isTopping",isTopping); + return this.update(wrapper); + } + + + private void changeTopping(Long businessId, Integer isTopping) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("businessId",businessId); + List list = this.list(); + + if (isTopping == 1 && list.size() > 0) { + List collect = list.stream().peek(item -> { + item.setIsTopping(0); + }).collect(Collectors.toList()); + boolean updateTopping = this.updateBatchById(collect); + ThrowUtils.throwIf(!updateTopping,ErrorCode.OPERATION_ERROR); + } + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesServiceImpl.java new file mode 100644 index 0000000..168b7d3 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/DishesServiceImpl.java @@ -0,0 +1,169 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.contant.CommonConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.DishesMapper; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.domain.SpecificationsDishes; +import com.bsz.school_send_back_end.model.dto.Dishes.DishesQueryRequest; +import com.bsz.school_send_back_end.model.vo.DishesVO; +import com.bsz.school_send_back_end.service.DishesService; +import com.bsz.school_send_back_end.service.SpecificationsDishesService; +import com.bsz.school_send_back_end.utils.SqlUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author pc +* @description 针对表【dishes(菜品表)】的数据库操作Service实现 +* @createDate 2024-06-29 17:23:31 +*/ +@Service +public class DishesServiceImpl extends ServiceImpl + implements DishesService { + + @Resource + private SpecificationsDishesService specificationsDishesService; + + @Override + public void removeByDishesGroupId(Long dishesGroupId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dishesGroupId",dishesGroupId); + List list = this.list(queryWrapper); + //判断该分组是否有菜品 + if (list.isEmpty()) { + return; + } + boolean remove = this.remove(queryWrapper); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + //删除中间表数据 + for (Dishes dishes : list) { + Long dishesId = dishes.getId(); + specificationsDishesService.deleteByDishesId(dishesId); + } + } + + @Override + public void validDishes(Dishes dishes, Boolean update) { + Long id = dishes.getId(); + Long dishesGroupId = dishes.getDishesGroupId(); + String dishesName = dishes.getDishesName(); + Double dishesPrice = dishes.getDishesPrice(); + String status = dishes.getStatus(); + Integer inventoryStatus = dishes.getInventoryStatus(); + + if (update) { + if (id == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + } + + if (StringUtils.isAnyBlank(dishesName,status)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + + if (dishesGroupId == null || dishesPrice == null || inventoryStatus == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + } + + @Override + public Long addDishes(Dishes dishes) { + //判断菜品是否存在 + validDishesName(dishes); + //保存代码 + boolean save = this.save(dishes); + ThrowUtils.throwIf(!save,ErrorCode.OPERATION_ERROR); + return dishes.getId(); + } + + @Override + public Boolean updateDishes(Dishes dishes) { + //判断菜品是否存在 + validDishesName(dishes); + //更新菜品 + return this.updateById(dishes); + } + + @Override + public List getDishesVOList(List dishesList) { + if (CollectionUtils.isEmpty(dishesList)) { + return new ArrayList<>(); + } + return dishesList.stream().map(item->{ + long count = getCount(item); + DishesVO dishesVO = new DishesVO(); + BeanUtils.copyProperties(item,dishesVO); + if (count > 0) { + dishesVO.setIsSpecification(1); + } + return dishesVO; + }).collect(Collectors.toList()); + } + + @Override + public DishesVO getDishesVO(Dishes dishes) { + if (dishes == null) { + return null; + } + long count = getCount(dishes); + DishesVO dishesVO = new DishesVO(); + + if (count > 0) { + dishesVO.setIsSpecification(1); + } + return dishesVO; + } + + @Override + public QueryWrapper getWrapper(DishesQueryRequest dishesQueryRequest) { + Long businessId = dishesQueryRequest.getBusinessId(); + Long dishesGroupId = dishesQueryRequest.getDishesGroupId(); + String status = dishesQueryRequest.getStatus(); + String dishesName = dishesQueryRequest.getDishesName(); + String sortField = dishesQueryRequest.getSortField(); + String sortOrder = dishesQueryRequest.getSortOrder(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(businessId != null, "businessId", businessId); + wrapper.eq(dishesGroupId != null, "dishesGroupId", dishesGroupId); + wrapper.eq(StringUtils.isNotBlank(status), "status", status); + wrapper.like(StringUtils.isNotBlank(dishesName), "dishesName", dishesName); + wrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField); + return wrapper; + } + + private void validDishesName(Dishes dishes) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dishesName",dishes.getDishesName()); + queryWrapper.eq("businessId",dishes.getBusinessId()); + long count = this.count(queryWrapper); + if (dishes.getId() == null) { + ThrowUtils.throwIf(count > 0,ErrorCode.PARAMS_ERROR,"已存在该菜品"); + } + else { + ThrowUtils.throwIf(count > 0,ErrorCode.PARAMS_ERROR,"已存在该菜品"); + } + } + + private long getCount(Dishes dishes) { + Long dishesId = dishes.getId(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dishesId",dishesId); + return specificationsDishesService.count(queryWrapper); + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrderDetailsServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrderDetailsServiceImpl.java new file mode 100644 index 0000000..deb8ba4 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrderDetailsServiceImpl.java @@ -0,0 +1,82 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.OrderDetailsMapper; +import com.bsz.school_send_back_end.model.domain.Dishes; +import com.bsz.school_send_back_end.model.domain.OrderDetails; +import com.bsz.school_send_back_end.model.vo.DishesVO; +import com.bsz.school_send_back_end.model.vo.OrderDetailsVO; +import com.bsz.school_send_back_end.service.DishesService; +import com.bsz.school_send_back_end.service.OrderDetailsService; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author 玄德 + * @description 针对表【order_details(订单详情表)】的数据库操作Service实现 + * @createDate 2024-04-05 17:57:44 + */ +@Service +public class OrderDetailsServiceImpl extends ServiceImpl + implements OrderDetailsService { + + @Resource + private DishesService dishesService; + + @Override + public void validOrderDetail(OrderDetails orderDetails) { + Long dishesId = orderDetails.getDishesId(); + Integer quantity = orderDetails.getQuantity(); + BigDecimal price = orderDetails.getPrice(); + // 校验菜品是否存在 + Dishes dishes = dishesService.getById(dishesId); + ThrowUtils.throwIf(dishes == null, ErrorCode.NOT_FOUND_ERROR, "菜品不存在"); + // 有参数则校验 + if (ObjectUtils.allNotNull(dishesId, quantity, price)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "菜品错误"); + } + } + + @Override + public OrderDetailsVO getOrderDetailsVO(OrderDetails orderDetails) { + if (orderDetails == null) { + return null; + } + OrderDetailsVO orderDetailsVO = new OrderDetailsVO(); + BeanUtils.copyProperties(orderDetails, orderDetailsVO); + // 关联查询菜品信息 + Long dishesId = orderDetails.getDishesId(); + Dishes dishes = null; + if (dishesId != null && dishesId > 0) { + dishes = dishesService.getById(dishesId); + } + DishesVO dishesVO = dishesService.getDishesVO(dishes); + orderDetailsVO.setDishesVO(dishesVO); + return orderDetailsVO; + } + + @Override + public List getOrderDetailsVO(List orderDetailsList) { + if (CollectionUtils.isEmpty(orderDetailsList)) { + return new ArrayList<>(); + } + return orderDetailsList.stream().map(this::getOrderDetailsVO).collect(Collectors.toList()); + } + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrdersServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrdersServiceImpl.java new file mode 100644 index 0000000..e325e7b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OrdersServiceImpl.java @@ -0,0 +1,163 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.contant.CommonConstant; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.mapper.OrdersMapper; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.OrderDetails; +import com.bsz.school_send_back_end.model.domain.Orders; +import com.bsz.school_send_back_end.model.dto.order.OrderQueryRequest; +import com.bsz.school_send_back_end.model.vo.BusinessVO; +import com.bsz.school_send_back_end.model.vo.OrderDetailsVO; +import com.bsz.school_send_back_end.model.vo.OrdersVO; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.OrderDetailsService; +import com.bsz.school_send_back_end.service.OrdersService; +import com.bsz.school_send_back_end.utils.RegexUtils; +import com.bsz.school_send_back_end.utils.SqlUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author 玄德 + * @description 针对表【orders(订单表)】的数据库操作Service实现 + * @createDate 2024-04-05 17:57:44 + */ +@Service +public class OrdersServiceImpl extends ServiceImpl + implements OrdersService { + + @Resource + private BusinessService businessService; + + @Resource + private OrderDetailsService orderDetailsService; + + + @Override + @Transactional(rollbackFor = Exception.class) + public synchronized long addOrder(Orders orders, List orderDetailsList) { + boolean saveOrder = this.save(orders); + if (!saveOrder) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建订单失败,数据库错误"); + } + // 创建订单菜品 + for (OrderDetails orderDetails : orderDetailsList) { + // 绑定订单和订单详情 + orderDetails.setOrderId(orders.getId()); + boolean saveDetail = orderDetailsService.save(orderDetails); + if (!saveDetail) { + log.error("创建订单菜品失败,订单id:" + orders.getId()); + throw new BusinessException(ErrorCode.OPERATION_ERROR, "订单菜品创建失败"); + } + } + return orders.getId(); + } + + @Override + public void validOrder(Orders orders) { + String userName = orders.getUserName(); + String phone = orders.getPhone(); + Long userId = orders.getUserId(); + Long businessId = orders.getBusinessId(); + BigDecimal totalPrice = orders.getTotalPrice(); + Integer pickupMethod = orders.getPickupMethod(); + Integer payMethod = orders.getPayMethod(); + if (StringUtils.isAnyBlank(userName, phone)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + if (StringUtils.isNotBlank(phone) && RegexUtils.isPhoneInvalid(phone)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "手机号格式错误"); + } + if (ObjectUtils.isEmpty(totalPrice) || totalPrice.floatValue() <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "价格错误"); + } + if (ObjectUtils.anyNull(userId, businessId, payMethod, pickupMethod)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数不全"); + } + } + + @Override + public OrdersVO getOrdersVO(Orders orders) { + if (orders == null) { + return null; + } + OrdersVO ordersVO = new OrdersVO(); + BeanUtils.copyProperties(orders, ordersVO); + // 关联查询商家信息 + Long businessId = orders.getBusinessId(); + Business business = null; + if (businessId != null && businessId > 0) { + business = businessService.getById(businessId); + } + BusinessVO businessVO = businessService.getBusinessVO(business); + ordersVO.setBusinessVO(businessVO); + // 关联查询订单详情信息 + Long orderId = orders.getId(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("orderId", orderId); + List orderDetailsList = orderDetailsService.list(queryWrapper); + List orderDetailsVOList = orderDetailsService.getOrderDetailsVO(orderDetailsList); + ordersVO.setOrderDetailsVOList(orderDetailsVOList); + // 关联查询评价状态 + + // 设置商品数量 + Integer number = 0; + for (OrderDetailsVO detailsVO : orderDetailsVOList) { + number += detailsVO.getQuantity(); + } + ordersVO.setNumber(number); + return ordersVO; + } + + @Override + public List getOrdersVO(List ordersList) { + if (CollectionUtils.isEmpty(ordersList)) { + return new ArrayList<>(); + } + return ordersList.stream().map(this::getOrdersVO).collect(Collectors.toList()); + } + + @Override + public QueryWrapper getQueryWrapper(OrderQueryRequest orderQueryRequest) { + if (orderQueryRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + Long id = orderQueryRequest.getId(); + Long userId = orderQueryRequest.getUserId(); + Long businessId = orderQueryRequest.getBusinessId(); + String pickupCode = orderQueryRequest.getPickupCode(); + Integer pickupMethod = orderQueryRequest.getPickupMethod(); + Integer state = orderQueryRequest.getState(); + String startTime = orderQueryRequest.getStartTime(); + String endTime = orderQueryRequest.getEndTime(); + String sortField = orderQueryRequest.getSortField(); + String sortOrder = orderQueryRequest.getSortOrder(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.like(ObjectUtils.isNotEmpty(id), "id", id); + queryWrapper.eq(ObjectUtils.isNotEmpty(userId), "userId", userId); + queryWrapper.eq(ObjectUtils.isNotEmpty(businessId), "businessId", businessId); + queryWrapper.eq(ObjectUtils.isNotEmpty(pickupMethod), "pickupMethod", pickupMethod); + queryWrapper.eq(ObjectUtils.isNotEmpty(state), "state", state); + queryWrapper.ge(StringUtils.isNotBlank(pickupCode), "pickupCode", pickupCode); + queryWrapper.ge(StringUtils.isNotBlank(startTime), "createTime", startTime); + queryWrapper.le(StringUtils.isNotBlank(endTime), "createTime", endTime); + queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), + sortField); + return queryWrapper; + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OssServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OssServiceImpl.java new file mode 100644 index 0000000..d8eda0b --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/OssServiceImpl.java @@ -0,0 +1,78 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.bsz.school_send_back_end.service.OssService; +import com.bsz.school_send_back_end.utils.ConstantPropertiesUtil; +import org.joda.time.DateTime; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + + +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +/** + * @author bsz + */ +@Service +public class OssServiceImpl implements OssService { + + //上传头像到OSS + @Override + public String uploadFileAvatar(MultipartFile file) { + + //工具类获取值 + String endpoint = ConstantPropertiesUtil.END_POINT; + String accessKeyId = ConstantPropertiesUtil.KEY_ID; + String accessKeySecret = ConstantPropertiesUtil.KEY_SECRET; + String bucketName = ConstantPropertiesUtil.BUCKET_NAME; + + + InputStream inputStream = null; + + + try { + // 创建OSS实例。 + OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + + // 获取上传文件的输入流 + inputStream = file.getInputStream(); + + + //获取文件名称 + String fileName = file.getOriginalFilename(); + //添加随机值 + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + fileName = uuid + fileName; + + + //把文件按照日期分类 + //获取当前日期 + String datePath = new DateTime().toString("yyyy/MM/dd"); + //拼接日期 + fileName = datePath + "/" + fileName; + + + //调用oss实例中的方法实现上传 + //参数1: Bucket名称 + //参数2: 上传到oss文件路径和文件名称 /aa/bb/1.jpg + //参数3: 上传文件的输入流 + ossClient.putObject(bucketName, fileName, inputStream); + // 关闭OSSClient。 + ossClient.shutdown(); + + //把上传后文件路径返回 + //需要把上传到阿里云oss路径手动拼接出来 + //https://achang-edu.oss-cn-hangzhou.aliyuncs.com/default.gif + String url = "http://" + bucketName + "." + endpoint + "/" + fileName; + + return url; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsDishesServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsDishesServiceImpl.java new file mode 100644 index 0000000..2af9c3f --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsDishesServiceImpl.java @@ -0,0 +1,85 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.SpecificationsDishesMapper; +import com.bsz.school_send_back_end.model.domain.Specifications; +import com.bsz.school_send_back_end.model.domain.SpecificationsDishes; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; +import com.bsz.school_send_back_end.service.AttributeService; +import com.bsz.school_send_back_end.service.SpecificationsDishesService; +import com.bsz.school_send_back_end.service.SpecificationsService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author xy +*/ +@Service +public class SpecificationsDishesServiceImpl extends ServiceImpl + implements SpecificationsDishesService { + @Resource + private SpecificationsService specificationsService; + + @Resource + private AttributeService attributeService; + + @Override + public void deleteByDishesId(Long dishesId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dishesId",dishesId); + long count = this.count(queryWrapper); + if (count < 1) { + return; + } + boolean remove = this.remove(queryWrapper); + ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR); + } + + @Override + public Boolean add(Long dishesId, List specificationsIds) { + if (CollectionUtils.isEmpty(specificationsIds)) { + return true; + } + + for (Long specificationsId: specificationsIds) { + SpecificationsDishes specificationsDishes = new SpecificationsDishes(); + specificationsDishes.setSpecificationsId(specificationsId); + specificationsDishes.setDishesId(dishesId); + boolean save = this.save(specificationsDishes); + ThrowUtils.throwIf(!save,ErrorCode.OPERATION_ERROR); + } + return true; + } + + @Override + public Boolean updateByDishesId(Long dishesId, List specificationsIds) { + //删除之前的中间表信息 + deleteByDishesId(dishesId); + //保存更新的中间表信息 + return add(dishesId,specificationsIds); + } + + @Override + public List getSpecificationsAddAttribute(List specificationsDishesList) { + List specificationsVOList = specificationsDishesList.stream().map(item -> { + Long specificationsId = item.getSpecificationsId(); + Specifications specifications = specificationsService.getById(specificationsId); + SpecificationsVO specificationsVO = new SpecificationsVO(); + BeanUtils.copyProperties(specifications, specificationsVO); + return specificationsVO; + }).collect(Collectors.toList()); + return attributeService.getBySpecificationsVoId(specificationsVOList); + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsServiceImpl.java new file mode 100644 index 0000000..1cd51fb --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SpecificationsServiceImpl.java @@ -0,0 +1,101 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.exception.ThrowUtils; +import com.bsz.school_send_back_end.mapper.SpecificationsMapper; +import com.bsz.school_send_back_end.model.domain.Business; +import com.bsz.school_send_back_end.model.domain.Specifications; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest; +import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest; +import com.bsz.school_send_back_end.model.vo.SpecificationsVO; +import com.bsz.school_send_back_end.service.AttributeService; +import com.bsz.school_send_back_end.service.BusinessService; +import com.bsz.school_send_back_end.service.SpecificationsService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* @author xy +*/ +@Service +public class SpecificationsServiceImpl extends ServiceImpl + implements SpecificationsService { + + @Resource + private BusinessService businessService; + + @Resource + private AttributeService attributeService; + + @Override + public void validSpecifications(Specifications specifications, boolean update) { + if (specifications == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + String specificationsName = specifications.getSpecificationsName(); + Long id = specifications.getId(); + + if (update) { + ThrowUtils.throwIf(id == null, ErrorCode.PARAMS_ERROR,"请提供规格id"); + } + + if (StringUtils.isBlank(specificationsName)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请填写规格名称"); + } + } + + @Override + public Boolean addSpecifications(Specifications specifications, List attributeAddRequests, HttpServletRequest request) { + //获取当前商户 + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + + //保存规格 + specifications.setBusinessId(businessId); + boolean save = this.save(specifications); + ThrowUtils.throwIf(!save, ErrorCode.PARAMS_ERROR); + Long specificationsId = specifications.getId(); + return attributeService.addAttribute(attributeAddRequests, businessId, specificationsId); + } + + @Override + public Boolean updateSpecifications(Specifications specifications, List attributeUpdateRequests, HttpServletRequest request) { + Long specificationsId = specifications.getId(); + //获取当期那登录商家信息 + Business loginBusiness = businessService.getLoginBusiness(request); + Long businessId = loginBusiness.getId(); + //更新规格信息 + specifications.setBusinessId(businessId); + boolean update = this.updateById(specifications); + ThrowUtils.throwIf(!update,ErrorCode.OPERATION_ERROR); + //更新规格的属性信息 + return attributeService.updateAttribute(attributeUpdateRequests, businessId, specificationsId); + } + + @Override + public List getSpecificationsVO(List specificationsList) { + if (CollectionUtils.isEmpty(specificationsList)){ + return new ArrayList<>(); + } + return specificationsList.stream().map(item ->{ + SpecificationsVO specificationsVO = new SpecificationsVO(); + BeanUtils.copyProperties(item,specificationsVO); + return specificationsVO; + }).collect(Collectors.toList()); + } + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SysteminfoServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SysteminfoServiceImpl.java new file mode 100644 index 0000000..5481652 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SysteminfoServiceImpl.java @@ -0,0 +1,22 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.model.domain.Systeminfo; +import com.bsz.school_send_back_end.mapper.SysteminfoMapper; +import com.bsz.school_send_back_end.service.SysteminfoService; +import org.springframework.stereotype.Service; + +/** +* @author pc +* @description 针对表【systeminfo(系统信息)】的数据库操作Service实现 +* @createDate 2024-09-23 19:16:42 +*/ +@Service +public class SysteminfoServiceImpl extends ServiceImpl + implements SysteminfoService { + +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SystemlogServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SystemlogServiceImpl.java new file mode 100644 index 0000000..c3c4591 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/SystemlogServiceImpl.java @@ -0,0 +1,45 @@ +package com.bsz.school_send_back_end.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.contant.CommonConstant; +import com.bsz.school_send_back_end.model.domain.Systemlog; +import com.bsz.school_send_back_end.model.dto.log.LogQueryRequest; +import com.bsz.school_send_back_end.service.SystemlogService; +import com.bsz.school_send_back_end.mapper.SystemlogMapper; +import com.bsz.school_send_back_end.utils.SqlUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +/** +* @author xy +*/ +@Service +public class SystemlogServiceImpl extends ServiceImpl + implements SystemlogService{ + + @Override + public QueryWrapper getQueryWrapper(LogQueryRequest logQueryRequest) { + Long userId = logQueryRequest.getUserId(); + String content = logQueryRequest.getContent(); + String ip = logQueryRequest.getIp(); + String startTime = logQueryRequest.getStartTime(); + String endTime = logQueryRequest.getEndTime(); + String sortField = logQueryRequest.getSortField(); + String sortOrder = logQueryRequest.getSortOrder(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(ObjectUtils.isNotEmpty(userId), "userId", userId); + queryWrapper.eq(StringUtils.isNotBlank(content), "content", content); + queryWrapper.eq(StringUtils.isNotBlank(ip), "ip", ip); + queryWrapper.ge(StringUtils.isNotBlank(startTime), "createTime", startTime); + queryWrapper.le(StringUtils.isNotBlank(endTime), "createTime", endTime); + queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), + sortField); + return queryWrapper; + } +} + + + + diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/UserServiceImpl.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..b9bcc03 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/service/impl/UserServiceImpl.java @@ -0,0 +1,362 @@ +package com.bsz.school_send_back_end.service.impl; + +import cn.hutool.core.util.RandomUtil; +import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsz.school_send_back_end.common.ErrorCode; +import com.bsz.school_send_back_end.exception.BusinessException; +import com.bsz.school_send_back_end.mapper.UserMapper; +import com.bsz.school_send_back_end.model.vo.LoginUserVO; +import com.bsz.school_send_back_end.model.domain.User; +import com.bsz.school_send_back_end.model.dto.user.UserSearchRequest; +import com.bsz.school_send_back_end.model.dto.user.UserUpdatePasswordRequest; +import com.bsz.school_send_back_end.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.DigestUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.bsz.school_send_back_end.contant.UserConstant.USER_LOGIN_STATE; + +/** + * @author bsz + */ +@Service +@Slf4j +public class UserServiceImpl extends ServiceImpl + implements UserService { + + @Resource + private UserMapper userMapper; + + /** + * 盐值 对密码进行混淆加密 + */ + private static final String SALT = "bsz"; + + /** + * 用户注册 + * + * @param userAccount 登陆账号 + * @param userPassword 登录密码 + * @param checkPassword 校验密码 + * @return 新id + */ + + @Override + public long userRegister(String userAccount, String userPassword, String checkPassword) { + + //1.非空 + if (StringUtils.isAllBlank(userAccount, userPassword, checkPassword)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为空"); + } + //2.账号长度不小于4位 + if (userAccount.length() < 4) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户账号过短"); + } + //3.密码长度不小于8位 + if (userPassword.length() < 8 || checkPassword.length() < 8) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户密码过短"); + } + //正则表达式看账户包不包含特殊字符 + String validPattern = "[`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + + Matcher matcher = Pattern.compile(validPattern).matcher(userAccount); + + if (matcher.find()) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "不符合规范"); + } + + //检验密码和校验密码是否相同 + if (!userPassword.equals(checkPassword)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "两次输入密码不同"); + } + + //账户不能重复,进行查询数据库看当中是否存在相同名称用户 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userAccount", userAccount); + Long count = userMapper.selectCount(queryWrapper); + if (count > 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "存在相同用户"); + } + + //对密码加密 + String encryptPassword = DigestUtils.md5DigestAsHex((SALT + userPassword).getBytes()); + + User user = new User(); + user.setUserAccount(userAccount); + user.setUserPassword(encryptPassword); + boolean saveResult = this.save(user); + if (!saveResult) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "插入失败!"); + } + return user.getId(); + } + + /** + * 登录 + * + * @param userAccount 登陆账号 + * @param userPassword 登陆密码 + * @param request 返回请求 + * @return 用户信息 + */ + + @Override + public LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request) { + //非空 + if (StringUtils.isAllBlank(userAccount, userPassword)) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为空"); + } + //账号长度不小于四位 + if (userAccount.length() < 4) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户账号过短"); + } + if (userPassword.length() < 8) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户密码过短"); + } + + //正则表达式看账户包不包含特殊字符 + String validPattern = "[`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + + Matcher matcher = Pattern.compile(validPattern).matcher(userAccount); + + if (matcher.find()) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "不符合规范"); + } + + //校验账号密码是否相同 + String encodePassword = DigestUtils.md5DigestAsHex((SALT + userPassword).getBytes(StandardCharsets.UTF_8)); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("userAccount", userAccount); + queryWrapper.eq("userPassword", encodePassword); + User user = userMapper.selectOne(queryWrapper); + //用户不存在 + if (user == null) { + log.info("user login failed, userAccount Cannot match userPassword"); + throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户账号或密码有误!"); + } + + //用户登陆成功 + request.getSession().setAttribute(USER_LOGIN_STATE, user); + return this.getLoginUserVO(user); + } + + /** + * 用户脱敏 + * + * @param originUser 未脱敏用户 + * @return 脱敏用户 + */ + @Override + public User getSafetyUser(User originUser) { + if (originUser == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为空"); + } + User safetyUser = new User(); + safetyUser.setId(originUser.getId()); + safetyUser.setUsername(originUser.getUsername()); + safetyUser.setUserAccount(originUser.getUserAccount()); + safetyUser.setAvatarUrl(originUser.getAvatarUrl()); + safetyUser.setGender(originUser.getGender()); + safetyUser.setPhone(originUser.getPhone()); + safetyUser.setEmail(originUser.getEmail()); + safetyUser.setUserStatus(originUser.getUserStatus()); + safetyUser.setCreateTime(originUser.getCreateTime()); + safetyUser.setUpdateTime(originUser.getUpdateTime()); + safetyUser.setUserStatus(originUser.getUserStatus()); + safetyUser.setUserRole(originUser.getUserRole()); + return safetyUser; + } + + /** + * 用户注销 + * + * @param request 请求对象 + * @return 返回1表示成功 + */ + @Override + public int userLogout(HttpServletRequest request) { + request.getSession().removeAttribute(USER_LOGIN_STATE); + return 1; + } + + /** + * 获取当前登陆的用户 + * + * @param request 请求对象 + * @return 用户信息 + */ + @Override + public User getLoginUser(HttpServletRequest request) { + //判断是否登录 + Object userObj = request.getSession().getAttribute(USER_LOGIN_STATE); + User currentUser = (User) userObj; + + if (currentUser == null || currentUser.getId() == null) { + throw new BusinessException(ErrorCode.NOT_LOGIN, "未登录"); + } + //从数据库中获取该用户的信息 + long userId = currentUser.getId(); + currentUser = this.getById(userId); + if (currentUser == null) { + throw new BusinessException(ErrorCode.NOT_LOGIN, "未登录"); + } + return currentUser; + } + + /** + * 分页查询 + * + * @param searchRequest + * @return + */ + + @Override + public QueryWrapper getQueryWrapper(UserSearchRequest searchRequest) { + + if (searchRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空"); + } + String username = searchRequest.getUsername(); + String userAccount = searchRequest.getUserAccount(); + Integer gender = searchRequest.getGender(); + String phone = searchRequest.getPhone(); + String email = searchRequest.getEmail(); + Integer userStatus = searchRequest.getUserStatus(); + String userRole = searchRequest.getUserRole(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + Date updateTime = searchRequest.getUpdateTime(); + Date createTime = searchRequest.getCreateTime(); + // username + if (StringUtils.isNotBlank(username)) { + queryWrapper.like("username", username); + } + // userAccount + if (StringUtils.isNotBlank(userAccount)) { + queryWrapper.like("userAccount", userAccount); + } + // gender + if (StringUtils.isNotBlank(username)) { + queryWrapper.eq("gender", gender); + } + // phone + if (StringUtils.isNotBlank(phone)) { + queryWrapper.like("phone", phone); + } + // email + if (StringUtils.isNotBlank(email)) { + queryWrapper.like("email", email); + } + // userStatus + if (userStatus != null) { + queryWrapper.eq("userStatus", userStatus); + } + + if (userRole != null) { + queryWrapper.eq("userRole", userRole); + } + if (updateTime != null) { + queryWrapper.like("updateTime", updateTime); + } + if (createTime != null) { + queryWrapper.like("createTime", createTime); + } + return queryWrapper; + } + + /** + * 用户登录(支付宝) + * + * @param openId + * @param userInfo + * @param request + * @return 脱敏后的用户信息 + */ + //TODO 表未设计openId 需要设计 + @Override + public LoginUserVO userLoginByAlipay(String openId, JSONObject userInfo, HttpServletRequest request) { + if (openId == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "openId为空"); + } + String nick_name = userInfo.getStr("nick_name"); + String avatar = userInfo.getStr("avatar"); + //单机锁 + synchronized (openId.intern()) { + //检查用户是否已经存在 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("openId", openId); + User user = this.getOne(queryWrapper); + if (user == null) { + user = new User(); + user.setOpenId(openId); + user.setUserPassword(RandomUtil.randomString(16)); + user.setAvatarUrl(avatar == null ? "https://xuande-hk.gitee.io/images/avatar.png" : avatar); + user.setUsername(nick_name == null ? "普通用户" + RandomUtil.randomString(6) : nick_name); + boolean result = this.save(user); + if (!result) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "用户创建失败"); + } + } + //记录用户的登录态 + request.getSession().setAttribute(USER_LOGIN_STATE, user); + //返回用户数据 + return getLoginUserVO(user); + } + } + + + /** + * 修改密码 + * + * @param updatePasswordRequest + * @param request + * @return + */ + @Override + public boolean updateUserPassword(UserUpdatePasswordRequest updatePasswordRequest, HttpServletRequest request) { + if (updatePasswordRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + User loginUser = getLoginUser(request); + Long userId = loginUser.getId(); + if (userId < 0 || userId == null) { + throw new BusinessException(ErrorCode.NULL_ERROR, "不存在该用户"); + } + User user = new User(); + BeanUtils.copyProperties(updatePasswordRequest, user); + user.setId(loginUser.getId()); + + // 使用 MD5 加密新密码 + String encryptedPassword = DigestUtils.md5DigestAsHex((SALT + updatePasswordRequest.getNewPassword()).getBytes()); + user.setUserPassword(encryptedPassword); + if (encryptedPassword.equals(updatePasswordRequest.getUserPassword())) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "修改密码不能相同"); + } + boolean result = updateById(user); + if (!result) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + return true; + } + + @Override + public LoginUserVO getLoginUserVO(User user) { + if (user == null) { + return null; + } + LoginUserVO loginUserVO = new LoginUserVO(); + BeanUtils.copyProperties(user, loginUserVO); + return loginUserVO; + } + +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/AlipayUtils.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/AlipayUtils.java new file mode 100644 index 0000000..feb4763 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/AlipayUtils.java @@ -0,0 +1,36 @@ +//package com.bsz.school_send_back_end.utils; +// +//import cn.hutool.json.JSONObject; +//import com.alipay.easysdk.factory.Factory; +//import com.alipay.easysdk.util.generic.models.AlipayOpenApiGenericResponse; +//import com.bsz.school_send_back_end.common.ErrorCode; +//import com.bsz.school_send_back_end.exception.BusinessException; +// +// +//import java.util.HashMap; +//import java.util.Map; +// +///** +// * 支付宝工具类 +// * +// * @author 玄德 +// */ +//public class AlipayUtils { +// +// /** +// * 获取用户信息 +// */ +// public static JSONObject getUserInfo(String accessToken) throws Exception { +// Map bizParams = new HashMap<>(); +// bizParams.put("auth_token", accessToken); +// AlipayOpenApiGenericResponse userInfoResponse = +// Factory.Util.Generic().execute("alipay.user.info.share", bizParams, null); +// String httpBody = userInfoResponse.getHttpBody(); +// if(httpBody == null) +// { +// throw new BusinessException(ErrorCode.SYSTEM_ERROR); +// } +// return new JSONObject(httpBody).getJSONObject("alipay_user_info_share_response"); +// } +// +//} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/ConstantPropertiesUtil.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/ConstantPropertiesUtil.java new file mode 100644 index 0000000..c64f411 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/ConstantPropertiesUtil.java @@ -0,0 +1,35 @@ +package com.bsz.school_send_back_end.utils; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * 常量类,读取配置文件application.properties中的配置 + * @author bsz + */ +@Component +public class ConstantPropertiesUtil implements InitializingBean { + + public static String END_POINT; + public static String KEY_ID; + public static String KEY_SECRET; + public static String BUCKET_NAME; + @Value("${aliyun.oss.file.endpoint}") + private String endpoint; + @Value("${aliyun.oss.file.keyid}") + private String keyid; + @Value("${aliyun.oss.file.keysecret}") + private String keysecret; + @Value("${aliyun.oss.file.bucketname}") + private String bucketname; + + @Override + public void afterPropertiesSet() throws Exception { + KEY_ID = this.keyid; + KEY_SECRET = this.keysecret; + END_POINT = this.endpoint; + BUCKET_NAME = this.bucketname; + } + +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RandomNumberGenerator.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RandomNumberGenerator.java new file mode 100644 index 0000000..87a55f0 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RandomNumberGenerator.java @@ -0,0 +1,14 @@ +package com.bsz.school_send_back_end.utils; + +import org.springframework.stereotype.Component; + +import java.util.Random; + +@Component +public class RandomNumberGenerator { + // 生成指定范围内的随机整数 + public int generateRandomNumber() { + Random random = new Random(); + return random.nextInt(9000 - 1000 + 1) + 1000; + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RegexUtils.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RegexUtils.java new file mode 100644 index 0000000..19bc724 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/RegexUtils.java @@ -0,0 +1,60 @@ +package com.bsz.school_send_back_end.utils; + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; + +import static com.bsz.school_send_back_end.contant.RegexConstant.*; + +/** + * @author 玄德 + */ +@SuppressWarnings("all") +public class RegexUtils { + + /** + * 是否是无效手机格式 + * + * @param phone 要校验的手机号 + * @return true:符合,false:不符合 + */ + public static boolean isPhoneInvalid(String phone) { + return mismatch(phone, PHONE_REGEX); + } + + /** + * 是否是无效邮箱格式 + * + * @param email 要校验的邮箱 + * @return true:符合,false:不符合 + */ + public static boolean isEmailInvalid(String email) { + return mismatch(email, EMAIL_REGEX); + } + + /** + * 是否是无效18位身份证格式 + * + * @param idCard 要校验的身份证号码 + * @return true:符合,false:不符合 + */ + public static boolean isIdCardInvalid(String idCard) { + return mismatch(idCard, ID_CARD_REGEX); + } + + /** + * 是否是无效验证码格式 + * + * @param code 要校验的验证码 + * @return true:符合,false:不符合 + */ + public static boolean isCodeInvalid(String code) { + return mismatch(code, VERIFY_CODE_REGEX); + } + + // 校验是否不符合正则格式 + private static boolean mismatch(String str, String regex) { + if (StringUtils.isBlank(str)) { + return true; + } + return !str.matches(regex); + } +} diff --git a/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/SqlUtils.java b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/SqlUtils.java new file mode 100644 index 0000000..59b2ec4 --- /dev/null +++ b/school_lend_back_end/src/main/java/com/bsz/school_send_back_end/utils/SqlUtils.java @@ -0,0 +1,27 @@ +package com.bsz.school_send_back_end.utils; + + +import org.apache.commons.lang3.StringUtils; + +/** + * SQL 工具 + * + * @author 程序员鱼皮 + * @from 编程导航知识星球 + */ +@SuppressWarnings("all") +public class SqlUtils { + + /** + * 校验排序字段是否合法(防止 SQL 注入) + * + * @param sortField + * @return + */ + public static boolean validSortField(String sortField) { + if (StringUtils.isBlank(sortField)) { + return false; + } + return !StringUtils.containsAny(sortField, "=", "(", ")", " "); + } +} diff --git a/school_lend_back_end/src/main/resources/application.yml b/school_lend_back_end/src/main/resources/application.yml new file mode 100644 index 0000000..dc7807f --- /dev/null +++ b/school_lend_back_end/src/main/resources/application.yml @@ -0,0 +1,53 @@ +spring: + application: + name: school_send_back_end + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://192.168.59.81/school_send +# username: school_send +# password: 12345678 +# url: jdbc:mysql://localhost:3306/school_send +# username: root +# password: 123456 + url: jdbc:mysql://39.101.78.35/school_send + username: school_send + password: 12345678 + mvc: + pathmatch: + matching-strategy: ant_path_matcher + profiles: + active: dev +knife4j: + enable: true +server: + port: 9999 + servlet: + context-path: /api +mybatis-plus: + configuration: + map-underscore-to-camel-case: false + global-config: + db-config: + logic-delete-field: isDelete + logic-delete-value: 1 + logic-not-delete-value: 0 + + +session: + timeout: 86400 + +aliyun: + oss: + file: + endpoint: xxxx + keyid: xxxx + keysecret: xxxx + bucketname: xxxx +# 支付宝相关 +alipay: + #支付宝开放平台 + appId: 2021004151684053 + alipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1WYUUWEH+kW2pdYoBJa6j5G3iWe3uL/3L1QXPenzrp/NC1M9W/yvniJnAiYR4pdopZmlWfEm7FpHxbLaxxcXe0jTkspq9vv9vDldyXgKr13QZBJu4hD3w4QZNa+85paANXkfcVKXCpIh6sWTaW78lBE5p7Q0M6O26OCj/K3iPD7x4+KagqS5w9YYS8AXlQdsZPBh99bO3+KuQzcK4o4bFGI+ut4HLvd2IxdF5LwfjucloN6SRbU06vsDtpjtA+Oeoet5Y0CNfkpgbh7wvvNIbM6XEqMtfKCzevPaqRxwrFkS8WUQTMOaQbJXATbPQDt7MoWGujFd37lYz7ESQZed2wIDAQAB" + appPrivateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCOoaURczOevheVDeG9tmdCZ+PSInYwCY+ak3Jcy5CG4wrbHHy30ejMv5jNnyX/iSyC3MYIfHQ2I5uxh7pO3QSiB8GpeM9Oy3bUCOtPVM8o7FJ+/pa6o0s25jmj+Lx6/Q4sAaDxhQPY8vUZdIitQyqNS4IVhDuIWAS1w3ngZWHhcbtCPrCk3wIJPCYbhHi8eTgCXTJ0TbJ/QR+Pj0SAiL46rwSRc9KB1alxL5RoTK4VWvdHlqbfowen6teQ6bo2W5UkUEP8kew6MH9a3QQZ3YdLKFHufSGMWk19Wh26CEsvnf/Mb6dnv6YzbmzZLtCHiKKvFN516peW8Exd9/EtJCu1AgMBAAECggEAPghReVhoL/cu3HXQIylsmXYDoIW6b0QJP8o25+Lk9bVTKF6oY24Y2MvPkkZQSWYIhNWuD0zJYi50bW7BecEoXawP7zwKtZNKGAfVB4i0HHFDo9XoCj4w3SyeDxGEL91VR5Bhxgj61mU8chi7xNc8b31SkzcSiUb2rXLZ091kB58/xtzQk2nZAhKhwms7gbX7qxm8+TWLRK9g4vWmsGVqbgFNj/sutqBURSeU/pHmW9PMqgcWvx6AwWWi+VgBUSoIgMnX7r7s6ZlgeDIgioii3JdCcr1nq39sVYPwFpwIe7a1DOCB58B+v2un1XoThC7ZNEcbwP5oYpUdFhSoxClrNQKBgQDJc/A1nz2yYiLUHUMJn2DhyTrOnCSclmowuzJVkyuo5gQPfZ3dTmjdPkM/fg09J3+zi3UCSwZd6dGMzJVHWooMniSiomZ/rY+o9SVTAJOjxt29N8jFN92b3fB43hbAWyBOuy4NMZMcr+4cADuqRHz2pKAeaALiZdpTbrTCzVXtqwKBgQC1QGS0sv8VU9fyBCyrYU4kQh8Fcvz0g6ObgUnHZi6UIL+Cy0/3JIGeIyvB/n47RF1wLUz4wykwW70e1qlMz7w21HM+DB8fVuzbO7SmQI3gDo024kQkWWGUhe3/w9ztzLF9ezleSN6wnrPeDbeMV+pURbsxIXA9xg7DYpZZ76ksHwKBgHQnF/oi7bTbpo88q/lxXq/wkaqtFuL+Sw378UKsD4Fb1j2ERTBj1Ey0aJvENyfqjVPddcKztWESvtL65pt0laI+0IrBLm4xiWJ2rmWUMIw+zn0aG/Wyh2Emb0+RZfbU0+TxQdUzn0nsGlMkw0IiKRcgxn2hpQAaj+6JJ0omkIPvAoGAZ2eGTKT17Cf6QgNprJiF6R+j7QruD11uoJABFHZSSoXoXGk7hMbZ/+sW0sUrJQrat93QVPeabxFXctmKmtzFBw7rdFGcC9gepvCIHnUju9jxbYdm0sn/ZqmF323RhAVMmUcMsqKmEWNpQFzZA4NAl7V0lxH5o/RzhbqgBk05WYcCgYEAny/umQs7+NYgwL/FztMJVljfQsGY81mhgrQyPhmg/7NiWmLodJtwQgSj3UitDVtUGhZRnuidO8P1XW0sUyDwc8xMLb+0qVxX4gMpM4J1B0UaIp+oPg7hCXeFGxkWQl8bPY0RFa3GOfT2/D63NpXqYw8Fe1lZWoIMz+PBdx0YN90=" +# alipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjqGlEXMznr4XlQ3hvbZnQmfj0iJ2MAmPmpNyXMuQhuMK2xx8t9HozL+YzZ8l/4ksgtzGCHx0NiObsYe6Tt0EogfBqXjPTst21AjrT1TPKOxSfv6WuqNLNuY5o/i8ev0OLAGg8YUD2PL1GXSIrUMqjUuCFYQ7iFgEtcN54GVh4XG7Qj6wpN8CCTwmG4R4vHk4Al0ydE2yf0Efj49EgIi+Oq8EkXPSgdWpcS+UaEyuFVr3R5am36MHp+rXkOm6NluVJFBD/JHsOjB/Wt0EGd2HSyhR7n0hjFpNfVodughLL53/zG+nZ7+mM25s2S7Qh4iirxTedeqXlvBMXffxLSQrtQIDAQAB" +# appPrivateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCOoaURczOevheVDeG9tmdCZ+PSInYwCY+ak3Jcy5CG4wrbHHy30ejMv5jNnyX/iSyC3MYIfHQ2I5uxh7pO3QSiB8GpeM9Oy3bUCOtPVM8o7FJ+/pa6o0s25jmj+Lx6/Q4sAaDxhQPY8vUZdIitQyqNS4IVhDuIWAS1w3ngZWHhcbtCPrCk3wIJPCYbhHi8eTgCXTJ0TbJ/QR+Pj0SAiL46rwSRc9KB1alxL5RoTK4VWvdHlqbfowen6teQ6bo2W5UkUEP8kew6MH9a3QQZ3YdLKFHufSGMWk19Wh26CEsvnf/Mb6dnv6YzbmzZLtCHiKKvFN516peW8Exd9/EtJCu1AgMBAAECggEAPghReVhoL/cu3HXQIylsmXYDoIW6b0QJP8o25+Lk9bVTKF6oY24Y2MvPkkZQSWYIhNWuD0zJYi50bW7BecEoXawP7zwKtZNKGAfVB4i0HHFDo9XoCj4w3SyeDxGEL91VR5Bhxgj61mU8chi7xNc8b31SkzcSiUb2rXLZ091kB58/xtzQk2nZAhKhwms7gbX7qxm8+TWLRK9g4vWmsGVqbgFNj/sutqBURSeU/pHmW9PMqgcWvx6AwWWi+VgBUSoIgMnX7r7s6ZlgeDIgioii3JdCcr1nq39sVYPwFpwIe7a1DOCB58B+v2un1XoThC7ZNEcbwP5oYpUdFhSoxClrNQKBgQDJc/A1nz2yYiLUHUMJn2DhyTrOnCSclmowuzJVkyuo5gQPfZ3dTmjdPkM/fg09J3+zi3UCSwZd6dGMzJVHWooMniSiomZ/rY+o9SVTAJOjxt29N8jFN92b3fB43hbAWyBOuy4NMZMcr+4cADuqRHz2pKAeaALiZdpTbrTCzVXtqwKBgQC1QGS0sv8VU9fyBCyrYU4kQh8Fcvz0g6ObgUnHZi6UIL+Cy0/3JIGeIyvB/n47RF1wLUz4wykwW70e1qlMz7w21HM+DB8fVuzbO7SmQI3gDo024kQkWWGUhe3/w9ztzLF9ezleSN6wnrPeDbeMV+pURbsxIXA9xg7DYpZZ76ksHwKBgHQnF/oi7bTbpo88q/lxXq/wkaqtFuL+Sw378UKsD4Fb1j2ERTBj1Ey0aJvENyfqjVPddcKztWESvtL65pt0laI+0IrBLm4xiWJ2rmWUMIw+zn0aG/Wyh2Emb0+RZfbU0+TxQdUzn0nsGlMkw0IiKRcgxn2hpQAaj+6JJ0omkIPvAoGAZ2eGTKT17Cf6QgNprJiF6R+j7QruD11uoJABFHZSSoXoXGk7hMbZ/+sW0sUrJQrat93QVPeabxFXctmKmtzFBw7rdFGcC9gepvCIHnUju9jxbYdm0sn/ZqmF323RhAVMmUcMsqKmEWNpQFzZA4NAl7V0lxH5o/RzhbqgBk05WYcCgYEAny/umQs7+NYgwL/FztMJVljfQsGY81mhgrQyPhmg/7NiWmLodJtwQgSj3UitDVtUGhZRnuidO8P1XW0sUyDwc8xMLb+0qVxX4gMpM4J1B0UaIp+oPg7hCXeFGxkWQl8bPY0RFa3GOfT2/D63NpXqYw8Fe1lZWoIMz+PBdx0YN90=" \ No newline at end of file diff --git a/school_lend_back_end/src/main/resources/mapper/AttributeMapper.xml b/school_lend_back_end/src/main/resources/mapper/AttributeMapper.xml new file mode 100644 index 0000000..6bfdba5 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/AttributeMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + id,businessId,specificationsId, + attributeName,attributeStatus,createTime, + updateTime + + diff --git a/school_lend_back_end/src/main/resources/mapper/BusinessAuthMapper.xml b/school_lend_back_end/src/main/resources/mapper/BusinessAuthMapper.xml new file mode 100644 index 0000000..5e9e65b --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/BusinessAuthMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + id,businessId,shopkeeper, + license,frontIdCard,backIdCard, + bankCard,createTime,updateTime, + isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/BusinessMapper.xml b/school_lend_back_end/src/main/resources/mapper/BusinessMapper.xml new file mode 100644 index 0000000..0650c87 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/BusinessMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id,userId,businessName, + businessAvatar,address,businessProfile, + businessImages,categoryId,startBusiness, + endBusiness,state,storeStatus, + createTime,updateTime,isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/CartMapper.xml b/school_lend_back_end/src/main/resources/mapper/CartMapper.xml new file mode 100644 index 0000000..0151134 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/CartMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + id,userId,businessId, + createTime,updateTime,dishesId, + quantity,price,subtotal, + selectedOptions,isDeleted + + diff --git a/school_lend_back_end/src/main/resources/mapper/CategoryMapper.xml b/school_lend_back_end/src/main/resources/mapper/CategoryMapper.xml new file mode 100644 index 0000000..fda684a --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/CategoryMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + id,name,image, + createTime,updateTime + + diff --git a/school_lend_back_end/src/main/resources/mapper/DishesGroupMapper.xml b/school_lend_back_end/src/main/resources/mapper/DishesGroupMapper.xml new file mode 100644 index 0000000..509a342 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/DishesGroupMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + id,businessId,groupName, + isTopping,createTime,updateTime, + isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/DishesMapper.xml b/school_lend_back_end/src/main/resources/mapper/DishesMapper.xml new file mode 100644 index 0000000..65fdb52 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/DishesMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + id,businessId,dishesGroupId, + dishesName,dishesImage,dishesPrice, + packPrice,inventoryStatus,status, + createTime,updateTime,isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/OrderDetailsMapper.xml b/school_lend_back_end/src/main/resources/mapper/OrderDetailsMapper.xml new file mode 100644 index 0000000..da4c22e --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/OrderDetailsMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + id,orderId,dishesId, + quantity,price,subtotal, + attributeNames,createTime,updateTime, + isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/OrdersMapper.xml b/school_lend_back_end/src/main/resources/mapper/OrdersMapper.xml new file mode 100644 index 0000000..b48e121 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/OrdersMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + id,pickupCode,userName, + phone,userId,businessId, + totalPrice,pickupMethod, + payMethod,pickupTime,notes, + state,createTime,updateTime, + isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/SpecificationsDishesMapper.xml b/school_lend_back_end/src/main/resources/mapper/SpecificationsDishesMapper.xml new file mode 100644 index 0000000..64679b2 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/SpecificationsDishesMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + id,dishesId,specificationsId, + createTime,updateTime,isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/SpecificationsMapper.xml b/school_lend_back_end/src/main/resources/mapper/SpecificationsMapper.xml new file mode 100644 index 0000000..0333f2b --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/SpecificationsMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + id,businessId,specificationsName, + createTime,updateTime,isDelete + + diff --git a/school_lend_back_end/src/main/resources/mapper/SysteminfoMapper.xml b/school_lend_back_end/src/main/resources/mapper/SysteminfoMapper.xml new file mode 100644 index 0000000..6d67beb --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/SysteminfoMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + id,type,content, + createTime + + diff --git a/school_lend_back_end/src/main/resources/mapper/SystemlogMapper.xml b/school_lend_back_end/src/main/resources/mapper/SystemlogMapper.xml new file mode 100644 index 0000000..b96f02c --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/SystemlogMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + id,userId,content, + ip,createTime + + diff --git a/school_lend_back_end/src/main/resources/mapper/UserMapper.xml b/school_lend_back_end/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..b6d59e4 --- /dev/null +++ b/school_lend_back_end/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + id,username,userAccount, + avatarUrl,gender,userPassword, + phone,email,userStatus, + createTime,updateTime,isDelete, + userRole + + + + diff --git a/school_lend_back_end/src/main/resources/static/index.html b/school_lend_back_end/src/main/resources/static/index.html new file mode 100644 index 0000000..89bb8ba --- /dev/null +++ b/school_lend_back_end/src/main/resources/static/index.html @@ -0,0 +1,6 @@ + + +

hello word!!!

+

this is a html page

+ + \ No newline at end of file diff --git a/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/UserCenterApplicationTests.java b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/UserCenterApplicationTests.java new file mode 100644 index 0000000..9d89941 --- /dev/null +++ b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/UserCenterApplicationTests.java @@ -0,0 +1,13 @@ +package com.bsz.school_send_back_end; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class UserCenterApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/controller/UserControllerTest.java b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/controller/UserControllerTest.java new file mode 100644 index 0000000..32971f9 --- /dev/null +++ b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/controller/UserControllerTest.java @@ -0,0 +1,27 @@ +package com.bsz.school_send_back_end.controller; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class UserControllerTest { + + + + @Test + void userRegister() { + System.out.println("已上传到测试分支 - 3"); + } + + @Test + void userLogin() { + } + + @Test + void searchUsers() { + } + + @Test + void deleteUser() { + } +} \ No newline at end of file diff --git a/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java new file mode 100644 index 0000000..0a0f3b5 --- /dev/null +++ b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/model/dto/business/BusinessAddRequest.java @@ -0,0 +1,4 @@ +package com.bsz.school_send_back_end.model.dto.business; + +public class BusinessAddRequest { +} diff --git a/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/service/UserServiceTest.java b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/service/UserServiceTest.java new file mode 100644 index 0000000..8cab629 --- /dev/null +++ b/school_lend_back_end/src/test/java/com/bsz/school_send_back_end/service/UserServiceTest.java @@ -0,0 +1,55 @@ +package com.bsz.school_send_back_end.service; + +import com.bsz.school_send_back_end.model.domain.User; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.util.DigestUtils; + +import javax.annotation.Resource; + + +/** + * 用户服务测试 + */ + +@SpringBootTest +class +UserServiceTest { + + @Resource + private UserService userService; + + + @Test + void textInsertUser(){ + for (int i = 0; i < 10; i ++ ) { + User user = new User(); + user.setUsername("bsz" + i + "号"); + user.setUserAccount("bsz" + i + "号"); + user.setAvatarUrl("https://img.zcool.cn/community/01a6095f110b9fa8012066219b67d4.png@1280w_1l_2o_100sh.png"); + user.setGender(0); + user.setUserPassword("64dafd451f41b8bcb260041b1a0a1551"); + user.setPhone("0000000" + i); + user.setEmail(i + "00000000@qq.com"); + boolean result = userService.save(user); + System.out.println("新增用户ID:"+user.getId()); + // 断言,判断一下是否符合预期结果。assertTrue:是否保存成功 + Assertions.assertTrue(result); + } + + + } + + +// @Test +// void userRegister() { +//// String userAccount = "yupi1"; +//// String userPassword = "12345678"; +//// String checkPassword = "12345678"; +//// +//// long l = userService.userRegister(userAccount, userPassword, checkPassword); +//// Assertions.assertTrue(l > 0); +//// System.out.println(1); +// } +} \ No newline at end of file