├── .gitignore
├── ReadMe.md
├── lib
├── javax.ejb.jar
├── javax.jms.jar
├── javax.persistence.jar
├── javax.resource.jar
├── javax.servlet.jar
├── javax.servlet.jsp.jar
├── javax.servlet.jsp.jstl.jar
└── javax.transaction.jar
├── mp-weixin.zip
├── nginx-1.20.2_Sky_take_out.zip
├── pom.xml
├── sky-common
├── pom.xml
└── src
│ └── main
│ ├── java
│ ├── com
│ │ └── sky
│ │ │ ├── constant
│ │ │ ├── AutoFillConstant.java
│ │ │ ├── JwtClaimsConstant.java
│ │ │ ├── MessageConstant.java
│ │ │ ├── PasswordConstant.java
│ │ │ └── StatusConstant.java
│ │ │ ├── context
│ │ │ └── BaseContext.java
│ │ │ ├── enumeration
│ │ │ └── OperationType.java
│ │ │ ├── exception
│ │ │ ├── AccountLockedException.java
│ │ │ ├── AccountNotFoundException.java
│ │ │ ├── AddressBookBusinessException.java
│ │ │ ├── BaseException.java
│ │ │ ├── DeletionNotAllowedException.java
│ │ │ ├── GlobalExceptionHandler.java
│ │ │ ├── LoginFailedException.java
│ │ │ ├── OrderBusinessException.java
│ │ │ ├── PasswordEditFailedException.java
│ │ │ ├── PasswordErrorException.java
│ │ │ ├── SetmealEnableFailedException.java
│ │ │ ├── ShoppingCartBusinessException.java
│ │ │ └── UserNotLoginException.java
│ │ │ ├── json
│ │ │ └── JacksonObjectMapper.java
│ │ │ ├── properties
│ │ │ ├── AliOssProperties.java
│ │ │ ├── JwtProperties.java
│ │ │ └── WeChatProperties.java
│ │ │ ├── result
│ │ │ ├── PageResult.java
│ │ │ └── Result.java
│ │ │ └── utils
│ │ │ ├── AliOssUtil.java
│ │ │ ├── HttpClientUtil.java
│ │ │ ├── IPAddressUtils.java
│ │ │ ├── JwtUtil.java
│ │ │ └── WeChatPayUtil.java
│ └── generator
│ │ └── mapper
│ │ ├── DishFlavorMapper.java
│ │ ├── DishMapper.java
│ │ ├── EmployeeMapper.java
│ │ ├── OrderDetailMapper.java
│ │ ├── OrdersMapper.java
│ │ ├── SetmealDishMapper.java
│ │ ├── SetmealMapper.java
│ │ └── ShoppingCartMapper.java
│ └── resources
│ └── mapper
│ ├── DishFlavorMapper.xml
│ ├── DishMapper.xml
│ ├── EmployeeMapper.xml
│ ├── OrderDetailMapper.xml
│ ├── OrdersMapper.xml
│ ├── SetmealDishMapper.xml
│ ├── SetmealMapper.xml
│ └── ShoppingCartMapper.xml
├── sky-pojo
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── sky
│ ├── dto
│ ├── CategoryDTO.java
│ ├── CategoryPageQueryDTO.java
│ ├── DataOverViewQueryDTO.java
│ ├── DishDTO.java
│ ├── DishPageQueryDTO.java
│ ├── EmployeeDTO.java
│ ├── EmployeeLoginDTO.java
│ ├── EmployeePageQueryDTO.java
│ ├── GoodsSalesDTO.java
│ ├── OrdersCancelDTO.java
│ ├── OrdersConfirmDTO.java
│ ├── OrdersDTO.java
│ ├── OrdersPageQueryDTO.java
│ ├── OrdersPaymentDTO.java
│ ├── OrdersRejectionDTO.java
│ ├── OrdersSubmitDTO.java
│ ├── PasswordEditDTO.java
│ ├── SetmealDTO.java
│ ├── SetmealPageQueryDTO.java
│ ├── ShoppingCartDTO.java
│ └── UserLoginDTO.java
│ ├── entity
│ ├── AddressBook.java
│ ├── Category.java
│ ├── Dish.java
│ ├── DishFlavor.java
│ ├── Employee.java
│ ├── OrderDetail.java
│ ├── Orders.java
│ ├── Setmeal.java
│ ├── SetmealDish.java
│ ├── ShoppingCart.java
│ └── User.java
│ └── vo
│ ├── BusinessDataVO.java
│ ├── DishItemVO.java
│ ├── DishOverViewVO.java
│ ├── DishVO.java
│ ├── EmployeeLoginVO.java
│ ├── OrderOverViewVO.java
│ ├── OrderPaymentVO.java
│ ├── OrderReportVO.java
│ ├── OrderStatisticsVO.java
│ ├── OrderSubmitVO.java
│ ├── OrderVO.java
│ ├── SalesTop10ReportVO.java
│ ├── SetmealOverViewVO.java
│ ├── SetmealVO.java
│ ├── TurnoverReportVO.java
│ ├── UserLoginVO.java
│ └── UserReportVO.java
├── sky-server
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── sky
│ │ ├── SkyApplication.java
│ │ ├── annotation
│ │ ├── AutoFill.java
│ │ └── OperationLog.java
│ │ ├── aspect
│ │ ├── AutoAspect.java
│ │ └── OperationDetect.java
│ │ ├── build
│ │ ├── OrderItem.java
│ │ └── OrderItemBuilder.java
│ │ ├── config
│ │ ├── OssConfiguration.java
│ │ ├── RedisConfiguration.java
│ │ ├── WebMvcConfiguration.java
│ │ └── WebSocketConfiguration.java
│ │ ├── controller
│ │ ├── admin
│ │ │ ├── CategoryController.java
│ │ │ ├── CommonController.java
│ │ │ ├── DishController.java
│ │ │ ├── EmployeeController.java
│ │ │ ├── OrderController.java
│ │ │ ├── ReportController.java
│ │ │ ├── SetMealController.java
│ │ │ ├── ShopController.java
│ │ │ └── WorkspaceController.java
│ │ └── user
│ │ │ ├── AddressBookController.java
│ │ │ ├── CategoryController.java
│ │ │ ├── DishController.java
│ │ │ ├── OderController.java
│ │ │ ├── PayNotifyController.java
│ │ │ ├── SetmealController.java
│ │ │ ├── ShopController.java
│ │ │ ├── ShoppingCartController.java
│ │ │ └── UserController.java
│ │ ├── handler
│ │ └── GlobalExceptionHandler.java
│ │ ├── interceptor
│ │ ├── JwtTokenAdminInterceptor.java
│ │ └── JwtTokenUserInterceptor.java
│ │ ├── mapper
│ │ ├── AddressBookMapper.java
│ │ ├── CategoryMapper.java
│ │ ├── DishFlavorMapper.java
│ │ ├── DishMapper.java
│ │ ├── EmployeeMapper.java
│ │ ├── OperationlogMapper.java
│ │ ├── OrderDetailMapper.java
│ │ ├── OrderMapper.java
│ │ ├── SetmealDishMapper.java
│ │ ├── SetmealMapper.java
│ │ ├── ShoppingCartMapper.java
│ │ └── UserMapper.java
│ │ ├── properties
│ │ └── WeChatProperties.java
│ │ ├── service
│ │ ├── AddressBookService.java
│ │ ├── CategoryService.java
│ │ ├── DishService.java
│ │ ├── EmployeeService.java
│ │ ├── OrderService.java
│ │ ├── ReportService.java
│ │ ├── SetMealService.java
│ │ ├── ShoppingCartService.java
│ │ ├── UserService.java
│ │ ├── WorkSpaceService.java
│ │ └── impl
│ │ │ ├── AddressBookServiceImpl.java
│ │ │ ├── CategoryServiceImpl.java
│ │ │ ├── DishServiceImpl.java
│ │ │ ├── EmployeeServiceImpl.java
│ │ │ ├── OrderServiceImpl.java
│ │ │ ├── OrderServiceImpl_Bulider.java
│ │ │ ├── ReportServiceImpl.java
│ │ │ ├── SetMealServiceImpl.java
│ │ │ ├── ShoppingCartServiceImpl.java
│ │ │ ├── UserServiceImpl.java
│ │ │ └── WorkSpaceServiceImpl.java
│ │ ├── task
│ │ ├── OrderTask.java
│ │ └── WebSocketTask.java
│ │ ├── utils
│ │ └── IPAddressUtils.java
│ │ └── websocket
│ │ └── WebSocketServer.java
│ └── resources
│ ├── application-dev.yml
│ ├── application.yml
│ ├── mapper
│ ├── AddressBookMapper.xml
│ ├── CategoryMapper.xml
│ ├── DishFlavorMapper.xml
│ ├── DishMapper.xml
│ ├── EmployeeMapper.xml
│ ├── OrderDetailMapper.xml
│ ├── OrderMapper.xml
│ ├── SetMealMapper.xml
│ ├── SetmealDishMapper.xml
│ ├── ShoppingCartMapper.xml
│ └── UserMapper.xml
│ └── template
│ └── 运营数据报表模板.xlsx
└── sky_take_out.sql
/.gitignore:
--------------------------------------------------------------------------------
1 | **/target/
2 | .idea
3 | *.iml
4 | *.class
5 | *Test.java
6 | **/test/
--------------------------------------------------------------------------------
/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## 快速搭建项目:
2 | 启动nginx ,nginx要放在无中文目录下
3 |
4 | 默认端口80 ,逆向代理到8080
5 |
6 | 导入sql
7 |
8 | 改yml的数据库配置
9 |
10 | 要上传图片,自己用自己的OSS服务
11 |
12 | 不会用redis就打开调试,多点一下平台的业务功能,出问题了把redis的注解注释了就不会有问题。
13 | ### 开发更新日志
14 | 2023/5/4____ 更新了微信小程序端的代码,若需要使用微信前端小程序需要注册小程序,导入更新的微信小程序代码进行编译,注意搜索端口8080,改为自己的端口。在yml配置自己小程序的Access Key,还有password。
15 |
--------------------------------------------------------------------------------
/lib/javax.ejb.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.ejb.jar
--------------------------------------------------------------------------------
/lib/javax.jms.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.jms.jar
--------------------------------------------------------------------------------
/lib/javax.persistence.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.persistence.jar
--------------------------------------------------------------------------------
/lib/javax.resource.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.resource.jar
--------------------------------------------------------------------------------
/lib/javax.servlet.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.servlet.jar
--------------------------------------------------------------------------------
/lib/javax.servlet.jsp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.servlet.jsp.jar
--------------------------------------------------------------------------------
/lib/javax.servlet.jsp.jstl.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.servlet.jsp.jstl.jar
--------------------------------------------------------------------------------
/lib/javax.transaction.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/lib/javax.transaction.jar
--------------------------------------------------------------------------------
/mp-weixin.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/mp-weixin.zip
--------------------------------------------------------------------------------
/nginx-1.20.2_Sky_take_out.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/nginx-1.20.2_Sky_take_out.zip
--------------------------------------------------------------------------------
/sky-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | sky-take-out
7 | com.sky
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 | sky-common
12 |
13 |
14 | org.projectlombok
15 | lombok
16 |
17 |
18 | com.alibaba
19 | fastjson
20 |
21 |
22 | commons-lang
23 | commons-lang
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-json
28 |
29 |
30 | io.jsonwebtoken
31 | jjwt
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-configuration-processor
37 | true
38 |
39 |
40 | com.aliyun.oss
41 | aliyun-sdk-oss
42 |
43 |
44 | javax.xml.bind
45 | jaxb-api
46 |
47 |
48 |
49 | com.github.wechatpay-apiv3
50 | wechatpay-apache-httpclient
51 |
52 |
53 | com.sky
54 | sky-pojo
55 | 1.0-SNAPSHOT
56 | compile
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/constant/AutoFillConstant.java:
--------------------------------------------------------------------------------
1 | package com.sky.constant;
2 |
3 | /**
4 | * 公共字段自动填充相关常量
5 | */
6 | public class AutoFillConstant {
7 | /**
8 | * 实体类中的方法名称
9 | */
10 | public static final String SET_CREATE_TIME = "setCreateTime";
11 | public static final String SET_UPDATE_TIME = "setUpdateTime";
12 | public static final String SET_CREATE_USER = "setCreateUser";
13 | public static final String SET_UPDATE_USER = "setUpdateUser";
14 | }
15 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/constant/JwtClaimsConstant.java:
--------------------------------------------------------------------------------
1 | package com.sky.constant;
2 |
3 | public class JwtClaimsConstant {
4 |
5 | public static final String EMP_ID = "empId";
6 | public static final String USER_ID = "userId";
7 | public static final String PHONE = "phone";
8 | public static final String USERNAME = "username";
9 | public static final String NAME = "name";
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/constant/MessageConstant.java:
--------------------------------------------------------------------------------
1 | package com.sky.constant;
2 |
3 | /**
4 | * 信息提示常量类
5 | */
6 | public class MessageConstant {
7 |
8 | public static final String PASSWORD_ERROR = "密码错误";
9 | public static final String ACCOUNT_NOT_FOUND = "账号不存在";
10 | public static final String ACCOUNT_LOCKED = "账号被锁定";
11 | public static final String UNKNOWN_ERROR = "未知错误";
12 | public static final String USER_NOT_LOGIN = "用户未登录";
13 | public static final String CATEGORY_BE_RELATED_BY_SETMEAL = "当前分类关联了套餐,不能删除";
14 | public static final String CATEGORY_BE_RELATED_BY_DISH = "当前分类关联了菜品,不能删除";
15 | public static final String SHOPPING_CART_IS_NULL = "购物车数据为空,不能下单";
16 | public static final String ADDRESS_BOOK_IS_NULL = "用户地址为空,不能下单";
17 | public static final String LOGIN_FAILED = "登录失败";
18 | public static final String UPLOAD_FAILED = "文件上传失败";
19 | public static final String SETMEAL_ENABLE_FAILED = "套餐内包含未启售菜品,无法启售";
20 | public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
21 | public static final String DISH_ON_SALE = "起售中的菜品不能删除";
22 | public static final String DISH_ON_SALE2 = "菜品已经关联套餐不可停售";
23 | public static final String SETMEAL_ON_SALE = "起售中的套餐不能删除";
24 | public static final String DISH_BE_RELATED_BY_SETMEAL = "当前菜品关联了套餐,不能删除";
25 | public static final String ORDER_STATUS_ERROR = "订单状态错误";
26 | public static final String ORDER_NOT_FOUND = "订单不存在";
27 |
28 |
29 | public static final String ALREADY_EXISTS = "用户名已存在";
30 | }
31 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/constant/PasswordConstant.java:
--------------------------------------------------------------------------------
1 | package com.sky.constant;
2 |
3 | /**
4 | * 密码常量
5 | */
6 | public class PasswordConstant {
7 |
8 | public static final String DEFAULT_PASSWORD = "123456";
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/constant/StatusConstant.java:
--------------------------------------------------------------------------------
1 | package com.sky.constant;
2 |
3 | /**
4 | * 状态常量,启用或者禁用
5 | */
6 | public class StatusConstant {
7 |
8 | //启用
9 | public static final Integer ENABLE = 1;
10 |
11 | //禁用
12 | public static final Integer DISABLE = 0;
13 | }
14 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/context/BaseContext.java:
--------------------------------------------------------------------------------
1 | package com.sky.context;
2 |
3 | public class BaseContext {
4 |
5 | public static ThreadLocal threadLocal = new ThreadLocal<>();
6 |
7 | public static void setCurrentId(Long id) {
8 | threadLocal.set(id);
9 | }
10 |
11 | public static Long getCurrentId() {
12 | return threadLocal.get();
13 | }
14 |
15 | public static void removeCurrentId() {
16 | threadLocal.remove();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/enumeration/OperationType.java:
--------------------------------------------------------------------------------
1 | package com.sky.enumeration;
2 |
3 | /**
4 | * 数据库操作类型
5 | */
6 | public enum OperationType {
7 |
8 | /**
9 | * 更新操作
10 | */
11 | UPDATE,
12 |
13 | /**
14 | * 插入操作
15 | */
16 | INSERT
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/AccountLockedException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 账号被锁定异常
5 | */
6 | public class AccountLockedException extends BaseException {
7 |
8 | public AccountLockedException() {
9 | }
10 |
11 | public AccountLockedException(String msg) {
12 | super(msg);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/AccountNotFoundException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 账号不存在异常
5 | */
6 | public class AccountNotFoundException extends BaseException {
7 |
8 | public AccountNotFoundException() {
9 | }
10 |
11 | public AccountNotFoundException(String msg) {
12 | super(msg);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/AddressBookBusinessException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | public class AddressBookBusinessException extends BaseException {
4 |
5 | public AddressBookBusinessException(String msg) {
6 | super(msg);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/BaseException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 业务异常
5 | */
6 | public class BaseException extends RuntimeException {
7 |
8 | public BaseException() {
9 | }
10 |
11 | public BaseException(String msg) {
12 | super(msg);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/DeletionNotAllowedException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | public class DeletionNotAllowedException extends BaseException {
4 |
5 | public DeletionNotAllowedException(String msg) {
6 | super(msg);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | import com.sky.constant.MessageConstant;
4 | import com.sky.result.Result;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 |
8 | import java.sql.SQLIntegrityConstraintViolationException;
9 | @Slf4j
10 | public class GlobalExceptionHandler {
11 | /**
12 | * 捕获sql异常
13 | * @param ex
14 | * @return
15 | */
16 | @ExceptionHandler
17 | public Result exceptionHandler(SQLIntegrityConstraintViolationException ex){
18 | log.error("异常信息:{}", ex.getMessage());
19 | String message = ex.getMessage();
20 | if(message.contains("Duplicate entry")){
21 | String[] split = message.split(" ");
22 | String name = split[2];
23 | return Result.error(name + MessageConstant.ALREADY_EXISTS);
24 | }
25 | return Result.error(MessageConstant.UNKNOWN_ERROR);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/LoginFailedException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 登录失败
5 | */
6 | public class LoginFailedException extends BaseException{
7 | public LoginFailedException(String msg){
8 | super(msg);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/OrderBusinessException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | public class OrderBusinessException extends BaseException {
4 |
5 | public OrderBusinessException(String msg) {
6 | super(msg);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/PasswordEditFailedException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 密码修改失败异常
5 | */
6 | public class PasswordEditFailedException extends BaseException{
7 |
8 | public PasswordEditFailedException(String msg){
9 | super(msg);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/PasswordErrorException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 密码错误异常
5 | */
6 | public class PasswordErrorException extends BaseException {
7 |
8 | public PasswordErrorException() {
9 | }
10 |
11 | public PasswordErrorException(String msg) {
12 | super(msg);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/SetmealEnableFailedException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | /**
4 | * 套餐启用失败异常
5 | */
6 | public class SetmealEnableFailedException extends BaseException {
7 |
8 | public SetmealEnableFailedException(){}
9 |
10 | public SetmealEnableFailedException(String msg){
11 | super(msg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/ShoppingCartBusinessException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | public class ShoppingCartBusinessException extends BaseException {
4 |
5 | public ShoppingCartBusinessException(String msg) {
6 | super(msg);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/exception/UserNotLoginException.java:
--------------------------------------------------------------------------------
1 | package com.sky.exception;
2 |
3 | public class UserNotLoginException extends BaseException {
4 |
5 | public UserNotLoginException() {
6 | }
7 |
8 | public UserNotLoginException(String msg) {
9 | super(msg);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/json/JacksonObjectMapper.java:
--------------------------------------------------------------------------------
1 | package com.sky.json;
2 |
3 | import com.fasterxml.jackson.databind.DeserializationFeature;
4 | import com.fasterxml.jackson.databind.ObjectMapper;
5 | import com.fasterxml.jackson.databind.module.SimpleModule;
6 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
7 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
8 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
9 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
10 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
11 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
12 |
13 | import java.time.LocalDate;
14 | import java.time.LocalDateTime;
15 | import java.time.LocalTime;
16 | import java.time.format.DateTimeFormatter;
17 |
18 | import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
19 |
20 | /**
21 | * 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象
22 | * 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象]
23 | * 从Java对象生成JSON的过程称为 [序列化Java对象到JSON]
24 | */
25 | public class JacksonObjectMapper extends ObjectMapper {
26 |
27 | public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
28 | //public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
29 | public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";
30 | public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
31 |
32 | public JacksonObjectMapper() {
33 | super();
34 | //收到未知属性时不报异常
35 | this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
36 |
37 | //反序列化时,属性不存在的兼容处理
38 | this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
39 |
40 | SimpleModule simpleModule = new SimpleModule()
41 | .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
42 | .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
43 | .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)))
44 | .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
45 | .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
46 | .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
47 |
48 | //注册功能模块 例如,可以添加自定义序列化器和反序列化器
49 | this.registerModule(simpleModule);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/properties/AliOssProperties.java:
--------------------------------------------------------------------------------
1 | package com.sky.properties;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @ConfigurationProperties(prefix = "sky.alioss")
9 | @Data
10 | public class AliOssProperties {
11 |
12 | private String endpoint;
13 | private String accessKeyId;
14 | private String accessKeySecret;
15 | private String bucketName;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/properties/JwtProperties.java:
--------------------------------------------------------------------------------
1 | package com.sky.properties;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @ConfigurationProperties(prefix = "sky.jwt")
9 | @Data
10 | public class JwtProperties {
11 |
12 | /**
13 | * 管理端员工生成jwt令牌相关配置
14 | */
15 | private String adminSecretKey;
16 | private long adminTtl;
17 | private String adminTokenName;
18 |
19 | /**
20 | * 用户端微信用户生成jwt令牌相关配置
21 | */
22 | private String userSecretKey;
23 | private long userTtl;
24 | private String userTokenName;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/properties/WeChatProperties.java:
--------------------------------------------------------------------------------
1 | package com.sky.properties;
2 |
3 | import lombok.Data;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.boot.context.properties.ConfigurationProperties;
6 | import org.springframework.stereotype.Component;
7 |
8 | @Component
9 | @ConfigurationProperties(prefix = "sky.wechat")
10 | @Data
11 | public class WeChatProperties {
12 |
13 | private String appid; //小程序的appid
14 | private String secret; //小程序的秘钥
15 | private String mchid; //商户号
16 | private String mchSerialNo; //商户API证书的证书序列号
17 | private String privateKeyFilePath; //商户私钥文件
18 | private String apiV3Key; //证书解密的密钥
19 | private String weChatPayCertFilePath; //平台证书
20 | private String notifyUrl; //支付成功的回调地址
21 | private String refundNotifyUrl; //退款成功的回调地址
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/result/PageResult.java:
--------------------------------------------------------------------------------
1 | package com.sky.result;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.io.Serializable;
8 | import java.util.List;
9 |
10 | /**
11 | * 封装分页查询结果
12 | */
13 | @Data
14 | @AllArgsConstructor
15 | @NoArgsConstructor
16 | public class PageResult implements Serializable {
17 |
18 | private long total; //总记录数
19 |
20 | private List records; //当前页数据集合
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/result/Result.java:
--------------------------------------------------------------------------------
1 | package com.sky.result;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * 后端统一返回结果
9 | * @param
10 | */
11 | @Data
12 | public class Result implements Serializable {
13 |
14 | private Integer code; //编码:1成功,0和其它数字为失败
15 | private String msg; //错误信息
16 | private T data; //数据
17 |
18 | public static Result success() {
19 | Result result = new Result();
20 | result.code = 1;
21 | return result;
22 | }
23 |
24 | public static Result success(T object) {
25 | Result result = new Result();
26 | result.data = object;
27 | result.code = 1;
28 | return result;
29 | }
30 |
31 | public static Result error(String msg) {
32 | Result result = new Result();
33 | result.msg = msg;
34 | result.code = 0;
35 | return result;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/utils/AliOssUtil.java:
--------------------------------------------------------------------------------
1 | package com.sky.utils;
2 |
3 | import com.aliyun.oss.ClientException;
4 | import com.aliyun.oss.OSS;
5 | import com.aliyun.oss.OSSClientBuilder;
6 | import com.aliyun.oss.OSSException;
7 | import lombok.AllArgsConstructor;
8 | import lombok.Data;
9 | import lombok.extern.slf4j.Slf4j;
10 | import java.io.ByteArrayInputStream;
11 |
12 | @Data
13 | @AllArgsConstructor
14 | @Slf4j
15 | public class AliOssUtil {
16 |
17 | private String endpoint;
18 | private String accessKeyId;
19 | private String accessKeySecret;
20 | private String bucketName;
21 |
22 | /**
23 | * 文件上传
24 | *
25 | * @param bytes
26 | * @param objectName
27 | * @return
28 | */
29 | public String upload(byte[] bytes, String objectName) {
30 |
31 | // 创建OSSClient实例。
32 | OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
33 |
34 | try {
35 | // 创建PutObject请求。
36 | ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(bytes));
37 | } catch (OSSException oe) {
38 | System.out.println("Caught an OSSException, which means your request made it to OSS, "
39 | + "but was rejected with an error response for some reason.");
40 | System.out.println("Error Message:" + oe.getErrorMessage());
41 | System.out.println("Error Code:" + oe.getErrorCode());
42 | System.out.println("Request ID:" + oe.getRequestId());
43 | System.out.println("Host ID:" + oe.getHostId());
44 | } catch (ClientException ce) {
45 | System.out.println("Caught an ClientException, which means the client encountered "
46 | + "a serious internal problem while trying to communicate with OSS, "
47 | + "such as not being able to access the network.");
48 | System.out.println("Error Message:" + ce.getMessage());
49 | } finally {
50 | if (ossClient != null) {
51 | ossClient.shutdown();
52 | }
53 | }
54 |
55 | //文件访问路径规则 https://BucketName.Endpoint/ObjectName
56 | StringBuilder stringBuilder = new StringBuilder("https://");
57 | stringBuilder
58 | .append(bucketName)
59 | .append(".")
60 | .append(endpoint)
61 | .append("/")
62 | .append(objectName);
63 |
64 | log.info("文件上传到:{}", stringBuilder.toString());
65 |
66 | return stringBuilder.toString();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/utils/IPAddressUtils.java:
--------------------------------------------------------------------------------
1 |
2 | import lombok.extern.slf4j.Slf4j;
3 | import org.springframework.stereotype.Component;
4 |
5 | import javax.servlet.http.HttpServletRequest;
6 | import java.net.InetAddress;
7 |
8 | /**
9 | * @Author Handsome
10 | * @Date 2022/6/7 11:09
11 | * @Version 1.0
12 | */
13 | @SuppressWarnings({"all"})
14 | @Slf4j
15 | @Component
16 | public class IPAddressUtils {
17 | /**
18 | * 获取IP地址
19 | */
20 | public static String getIpAdrress(HttpServletRequest request) {
21 | String ipAddress = request.getHeader("X-Forwarded-For");
22 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
23 | ipAddress = request.getHeader("Proxy-Client-IP");
24 | }
25 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
26 | ipAddress = request.getHeader("WL-Proxy-Client-IP");
27 | }
28 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
29 | ipAddress = request.getRemoteAddr();
30 | if ("127.0.0.1".equals(ipAddress) || "0:0:0:0:0:0:0:1".equals(ipAddress)) {
31 | // 根据网卡取本机配置的IP
32 | InetAddress inet = null;
33 | try {
34 | inet = InetAddress.getLocalHost();
35 | } catch (Exception e) {
36 | log.error("根据网卡获取本机配置的IP异常=>", e.getMessage());
37 | }
38 | if (inet.getHostAddress() != null) {
39 | ipAddress = inet.getHostAddress();
40 | }
41 | }
42 | }
43 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
44 | if (ipAddress != null && ipAddress.length() > 15) {
45 | if (ipAddress.indexOf(",") > 0) {
46 | ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
47 | }
48 | }
49 | return ipAddress;
50 | }
51 | }
--------------------------------------------------------------------------------
/sky-common/src/main/java/com/sky/utils/JwtUtil.java:
--------------------------------------------------------------------------------
1 | package com.sky.utils;
2 |
3 | import io.jsonwebtoken.Claims;
4 | import io.jsonwebtoken.JwtBuilder;
5 | import io.jsonwebtoken.Jwts;
6 | import io.jsonwebtoken.SignatureAlgorithm;
7 | import java.nio.charset.StandardCharsets;
8 | import java.util.Date;
9 | import java.util.Map;
10 |
11 | public class JwtUtil {
12 | /**
13 | * 生成jwt
14 | * 使用Hs256算法, 私匙使用固定秘钥
15 | *
16 | * @param secretKey jwt秘钥
17 | * @param ttlMillis jwt过期时间(毫秒)
18 | * @param claims 设置的信息
19 | * @return
20 | */
21 | public static String createJWT(String secretKey, long ttlMillis, Map claims) {
22 | // 指定签名的时候使用的签名算法,也就是header那部分
23 | SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
24 |
25 | // 生成JWT的时间
26 | long expMillis = System.currentTimeMillis() + ttlMillis;
27 | Date exp = new Date(expMillis);
28 |
29 | // 设置jwt的body
30 | JwtBuilder builder = Jwts.builder()
31 | // 如果有私有声明,一定要先设置这个自己创建的私有的声明,这个是给builder的claim赋值,一旦写在标准的声明赋值之后,就是覆盖了那些标准的声明的
32 | .setClaims(claims)
33 | // 设置签名使用的签名算法和签名使用的秘钥
34 | .signWith(signatureAlgorithm, secretKey.getBytes(StandardCharsets.UTF_8))
35 | // 设置过期时间
36 | .setExpiration(exp);
37 |
38 | return builder.compact();
39 | }
40 |
41 | /**
42 | * Token解密
43 | *
44 | * @param secretKey jwt秘钥 此秘钥一定要保留好在服务端, 不能暴露出去, 否则sign就可以被伪造, 如果对接多个客户端建议改造成多个
45 | * @param token 加密后的token
46 | * @return
47 | */
48 | public static Claims parseJWT(String secretKey, String token) {
49 | // 得到DefaultJwtParser
50 | Claims claims = Jwts.parser()
51 | // 设置签名的秘钥
52 | .setSigningKey(secretKey.getBytes(StandardCharsets.UTF_8))
53 | // 设置需要解析的jwt
54 | .parseClaimsJws(token).getBody();
55 | return claims;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/DishFlavorMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 |
4 | import com.sky.entity.DishFlavor;
5 |
6 | /**
7 | * @author O.Dentist
8 | * @description 针对表【dish_flavor(菜品口味关系表)】的数据库操作Mapper
9 | * @createDate 2023-04-20 11:12:38
10 | * @Entity generator.domain.DishFlavor
11 | */
12 | public interface DishFlavorMapper {
13 |
14 | int deleteByPrimaryKey(Long id);
15 |
16 | int insert(DishFlavor record);
17 |
18 | int insertSelective(DishFlavor record);
19 |
20 | DishFlavor selectByPrimaryKey(Long id);
21 |
22 | int updateByPrimaryKeySelective(DishFlavor record);
23 |
24 | int updateByPrimaryKey(DishFlavor record);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/DishMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 |
4 | import com.sky.entity.Dish;
5 |
6 | /**
7 | * @author O.Dentist
8 | * @description 针对表【dish(菜品)】的数据库操作Mapper
9 | * @createDate 2023-04-19 14:14:41
10 | * @Entity generator.domain.Dish
11 | */
12 | public interface DishMapper {
13 |
14 | int deleteByPrimaryKey(Long id);
15 |
16 | int insert(Dish record);
17 |
18 | int insertSelective(Dish record);
19 |
20 | Dish selectByPrimaryKey(Long id);
21 |
22 | int updateByPrimaryKeySelective(Dish record);
23 |
24 | int updateByPrimaryKey(Dish record);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/EmployeeMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 |
4 | import com.sky.entity.Employee;
5 |
6 | /**
7 | * @author O.Dentist
8 | * @description 针对表【employee(员工信息)】的数据库操作Mapper
9 | * @createDate 2023-04-17 21:31:52
10 | * @Entity generator.domain.Employee
11 | */
12 | public interface EmployeeMapper {
13 |
14 | int deleteByPrimaryKey(Long id);
15 |
16 | int insert(Employee record);
17 |
18 | int insertSelective(Employee record);
19 |
20 | Employee selectByPrimaryKey(Long id);
21 |
22 | int updateByPrimaryKeySelective(Employee record);
23 |
24 | int updateByPrimaryKey(Employee record);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/OrderDetailMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 | import com.sky.entity.OrderDetail;
4 |
5 | /**
6 | * @author O.Dentist
7 | * @description 针对表【order_detail(订单明细表)】的数据库操作Mapper
8 | * @createDate 2023-04-28 15:38:18
9 | * @Entity generator.domain.OrderDetail
10 | */
11 | public interface OrderDetailMapper {
12 |
13 | int deleteByPrimaryKey(Long id);
14 |
15 | int insert(OrderDetail record);
16 |
17 | int insertSelective(OrderDetail record);
18 |
19 | OrderDetail selectByPrimaryKey(Long id);
20 |
21 | int updateByPrimaryKeySelective(OrderDetail record);
22 |
23 | int updateByPrimaryKey(OrderDetail record);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/OrdersMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 | import com.sky.entity.Orders;
4 |
5 | /**
6 | * @author O.Dentist
7 | * @description 针对表【orders(订单表)】的数据库操作Mapper
8 | * @createDate 2023-04-28 15:03:00
9 | * @Entity generator.domain.Orders
10 | */
11 | public interface OrdersMapper {
12 |
13 | int deleteByPrimaryKey(Long id);
14 |
15 | int insert(Orders record);
16 |
17 | int insertSelective(Orders record);
18 |
19 | Orders selectByPrimaryKey(Long id);
20 |
21 | int updateByPrimaryKeySelective(Orders record);
22 |
23 | int updateByPrimaryKey(Orders record);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/SetmealDishMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 |
4 | import com.sky.entity.SetmealDish;
5 |
6 | /**
7 | * @author O.Dentist
8 | * @description 针对表【setmeal_dish(套餐菜品关系)】的数据库操作Mapper
9 | * @createDate 2023-04-20 19:34:17
10 | * @Entity generator.domain.SetmealDish
11 | */
12 | public interface SetmealDishMapper {
13 |
14 | int deleteByPrimaryKey(Long id);
15 |
16 | int insert(SetmealDish record);
17 |
18 | int insertSelective(SetmealDish record);
19 |
20 | SetmealDish selectByPrimaryKey(Long id);
21 |
22 | int updateByPrimaryKeySelective(SetmealDish record);
23 |
24 | int updateByPrimaryKey(SetmealDish record);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/SetmealMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 |
4 | import com.sky.entity.Setmeal;
5 |
6 | /**
7 | * @author O.Dentist
8 | * @description 针对表【setmeal(套餐)】的数据库操作Mapper
9 | * @createDate 2023-04-20 16:05:17
10 | * @Entity generator.domain.Setmeal
11 | */
12 | public interface SetmealMapper {
13 |
14 | int deleteByPrimaryKey(Long id);
15 |
16 | int insert(Setmeal record);
17 |
18 | int insertSelective(Setmeal record);
19 |
20 | Setmeal selectByPrimaryKey(Long id);
21 |
22 | int updateByPrimaryKeySelective(Setmeal record);
23 |
24 | int updateByPrimaryKey(Setmeal record);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sky-common/src/main/java/generator/mapper/ShoppingCartMapper.java:
--------------------------------------------------------------------------------
1 | package generator.mapper;
2 |
3 | import com.sky.entity.ShoppingCart;
4 |
5 | /**
6 | * @author O.Dentist
7 | * @description 针对表【shopping_cart(购物车)】的数据库操作Mapper
8 | * @createDate 2023-04-27 17:06:52
9 | * @Entity generator.domain.ShoppingCart
10 | */
11 | public interface ShoppingCartMapper {
12 |
13 | int deleteByPrimaryKey(Long id);
14 |
15 | int insert(ShoppingCart record);
16 |
17 | int insertSelective(ShoppingCart record);
18 |
19 | ShoppingCart selectByPrimaryKey(Long id);
20 |
21 | int updateByPrimaryKeySelective(ShoppingCart record);
22 |
23 | int updateByPrimaryKey(ShoppingCart record);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sky-common/src/main/resources/mapper/DishFlavorMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | id,dish_id,name,
16 | value
17 |
18 |
19 |
25 |
26 |
27 | delete from dish_flavor
28 | where id = #{id,jdbcType=BIGINT}
29 |
30 |
31 | insert into dish_flavor
32 | ( id,dish_id,name
33 | ,value)
34 | values (#{id,jdbcType=BIGINT},#{dishId,jdbcType=BIGINT},#{name,jdbcType=VARCHAR}
35 | ,#{value,jdbcType=VARCHAR})
36 |
37 |
38 | insert into dish_flavor
39 |
40 | id,
41 | dish_id,
42 | name,
43 | value,
44 |
45 |
46 | #{id,jdbcType=BIGINT},
47 | #{dishId,jdbcType=BIGINT},
48 | #{name,jdbcType=VARCHAR},
49 | #{value,jdbcType=VARCHAR},
50 |
51 |
52 |
53 | update dish_flavor
54 |
55 |
56 | dish_id = #{dishId,jdbcType=BIGINT},
57 |
58 |
59 | name = #{name,jdbcType=VARCHAR},
60 |
61 |
62 | value = #{value,jdbcType=VARCHAR},
63 |
64 |
65 | where id = #{id,jdbcType=BIGINT}
66 |
67 |
68 | update dish_flavor
69 | set
70 | dish_id = #{dishId,jdbcType=BIGINT},
71 | name = #{name,jdbcType=VARCHAR},
72 | value = #{value,jdbcType=VARCHAR}
73 | where id = #{id,jdbcType=BIGINT}
74 |
75 |
76 |
--------------------------------------------------------------------------------
/sky-common/src/main/resources/mapper/SetmealDishMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | id,setmeal_id,dish_id,
18 | name,price,copies
19 |
20 |
21 |
27 |
28 |
29 | delete from setmeal_dish
30 | where id = #{id,jdbcType=BIGINT}
31 |
32 |
33 | insert into setmeal_dish
34 | ( id,setmeal_id,dish_id
35 | ,name,price,copies
36 | )
37 | values (#{id,jdbcType=BIGINT},#{setmealId,jdbcType=BIGINT},#{dishId,jdbcType=BIGINT}
38 | ,#{name,jdbcType=VARCHAR},#{price,jdbcType=DECIMAL},#{copies,jdbcType=INTEGER}
39 | )
40 |
41 |
42 | insert into setmeal_dish
43 |
44 | id,
45 | setmeal_id,
46 | dish_id,
47 | name,
48 | price,
49 | copies,
50 |
51 |
52 | #{id,jdbcType=BIGINT},
53 | #{setmealId,jdbcType=BIGINT},
54 | #{dishId,jdbcType=BIGINT},
55 | #{name,jdbcType=VARCHAR},
56 | #{price,jdbcType=DECIMAL},
57 | #{copies,jdbcType=INTEGER},
58 |
59 |
60 |
61 | update setmeal_dish
62 |
63 |
64 | setmeal_id = #{setmealId,jdbcType=BIGINT},
65 |
66 |
67 | dish_id = #{dishId,jdbcType=BIGINT},
68 |
69 |
70 | name = #{name,jdbcType=VARCHAR},
71 |
72 |
73 | price = #{price,jdbcType=DECIMAL},
74 |
75 |
76 | copies = #{copies,jdbcType=INTEGER},
77 |
78 |
79 | where id = #{id,jdbcType=BIGINT}
80 |
81 |
82 | update setmeal_dish
83 | set
84 | setmeal_id = #{setmealId,jdbcType=BIGINT},
85 | dish_id = #{dishId,jdbcType=BIGINT},
86 | name = #{name,jdbcType=VARCHAR},
87 | price = #{price,jdbcType=DECIMAL},
88 | copies = #{copies,jdbcType=INTEGER}
89 | where id = #{id,jdbcType=BIGINT}
90 |
91 |
92 |
--------------------------------------------------------------------------------
/sky-pojo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | sky-take-out
7 | com.sky
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 | sky-pojo
12 |
13 |
14 | org.projectlombok
15 | lombok
16 |
17 |
18 | com.fasterxml.jackson.core
19 | jackson-databind
20 | 2.9.2
21 |
22 |
23 | com.github.xiaoymin
24 | knife4j-spring-boot-starter
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/CategoryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class CategoryDTO implements Serializable {
9 |
10 | //主键
11 | private Long id;
12 |
13 | //类型 1 菜品分类 2 套餐分类
14 | private Integer type;
15 |
16 | //分类名称
17 | private String name;
18 |
19 | //排序
20 | private Integer sort;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/CategoryPageQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class CategoryPageQueryDTO implements Serializable {
9 |
10 | //页码
11 | private int page;
12 |
13 | //每页记录数
14 | private int pageSize;
15 |
16 | //分类名称
17 | private String name;
18 |
19 | //分类类型 1菜品分类 2套餐分类
20 | private Integer type;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/DataOverViewQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalDateTime;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class DataOverViewQueryDTO implements Serializable {
16 |
17 | private LocalDateTime begin;
18 |
19 | private LocalDateTime end;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/DishDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import com.sky.entity.DishFlavor;
4 | import lombok.Data;
5 | import java.io.Serializable;
6 | import java.math.BigDecimal;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | @Data
11 | public class DishDTO implements Serializable {
12 |
13 | private Long id;
14 | //菜品名称
15 | private String name;
16 | //菜品分类id
17 | private Long categoryId;
18 | //菜品价格
19 | private BigDecimal price;
20 | //图片
21 | private String image;
22 | //描述信息
23 | private String description;
24 | //0 停售 1 起售
25 | private Integer status;
26 | //口味
27 | private List flavors = new ArrayList<>();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/DishPageQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class DishPageQueryDTO implements Serializable {
9 |
10 | private int page;
11 |
12 | private int pageSize;
13 |
14 | private String name;
15 |
16 | //分类id
17 | private Integer categoryId;
18 |
19 | //状态 0表示禁用 1表示启用
20 | private Integer status;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/EmployeeDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class EmployeeDTO implements Serializable {
9 |
10 | private Long id;
11 |
12 | private String username;
13 |
14 | private String name;
15 |
16 | private String phone;
17 |
18 | private String sex;
19 |
20 | private String idNumber;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/EmployeeLoginDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import io.swagger.annotations.ApiModel;
4 | import io.swagger.annotations.ApiModelProperty;
5 | import lombok.Data;
6 |
7 | import java.io.Serializable;
8 |
9 | @Data
10 | @ApiModel(description = "员工登录时传递的数据模型")
11 | public class EmployeeLoginDTO implements Serializable {
12 |
13 | @ApiModelProperty("用户名")
14 | private String username;
15 |
16 | @ApiModelProperty("密码")
17 | private String password;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/EmployeePageQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class EmployeePageQueryDTO implements Serializable {
9 |
10 | //员工姓名
11 | private String name;
12 |
13 | //页码
14 | private int page;
15 |
16 | //每页显示记录数
17 | private int pageSize;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/GoodsSalesDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Builder
14 | public class GoodsSalesDTO implements Serializable {
15 | //商品名称
16 | private String name;
17 |
18 | //销量
19 | private Integer number;
20 | }
21 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersCancelDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class OrdersCancelDTO implements Serializable {
9 |
10 | private Long id;
11 | //订单取消原因
12 | private String cancelReason;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersConfirmDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class OrdersConfirmDTO implements Serializable {
9 |
10 | private Long id;
11 | //订单状态 1待付款 2待接单 3 已接单 4 派送中 5 已完成 6 已取消 7 退款
12 | private Integer status;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import com.sky.entity.OrderDetail;
4 | import lombok.Data;
5 | import java.io.Serializable;
6 | import java.math.BigDecimal;
7 | import java.time.LocalDateTime;
8 | import java.util.List;
9 |
10 | @Data
11 | public class OrdersDTO implements Serializable {
12 |
13 | private Long id;
14 |
15 | //订单号
16 | private String number;
17 |
18 | //订单状态 1待付款,2待派送,3已派送,4已完成,5已取消
19 | private Integer status;
20 |
21 | //下单用户id
22 | private Long userId;
23 |
24 | //地址id
25 | private Long addressBookId;
26 |
27 | //下单时间
28 | private LocalDateTime orderTime;
29 |
30 | //结账时间
31 | private LocalDateTime checkoutTime;
32 |
33 | //支付方式 1微信,2支付宝
34 | private Integer payMethod;
35 |
36 | //实收金额
37 | private BigDecimal amount;
38 |
39 | //备注
40 | private String remark;
41 |
42 | //用户名
43 | private String userName;
44 |
45 | //手机号
46 | private String phone;
47 |
48 | //地址
49 | private String address;
50 |
51 | //收货人
52 | private String consignee;
53 |
54 | private List orderDetails;
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersPageQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 | import org.springframework.format.annotation.DateTimeFormat;
5 |
6 | import java.io.Serializable;
7 | import java.time.LocalDateTime;
8 |
9 | @Data
10 | public class OrdersPageQueryDTO implements Serializable {
11 |
12 | private int page;
13 |
14 | private int pageSize;
15 |
16 | private String number;
17 |
18 | private String phone;
19 |
20 | private Integer status;
21 |
22 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
23 | private LocalDateTime beginTime;
24 |
25 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
26 | private LocalDateTime endTime;
27 |
28 | private Long userId;
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersPaymentDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 | import java.io.Serializable;
5 |
6 | @Data
7 | public class OrdersPaymentDTO implements Serializable {
8 | //订单号
9 | private String orderNumber;
10 |
11 | //付款方式
12 | private Integer payMethod;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersRejectionDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class OrdersRejectionDTO implements Serializable {
9 |
10 | private Long id;
11 |
12 | //订单拒绝原因
13 | private String rejectionReason;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/OrdersSubmitDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import com.fasterxml.jackson.annotation.JsonFormat;
4 | import lombok.Data;
5 |
6 | import java.io.Serializable;
7 | import java.math.BigDecimal;
8 | import java.time.LocalDateTime;
9 |
10 | @Data
11 | public class OrdersSubmitDTO implements Serializable {
12 | //地址簿id
13 | private Long addressBookId;
14 | //付款方式
15 | private int payMethod;
16 | //备注
17 | private String remark;
18 | //预计送达时间
19 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
20 | private LocalDateTime estimatedDeliveryTime;
21 | //配送状态 1立即送出 0选择具体时间
22 | private Integer deliveryStatus;
23 | //餐具数量
24 | private Integer tablewareNumber;
25 | //餐具数量状态 1按餐量提供 0选择具体数量
26 | private Integer tablewareStatus;
27 | //打包费
28 | private Integer packAmount;
29 | //总金额
30 | private BigDecimal amount;
31 | }
32 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/PasswordEditDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class PasswordEditDTO implements Serializable {
9 |
10 | //员工id
11 | private Long empId;
12 |
13 | //旧密码
14 | private String oldPassword;
15 |
16 | //新密码
17 | private String newPassword;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/SetmealDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import com.sky.entity.SetmealDish;
4 | import lombok.Data;
5 | import java.io.Serializable;
6 | import java.math.BigDecimal;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | @Data
11 | public class SetmealDTO implements Serializable {
12 |
13 | private Long id;
14 |
15 | //分类id
16 | private Long categoryId;
17 |
18 | //套餐名称
19 | private String name;
20 |
21 | //套餐价格
22 | private BigDecimal price;
23 |
24 | //状态 0:停用 1:启用
25 | private Integer status;
26 |
27 | //描述信息
28 | private String description;
29 |
30 | //图片
31 | private String image;
32 |
33 | //套餐菜品关系
34 | private List setmealDishes = new ArrayList<>();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/SetmealPageQueryDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | @Data
8 | public class SetmealPageQueryDTO implements Serializable {
9 |
10 | private int page;
11 |
12 | private int pageSize;
13 |
14 | private String name;
15 |
16 | //分类id
17 | private Integer categoryId;
18 |
19 | //状态 0表示禁用 1表示启用
20 | private Integer status;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/ShoppingCartDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 | import java.io.Serializable;
5 |
6 | @Data
7 | public class ShoppingCartDTO implements Serializable {
8 |
9 | private Long dishId;
10 | private Long setmealId;
11 | private String dishFlavor;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/dto/UserLoginDTO.java:
--------------------------------------------------------------------------------
1 | package com.sky.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * C端用户登录
9 | */
10 | @Data
11 | public class UserLoginDTO implements Serializable {
12 |
13 | private String code;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/AddressBook.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 地址簿
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class AddressBook implements Serializable {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | private Long id;
22 |
23 | //用户id
24 | private Long userId;
25 |
26 | //收货人
27 | private String consignee;
28 |
29 | //手机号
30 | private String phone;
31 |
32 | //性别 0 女 1 男
33 | private String sex;
34 |
35 | //省级区划编号
36 | private String provinceCode;
37 |
38 | //省级名称
39 | private String provinceName;
40 |
41 | //市级区划编号
42 | private String cityCode;
43 |
44 | //市级名称
45 | private String cityName;
46 |
47 | //区级区划编号
48 | private String districtCode;
49 |
50 | //区级名称
51 | private String districtName;
52 |
53 | //详细地址
54 | private String detail;
55 |
56 | //标签
57 | private String label;
58 |
59 | //是否默认 0否 1是
60 | private Integer isDefault;
61 | }
62 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/Category.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import java.io.Serializable;
8 | import java.time.LocalDateTime;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class Category implements Serializable {
15 |
16 | private static final long serialVersionUID = 1L;
17 |
18 | private Long id;
19 |
20 | //类型: 1菜品分类 2套餐分类
21 | private Integer type;
22 |
23 | //分类名称
24 | private String name;
25 |
26 | //顺序
27 | private Integer sort;
28 |
29 | //分类状态 0标识禁用 1表示启用
30 | private Integer status;
31 |
32 | //创建时间
33 | private LocalDateTime createTime;
34 |
35 | //更新时间
36 | private LocalDateTime updateTime;
37 |
38 | //创建人
39 | private Long createUser;
40 |
41 | //修改人
42 | private Long updateUser;
43 | }
44 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/Dish.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import java.io.Serializable;
8 | import java.math.BigDecimal;
9 | import java.time.LocalDateTime;
10 |
11 | /**
12 | * 菜品
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Dish implements Serializable {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | private Long id;
23 |
24 | //菜品名称
25 | private String name;
26 |
27 | //菜品分类id
28 | private Long categoryId;
29 |
30 | //菜品价格
31 | private BigDecimal price;
32 |
33 | //图片
34 | private String image;
35 |
36 | //描述信息
37 | private String description;
38 |
39 | //0 停售 1 起售
40 | private Integer status;
41 |
42 | private LocalDateTime createTime;
43 |
44 | private LocalDateTime updateTime;
45 |
46 | private Long createUser;
47 |
48 | private Long updateUser;
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/DishFlavor.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 菜品口味
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class DishFlavor implements Serializable {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | private Long id;
22 | //菜品id
23 | private Long dishId;
24 |
25 | //口味名称
26 | private String name;
27 |
28 | //口味数据list
29 | private String value;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/Employee.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalDateTime;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class Employee implements Serializable {
16 |
17 | private static final long serialVersionUID = 1L;
18 |
19 | private Long id;
20 |
21 | private String username;
22 |
23 | private String name;
24 |
25 | private String password;
26 |
27 | private String phone;
28 |
29 | private String sex;
30 |
31 | private String idNumber;
32 |
33 | private Integer status;
34 |
35 | //在属性上加入注解,对日期进行格式化
36 | //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
37 | private LocalDateTime createTime;
38 |
39 | //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
40 | private LocalDateTime updateTime;
41 |
42 | private Long createUser;
43 |
44 | private Long updateUser;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/OrderDetail.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 |
11 | /**
12 | * 订单明细
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class OrderDetail implements Serializable {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | private Long id;
23 |
24 | //名称
25 | private String name;
26 |
27 | //订单id
28 | private Long orderId;
29 |
30 | //菜品id
31 | private Long dishId;
32 |
33 | //套餐id
34 | private Long setmealId;
35 |
36 | //口味
37 | private String dishFlavor;
38 |
39 | //数量
40 | private Integer number;
41 |
42 | //金额
43 | private BigDecimal amount;
44 |
45 | //图片
46 | private String image;
47 | }
48 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/Orders.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalDateTime;
11 |
12 | /**
13 | * 订单
14 | */
15 | @Data
16 | @Builder
17 | @NoArgsConstructor
18 | @AllArgsConstructor
19 | public class Orders implements Serializable {
20 |
21 | /**
22 | * 订单状态 1待付款 2待接单 3已接单 4派送中 5已完成 6已取消
23 | */
24 | public static final Integer PENDING_PAYMENT = 1;
25 | public static final Integer TO_BE_CONFIRMED = 2;
26 | public static final Integer CONFIRMED = 3;
27 | public static final Integer DELIVERY_IN_PROGRESS = 4;
28 | public static final Integer COMPLETED = 5;
29 | public static final Integer CANCELLED = 6;
30 |
31 | /**
32 | * 支付状态 0未支付 1已支付 2退款
33 | */
34 | public static final Integer UN_PAID = 0;
35 | public static final Integer PAID = 1;
36 | public static final Integer REFUND = 2;
37 |
38 | private static final long serialVersionUID = 1L;
39 |
40 | private Long id;
41 |
42 | //订单号
43 | private String number;
44 |
45 | //订单状态 1待付款 2待接单 3已接单 4派送中 5已完成 6已取消 7退款
46 | private Integer status;
47 |
48 | //下单用户id
49 | private Long userId;
50 |
51 | //地址id
52 | private Long addressBookId;
53 |
54 | //下单时间
55 | private LocalDateTime orderTime;
56 |
57 | //结账时间
58 | private LocalDateTime checkoutTime;
59 |
60 | //支付方式 1微信,2支付宝
61 | private Integer payMethod;
62 |
63 | //支付状态 0未支付 1已支付 2退款
64 | private Integer payStatus;
65 |
66 | //实收金额
67 | private BigDecimal amount;
68 |
69 | //备注
70 | private String remark;
71 |
72 | //用户名
73 | private String userName;
74 |
75 | //手机号
76 | private String phone;
77 |
78 | //地址
79 | private String address;
80 |
81 | //收货人
82 | private String consignee;
83 |
84 | //订单取消原因
85 | private String cancelReason;
86 |
87 | //订单拒绝原因
88 | private String rejectionReason;
89 |
90 | //订单取消时间
91 | private LocalDateTime cancelTime;
92 |
93 | //预计送达时间
94 | private LocalDateTime estimatedDeliveryTime;
95 |
96 | //配送状态 1立即送出 0选择具体时间
97 | private Integer deliveryStatus;
98 |
99 | //送达时间
100 | private LocalDateTime deliveryTime;
101 |
102 | //打包费
103 | private int packAmount;
104 |
105 | //餐具数量
106 | private int tablewareNumber;
107 |
108 | //餐具数量状态 1按餐量提供 0选择具体数量
109 | private Integer tablewareStatus;
110 | }
111 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/Setmeal.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import java.io.Serializable;
8 | import java.math.BigDecimal;
9 | import java.time.LocalDateTime;
10 |
11 | /**
12 | * 套餐
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Setmeal implements Serializable {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | private Long id;
23 |
24 | //分类id
25 | private Long categoryId;
26 |
27 | //套餐名称
28 | private String name;
29 |
30 | //套餐价格
31 | private BigDecimal price;
32 |
33 | //状态 0:停用 1:启用
34 | private Integer status;
35 |
36 | //描述信息
37 | private String description;
38 |
39 | //图片
40 | private String image;
41 |
42 | private LocalDateTime createTime;
43 |
44 | private LocalDateTime updateTime;
45 |
46 | private Long createUser;
47 |
48 | private Long updateUser;
49 | }
50 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/SetmealDish.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 |
11 | /**
12 | * 套餐菜品关系
13 | */
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class SetmealDish implements Serializable {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | private Long id;
23 |
24 | //套餐id
25 | private Long setmealId;
26 |
27 | //菜品id
28 | private Long dishId;
29 |
30 | //菜品名称 (冗余字段)
31 | private String name;
32 |
33 | //菜品原价
34 | private BigDecimal price;
35 |
36 | //份数
37 | private Integer copies;
38 | }
39 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/ShoppingCart.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalDateTime;
11 |
12 | /**
13 | * 购物车
14 | */
15 | @Data
16 | @Builder
17 | @NoArgsConstructor
18 | @AllArgsConstructor
19 | public class ShoppingCart implements Serializable {
20 |
21 | private static final long serialVersionUID = 1L;
22 |
23 | private Long id;
24 |
25 | //名称
26 | private String name;
27 |
28 | //用户id
29 | private Long userId;
30 |
31 | //菜品id
32 | private Long dishId;
33 |
34 | //套餐id
35 | private Long setmealId;
36 |
37 | //口味
38 | private String dishFlavor;
39 |
40 | //数量
41 | private Integer number;
42 |
43 | //金额
44 | private BigDecimal amount;
45 |
46 | //图片
47 | private String image;
48 |
49 | private LocalDateTime createTime;
50 | }
51 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.sky.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalDate;
10 | import java.time.LocalDateTime;
11 |
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | public class User implements Serializable {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | private Long id;
21 |
22 | //微信用户唯一标识
23 | private String openid;
24 |
25 | //姓名
26 | private String name;
27 |
28 | //手机号
29 | private String phone;
30 |
31 | //性别 0 女 1 男
32 | private String sex;
33 |
34 | //身份证号
35 | private String idNumber;
36 |
37 | //头像
38 | private String avatar;
39 |
40 | //注册时间
41 | private LocalDateTime createTime;
42 | }
43 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/BusinessDataVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 数据概览
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class BusinessDataVO implements Serializable {
18 |
19 | private Double turnover;//营业额
20 |
21 | private Integer validOrderCount;//有效订单数
22 |
23 | private Double orderCompletionRate;//订单完成率
24 |
25 | private Double unitPrice;//平均客单价
26 |
27 | private Integer newUsers;//新增用户数
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/DishItemVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class DishItemVO implements Serializable {
15 |
16 | //菜品名称
17 | private String name;
18 |
19 | //份数
20 | private Integer copies;
21 |
22 | //菜品图片
23 | private String image;
24 |
25 | //菜品描述
26 | private String description;
27 | }
28 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/DishOverViewVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 菜品总览
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class DishOverViewVO implements Serializable {
18 | // 已启售数量
19 | private Integer sold;
20 |
21 | // 已停售数量
22 | private Integer discontinued;
23 | }
24 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/DishVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import com.sky.entity.DishFlavor;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalDateTime;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class DishVO implements Serializable {
19 |
20 | private Long id;
21 | //菜品名称
22 | private String name;
23 | //菜品分类id
24 | private Long categoryId;
25 | //菜品价格
26 | private BigDecimal price;
27 | //图片
28 | private String image;
29 | //描述信息
30 | private String description;
31 | //0 停售 1 起售
32 | private Integer status;
33 | //更新时间
34 | private LocalDateTime updateTime;
35 | //分类名称
36 | private String categoryName;
37 | //菜品关联的口味
38 | private List flavors = new ArrayList<>();
39 |
40 | //private Integer copies;
41 | }
42 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/EmployeeLoginVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import io.swagger.annotations.ApiModel;
4 | import io.swagger.annotations.ApiModelProperty;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Builder;
7 | import lombok.Data;
8 | import lombok.NoArgsConstructor;
9 |
10 | import java.io.Serializable;
11 |
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | @ApiModel(description = "员工登录返回的数据格式")
17 | public class EmployeeLoginVO implements Serializable {
18 |
19 | @ApiModelProperty("主键值")
20 | private Long id;
21 |
22 | @ApiModelProperty("用户名")
23 | private String userName;
24 |
25 | @ApiModelProperty("姓名")
26 | private String name;
27 |
28 | @ApiModelProperty("jwt令牌")
29 | private String token;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderOverViewVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 订单概览数据
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class OrderOverViewVO implements Serializable {
18 | //待接单数量
19 | private Integer waitingOrders;
20 |
21 | //待派送数量
22 | private Integer deliveredOrders;
23 |
24 | //已完成数量
25 | private Integer completedOrders;
26 |
27 | //已取消数量
28 | private Integer cancelledOrders;
29 |
30 | //全部订单
31 | private Integer allOrders;
32 | }
33 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderPaymentVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalDateTime;
10 |
11 | @Data
12 | @Builder
13 | @NoArgsConstructor
14 | @AllArgsConstructor
15 | public class OrderPaymentVO implements Serializable {
16 |
17 | private String nonceStr; //随机字符串
18 | private String paySign; //签名
19 | private String timeStamp; //时间戳
20 | private String signType; //签名算法
21 | private String packageStr; //统一下单接口返回的 prepay_id 参数值
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderReportVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class OrderReportVO implements Serializable {
15 |
16 | //日期,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03
17 | private String dateList;
18 |
19 | //每日订单数,以逗号分隔,例如:260,210,215
20 | private String orderCountList;
21 |
22 | //每日有效订单数,以逗号分隔,例如:20,21,10
23 | private String validOrderCountList;
24 |
25 | //订单总数
26 | private Integer totalOrderCount;
27 |
28 | //有效订单数
29 | private Integer validOrderCount;
30 |
31 | //订单完成率
32 | private Double orderCompletionRate;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderStatisticsVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.Data;
4 | import java.io.Serializable;
5 |
6 | @Data
7 | public class OrderStatisticsVO implements Serializable {
8 | //待接单数量
9 | private Integer toBeConfirmed;
10 |
11 | //待派送数量
12 | private Integer confirmed;
13 |
14 | //派送中数量
15 | private Integer deliveryInProgress;
16 | }
17 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderSubmitVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalDateTime;
11 |
12 | @Data
13 | @Builder
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | public class OrderSubmitVO implements Serializable {
17 | //订单id
18 | private Long id;
19 | //订单号
20 | private String orderNumber;
21 | //订单金额
22 | private BigDecimal orderAmount;
23 | //下单时间
24 | private LocalDateTime orderTime;
25 | }
26 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/OrderVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import com.sky.entity.OrderDetail;
4 | import com.sky.entity.Orders;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import java.io.Serializable;
9 | import java.util.List;
10 |
11 | @Data
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class OrderVO extends Orders implements Serializable {
15 |
16 | //订单菜品信息
17 | private String orderDishes;
18 |
19 | //订单详情
20 | private List orderDetailList;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/SalesTop10ReportVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class SalesTop10ReportVO implements Serializable {
15 |
16 | //商品名称列表,以逗号分隔,例如:鱼香肉丝,宫保鸡丁,水煮鱼
17 | private String nameList;
18 |
19 | //销量列表,以逗号分隔,例如:260,215,200
20 | private String numberList;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/SetmealOverViewVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 套餐总览
12 | */
13 | @Data
14 | @Builder
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class SetmealOverViewVO implements Serializable {
18 | // 已启售数量
19 | private Integer sold;
20 |
21 | // 已停售数量
22 | private Integer discontinued;
23 | }
24 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/SetmealVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import com.sky.entity.SetmealDish;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Builder;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalDateTime;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | @Data
15 | @Builder
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class SetmealVO implements Serializable {
19 |
20 | private Long id;
21 |
22 | //分类id
23 | private Long categoryId;
24 |
25 | //套餐名称
26 | private String name;
27 |
28 | //套餐价格
29 | private BigDecimal price;
30 |
31 | //状态 0:停用 1:启用
32 | private Integer status;
33 |
34 | //描述信息
35 | private String description;
36 |
37 | //图片
38 | private String image;
39 |
40 | //更新时间
41 | private LocalDateTime updateTime;
42 |
43 | //分类名称
44 | private String categoryName;
45 |
46 | //套餐和菜品的关联关系
47 | private List setmealDishes = new ArrayList<>();
48 | }
49 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/TurnoverReportVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class TurnoverReportVO implements Serializable {
15 |
16 | //日期,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03
17 | private String dateList;
18 |
19 | //营业额,以逗号分隔,例如:406.0,1520.0,75.0
20 | private String turnoverList;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/UserLoginVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class UserLoginVO implements Serializable {
15 |
16 | private Long id;
17 | private String openid;
18 | private String token;
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/sky-pojo/src/main/java/com/sky/vo/UserReportVO.java:
--------------------------------------------------------------------------------
1 | package com.sky.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.Serializable;
9 |
10 | @Data
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class UserReportVO implements Serializable {
15 |
16 | //日期,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03
17 | private String dateList;
18 |
19 | //用户总量,以逗号分隔,例如:200,210,220
20 | private String totalUserList;
21 |
22 | //新增用户,以逗号分隔,例如:20,21,10
23 | private String newUserList;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sky-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | sky-take-out
7 | com.sky
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 | sky-server
12 |
13 |
14 |
15 | com.sky
16 | sky-common
17 | 1.0-SNAPSHOT
18 |
19 |
20 |
21 | com.sky
22 | sky-pojo
23 | 1.0-SNAPSHOT
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-test
34 | test
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-web
40 | compile
41 |
42 |
43 |
44 | mysql
45 | mysql-connector-java
46 | runtime
47 |
48 |
49 |
50 | org.mybatis.spring.boot
51 | mybatis-spring-boot-starter
52 |
53 |
54 |
55 | org.projectlombok
56 | lombok
57 |
58 |
59 |
60 | com.alibaba
61 | fastjson
62 |
63 |
64 |
65 | com.alibaba
66 | druid-spring-boot-starter
67 |
68 |
69 |
70 | com.github.pagehelper
71 | pagehelper-spring-boot-starter
72 |
73 |
74 |
75 | org.aspectj
76 | aspectjrt
77 |
78 |
79 |
80 | org.aspectj
81 | aspectjweaver
82 |
83 |
84 |
85 | com.github.xiaoymin
86 | knife4j-spring-boot-starter
87 |
88 |
89 |
90 | org.springframework.boot
91 | spring-boot-starter-data-redis
92 |
93 |
94 |
95 | redis.clients
96 | jedis
97 |
98 |
99 |
100 | org.springframework.boot
101 | spring-boot-configuration-processor
102 |
103 |
104 |
105 | org.springframework.boot
106 | spring-boot-starter-cache
107 |
108 |
109 |
110 | org.springframework.boot
111 | spring-boot-starter-websocket
112 |
113 |
114 |
115 | javax.xml.bind
116 | jaxb-api
117 |
118 |
119 |
120 |
121 | org.apache.poi
122 | poi
123 |
124 |
125 | org.apache.poi
126 | poi-ooxml
127 |
128 |
129 |
130 |
131 |
132 |
133 | org.springframework.boot
134 | spring-boot-maven-plugin
135 |
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/SkyApplication.java:
--------------------------------------------------------------------------------
1 | package com.sky;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cache.annotation.EnableCaching;
7 | import org.springframework.scheduling.annotation.EnableScheduling;
8 | import org.springframework.transaction.annotation.EnableTransactionManagement;
9 |
10 | @SpringBootApplication
11 | @EnableTransactionManagement //开启注解方式的事务管理
12 | @EnableCaching //调用redis缓存
13 | @EnableScheduling //开启定时任务
14 | @Slf4j
15 | public class SkyApplication {
16 | public static void main(String[] args) {
17 | SpringApplication.run(SkyApplication.class, args);
18 | log.info("server started");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/annotation/AutoFill.java:
--------------------------------------------------------------------------------
1 | package com.sky.annotation;
2 |
3 | import com.sky.enumeration.OperationType;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | @Target(ElementType.METHOD)
10 | @Retention(RetentionPolicy.RUNTIME)
11 | public @interface AutoFill {
12 | //数据库操作类型:UPDATE INSERT
13 | OperationType value();
14 | }
15 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/annotation/OperationLog.java:
--------------------------------------------------------------------------------
1 | package com.sky.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Target(ElementType.METHOD)
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface OperationLog {
11 | }
12 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/aspect/AutoAspect.java:
--------------------------------------------------------------------------------
1 | package com.sky.aspect;
2 |
3 | import com.sky.annotation.AutoFill;
4 | import com.sky.constant.AutoFillConstant;
5 | import com.sky.context.BaseContext;
6 | import com.sky.enumeration.OperationType;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.aspectj.lang.JoinPoint;
9 | import org.aspectj.lang.annotation.Aspect;
10 | import org.aspectj.lang.annotation.Before;
11 | import org.aspectj.lang.annotation.Pointcut;
12 | import org.aspectj.lang.reflect.MethodSignature;
13 | import org.springframework.stereotype.Component;
14 |
15 | import java.lang.reflect.InvocationTargetException;
16 | import java.lang.reflect.Method;
17 | import java.time.LocalDateTime;
18 | import java.util.HashMap;
19 |
20 | @Aspect
21 | @Component
22 | @Slf4j
23 | public class AutoAspect {
24 | //@Pointcut("execution(* com.sky.mapper.*.insert*(..)) || execution( * com.sky.mapper.*.update*(..))")
25 | @Pointcut("@annotation(com.sky.annotation.AutoFill)")
26 | public void autoFillPointCut() {
27 | }
28 |
29 | @Before("autoFillPointCut()")
30 | public void autoFill(JoinPoint joinPoint) {
31 | log.info("开始填充公共字段");
32 | String name = joinPoint.getSignature().getName();
33 |
34 | MethodSignature signature = (MethodSignature) joinPoint.getSignature();
35 | AutoFill autoFill = signature.getMethod().getAnnotation(AutoFill.class);
36 | OperationType operationType = autoFill.value();
37 | Object[] args = joinPoint.getArgs();
38 | if (args == null || args.length == 0) return;
39 | Object entity = args[0];
40 |
41 | //初始数据准备
42 | LocalDateTime now = LocalDateTime.now();
43 | Long currentId = BaseContext.getCurrentId();
44 |
45 | if (operationType == OperationType.INSERT) {
46 | //if (name.contains("insert")) {
47 | try {
48 | Method setCreateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_TIME, LocalDateTime.class);
49 | Method setCreateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_USER, Long.class);
50 | Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class);
51 | Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class);
52 | //情况1字段填充
53 | setCreateTime.invoke(entity, now);
54 | setUpdateTime.invoke(entity, now);
55 | setCreateUser.invoke(entity, currentId);
56 | setUpdateUser.invoke(entity, currentId);
57 | } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
58 | e.printStackTrace();
59 | }
60 | } else if (operationType == OperationType.UPDATE) {
61 | //else if (name.contains("update")){
62 | try {
63 | Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class);
64 | Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class);
65 | //情况2字段填充
66 | setUpdateTime.invoke(entity, now);
67 | setUpdateUser.invoke(entity, currentId);
68 | } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
69 | e.printStackTrace();
70 | }
71 | }
72 | }
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/aspect/OperationDetect.java:
--------------------------------------------------------------------------------
1 | package com.sky.aspect;
2 |
3 | import com.alibaba.druid.support.http.util.IPAddress;
4 | import com.alibaba.fastjson.JSONObject;
5 | import com.sky.context.BaseContext;
6 | import com.sky.mapper.OperationlogMapper;
7 | import com.sky.utils.IPAddressUtils;
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | import org.aspectj.lang.ProceedingJoinPoint;
11 | import org.aspectj.lang.annotation.Around;
12 | import org.aspectj.lang.annotation.Aspect;
13 |
14 | import org.springframework.beans.factory.annotation.Autowired;
15 | import org.springframework.stereotype.Component;
16 | import org.springframework.web.context.request.RequestContextHolder;
17 | import org.springframework.web.context.request.ServletRequestAttributes;
18 |
19 | import javax.servlet.http.HttpServletRequest;
20 | import java.time.LocalDateTime;
21 |
22 | @Aspect
23 | @Component
24 | @Slf4j
25 | public class OperationDetect {
26 | @Autowired
27 | OperationlogMapper operationlogMapper;
28 |
29 | @Around("@annotation(com.sky.annotation.OperationLog)")
30 | public Object operationDetect(ProceedingJoinPoint joinPoint) throws Throwable {
31 | Long userId = BaseContext.getCurrentId();
32 | String exceptionDetected=null;
33 | Object proceed=null;
34 | LocalDateTime updateTime = LocalDateTime.now();
35 | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
36 | HttpServletRequest request = attributes.getRequest();
37 | String url = request.getRequestURL().toString();
38 | String[] split = url.split("/");
39 | int portCheck = split[3].equals("admin")?1:2;
40 | HttpServletRequest request1 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
41 | // 获取请求用户IP
42 |
43 | String ip = IPAddressUtils.getIpAdrress(request1);
44 | if (ip == null) {
45 | return "error/limit";
46 | }
47 | String method = joinPoint.getSignature().getName();
48 | String args = JSONObject.toJSONString(joinPoint.getArgs());
49 | try {
50 | proceed = joinPoint.proceed();
51 | } catch (Throwable ex) {
52 | exceptionDetected = ex.getMessage();
53 | ex.printStackTrace();
54 | }finally {
55 | operationlogMapper.insert(url,portCheck,ip,method,exceptionDetected,args,userId,updateTime);
56 | }
57 | return proceed;
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/build/OrderItem.java:
--------------------------------------------------------------------------------
1 | package com.sky.build;
2 |
3 | import com.sky.entity.OrderDetail;
4 | import com.sky.entity.Orders;
5 | import lombok.Data;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | public class OrderItem {
11 | private Orders orders;
12 | private List orderDetailList;
13 | }
14 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/build/OrderItemBuilder.java:
--------------------------------------------------------------------------------
1 | package com.sky.build;
2 |
3 | import com.sky.constant.MessageConstant;
4 | import com.sky.context.BaseContext;
5 | import com.sky.dto.OrdersSubmitDTO;
6 | import com.sky.entity.*;
7 | import com.sky.exception.AddressBookBusinessException;
8 | import com.sky.exception.ShoppingCartBusinessException;
9 | import com.sky.mapper.*;
10 | import lombok.Data;
11 | import org.springframework.beans.BeanUtils;
12 | import java.time.LocalDateTime;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | @Data
17 | public class OrderItemBuilder {
18 |
19 | // 问题:你明明不是一个spring相关的类,但是这个类在构建对象时候,肯定会使用
20 | // 到一些spring相关的内容
21 | // 方式一、把当前这个类交给spring管理,直接就可以使用@Autowired 拿到这些要使用的mapper,或者是spring相关的内容
22 | // 方式二、构造方法传参
23 | private AddressBookMapper addressBookMapper;
24 | private ShoppingCartMapper cartMapper;
25 | private UserMapper userMapper;
26 | private OrderItem orderItem;
27 | private OrdersSubmitDTO submitDTO;
28 | private Long userId;
29 | private String orderId;
30 |
31 | public OrderItemBuilder(AddressBookMapper addressBookMapper, ShoppingCartMapper cartMapper
32 | , UserMapper userMapper
33 | , OrdersSubmitDTO submitDTO
34 | ) {
35 | this.addressBookMapper = addressBookMapper;
36 | this.cartMapper = cartMapper;
37 | this.userMapper = userMapper;
38 | this.submitDTO = submitDTO;
39 | this.orderItem = new OrderItem();
40 | this.userId = BaseContext.getCurrentId();
41 | this.orderId = String.valueOf(System.currentTimeMillis());
42 | }
43 | //其实订单要使用到对象,肯定是非常多的,比如快照,比如售后,比如支付,比如配送
44 |
45 | //当你去builderOrder的时候,虽然此时的orders 并没有id
46 | public OrderItemBuilder builderOrders() {
47 |
48 | AddressBook addressBook = addressBookMapper.getById(submitDTO.getAddressBookId());
49 | if(addressBook == null){
50 | throw new AddressBookBusinessException(MessageConstant.ADDRESS_BOOK_IS_NULL);
51 | }
52 | Orders orders = new Orders();
53 | BeanUtils.copyProperties(submitDTO,orders);
54 | //一般订单号确实需要单独处理成一个字段,主要原因是因为 1、支付时候需要使用 2、订单号通常都会具备一些特有含义
55 | User user = userMapper.getById(userId);
56 | orders.setUserName(user.getName());
57 |
58 |
59 | //手动去设置主键id
60 | orders.setId(Long.parseLong(orderId));
61 |
62 | // 假设这个就是雪花算法生成的id 我就让订单表的id和 number保持一致
63 | orders.setNumber(orderId);
64 | orders.setStatus(Orders.PENDING_PAYMENT); //魔法数字 使用枚举来限制入参
65 | orders.setUserId(BaseContext.getCurrentId());
66 | orders.setOrderTime(LocalDateTime.now());
67 | orders.setPayStatus(Orders.UN_PAID);
68 | orders.setPhone(addressBook.getPhone());
69 | orders.setAddress(addressBook.getDetail());
70 | orders.setConsignee(addressBook.getConsignee());
71 | orderItem.setOrders(orders);
72 | return this;
73 | }
74 |
75 |
76 | public OrderItemBuilder builderOrderDetails() {
77 |
78 | ShoppingCart cart = new ShoppingCart();
79 | cart.setUserId(userId);
80 | List cartList = cartMapper.checkShoppingCartList(cart);
81 | if(cartList == null || cartList.size() == 0){
82 | throw new ShoppingCartBusinessException(MessageConstant.SHOPPING_CART_IS_NULL);
83 | }
84 | List orderDetails = new ArrayList<>();
85 | for (ShoppingCart shoppingCart : cartList) {
86 | OrderDetail orderDetail = new OrderDetail();
87 | BeanUtils.copyProperties(shoppingCart,orderDetail);
88 | orderDetail.setOrderId(Long.parseLong(orderId));
89 | orderDetails.add(orderDetail);
90 | }
91 | orderItem.setOrderDetailList(orderDetails);
92 | return this;
93 | }
94 |
95 | public OrderItem build() {
96 | return orderItem;
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/config/OssConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.sky.config;
2 |
3 | import com.sky.properties.AliOssProperties;
4 | import com.sky.utils.AliOssUtil;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | @Configuration
11 | @Slf4j
12 | public class OssConfiguration {
13 |
14 | @Bean
15 | @ConditionalOnMissingBean
16 | public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties){
17 | log.info("开始创建阿里云文件上传工具类对象:{}",aliOssProperties);
18 | return new AliOssUtil(aliOssProperties.getEndpoint(),
19 | aliOssProperties.getAccessKeyId(),
20 | aliOssProperties.getAccessKeySecret(),
21 | aliOssProperties.getBucketName());
22 | }
23 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/config/RedisConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.sky.config;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.data.redis.connection.RedisConnectionFactory;
7 | import org.springframework.data.redis.core.RedisTemplate;
8 | import org.springframework.data.redis.serializer.StringRedisSerializer;
9 |
10 | @Configuration
11 | @Slf4j
12 | public class RedisConfiguration {
13 |
14 | @Bean
15 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
16 | log.info("开始创建redis模板对象...");
17 | RedisTemplate redisTemplate = new RedisTemplate();
18 | //设置redis的连接工厂对象
19 | redisTemplate.setConnectionFactory(redisConnectionFactory);
20 | //设置redis key的序列化器
21 | redisTemplate.setKeySerializer(new StringRedisSerializer());
22 | return redisTemplate;
23 | }
24 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/config/WebSocketConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.sky.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter;
6 |
7 | /**
8 | * WebSocket配置类,用于注册WebSocket的Bean
9 | */
10 | @Configuration
11 | public class WebSocketConfiguration {
12 |
13 | @Bean
14 | public ServerEndpointExporter serverEndpointExporter() {
15 | return new ServerEndpointExporter();
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/CategoryController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.annotation.OperationLog;
4 | import com.sky.dto.CategoryDTO;
5 | import com.sky.dto.CategoryPageQueryDTO;
6 | import com.sky.entity.Category;
7 | import com.sky.result.PageResult;
8 | import com.sky.result.Result;
9 | import com.sky.service.CategoryService;
10 | import io.swagger.annotations.Api;
11 | import io.swagger.annotations.ApiOperation;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.beans.factory.annotation.Autowired;
14 | import org.springframework.web.bind.annotation.*;
15 | import java.util.List;
16 |
17 | /**
18 | * 分类管理
19 | */
20 | @RestController
21 | @RequestMapping("/admin/category")
22 | @Api(tags = "分类相关接口")
23 | @Slf4j
24 | public class CategoryController {
25 |
26 | @Autowired
27 | private CategoryService categoryService;
28 |
29 | /**
30 | * 新增分类
31 | * @param categoryDTO
32 | * @return
33 | */
34 | @PostMapping
35 | @ApiOperation("新增分类")
36 | public Result save(@RequestBody CategoryDTO categoryDTO){
37 | log.info("新增分类:{}", categoryDTO);
38 | categoryService.save(categoryDTO);
39 | return Result.success();
40 | }
41 |
42 | /**
43 | * 分类分页查询
44 | * @param categoryPageQueryDTO
45 | * @return
46 | */
47 | @OperationLog
48 | @GetMapping("/page")
49 | @ApiOperation("分类分页查询")
50 | public Result page(CategoryPageQueryDTO categoryPageQueryDTO){
51 | log.info("分页查询:{}", categoryPageQueryDTO);
52 | PageResult pageResult = categoryService.pageQuery(categoryPageQueryDTO);
53 | return Result.success(pageResult);
54 | }
55 |
56 | /**
57 | * 删除分类
58 | * @param id
59 | * @return
60 | */
61 | @DeleteMapping
62 | @ApiOperation("删除分类")
63 | public Result deleteById(Long id){
64 | log.info("删除分类:{}", id);
65 | categoryService.deleteById(id);
66 | return Result.success();
67 | }
68 |
69 | /**
70 | * 修改分类
71 | * @param categoryDTO
72 | * @return
73 | */
74 | @PutMapping
75 | @ApiOperation("修改分类")
76 | public Result update(@RequestBody CategoryDTO categoryDTO){
77 | categoryService.update(categoryDTO);
78 | return Result.success();
79 | }
80 |
81 | /**
82 | * 启用、禁用分类
83 | * @param status
84 | * @param id
85 | * @return
86 | */
87 | @PostMapping("/status/{status}")
88 | @ApiOperation("启用禁用分类")
89 | public Result startOrStop(@PathVariable("status") Integer status, Long id){
90 | categoryService.startOrStop(status,id);
91 | return Result.success();
92 | }
93 |
94 | /**
95 | * 根据类型查询分类
96 | * @param type
97 | * @return
98 | */
99 | @GetMapping("/list")
100 | @ApiOperation("根据类型查询分类")
101 | public Result> list(Integer type){
102 | List list = categoryService.list(type);
103 | return Result.success(list);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/CommonController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.constant.MessageConstant;
4 | import com.sky.result.Result;
5 | import com.sky.utils.AliOssUtil;
6 | import io.swagger.annotations.Api;
7 | import io.swagger.annotations.ApiOperation;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.PostMapping;
11 | import org.springframework.web.bind.annotation.RequestMapping;
12 | import org.springframework.web.bind.annotation.RestController;
13 | import org.springframework.web.multipart.MultipartFile;
14 |
15 | import java.io.IOException;
16 | import java.util.UUID;
17 |
18 | /**
19 | * 通用接口
20 | */
21 | @RestController
22 | @RequestMapping("/admin/common")
23 | @Api(tags = "通用接口")
24 | @Slf4j
25 | public class CommonController {
26 |
27 | @Autowired
28 | private AliOssUtil aliOssUtil;
29 |
30 | /**
31 | * 文件上传
32 | * @param file
33 | * @return
34 | */
35 | @PostMapping("/upload")
36 | @ApiOperation("文件上传")
37 | public Result upload(MultipartFile file){
38 | log.info("文件上传:{}",file);
39 |
40 | try {
41 | //原始文件名
42 | String originalFilename = file.getOriginalFilename();
43 | //截取原始文件名的后缀 dfdfdf.png
44 | String extension = originalFilename.substring(originalFilename.lastIndexOf("."));
45 | //构造新文件名称
46 | String objectName = UUID.randomUUID().toString() + extension;
47 |
48 | //文件的请求路径
49 | String filePath = aliOssUtil.upload(file.getBytes(), objectName);
50 | return Result.success(filePath);
51 | } catch (IOException e) {
52 | log.error("文件上传失败:{}", e);
53 | }
54 |
55 | return Result.error(MessageConstant.UPLOAD_FAILED);
56 | }
57 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/DishController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.dto.DishDTO;
4 | import com.sky.dto.DishPageQueryDTO;
5 | import com.sky.entity.Dish;
6 | import com.sky.result.PageResult;
7 | import com.sky.result.Result;
8 | import com.sky.service.DishService;
9 | import com.sky.vo.DishVO;
10 | import io.swagger.annotations.Api;
11 | import io.swagger.annotations.ApiOperation;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.beans.factory.annotation.Autowired;
14 | import org.springframework.data.redis.core.RedisTemplate;
15 | import org.springframework.web.bind.annotation.*;
16 | import java.util.List;
17 |
18 | /**
19 | * 菜品管理
20 | */
21 | @RestController
22 | @RequestMapping("/admin/dish")
23 | @Api(tags = "菜品相关接口")
24 | @Slf4j
25 | public class DishController {
26 | @Autowired
27 | DishService dishService;
28 | @Autowired
29 | RedisTemplate redisTemplate;
30 |
31 | /**
32 | * 新增菜品
33 | * @param dishDTO
34 | * @return
35 | */
36 | @PostMapping
37 | @ApiOperation("新增菜品")
38 | public Result save (@RequestBody DishDTO dishDTO){
39 | log.info("新增菜品{}",dishDTO);
40 | dishService.save(dishDTO);
41 | return Result.success();
42 | }
43 |
44 | /**
45 | * 菜品分页
46 | * @param dishPageQueryDTO
47 | * @return
48 | */
49 | @GetMapping("/page")
50 | @ApiOperation("菜品分页")
51 | public Result page(DishPageQueryDTO dishPageQueryDTO){
52 | log.info("分页查询:{}", dishPageQueryDTO);
53 | PageResult pageResult=dishService.pageQuery(dishPageQueryDTO);
54 | return Result.success(pageResult);
55 | }
56 |
57 |
58 | /**
59 | * 批量删除菜品
60 | * @param ids
61 | * @return
62 | */
63 | @DeleteMapping
64 | @ApiOperation("批量删除菜品")
65 | public Result delete(@RequestParam List ids){
66 | log.info("菜品批量删除:{}", ids);
67 | dishService.delete(ids);
68 | return Result.success();
69 | }
70 |
71 | /**
72 | * 回显
73 | * @param id
74 | * @return
75 | */
76 | @GetMapping("/{id}")
77 | @ApiOperation("根据id查询菜品")
78 | public Result getById(@PathVariable Long id){
79 | log.info("根据id查询菜品");
80 | DishVO dishVO=dishService.getByIdWithFlavor(id);
81 | return Result.success(dishVO);
82 | }
83 |
84 | /**
85 | * 修改菜品
86 | * @param dishDTO
87 | * @return
88 | */
89 | @PutMapping
90 | @ApiOperation("修改菜品")
91 | public Result update(@RequestBody DishDTO dishDTO){
92 | log.info("修改菜品");
93 | dishService.updateWithFlavor(dishDTO);
94 | return Result.success();
95 | }
96 |
97 |
98 | /**
99 | * 根据分类查询菜品
100 | * @param categoryId
101 | * @return
102 | */
103 | @GetMapping("/list")
104 | @ApiOperation("根据分类查询菜品")
105 | public Result> queryByCategoryId(Long categoryId){
106 | //构造redis中的key,规则:dish_分类id
107 | log.info("根据分类查询菜品{}",categoryId);
108 | List dish=dishService.queryByCategoryId(categoryId);
109 | return Result.success(dish);
110 | }
111 |
112 | @PostMapping("status/{status}")
113 | @ApiOperation("菜品起售、停售")
114 | public Result updateDishStatus(@PathVariable int status,Long id){
115 | log.info("菜品起售、停售");
116 |
117 | dishService.updateDishStatus(status,id);
118 | return Result.success();
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/EmployeeController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.constant.JwtClaimsConstant;
4 | import com.sky.dto.EmployeeDTO;
5 | import com.sky.dto.EmployeeLoginDTO;
6 | import com.sky.dto.EmployeePageQueryDTO;
7 | import com.sky.dto.PasswordEditDTO;
8 | import com.sky.entity.Employee;
9 | import com.sky.properties.JwtProperties;
10 | import com.sky.result.PageResult;
11 | import com.sky.result.Result;
12 | import com.sky.service.EmployeeService;
13 | import com.sky.utils.JwtUtil;
14 | import com.sky.vo.EmployeeLoginVO;
15 | import io.swagger.annotations.Api;
16 | import io.swagger.annotations.ApiOperation;
17 | import lombok.extern.slf4j.Slf4j;
18 | import org.springframework.beans.factory.annotation.Autowired;
19 | import org.springframework.web.bind.annotation.*;
20 |
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | /**
25 | * 员工管理
26 | */
27 | @RestController
28 | @RequestMapping("/admin/employee")
29 | @Slf4j
30 | @Api(tags = "员工分类")
31 | public class EmployeeController {
32 |
33 | @Autowired
34 | private EmployeeService employeeService;
35 | @Autowired
36 | private JwtProperties jwtProperties;
37 |
38 | /**
39 | * 登录
40 | *
41 | * @param employeeLoginDTO
42 | * @return
43 | */
44 | @PostMapping("/login")
45 | public Result login(@RequestBody EmployeeLoginDTO employeeLoginDTO) {
46 | log.info("员工登录:{}", employeeLoginDTO);
47 |
48 | Employee employee = employeeService.login(employeeLoginDTO);
49 |
50 | //登录成功后,生成jwt令牌
51 | Map claims = new HashMap<>();
52 | claims.put(JwtClaimsConstant.EMP_ID, employee.getId());
53 | String token = JwtUtil.createJWT(
54 | jwtProperties.getAdminSecretKey(),
55 | jwtProperties.getAdminTtl(),
56 | claims);
57 |
58 | EmployeeLoginVO employeeLoginVO = EmployeeLoginVO.builder()
59 | .id(employee.getId())
60 | .userName(employee.getUsername())
61 | .name(employee.getName())
62 | .token(token)
63 | .build();
64 |
65 | return Result.success(employeeLoginVO);
66 | }
67 |
68 | /**
69 | * 退出
70 | *
71 | * @return
72 | */
73 | @PostMapping("/logout")
74 | public Result logout() {
75 | return Result.success();
76 | }
77 |
78 | /**
79 | * 新增员工接口
80 | * @param employeeDTO
81 | * @return
82 | */
83 | @PostMapping
84 | @ApiOperation("新增员工接口")
85 | public Result save(@RequestBody EmployeeDTO employeeDTO){
86 | employeeService.save(employeeDTO);
87 | log.info("新增员工:{}",employeeDTO);
88 | return Result.success();
89 | }
90 |
91 | /**
92 | * 分页查询
93 | * @param employeePageQueryDTO
94 | * @return
95 | */
96 | @GetMapping("/page")
97 | @ApiOperation("员工分页查询")
98 | public Result page(EmployeePageQueryDTO employeePageQueryDTO){
99 | log.info("分页查询:{}",employeePageQueryDTO);
100 | PageResult pageResult = employeeService.page(employeePageQueryDTO);
101 | return Result.success(pageResult);
102 | }
103 |
104 | /**
105 | * 启用禁用员工账号
106 | * @param status
107 | * @param id
108 | * @return
109 | */
110 | @PostMapping("/status/{status}")
111 | @ApiOperation("启用禁用员工账号")
112 | public ResultstartOrStop(@PathVariable Integer status,Long id){
113 | log.info("启用或禁用员员工账户:{},{}",status,id);
114 | employeeService.startOrStop(status,id);
115 | return Result.success();
116 | }
117 |
118 | /**
119 | * 根据id查询员工
120 | * 回显
121 | * @param id
122 | * @return
123 | */
124 | @GetMapping("/{id}")
125 | @ApiOperation("根据id查询员工")
126 | public Result getById(@PathVariable Long id){
127 | return Result.success(employeeService.getById(id));
128 | }
129 |
130 | /**
131 | * 编辑员工信息
132 | * @param employeeDTO
133 | * @return
134 | */
135 | @PutMapping
136 | @ApiOperation("编辑员工信息")
137 | public Result update(@RequestBody EmployeeDTO employeeDTO){
138 | log.info("编辑员工信息{}",employeeDTO);
139 | employeeService.update(employeeDTO);
140 | return Result.success();
141 | }
142 |
143 | @PutMapping("/editPassword")
144 | @ApiOperation("编辑员工信息")
145 | public Result editPassword(@RequestBody PasswordEditDTO passwordEditDTO){
146 | log.info("editPassword{}",passwordEditDTO);
147 | employeeService.editPassword(passwordEditDTO);
148 | return Result.success();
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/OrderController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.github.pagehelper.Page;
4 | import com.sky.dto.OrdersCancelDTO;
5 | import com.sky.dto.OrdersConfirmDTO;
6 | import com.sky.dto.OrdersPageQueryDTO;
7 | import com.sky.dto.OrdersRejectionDTO;
8 | import com.sky.result.PageResult;
9 | import com.sky.result.Result;
10 | import com.sky.service.OrderService;
11 | import com.sky.vo.OrderStatisticsVO;
12 | import com.sky.vo.OrderVO;
13 | import io.swagger.annotations.Api;
14 | import io.swagger.annotations.ApiOperation;
15 | import lombok.extern.slf4j.Slf4j;
16 | import org.springframework.beans.factory.annotation.Autowired;
17 | import org.springframework.web.bind.annotation.*;
18 |
19 | import java.util.List;
20 |
21 |
22 | @Slf4j
23 | @Api("订单管理接口")
24 | @RestController
25 | @RequestMapping("/admin/order")
26 | public class OrderController {
27 | @Autowired
28 | OrderService orderService;
29 |
30 | @GetMapping("/conditionSearch")
31 | public Result conditionSearchOrders(OrdersPageQueryDTO ordersPageQueryDTO){
32 | log.info("订单搜索");
33 | PageResult pageResult=orderService.conditionSearchOrders(ordersPageQueryDTO);
34 | return Result.success(pageResult);
35 | }
36 |
37 | @GetMapping("/details/{id}")
38 | public Result searchOrderDetails(@PathVariable Long id){
39 | log.info("订单明细查询");
40 | OrderVO orderVO = orderService.checkOrderDetail(id);
41 | return Result.success(orderVO);
42 | }
43 |
44 | @PutMapping("/cancel")
45 | public Result cancelOrdersBackend(@RequestBody OrdersCancelDTO ordersCancelDTO){
46 | log.info("订单取消");
47 | orderService.cancelOrderBackend(ordersCancelDTO);
48 | return Result.success();
49 | }
50 |
51 | @PutMapping("/rejection")
52 | public Result rejectionOrders(@RequestBody OrdersRejectionDTO ordersRejectionDTO) throws Exception {
53 | log.info("拒绝订单");
54 | orderService.rejectionOrders(ordersRejectionDTO);
55 | return Result.success();
56 | }
57 |
58 | /**
59 | * 接单
60 | *
61 | * @return
62 | */
63 | @PutMapping("/confirm")
64 | @ApiOperation("接单")
65 | public Result confirm(@RequestBody OrdersConfirmDTO ordersConfirmDTO) {
66 | orderService.confirm(ordersConfirmDTO);
67 | return Result.success();
68 | }
69 |
70 | /**
71 | * 派送订单
72 | *
73 | * @return
74 | */
75 | @PutMapping("/delivery/{id}")
76 | @ApiOperation("派送订单")
77 | public Result delivery(@PathVariable Long id) {
78 | orderService.delivery(id);
79 | return Result.success();
80 | }
81 |
82 | /**
83 | * 完成订单
84 | *
85 | * @return
86 | */
87 | @PutMapping("/complete/{id}")
88 | @ApiOperation("完成订单")
89 | public Result complete(@PathVariable("id") Long id) {
90 | orderService.complete(id);
91 | return Result.success();
92 | }
93 |
94 | @GetMapping("/statistics")
95 | public Result queryOrderStatistics(){
96 | log.info("各个状态的订单数量统计");
97 | OrderStatisticsVO statisticsVO=orderService.queryOrderStatistics();
98 | return Result.success(statisticsVO);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/ReportController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.result.Result;
4 | import com.sky.service.ReportService;
5 | import com.sky.vo.OrderReportVO;
6 | import com.sky.vo.SalesTop10ReportVO;
7 | import com.sky.vo.TurnoverReportVO;
8 | import com.sky.vo.UserReportVO;
9 | import io.swagger.annotations.Api;
10 | import io.swagger.annotations.ApiOperation;
11 | import lombok.extern.slf4j.Slf4j;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.format.annotation.DateTimeFormat;
14 | import org.springframework.web.bind.annotation.GetMapping;
15 | import org.springframework.web.bind.annotation.RequestMapping;
16 | import org.springframework.web.bind.annotation.RestController;
17 |
18 | import javax.servlet.http.HttpServletResponse;
19 | import java.time.LocalDate;
20 |
21 | /**
22 | * 报表
23 | */
24 | @RestController
25 | @RequestMapping("/admin/report")
26 | @Slf4j
27 | @Api(tags = "统计报表相关接口")
28 | public class ReportController {
29 |
30 | @Autowired
31 | private ReportService reportService;
32 |
33 | /**
34 | * 营业额数据统计
35 | *
36 | * @param begin
37 | * @param end
38 | * @return
39 | */
40 | @GetMapping("/turnoverStatistics")
41 | @ApiOperation("营业额数据统计")
42 | public Result turnoverStatistics(
43 | @DateTimeFormat(pattern = "yyyy-MM-dd")
44 | LocalDate begin,
45 | @DateTimeFormat(pattern = "yyyy-MM-dd")
46 | LocalDate end) {
47 | return Result.success(reportService.getTurnover(begin, end));
48 | }
49 | @GetMapping("/userStatistics")
50 | @ApiOperation("用户统计接口")
51 | public Result userStatistics(
52 | @DateTimeFormat(pattern = "yyyy-MM-dd")
53 | LocalDate begin,
54 | @DateTimeFormat(pattern = "yyyy-MM-dd")
55 | LocalDate end) {
56 | return Result.success(reportService.getUserStatistics(begin, end));
57 | }
58 |
59 | @GetMapping("/ordersStatistics")
60 | @ApiOperation("订单统计")
61 | public Result ordersStatistics(
62 | @DateTimeFormat(pattern = "yyyy-MM-dd")
63 | LocalDate begin,
64 | @DateTimeFormat(pattern = "yyyy-MM-dd")
65 | LocalDate end){
66 |
67 | return Result.success(reportService.getOrdersStatistics(begin,end));
68 | }
69 |
70 |
71 | @GetMapping("/top10")
72 | @ApiOperation("查询销量排名top10接口")
73 | public Result top10(
74 | @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
75 | @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
76 | SalesTop10ReportVO salesTop10ReportVO=reportService.getTop10(begin,end);
77 | System.out.println(salesTop10ReportVO.toString());
78 | return Result.success(salesTop10ReportVO);
79 | }
80 |
81 | /**
82 | * 导出运营数据报表
83 | * @param response
84 | */
85 | @GetMapping("/export")
86 | @ApiOperation("导出运营数据报表")
87 | public void export(HttpServletResponse response){
88 | reportService.exportBusinessData(response);
89 | }
90 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/SetMealController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.dto.SetmealDTO;
4 | import com.sky.dto.SetmealPageQueryDTO;
5 | import com.sky.mapper.SetmealMapper;
6 | import com.sky.result.PageResult;
7 | import com.sky.result.Result;
8 | import com.sky.service.SetMealService;
9 | import com.sky.vo.SetmealVO;
10 | import io.swagger.annotations.Api;
11 | import io.swagger.annotations.ApiOperation;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.beans.factory.annotation.Autowired;
14 | import org.springframework.cache.annotation.CacheEvict;
15 | import org.springframework.web.bind.annotation.*;
16 |
17 | import java.util.List;
18 |
19 | @RestController
20 | @Slf4j
21 | @Api(tags = "套餐分类接口")
22 | @RequestMapping("/admin/setmeal")
23 | public class SetMealController {
24 | @Autowired
25 | SetMealService setMealService;
26 |
27 | @ApiOperation("根据id查询套餐")
28 | @GetMapping("/{id}")
29 | public Result queryById(@PathVariable Long id){
30 | log.info("根据id查询套餐");
31 | SetmealVO setmealVO=setMealService.queryById(id);
32 | return Result.success(setmealVO);
33 | }
34 |
35 | @ApiOperation("新增套餐")
36 | @CacheEvict(cacheNames = "setmealCache",key = "#setmealDTO.categoryId")
37 | @PostMapping
38 | public Result saveSetMeal(@RequestBody SetmealDTO setmealDTO){
39 | log.info("新增套餐");
40 | setMealService.saveSetMeal(setmealDTO);
41 | return Result.success();
42 | }
43 |
44 | @GetMapping("/page")
45 | @ApiOperation("分页查询套餐")
46 | public Result page(SetmealPageQueryDTO setmealPageQueryDTO){
47 | log.info("分页查询套餐{}",setmealPageQueryDTO);
48 | PageResult pageResult=setMealService.page(setmealPageQueryDTO);
49 | return Result.success(pageResult);
50 | }
51 |
52 | @PutMapping
53 | @CacheEvict(cacheNames = "setmealCache",allEntries = true)
54 | @ApiOperation("修改套餐")
55 | public Result updateSetmeal(@RequestBody SetmealDTO setmealDTO){
56 | log.info("修改套餐{}",setmealDTO);
57 | setMealService.updateSetmeal(setmealDTO);
58 | return Result.success();
59 | }
60 |
61 | @DeleteMapping
62 | @CacheEvict(cacheNames = "setmealCache",allEntries = true)
63 | @ApiOperation("批量删除套餐")
64 | public Result delete(@RequestParam List ids){
65 | log.info("批量删除套餐{}",ids);
66 | setMealService.delete(ids);
67 | return Result.success();
68 | }
69 |
70 | @PostMapping("status/{status}")
71 | @CacheEvict(cacheNames = "setmealCache",allEntries = true)
72 | @ApiOperation("套餐起售、停售")
73 | public Result updateSetmealStatus(@PathVariable int status,Long id){
74 | log.info("套餐起售、停售{}",id);
75 | setMealService.updateSetmealStatus(status,id);
76 | return Result.success();
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/ShopController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.result.Result;
4 | import io.swagger.annotations.Api;
5 | import io.swagger.annotations.ApiOperation;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.aspectj.lang.annotation.Pointcut;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.data.redis.core.RedisTemplate;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | @RestController("adminShopController")
13 | @RequestMapping("/admin/shop")
14 | @Api(tags = "店铺相关接口")
15 | @Slf4j
16 | public class ShopController {
17 |
18 | public static final String KEY = "SHOP_STATUS";
19 |
20 | @Autowired
21 | private RedisTemplate redisTemplate;
22 |
23 | /**
24 | * 设置店铺的营业状态
25 | * @param status
26 | * @return
27 | */
28 | @PutMapping("/{status}")
29 | @ApiOperation("设置店铺的营业状态")
30 | public Result setStatus(@PathVariable Integer status){
31 | log.info("设置店铺的营业状态为:{}",status == 1 ? "营业中" : "打烊中");
32 | redisTemplate.opsForValue().set(KEY,status);
33 | return Result.success();
34 | }
35 |
36 | @GetMapping("/status")
37 | @ApiOperation("获取店铺的营业状态")
38 | public Result getStatus(){
39 | Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
40 | log.info("获取到店铺的营业状态为:{}",status == 1 ? "营业中" : "打烊中");
41 | return Result.success(status);
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/admin/WorkspaceController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.admin;
2 |
3 | import com.sky.result.Result;
4 | import com.sky.service.WorkSpaceService;
5 | import com.sky.vo.BusinessDataVO;
6 | import com.sky.vo.DishOverViewVO;
7 | import com.sky.vo.OrderOverViewVO;
8 | import com.sky.vo.SetmealOverViewVO;
9 | import lombok.extern.slf4j.Slf4j;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.web.bind.annotation.GetMapping;
12 | import org.springframework.web.bind.annotation.RequestMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | @Slf4j
16 | @RestController
17 | @RequestMapping("/admin/workspace")
18 | public class WorkspaceController {
19 | @Autowired
20 | WorkSpaceService workSpaceService;
21 |
22 |
23 | @GetMapping("/businessData")
24 | public Result queryBusinessData(){
25 | log.info("今日数据查询");
26 | BusinessDataVO businessDataVO=workSpaceService.queryBusinessData();
27 | return Result.success(businessDataVO);
28 | }
29 |
30 | @GetMapping("/overviewSetmeals")
31 | public Result queryOverviewSetmeals(){
32 | log.info("查询套餐总览");
33 | SetmealOverViewVO setmealOverViewVO=workSpaceService.queryOverviewSetmeals();
34 | return Result.success(setmealOverViewVO);
35 | }
36 |
37 | @GetMapping("/overviewDishes")
38 | public Result queryOverviewDishes(){
39 | log.info("查询菜品总览");
40 | DishOverViewVO dishOverViewVO=workSpaceService.queryOverviewDishes();
41 | return Result.success(dishOverViewVO);
42 | }
43 |
44 | @GetMapping("/overviewOrders")
45 | public Result queryOverviewOrders(){
46 | log.info("查询订单总览");
47 | OrderOverViewVO orderOverViewVO=workSpaceService.queryOverviewOrders();
48 | return Result.success(orderOverViewVO);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/user/AddressBookController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.user;
2 |
3 | import com.sky.context.BaseContext;
4 | import com.sky.entity.AddressBook;
5 | import com.sky.result.Result;
6 | import com.sky.service.AddressBookService;
7 | import io.swagger.annotations.Api;
8 | import io.swagger.annotations.ApiOperation;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.*;
11 | import java.util.List;
12 |
13 | @RestController
14 | @RequestMapping("/user/addressBook")
15 | @Api(tags = "C端地址簿接口")
16 | public class AddressBookController {
17 |
18 | @Autowired
19 | private AddressBookService addressBookService;
20 |
21 | /**
22 | * 查询当前登录用户的所有地址信息
23 | *
24 | * @return
25 | */
26 | @GetMapping("/list")
27 | @ApiOperation("查询当前登录用户的所有地址信息")
28 | public Result> list() {
29 | AddressBook addressBook = new AddressBook();
30 | addressBook.setUserId(BaseContext.getCurrentId());
31 | List list = addressBookService.list(addressBook);
32 | return Result.success(list);
33 | }
34 |
35 | /**
36 | * 新增地址
37 | *
38 | * @param addressBook
39 | * @return
40 | */
41 | @PostMapping
42 | @ApiOperation("新增地址")
43 | public Result save(@RequestBody AddressBook addressBook) {
44 | addressBookService.save(addressBook);
45 | return Result.success();
46 | }
47 |
48 | @GetMapping("/{id}")
49 | @ApiOperation("根据id查询地址")
50 | public Result getById(@PathVariable Long id) {
51 | AddressBook addressBook = addressBookService.getById(id);
52 | return Result.success(addressBook);
53 | }
54 |
55 | /**
56 | * 根据id修改地址
57 | *
58 | * @param addressBook
59 | * @return
60 | */
61 | @PutMapping
62 | @ApiOperation("根据id修改地址")
63 | public Result update(@RequestBody AddressBook addressBook) {
64 | addressBookService.update(addressBook);
65 | return Result.success();
66 | }
67 |
68 | /**
69 | * 设置默认地址
70 | *
71 | * @param addressBook
72 | * @return
73 | */
74 | @PutMapping("/default")
75 | @ApiOperation("设置默认地址")
76 | public Result setDefault(@RequestBody AddressBook addressBook) {
77 | addressBookService.setDefault(addressBook);
78 | return Result.success();
79 | }
80 |
81 | /**
82 | * 根据id删除地址
83 | *
84 | * @param id
85 | * @return
86 | */
87 | @DeleteMapping
88 | @ApiOperation("根据id删除地址")
89 | public Result deleteById(Long id) {
90 | addressBookService.deleteById(id);
91 | return Result.success();
92 | }
93 |
94 | /**
95 | * 查询默认地址
96 | */
97 | @GetMapping("default")
98 | @ApiOperation("查询默认地址")
99 | public Result getDefault() {
100 | //SQL:select * from address_book where user_id = ? and is_default = 1
101 | AddressBook addressBook = new AddressBook();
102 | addressBook.setIsDefault(1);
103 | addressBook.setUserId(BaseContext.getCurrentId());
104 | List list = addressBookService.list(addressBook);
105 |
106 | if (list != null && list.size() == 1) {
107 | return Result.success(list.get(0));
108 | }
109 |
110 | return Result.error("没有查询到默认地址");
111 | }
112 |
113 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/user/CategoryController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.user;
2 |
3 | import com.sky.entity.Category;
4 | import com.sky.result.Result;
5 | import com.sky.service.CategoryService;
6 | import io.swagger.annotations.Api;
7 | import io.swagger.annotations.ApiOperation;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.web.bind.annotation.GetMapping;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import java.util.List;
13 |
14 | @RestController("userCategoryController")
15 | @RequestMapping("/user/category")
16 | @Api(tags = "C端-分类接口")
17 | public class CategoryController {
18 |
19 | @Autowired
20 | private CategoryService categoryService;
21 |
22 | /**
23 | * 查询分类
24 | * @param type
25 | * @return
26 | */
27 | @GetMapping("/list")
28 | @ApiOperation("查询分类")
29 | public Result> list(Integer type) {
30 | List list = categoryService.list(type);
31 | return Result.success(list);
32 | }
33 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/user/DishController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.user;
2 |
3 | import com.sky.constant.StatusConstant;
4 | import com.sky.entity.Dish;
5 | import com.sky.result.Result;
6 | import com.sky.service.DishService;
7 | import com.sky.vo.DishVO;
8 | import io.swagger.annotations.Api;
9 | import io.swagger.annotations.ApiOperation;
10 | import lombok.extern.slf4j.Slf4j;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 | import org.springframework.web.bind.annotation.RequestMapping;
14 | import org.springframework.web.bind.annotation.RestController;
15 | import java.util.List;
16 |
17 | @RestController("userDishController")
18 | @RequestMapping("/user/dish")
19 | @Slf4j
20 | @Api(tags = "C端-菜品浏览接口")
21 | public class DishController {
22 | @Autowired
23 | private DishService dishService;
24 |
25 | /**
26 | * 根据分类id查询菜品
27 | *
28 | * @param categoryId
29 | * @return
30 | */
31 | @GetMapping("/list")
32 | @ApiOperation("根据分类id查询菜品")
33 | public Result> list(Long categoryId) {
34 | Dish dish = new Dish();
35 | dish.setCategoryId(categoryId);
36 | dish.setStatus(StatusConstant.ENABLE);//查询起售中的菜品
37 |
38 | List list = dishService.listWithFlavor(dish);
39 |
40 | return Result.success(list);
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/user/OderController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.user;
2 |
3 | import com.sky.dto.OrdersPageQueryDTO;
4 | import com.sky.dto.OrdersPaymentDTO;
5 | import com.sky.dto.OrdersSubmitDTO;
6 | import com.sky.entity.OrderDetail;
7 | import com.sky.result.PageResult;
8 | import com.sky.result.Result;
9 | import com.sky.service.OrderService;
10 | import com.sky.vo.OrderPaymentVO;
11 | import com.sky.vo.OrderSubmitVO;
12 | import com.sky.vo.OrderVO;
13 | import io.swagger.annotations.Api;
14 | import io.swagger.annotations.ApiOperation;
15 | import lombok.extern.slf4j.Slf4j;
16 | import org.springframework.beans.factory.annotation.Autowired;
17 | import org.springframework.web.bind.annotation.*;
18 |
19 | import java.util.List;
20 |
21 |
22 | @RestController
23 | @Slf4j
24 | @Api(tags = "C端-订单接口")
25 | @RequestMapping("/user/order")
26 | public class OderController {
27 |
28 | @Autowired
29 | OrderService orderService;
30 |
31 | @PostMapping("/submit")
32 | @ApiOperation("用户下单")
33 | public Result oderSubmit(@RequestBody OrdersSubmitDTO ordersSubmitDTO){
34 | log.info("用户下单{}",ordersSubmitDTO);
35 | OrderSubmitVO orderSubmitVO = orderService.oderSubmit(ordersSubmitDTO);
36 | return Result.success(orderSubmitVO);
37 | }
38 | /**
39 | * 订单支付
40 | *
41 | * @param ordersPaymentDTO
42 | * @return
43 | */
44 | @PutMapping("/payment")
45 | @ApiOperation("订单支付")
46 | public Result payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO) throws Exception {
47 | log.info("订单支付:{}", ordersPaymentDTO);
48 | OrderPaymentVO orderPaymentVO = orderService.payment(ordersPaymentDTO);
49 | log.info("生成预支付交易单:{}", orderPaymentVO);
50 | return Result.success(orderPaymentVO);
51 | }
52 |
53 | @GetMapping("/historyOrders")
54 | @ApiOperation("历史订单查询")
55 | public Result checkHistoryOrders( OrdersPageQueryDTO ordersPageQueryDTO){
56 | log.info("查询历史订单");
57 | PageResult pageResult=orderService.checkHistoryOrders(ordersPageQueryDTO);
58 | return Result.success(pageResult);
59 | }
60 |
61 |
62 | @GetMapping("orderDetail/{id}")
63 | @ApiOperation("查询订单详情")
64 | public Result checkOrderDetail(@PathVariable Long id){
65 | log.info("查询订单详情");
66 | OrderVO orderDetailList=orderService.checkOrderDetail(id);
67 | return Result.success(orderDetailList);
68 | }
69 |
70 | @PutMapping("/cancel/{id}")
71 | @ApiOperation("取消订单")
72 | public Result cancelOrder(@PathVariable Long id) throws Exception {
73 | log.info("取消订单");
74 | orderService.cancelOrder(id);
75 | return Result.success();
76 | }
77 |
78 |
79 |
80 |
81 | @PutMapping("/repetition/{id}")
82 | @ApiOperation("再来一单")
83 | public Result orderAgain(@PathVariable Long id){
84 | log.info("再来一单");
85 | orderService.orderAgain(id);
86 | return Result.success();
87 | }
88 | @GetMapping("/reminder/{id}")
89 | @ApiOperation("用户催单")
90 | public Result reminder(@PathVariable("id") Long id) {
91 | orderService.reminder(id);
92 | return Result.success();
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/sky-server/src/main/java/com/sky/controller/user/PayNotifyController.java:
--------------------------------------------------------------------------------
1 | package com.sky.controller.user;
2 |
3 | import com.alibaba.druid.support.json.JSONUtils;
4 | import com.alibaba.fastjson.JSON;
5 | import com.alibaba.fastjson.JSONObject;
6 | import com.sky.properties.WeChatProperties;
7 | import com.sky.service.OrderService;
8 | import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
9 | import lombok.extern.slf4j.Slf4j;
10 | import org.apache.http.entity.ContentType;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.web.bind.annotation.RequestMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 | import javax.servlet.http.HttpServletRequest;
15 | import javax.servlet.http.HttpServletResponse;
16 | import java.io.BufferedReader;
17 | import java.nio.charset.StandardCharsets;
18 | import java.util.HashMap;
19 |
20 | /**
21 | * 支付回调相关接口
22 | */
23 | @RestController
24 | @RequestMapping("/notify")
25 | @Slf4j
26 | public class PayNotifyController {
27 | @Autowired
28 | private OrderService orderService;
29 | @Autowired
30 | private WeChatProperties weChatProperties;
31 |
32 | /**
33 | * 支付成功回调
34 | *
35 | * @param request
36 | */
37 | @RequestMapping("/paySuccess")
38 | public void paySuccessNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
39 | //读取数据
40 | String body = readData(request);
41 | log.info("支付成功回调:{}", body);
42 |
43 | //数据解密
44 | String plainText = decryptData(body);
45 | log.info("解密后的文本:{}", plainText);
46 |
47 | JSONObject jsonObject = JSON.parseObject(plainText);
48 | String outTradeNo = jsonObject.getString("out_trade_no");//商户平台订单号
49 | String transactionId = jsonObject.getString("transaction_id");//微信支付交易号
50 |
51 | log.info("商户平台订单号:{}", outTradeNo);
52 | log.info("微信支付交易号:{}", transactionId);
53 |
54 | //业务处理,修改订单状态、来单提醒
55 | orderService.paySuccess(outTradeNo);
56 |
57 | //给微信响应
58 | responseToWeixin(response);
59 | }
60 |
61 | /**
62 | * 读取数据
63 | *
64 | * @param request
65 | * @return
66 | * @throws Exception
67 | */
68 | private String readData(HttpServletRequest request) throws Exception {
69 | BufferedReader reader = request.getReader();
70 | StringBuilder result = new StringBuilder();
71 | String line = null;
72 | while ((line = reader.readLine()) != null) {
73 | if (result.length() > 0) {
74 | result.append("\n");
75 | }
76 | result.append(line);
77 | }
78 | return result.toString();
79 | }
80 |
81 | /**
82 | * 数据解密
83 | *
84 | * @param body
85 | * @return
86 | * @throws Exception
87 | */
88 | private String decryptData(String body) throws Exception {
89 | JSONObject resultObject = JSON.parseObject(body);
90 | JSONObject resource = resultObject.getJSONObject("resource");
91 | String ciphertext = resource.getString("ciphertext");
92 | String nonce = resource.getString("nonce");
93 | String associatedData = resource.getString("associated_data");
94 |
95 | AesUtil aesUtil = new AesUtil(weChatProperties.getApiV3Key().getBytes(StandardCharsets.UTF_8));
96 | //密文解密
97 | String plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8),
98 | nonce.getBytes(StandardCharsets.UTF_8),
99 | ciphertext);
100 |
101 | return plainText;
102 | }
103 |
104 | /**
105 | * 给微信响应
106 | * @param response
107 | */
108 | private void responseToWeixin(HttpServletResponse response) throws Exception{
109 | response.setStatus(200);
110 | HashMap