├── .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 map = new HashMap<>(); 111 | map.put("code", "SUCCESS"); 112 | map.put("message", "SUCCESS"); 113 | response.setHeader("Content-type", ContentType.APPLICATION_JSON.toString()); 114 | response.getOutputStream().write(JSONUtils.toJSONString(map).getBytes(StandardCharsets.UTF_8)); 115 | response.flushBuffer(); 116 | } 117 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/controller/user/SetmealController.java: -------------------------------------------------------------------------------- 1 | package com.sky.controller.user; 2 | 3 | import com.sky.constant.StatusConstant; 4 | import com.sky.entity.Setmeal; 5 | import com.sky.result.Result; 6 | import com.sky.service.SetMealService; 7 | import com.sky.vo.DishItemVO; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.cache.annotation.Cacheable; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import java.util.List; 17 | 18 | @RestController("userSetmealController") 19 | @RequestMapping("/user/setmeal") 20 | @Api(tags = "C端-套餐浏览接口") 21 | public class SetmealController { 22 | @Autowired 23 | private SetMealService setmealService; 24 | 25 | /** 26 | * 条件查询 27 | * 28 | * @param categoryId 29 | * @return 30 | */ 31 | @GetMapping("/list") 32 | @ApiOperation("根据分类id查询套餐") 33 | @Cacheable(cacheNames = "setmealCache",key = "#categoryId") 34 | public Result> list(Long categoryId) { 35 | Setmeal setmeal = new Setmeal(); 36 | setmeal.setCategoryId(categoryId); 37 | setmeal.setStatus(StatusConstant.ENABLE); 38 | 39 | List list = setmealService.list(setmeal); 40 | return Result.success(list); 41 | } 42 | 43 | /** 44 | * 根据套餐id查询包含的菜品列表 45 | * 46 | * @param id 47 | * @return 48 | */ 49 | @GetMapping("/dish/{id}") 50 | @ApiOperation("根据套餐id查询包含的菜品列表") 51 | public Result> dishList(@PathVariable("id") Long id) { 52 | List list = setmealService.getDishItemById(id); 53 | return Result.success(list); 54 | } 55 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/controller/user/ShopController.java: -------------------------------------------------------------------------------- 1 | package com.sky.controller.user; 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.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController("userShopController") 12 | @RequestMapping("/user/shop") 13 | @Api(tags = "店铺相关接口") 14 | @Slf4j 15 | public class ShopController { 16 | 17 | public static final String KEY = "SHOP_STATUS"; 18 | 19 | @Autowired 20 | private RedisTemplate redisTemplate; 21 | 22 | /** 23 | * 获取店铺的营业状态 24 | * @return 25 | */ 26 | @GetMapping("/status") 27 | @ApiOperation("获取店铺的营业状态") 28 | public Result getStatus(){ 29 | Integer status = (Integer) redisTemplate.opsForValue().get(KEY); 30 | log.info("获取到店铺的营业状态为:{}",status == 1 ? "营业中" : "打烊中"); 31 | return Result.success(status); 32 | } 33 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/controller/user/ShoppingCartController.java: -------------------------------------------------------------------------------- 1 | package com.sky.controller.user; 2 | 3 | 4 | import com.sky.dto.ShoppingCartDTO; 5 | import com.sky.entity.ShoppingCart; 6 | import com.sky.result.Result; 7 | import com.sky.service.ShoppingCartService; 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.*; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * 购物车 18 | */ 19 | @RestController 20 | @RequestMapping("/user/shoppingCart") 21 | @Slf4j 22 | @Api(tags = "C端-购物车接口") 23 | public class ShoppingCartController { 24 | 25 | @Autowired 26 | private ShoppingCartService shoppingCartService; 27 | 28 | /** 29 | * 添加购物车 30 | * @param shoppingCartDTO 31 | * @return 32 | */ 33 | @PostMapping("/add") 34 | @ApiOperation("添加购物车") 35 | public Result add(@RequestBody ShoppingCartDTO shoppingCartDTO){ 36 | log.info("添加购物车{}",shoppingCartDTO); 37 | shoppingCartService.addShopPingCart(shoppingCartDTO); 38 | return Result.success(); 39 | } 40 | 41 | 42 | @GetMapping("/list") 43 | @ApiOperation("查看购物车") 44 | public Result> checkShoppingCart(){ 45 | log.info("查看购物车"); 46 | List shoppingCartList=shoppingCartService.checkShoppingCart(); 47 | return Result.success(shoppingCartList); 48 | } 49 | 50 | @DeleteMapping 51 | @ApiOperation("清空购物车") 52 | public Result cleanShoppingCart(){ 53 | log.info("开始清空购物车"); 54 | shoppingCartService.cleanShoppingCart(); 55 | return Result.success(); 56 | } 57 | 58 | @PostMapping("/sub") 59 | @ApiOperation("减少购物车数量") 60 | public Result substanceShoppingCart(@RequestBody ShoppingCartDTO shoppingCartDTO){ 61 | log.info("减少购物车货物数量"); 62 | shoppingCartService.substanceShoppingCart(shoppingCartDTO); 63 | return Result.success(); 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/controller/user/UserController.java: -------------------------------------------------------------------------------- 1 | package com.sky.controller.user; 2 | 3 | import com.sky.constant.JwtClaimsConstant; 4 | import com.sky.dto.UserLoginDTO; 5 | import com.sky.entity.User; 6 | import com.sky.properties.JwtProperties; 7 | import com.sky.result.Result; 8 | import com.sky.service.UserService; 9 | import com.sky.utils.JwtUtil; 10 | import com.sky.vo.UserLoginVO; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.PostMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | @RestController 23 | @RequestMapping("/user/user") 24 | @Api(tags = "C端用户相关接口") 25 | @Slf4j 26 | public class UserController { 27 | 28 | @Autowired 29 | private UserService userService; 30 | @Autowired 31 | private JwtProperties jwtProperties; 32 | 33 | /** 34 | * 微信登录 35 | * @param userLoginDTO 36 | * @return 37 | */ 38 | @PostMapping("/login") 39 | @ApiOperation("微信登录") 40 | public Result login(@RequestBody UserLoginDTO userLoginDTO){ 41 | log.info("微信用户登录:{}",userLoginDTO.getCode()); 42 | 43 | //微信登录 44 | User user = userService.wxLogin(userLoginDTO);//后绪步骤实现 45 | 46 | //为微信用户生成jwt令牌 47 | Map claims = new HashMap<>(); 48 | claims.put(JwtClaimsConstant.USER_ID,user.getId()); 49 | String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims); 50 | 51 | UserLoginVO userLoginVO = UserLoginVO.builder() 52 | .id(user.getId()) 53 | .openid(user.getOpenid()) 54 | .token(token) 55 | .build(); 56 | return Result.success(userLoginVO); 57 | } 58 | 59 | @ApiOperation("退出登录") 60 | @PostMapping("/logout") 61 | public Result logout() { 62 | return Result.success(); 63 | } 64 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.sky.handler; 2 | 3 | import com.sky.exception.BaseException; 4 | import com.sky.result.Result; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.RestControllerAdvice; 8 | 9 | /** 10 | * 全局异常处理器,处理项目中抛出的业务异常 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | /** 17 | * 捕获业务异常 18 | * @param ex 19 | * @return 20 | */ 21 | @ExceptionHandler 22 | public Result exceptionHandler(BaseException ex){ 23 | log.error("异常信息:{}", ex.getMessage()); 24 | return Result.error(ex.getMessage()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/interceptor/JwtTokenAdminInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.sky.interceptor; 2 | 3 | import com.sky.constant.JwtClaimsConstant; 4 | import com.sky.context.BaseContext; 5 | import com.sky.properties.JwtProperties; 6 | import com.sky.utils.JwtUtil; 7 | import io.jsonwebtoken.Claims; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.method.HandlerMethod; 12 | import org.springframework.web.servlet.HandlerInterceptor; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | /** 17 | * jwt令牌校验的拦截器 18 | */ 19 | @Component 20 | @Slf4j 21 | public class JwtTokenAdminInterceptor implements HandlerInterceptor { 22 | 23 | @Autowired 24 | private JwtProperties jwtProperties; 25 | 26 | @Override 27 | /** 28 | * 校验jwt 29 | * 30 | * @param request 31 | * @param response 32 | * @param handler 33 | * @return 34 | * @throws Exception 35 | */ 36 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 37 | //判断当前拦截到的是Controller的方法还是其他资源 38 | if (!(handler instanceof HandlerMethod)) { 39 | //当前拦截到的不是动态方法,直接放行 40 | return true; 41 | } 42 | 43 | //1、从请求头中获取令牌 44 | String token = request.getHeader(jwtProperties.getAdminTokenName()); 45 | 46 | //2、校验令牌 47 | try { 48 | log.info("jwt校验:{}", token); 49 | Claims claims = JwtUtil.parseJWT(jwtProperties.getAdminSecretKey(), token); 50 | Long empId = Long.valueOf(claims.get(JwtClaimsConstant.EMP_ID).toString()); 51 | BaseContext.setCurrentId(empId); 52 | log.info("当前员工id:{}", empId); 53 | //3、通过,放行 54 | return true; 55 | } catch (Exception ex) { 56 | //4、不通过,响应401状态码 57 | response.setStatus(401); 58 | return false; 59 | } 60 | } 61 | 62 | /** 63 | * 防止本地线程内存泄漏 64 | * @param request 65 | * @param response 66 | * @param handler 67 | * @param ex 68 | * @throws Exception 69 | */ 70 | @Override 71 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 72 | BaseContext.removeCurrentId(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/interceptor/JwtTokenUserInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.sky.interceptor; 2 | 3 | import com.sky.constant.JwtClaimsConstant; 4 | import com.sky.context.BaseContext; 5 | import com.sky.properties.JwtProperties; 6 | import com.sky.utils.JwtUtil; 7 | import io.jsonwebtoken.Claims; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.method.HandlerMethod; 12 | import org.springframework.web.servlet.HandlerInterceptor; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | /** 18 | * jwt令牌校验的拦截器 19 | */ 20 | @Component 21 | @Slf4j 22 | public class JwtTokenUserInterceptor implements HandlerInterceptor { 23 | 24 | @Autowired 25 | private JwtProperties jwtProperties; 26 | 27 | /** 28 | * 校验jwt 29 | * 30 | * @param request 31 | * @param response 32 | * @param handler 33 | * @return 34 | * @throws Exception 35 | */ 36 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 37 | //判断当前拦截到的是Controller的方法还是其他资源 38 | if (!(handler instanceof HandlerMethod)) { 39 | //当前拦截到的不是动态方法,直接放行 40 | return true; 41 | } 42 | 43 | //1、从请求头中获取令牌 44 | String token = request.getHeader(jwtProperties.getUserTokenName()); 45 | 46 | //2、校验令牌 47 | try { 48 | log.info("jwt校验:{}", token); 49 | Claims claims = JwtUtil.parseJWT(jwtProperties.getUserSecretKey(), token); 50 | Long userId = Long.valueOf(claims.get(JwtClaimsConstant.USER_ID).toString()); 51 | log.info("当前用户的id:{}", userId); 52 | BaseContext.setCurrentId(userId); 53 | //3、通过,放行 54 | return true; 55 | } catch (Exception ex) { 56 | //4、不通过,响应401状态码 57 | response.setStatus(401); 58 | return false; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/AddressBookMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.sky.entity.AddressBook; 4 | import org.apache.ibatis.annotations.*; 5 | import java.util.List; 6 | 7 | @Mapper 8 | public interface AddressBookMapper { 9 | 10 | /** 11 | * 条件查询 12 | * @param addressBook 13 | * @return 14 | */ 15 | List list(AddressBook addressBook); 16 | 17 | /** 18 | * 新增 19 | * @param addressBook 20 | */ 21 | @Insert("insert into address_book" + 22 | " (user_id, consignee, phone, sex, province_code, province_name, city_code, city_name, district_code," + 23 | " district_name, detail, label, is_default)" + 24 | " values (#{userId}, #{consignee}, #{phone}, #{sex}, #{provinceCode}, #{provinceName}, #{cityCode}, #{cityName}," + 25 | " #{districtCode}, #{districtName}, #{detail}, #{label}, #{isDefault})") 26 | void insert(AddressBook addressBook); 27 | 28 | /** 29 | * 根据id查询 30 | * @param id 31 | * @return 32 | */ 33 | @Select("select * from address_book where id = #{id}") 34 | AddressBook getById(Long id); 35 | 36 | /** 37 | * 根据id修改 38 | * @param addressBook 39 | */ 40 | void update(AddressBook addressBook); 41 | 42 | /** 43 | * 根据 用户id修改 是否默认地址 44 | * @param addressBook 45 | */ 46 | @Update("update address_book set is_default = #{isDefault} where user_id = #{userId}") 47 | void updateIsDefaultByUserId(AddressBook addressBook); 48 | 49 | /** 50 | * 根据id删除地址 51 | * @param id 52 | */ 53 | @Delete("delete from address_book where id = #{id}") 54 | void deleteById(Long id); 55 | 56 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.annotation.AutoFill; 5 | import com.sky.enumeration.OperationType; 6 | import com.sky.dto.CategoryPageQueryDTO; 7 | import com.sky.entity.Category; 8 | import org.apache.ibatis.annotations.Delete; 9 | import org.apache.ibatis.annotations.Insert; 10 | import org.apache.ibatis.annotations.Mapper; 11 | import java.util.List; 12 | 13 | @Mapper 14 | public interface CategoryMapper { 15 | 16 | /** 17 | * 插入数据 18 | * @param category 19 | */ 20 | @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user)" + 21 | " VALUES" + 22 | " (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})") 23 | @AutoFill(value = OperationType.INSERT) 24 | void insert(Category category); 25 | 26 | /** 27 | * 分页查询 28 | * @param categoryPageQueryDTO 29 | * @return 30 | */ 31 | Page pageQuery(CategoryPageQueryDTO categoryPageQueryDTO); 32 | 33 | /** 34 | * 根据id删除分类 35 | * @param id 36 | */ 37 | @Delete("delete from category where id = #{id}") 38 | void deleteById(Long id); 39 | 40 | /** 41 | * 根据id修改分类 42 | * @param category 43 | */ 44 | @AutoFill(value = OperationType.UPDATE) 45 | void update(Category category); 46 | 47 | /** 48 | * 根据类型查询分类 49 | * @param type 50 | * @return 51 | */ 52 | List list(Integer type); 53 | } 54 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/DishFlavorMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.dto.DishPageQueryDTO; 5 | import com.sky.entity.Dish; 6 | import com.sky.entity.DishFlavor; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Select; 9 | 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface DishFlavorMapper { 14 | /** 15 | * 批量插入口味数据 16 | * @param flavors 17 | */ 18 | 19 | void insertBatch(List flavors); 20 | 21 | List getByDishId(Long id); 22 | 23 | void deleteById(Long id); 24 | } 25 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/DishMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.annotation.AutoFill; 5 | import com.sky.constant.AutoFillConstant; 6 | import com.sky.dto.DishDTO; 7 | import com.sky.dto.DishPageQueryDTO; 8 | import com.sky.entity.Dish; 9 | import com.sky.enumeration.OperationType; 10 | import com.sky.vo.DishVO; 11 | import org.apache.ibatis.annotations.Mapper; 12 | import org.apache.ibatis.annotations.Select; 13 | 14 | import java.util.List; 15 | 16 | @Mapper 17 | public interface DishMapper { 18 | 19 | /** 20 | * 根据分类id查询菜品数量 21 | * @param categoryId 22 | * @return 23 | */ 24 | @Select("select count(id) from dish where category_id = #{categoryId}") 25 | Integer countByCategoryId(Long categoryId); 26 | 27 | @AutoFill(value = OperationType.INSERT) 28 | void insert(Dish dish); 29 | 30 | Page pageQuery(DishPageQueryDTO dishPageQueryDTO); 31 | 32 | void delete(List ids); 33 | 34 | //@Select("select status from dish where id=#{id}") 35 | Dish getById(Long id); 36 | 37 | @AutoFill(value = OperationType.UPDATE) 38 | void update(Dish dish); 39 | 40 | 41 | List queryByCategoryId(Dish dish); 42 | 43 | @Select("select count(status) from dish where status=1") 44 | Integer queryStatus_ON(); 45 | @Select("select count(status) from dish where status=0") 46 | Integer queryStatus_OFF(); 47 | } 48 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/EmployeeMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.annotation.AutoFill; 5 | import com.sky.dto.EmployeePageQueryDTO; 6 | import com.sky.entity.Employee; 7 | import com.sky.enumeration.OperationType; 8 | import org.apache.ibatis.annotations.Insert; 9 | import org.apache.ibatis.annotations.Mapper; 10 | import org.apache.ibatis.annotations.Select; 11 | 12 | @Mapper 13 | public interface EmployeeMapper { 14 | 15 | /** 16 | * 根据用户名查询员工 17 | * 18 | * @param username 19 | * @return 20 | */ 21 | @Select("select * from employee where username = #{username}") 22 | Employee getByUsername(String username); 23 | 24 | @Insert("insert into employee"+"(name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user)" +"VALUES" + 25 | "(#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{status}, #{createTime},#{updateTime},#{createUser}, #{updateUser})") 26 | @AutoFill(value = OperationType.INSERT) 27 | void insert(Employee employee); 28 | 29 | Page pageQuery(EmployeePageQueryDTO employeePageQueryDTO); 30 | 31 | @AutoFill(value = OperationType.UPDATE) 32 | void update(Employee employee); 33 | 34 | Employee getById(Long id); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/OperationlogMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import org.apache.ibatis.annotations.Insert; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Mapper 9 | public interface OperationlogMapper { 10 | 11 | 12 | @Insert("insert into operation_log (url, port_check, ip, method, exception_detected, args, user_id, update_time) " + 13 | "values (#{url},#{portCheck},#{ip},#{method},#{exceptionDetected},#{args},#{userId},#{updateTime})") 14 | void insert(String url, int portCheck, String ip, String method, String exceptionDetected, String args, Long userId, LocalDateTime updateTime); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/OrderDetailMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | import com.sky.entity.OrderDetail; 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Select; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface OrderDetailMapper { 10 | void insertDetailList(List orderDetailList); 11 | 12 | @Select("select * from order_detail where order_id=#{id}") 13 | List queryByOrderId(Long id); 14 | 15 | @Select("select * from order_detail where dish_id=#{id}") 16 | List queryByDishId(Long id); 17 | } 18 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.dto.GoodsSalesDTO; 5 | import com.sky.dto.OrdersPageQueryDTO; 6 | import com.sky.entity.Orders; 7 | import com.sky.vo.OrderStatisticsVO; 8 | import com.sky.vo.OrderVO; 9 | import io.swagger.models.auth.In; 10 | import org.apache.ibatis.annotations.Mapper; 11 | import org.apache.ibatis.annotations.Select; 12 | 13 | import java.time.LocalDateTime; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @Mapper 18 | public interface OrderMapper { 19 | void insertOrders(Orders orders); 20 | /** 21 | * 根据订单号和用户id查询订单 22 | * @param orderNumber 23 | * @param userId 24 | */ 25 | @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}") 26 | Orders getByNumberAndUserId(String orderNumber, Long userId); 27 | 28 | /** 29 | * 修改订单信息 30 | * @param orders 31 | */ 32 | void update(Orders orders); 33 | 34 | Page queryHistoryOrdersList(OrdersPageQueryDTO ordersPageQueryDTO); 35 | 36 | @Select("select * from orders where id=#{id}") 37 | Orders queryById(Long id); 38 | 39 | Page queryConditionSearchOrders(OrdersPageQueryDTO ordersPageQueryDTO); 40 | 41 | Integer countStatus(Integer toBeConfirmed); 42 | 43 | Integer checkValidOrderCount(); 44 | 45 | Double queryTurnover(); 46 | 47 | Integer queryAllOrderCount(); 48 | 49 | Integer queryWaitingOrders(); 50 | 51 | Integer queryDeliveredOrders(); 52 | 53 | Integer queryCompletedOrders(); 54 | 55 | Integer queryCancelledOrders(); 56 | 57 | Integer queryAllOrders(); 58 | 59 | @Select("select * from orders where status = #{status} and order_time < #{orderTime}") 60 | List getByStatusAndOrdertimeLT(Integer status, LocalDateTime orderTime); 61 | 62 | Double sumByMap(Map map); 63 | 64 | Integer todayValidOrderCount(Map map); 65 | 66 | Integer todayOrderCount(LocalDateTime begin, LocalDateTime end); 67 | 68 | Integer queryTotalOrderCount(); 69 | 70 | Integer queryTotalValidOrderCount(); 71 | 72 | List getSalesTop10(LocalDateTime beginTime, LocalDateTime endTime); 73 | 74 | Integer countByMap(Map map); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/SetmealDishMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.sky.entity.Dish; 4 | import com.sky.entity.SetmealDish; 5 | import io.swagger.models.auth.In; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface SetmealDishMapper { 12 | List getSetmealIdsByDishIds(List ids); 13 | 14 | int queryConnect(Dish dish); 15 | } 16 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/SetmealMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.sky.annotation.AutoFill; 5 | import com.sky.dto.SetmealPageQueryDTO; 6 | import com.sky.entity.Setmeal; 7 | import com.sky.entity.SetmealDish; 8 | import com.sky.enumeration.OperationType; 9 | import com.sky.vo.DishItemVO; 10 | import com.sky.vo.SetmealVO; 11 | import org.apache.ibatis.annotations.Mapper; 12 | import org.apache.ibatis.annotations.Select; 13 | 14 | import java.util.List; 15 | 16 | @Mapper 17 | public interface SetmealMapper { 18 | 19 | /** 20 | * 根据分类id查询套餐的数量 21 | * @param id 22 | * @return 23 | */ 24 | @Select("select count(id) from setmeal where category_id = #{categoryId}") 25 | Integer countByCategoryId(Long id); 26 | 27 | SetmealVO queryById(Long id); 28 | 29 | Setmeal querySetMealById(Long id); 30 | 31 | void saveSetmealDish(SetmealDish setmealDish); 32 | @AutoFill(OperationType.INSERT) 33 | void insert(Setmeal setmeal); 34 | 35 | Page pageQuery(SetmealPageQueryDTO setmealPageQueryDTO); 36 | @AutoFill(OperationType.UPDATE) 37 | void update(Setmeal setmeal); 38 | @AutoFill(OperationType.UPDATE) 39 | void updateSetmealDishes(SetmealDish setmealDish); 40 | 41 | void deleteSetmealDishesById(Long id); 42 | @AutoFill(OperationType.INSERT) 43 | void insertSetmealDishes(SetmealDish setmealDish); 44 | 45 | void delete(List ids); 46 | 47 | /** 48 | * 动态条件查询套餐 49 | * @param setmeal 50 | * @return 51 | */ 52 | List list(Setmeal setmeal); 53 | 54 | /** 55 | * 根据套餐id查询菜品选项 56 | * @param setmealId 57 | * @return 58 | */ 59 | @Select("select sd.name, sd.copies, d.image, d.description " + 60 | "from setmeal_dish sd left join dish d on sd.dish_id = d.id " + 61 | "where sd.setmeal_id = #{setmealId}") 62 | List getDishItemBySetmealId(Long setmealId); 63 | 64 | @Select("select count(status) from setmeal where status=1") 65 | Integer queryStatus_ON(); 66 | 67 | @Select("select count(status) from setmeal where status=0") 68 | Integer queryStatus_OFF(); 69 | } 70 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/ShoppingCartMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.sky.entity.Dish; 4 | import com.sky.entity.ShoppingCart; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface ShoppingCartMapper { 11 | 12 | 13 | List checkShoppingCartList(ShoppingCart shoppingCart); 14 | 15 | void updateShoppingCart(ShoppingCart cart); 16 | 17 | void insert(ShoppingCart shoppingCart); 18 | 19 | void deleteByUserId(ShoppingCart shoppingCart); 20 | 21 | void deleteShoppingCart(ShoppingCart shoppingCartChecked); 22 | } 23 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.sky.mapper; 2 | 3 | import com.sky.entity.User; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Select; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | @Mapper 11 | public interface UserMapper { 12 | 13 | /** 14 | * 根据openid查询用户 15 | * @param openid 16 | * @return 17 | */ 18 | @Select("select * from user where openid = #{openid}") 19 | User getByOpenid(String openid); 20 | 21 | /** 22 | * 插入数据 23 | * @param user 24 | */ 25 | void insert(User user); 26 | 27 | @Select("select * from user where id=#{userId}") 28 | User getById(Long userId); 29 | 30 | Integer queryAll(); 31 | 32 | Integer queryNewCustomers(Map map); 33 | } -------------------------------------------------------------------------------- /sky-server/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 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/AddressBookService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.entity.AddressBook; 4 | import java.util.List; 5 | 6 | public interface AddressBookService { 7 | 8 | List list(AddressBook addressBook); 9 | 10 | void save(AddressBook addressBook); 11 | 12 | AddressBook getById(Long id); 13 | 14 | void update(AddressBook addressBook); 15 | 16 | void setDefault(AddressBook addressBook); 17 | 18 | void deleteById(Long id); 19 | 20 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.CategoryDTO; 4 | import com.sky.dto.CategoryPageQueryDTO; 5 | import com.sky.entity.Category; 6 | import com.sky.result.PageResult; 7 | import java.util.List; 8 | 9 | public interface CategoryService { 10 | 11 | /** 12 | * 新增分类 13 | * @param categoryDTO 14 | */ 15 | void save(CategoryDTO categoryDTO); 16 | 17 | /** 18 | * 分页查询 19 | * @param categoryPageQueryDTO 20 | * @return 21 | */ 22 | PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO); 23 | 24 | /** 25 | * 根据id删除分类 26 | * @param id 27 | */ 28 | void deleteById(Long id); 29 | 30 | /** 31 | * 修改分类 32 | * @param categoryDTO 33 | */ 34 | void update(CategoryDTO categoryDTO); 35 | 36 | /** 37 | * 启用、禁用分类 38 | * @param status 39 | * @param id 40 | */ 41 | void startOrStop(Integer status, Long id); 42 | 43 | /** 44 | * 根据类型查询分类 45 | * @param type 46 | * @return 47 | */ 48 | List list(Integer type); 49 | } 50 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/DishService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 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.vo.DishVO; 8 | 9 | import java.util.List; 10 | 11 | public interface DishService { 12 | void save(DishDTO dishDTO); 13 | 14 | PageResult pageQuery(DishPageQueryDTO dishPageQueryDTO); 15 | 16 | void delete(List ids); 17 | 18 | DishVO getByIdWithFlavor(Long id); 19 | 20 | void updateWithFlavor(DishDTO dishDTO); 21 | 22 | List queryByCategoryId(Long id); 23 | 24 | void updateDishStatus(int status,Long id); 25 | 26 | List listWithFlavor(Dish dish); 27 | } 28 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.EmployeeDTO; 4 | import com.sky.dto.EmployeeLoginDTO; 5 | import com.sky.dto.EmployeePageQueryDTO; 6 | import com.sky.dto.PasswordEditDTO; 7 | import com.sky.entity.Employee; 8 | import com.sky.result.PageResult; 9 | import com.sky.result.Result; 10 | 11 | public interface EmployeeService { 12 | 13 | /** 14 | * 员工登录 15 | * @param employeeLoginDTO 16 | * @return 17 | */ 18 | Employee login(EmployeeLoginDTO employeeLoginDTO); 19 | 20 | 21 | void save(EmployeeDTO employeeDTO); 22 | 23 | PageResult page(EmployeePageQueryDTO employeePageQueryDTO); 24 | 25 | void startOrStop(Integer status, Long id); 26 | 27 | Employee getById(Long id); 28 | 29 | void update(EmployeeDTO employeeDTO); 30 | 31 | void editPassword(PasswordEditDTO passwordEditDTO); 32 | } 33 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.*; 4 | import com.sky.entity.OrderDetail; 5 | import com.sky.result.PageResult; 6 | import com.sky.vo.OrderPaymentVO; 7 | import com.sky.vo.OrderStatisticsVO; 8 | import com.sky.vo.OrderSubmitVO; 9 | import com.sky.vo.OrderVO; 10 | 11 | import java.util.List; 12 | 13 | public interface OrderService { 14 | OrderSubmitVO oderSubmit(OrdersSubmitDTO ordersSubmitDTO); 15 | /** 16 | * 订单支付 17 | * @param ordersPaymentDTO 18 | * @return 19 | */ 20 | OrderPaymentVO payment(OrdersPaymentDTO ordersPaymentDTO) throws Exception; 21 | 22 | /** 23 | * 支付成功,修改订单状态 24 | * @param outTradeNo 25 | */ 26 | void paySuccess(String outTradeNo); 27 | 28 | PageResult checkHistoryOrders(OrdersPageQueryDTO ordersPageQueryDTO); 29 | 30 | OrderVO checkOrderDetail(Long id); 31 | 32 | void cancelOrder(Long id) throws Exception; 33 | 34 | void orderAgain(Long id); 35 | 36 | PageResult conditionSearchOrders(OrdersPageQueryDTO ordersPageQueryDTO); 37 | 38 | void cancelOrderBackend(OrdersCancelDTO ordersCancelDTO); 39 | 40 | void rejectionOrders(OrdersRejectionDTO ordersRejectionDTO) throws Exception; 41 | 42 | void confirm(OrdersConfirmDTO ordersConfirmDTO); 43 | 44 | void delivery(Long id); 45 | 46 | void complete(Long id); 47 | 48 | OrderStatisticsVO queryOrderStatistics(); 49 | 50 | void reminder(Long id); 51 | } 52 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/ReportService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.vo.OrderReportVO; 4 | import com.sky.vo.SalesTop10ReportVO; 5 | import com.sky.vo.TurnoverReportVO; 6 | import com.sky.vo.UserReportVO; 7 | 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.time.LocalDate; 10 | 11 | public interface ReportService { 12 | TurnoverReportVO getTurnover(LocalDate begin, LocalDate end); 13 | 14 | UserReportVO getUserStatistics(LocalDate begin, LocalDate end); 15 | 16 | OrderReportVO getOrdersStatistics(LocalDate begin, LocalDate end); 17 | 18 | SalesTop10ReportVO getTop10(LocalDate begin, LocalDate end); 19 | 20 | void exportBusinessData(HttpServletResponse response); 21 | } 22 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/SetMealService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.SetmealDTO; 4 | import com.sky.dto.SetmealPageQueryDTO; 5 | import com.sky.entity.Setmeal; 6 | import com.sky.result.PageResult; 7 | import com.sky.vo.DishItemVO; 8 | import com.sky.vo.SetmealVO; 9 | 10 | import java.util.List; 11 | 12 | public interface SetMealService { 13 | SetmealVO queryById(Long id); 14 | 15 | void saveSetMeal(SetmealDTO setmealDTO); 16 | 17 | PageResult page(SetmealPageQueryDTO setmealPageQueryDTO); 18 | 19 | void updateSetmeal(SetmealDTO setmealDTO); 20 | 21 | void delete(List ids); 22 | 23 | void updateSetmealStatus(int status, Long id); 24 | 25 | /** 26 | * 条件查询 27 | * @param setmeal 28 | * @return 29 | */ 30 | List list(Setmeal setmeal); 31 | 32 | /** 33 | * 根据id查询菜品选项 34 | * @param id 35 | * @return 36 | */ 37 | List getDishItemById(Long id); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/ShoppingCartService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.ShoppingCartDTO; 4 | import com.sky.entity.ShoppingCart; 5 | 6 | import java.util.List; 7 | 8 | public interface ShoppingCartService { 9 | void addShopPingCart(ShoppingCartDTO shoppingCartDTO); 10 | 11 | List checkShoppingCart(); 12 | 13 | void cleanShoppingCart(); 14 | 15 | void substanceShoppingCart(ShoppingCartDTO shoppingCartDTO); 16 | } 17 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.dto.UserLoginDTO; 4 | import com.sky.entity.User; 5 | 6 | public interface UserService { 7 | 8 | /** 9 | * 微信登录 10 | * @param userLoginDTO 11 | * @return 12 | */ 13 | User wxLogin(UserLoginDTO userLoginDTO); 14 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/WorkSpaceService.java: -------------------------------------------------------------------------------- 1 | package com.sky.service; 2 | 3 | import com.sky.vo.BusinessDataVO; 4 | import com.sky.vo.DishOverViewVO; 5 | import com.sky.vo.OrderOverViewVO; 6 | import com.sky.vo.SetmealOverViewVO; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | public interface WorkSpaceService { 11 | BusinessDataVO queryBusinessData(); 12 | 13 | SetmealOverViewVO queryOverviewSetmeals(); 14 | 15 | DishOverViewVO queryOverviewDishes(); 16 | 17 | OrderOverViewVO queryOverviewOrders(); 18 | 19 | BusinessDataVO getBusinessData(LocalDateTime of, LocalDateTime of1); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/impl/AddressBookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sky.service.impl; 2 | 3 | import com.sky.context.BaseContext; 4 | import com.sky.entity.AddressBook; 5 | import com.sky.mapper.AddressBookMapper; 6 | import com.sky.service.AddressBookService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | import java.util.List; 12 | 13 | @Service 14 | @Slf4j 15 | public class AddressBookServiceImpl implements AddressBookService { 16 | @Autowired 17 | private AddressBookMapper addressBookMapper; 18 | 19 | /** 20 | * 条件查询 21 | * 22 | * @param addressBook 23 | * @return 24 | */ 25 | public List list(AddressBook addressBook) { 26 | return addressBookMapper.list(addressBook); 27 | } 28 | 29 | /** 30 | * 新增地址 31 | * 32 | * @param addressBook 33 | */ 34 | public void save(AddressBook addressBook) { 35 | addressBook.setUserId(BaseContext.getCurrentId()); 36 | addressBook.setIsDefault(0); 37 | addressBookMapper.insert(addressBook); 38 | } 39 | 40 | /** 41 | * 根据id查询 42 | * 43 | * @param id 44 | * @return 45 | */ 46 | public AddressBook getById(Long id) { 47 | AddressBook addressBook = addressBookMapper.getById(id); 48 | return addressBook; 49 | } 50 | 51 | /** 52 | * 根据id修改地址 53 | * 54 | * @param addressBook 55 | */ 56 | public void update(AddressBook addressBook) { 57 | addressBookMapper.update(addressBook); 58 | } 59 | 60 | /** 61 | * 设置默认地址 62 | * 63 | * @param addressBook 64 | */ 65 | @Transactional 66 | public void setDefault(AddressBook addressBook) { 67 | //1、将当前用户的所有地址修改为非默认地址 update address_book set is_default = ? where user_id = ? 68 | addressBook.setIsDefault(0); 69 | addressBook.setUserId(BaseContext.getCurrentId()); 70 | addressBookMapper.updateIsDefaultByUserId(addressBook); 71 | 72 | //2、将当前地址改为默认地址 update address_book set is_default = ? where id = ? 73 | addressBook.setIsDefault(1); 74 | addressBookMapper.update(addressBook); 75 | } 76 | 77 | /** 78 | * 根据id删除地址 79 | * 80 | * @param id 81 | */ 82 | public void deleteById(Long id) { 83 | addressBookMapper.deleteById(id); 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sky.service.impl; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.github.pagehelper.PageHelper; 5 | import com.sky.constant.MessageConstant; 6 | import com.sky.constant.StatusConstant; 7 | import com.sky.context.BaseContext; 8 | import com.sky.dto.CategoryDTO; 9 | import com.sky.dto.CategoryPageQueryDTO; 10 | import com.sky.entity.Category; 11 | import com.sky.exception.DeletionNotAllowedException; 12 | import com.sky.mapper.CategoryMapper; 13 | import com.sky.mapper.DishMapper; 14 | import com.sky.mapper.SetmealMapper; 15 | import com.sky.result.PageResult; 16 | import com.sky.service.CategoryService; 17 | import lombok.extern.slf4j.Slf4j; 18 | import org.apache.ibatis.annotations.Param; 19 | import org.springframework.beans.BeanUtils; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Service; 22 | import org.springframework.web.bind.annotation.RequestParam; 23 | 24 | import java.time.LocalDateTime; 25 | import java.util.List; 26 | 27 | /** 28 | * 分类业务层 29 | */ 30 | @Service 31 | @Slf4j 32 | public class CategoryServiceImpl implements CategoryService { 33 | 34 | @Autowired 35 | private CategoryMapper categoryMapper; 36 | @Autowired 37 | private DishMapper dishMapper; 38 | @Autowired 39 | private SetmealMapper setmealMapper; 40 | 41 | /** 42 | * 新增分类 43 | * @param categoryDTO 44 | */ 45 | public void save(CategoryDTO categoryDTO) { 46 | Category category = new Category(); 47 | //属性拷贝 48 | BeanUtils.copyProperties(categoryDTO, category); 49 | 50 | //分类状态默认为禁用状态0 51 | category.setStatus(StatusConstant.DISABLE); 52 | 53 | //设置创建时间、修改时间、创建人、修改人 54 | category.setCreateTime(LocalDateTime.now()); 55 | category.setUpdateTime(LocalDateTime.now()); 56 | category.setCreateUser(BaseContext.getCurrentId()); 57 | category.setUpdateUser(BaseContext.getCurrentId()); 58 | 59 | categoryMapper.insert(category); 60 | } 61 | 62 | /** 63 | * 分页查询 64 | * @param categoryPageQueryDTO 65 | * @return 66 | */ 67 | public PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO) { 68 | PageHelper.startPage( categoryPageQueryDTO.getPage(), 69 | categoryPageQueryDTO.getPageSize()); 70 | //下一条sql进行分页自动加入limit关键字分页 71 | Page page = categoryMapper.pageQuery(categoryPageQueryDTO); 72 | return new PageResult(page.getTotal(), page.getResult()); 73 | } 74 | 75 | /** 76 | * 根据id删除分类 77 | * @param id 78 | */ 79 | public void deleteById(Long id) { 80 | //查询当前分类是否关联了菜品,如果关联了就抛出业务异常 81 | Integer count = dishMapper.countByCategoryId(id); 82 | if(count > 0){ 83 | //当前分类下有菜品,不能删除 84 | throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_DISH); 85 | } 86 | 87 | //查询当前分类是否关联了套餐,如果关联了就抛出业务异常 88 | count = setmealMapper.countByCategoryId(id); 89 | if(count > 0){ 90 | //当前分类下有菜品,不能删除 91 | throw new DeletionNotAllowedException(MessageConstant.CATEGORY_BE_RELATED_BY_SETMEAL); 92 | } 93 | 94 | //删除分类数据 95 | categoryMapper.deleteById(id); 96 | } 97 | 98 | /** 99 | * 修改分类 100 | * @param categoryDTO 101 | */ 102 | public void update(CategoryDTO categoryDTO) { 103 | Category category = new Category(); 104 | BeanUtils.copyProperties(categoryDTO,category); 105 | 106 | //设置修改时间、修改人 107 | category.setUpdateTime(LocalDateTime.now()); 108 | category.setUpdateUser(BaseContext.getCurrentId()); 109 | 110 | categoryMapper.update(category); 111 | } 112 | 113 | /** 114 | * 启用、禁用分类 115 | * @param status 116 | * @param id 117 | */ 118 | public void startOrStop(Integer status, Long id) { 119 | Category category = Category.builder() 120 | .id(id) 121 | .status(status) 122 | .updateTime(LocalDateTime.now()) 123 | .updateUser(BaseContext.getCurrentId()) 124 | .build(); 125 | categoryMapper.update(category); 126 | } 127 | 128 | /** 129 | * 根据类型查询分类 130 | * @param type 131 | * @return 132 | */ 133 | public List list(Integer type) { 134 | return categoryMapper.list(type); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/impl/SetMealServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sky.service.impl; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.github.pagehelper.PageHelper; 5 | import com.sky.constant.MessageConstant; 6 | import com.sky.dto.SetmealDTO; 7 | import com.sky.dto.SetmealPageQueryDTO; 8 | import com.sky.entity.Setmeal; 9 | import com.sky.entity.SetmealDish; 10 | import com.sky.exception.DeletionNotAllowedException; 11 | import com.sky.mapper.DishMapper; 12 | import com.sky.mapper.SetmealDishMapper; 13 | import com.sky.mapper.SetmealMapper; 14 | import com.sky.result.PageResult; 15 | import com.sky.service.SetMealService; 16 | import com.sky.vo.DishItemVO; 17 | import com.sky.vo.SetmealVO; 18 | import org.springframework.beans.BeanUtils; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.stereotype.Service; 21 | import org.springframework.transaction.annotation.Transactional; 22 | 23 | import java.util.List; 24 | 25 | @Service 26 | 27 | public class SetMealServiceImpl implements SetMealService { 28 | 29 | @Autowired 30 | private SetmealMapper setmealMapper; 31 | @Autowired 32 | private SetmealDishMapper setmealDishMapper; 33 | @Autowired 34 | private DishMapper dishMapper; 35 | @Override 36 | public SetmealVO queryById(Long id) { 37 | SetmealVO setmealVO=setmealMapper.queryById(id); 38 | return setmealVO; 39 | } 40 | 41 | @Transactional 42 | @Override 43 | public void saveSetMeal(SetmealDTO setmealDTO) { 44 | List setmealDishes = setmealDTO.getSetmealDishes(); 45 | Setmeal setmeal = new Setmeal(); 46 | BeanUtils.copyProperties(setmealDTO,setmeal); 47 | setmealMapper.insert(setmeal); 48 | if (setmealDishes != null && setmealDishes.size() > 0) { 49 | for (SetmealDish setmealDish : setmealDishes) { 50 | setmealDish.setSetmealId(setmeal.getId()); 51 | setmealMapper.saveSetmealDish(setmealDish); 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | public PageResult page(SetmealPageQueryDTO setmealPageQueryDTO) { 58 | PageHelper.startPage(setmealPageQueryDTO.getPage(),setmealPageQueryDTO.getPageSize()); 59 | Page page = setmealMapper.pageQuery(setmealPageQueryDTO); 60 | return new PageResult(page.getTotal(),page.getResult()); 61 | } 62 | 63 | @Transactional 64 | @Override 65 | public void updateSetmeal(SetmealDTO setmealDTO) { 66 | Setmeal setmeal = new Setmeal(); 67 | BeanUtils.copyProperties(setmealDTO,setmeal); 68 | setmealMapper.update(setmeal); 69 | List setmealDishes = setmealDTO.getSetmealDishes(); 70 | if (setmealDishes!=null && setmealDishes.size()>0){ 71 | setmealMapper.deleteSetmealDishesById(setmeal.getId()); 72 | for (SetmealDish setmealDish : setmealDishes) { 73 | setmealDish.setSetmealId(setmeal.getId()); 74 | setmealMapper.insertSetmealDishes(setmealDish); 75 | } 76 | } 77 | } 78 | 79 | @Transactional 80 | @Override 81 | public void delete(List ids) { 82 | for (Long id : ids) { 83 | if(setmealMapper.queryById(id).getStatus()!=0){ 84 | throw new DeletionNotAllowedException(MessageConstant.SETMEAL_ON_SALE); 85 | } 86 | } 87 | setmealMapper.delete(ids); 88 | for (Long id : ids) { 89 | setmealMapper.deleteSetmealDishesById(id); 90 | } 91 | } 92 | 93 | @Override 94 | public void updateSetmealStatus(int status, Long id) { 95 | Setmeal setmeal = Setmeal.builder().status(status).id(id).build(); 96 | setmealMapper.update(setmeal); 97 | } 98 | 99 | /** 100 | * 条件查询 101 | * @param setmeal 102 | * @return 103 | */ 104 | public List list(Setmeal setmeal) { 105 | List list = setmealMapper.list(setmeal); 106 | return list; 107 | } 108 | 109 | /** 110 | * 根据id查询菜品选项 111 | * @param id 112 | * @return 113 | */ 114 | public List getDishItemById(Long id) { 115 | return setmealMapper.getDishItemBySetmealId(id); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sky.service.impl; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.sky.constant.MessageConstant; 6 | import com.sky.dto.UserLoginDTO; 7 | import com.sky.entity.User; 8 | import com.sky.exception.LoginFailedException; 9 | import com.sky.mapper.UserMapper; 10 | import com.sky.properties.WeChatProperties; 11 | import com.sky.service.UserService; 12 | import com.sky.utils.HttpClientUtil; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.time.LocalDateTime; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | @Service 22 | @Slf4j 23 | public class UserServiceImpl implements UserService { 24 | 25 | //微信服务接口地址 26 | public static final String WX_LOGIN = "https://api.weixin.qq.com/sns/jscode2session"; 27 | 28 | @Autowired 29 | private WeChatProperties weChatProperties; 30 | @Autowired 31 | private UserMapper userMapper; 32 | 33 | /** 34 | * 微信登录 35 | * @param userLoginDTO 36 | * @return 37 | */ 38 | public User wxLogin(UserLoginDTO userLoginDTO) { 39 | String openid = getOpenid(userLoginDTO.getCode()); 40 | 41 | //判断openid是否为空,如果为空表示登录失败,抛出业务异常 42 | if(openid == null){ 43 | throw new LoginFailedException(MessageConstant.LOGIN_FAILED); 44 | } 45 | 46 | //判断当前用户是否为新用户 47 | User user = userMapper.getByOpenid(openid); 48 | 49 | //如果是新用户,自动完成注册 50 | if(user == null){ 51 | user = User.builder() 52 | .openid(openid) 53 | .createTime(LocalDateTime.now()) 54 | .build(); 55 | userMapper.insert(user);//后绪步骤实现 56 | } 57 | 58 | //返回这个用户对象 59 | return user; 60 | } 61 | 62 | /** 63 | * 调用微信接口服务,获取微信用户的openid 64 | * @param code 65 | * @return 66 | */ 67 | private String getOpenid(String code){ 68 | //调用微信接口服务,获得当前微信用户的openid 69 | Map map = new HashMap<>(); 70 | map.put("appid",weChatProperties.getAppid()); 71 | map.put("secret",weChatProperties.getSecret()); 72 | map.put("js_code",code); 73 | map.put("grant_type","authorization_code"); 74 | String json = HttpClientUtil.doGet(WX_LOGIN, map); 75 | 76 | JSONObject jsonObject = JSON.parseObject(json); 77 | String openid = jsonObject.getString("openid"); 78 | return openid; 79 | } 80 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/task/OrderTask.java: -------------------------------------------------------------------------------- 1 | package com.sky.task; 2 | 3 | import com.sky.entity.Orders; 4 | import com.sky.mapper.OrderMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.time.LocalDateTime; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * 自定义定时任务,实现订单状态定时处理 16 | */ 17 | @Component 18 | @Slf4j 19 | public class OrderTask { 20 | 21 | @Autowired 22 | private OrderMapper orderMapper; 23 | 24 | /** 25 | * 处理支付超时订单 26 | */ 27 | @Scheduled(cron = "0 * * * * ?") 28 | public void processTimeoutOrder(){ 29 | log.info("处理支付超时订单:{}", new Date()); 30 | 31 | LocalDateTime time = LocalDateTime.now().plusMinutes(-15); 32 | 33 | // select * from orders where status = 1 and order_time < 当前时间-15分钟 34 | List ordersList = orderMapper.getByStatusAndOrdertimeLT(Orders.PENDING_PAYMENT, time); 35 | if(ordersList != null && ordersList.size() > 0){ 36 | ordersList.forEach(order -> { 37 | order.setStatus(Orders.CANCELLED); 38 | order.setCancelReason("支付超时,自动取消"); 39 | order.setCancelTime(LocalDateTime.now()); 40 | orderMapper.update(order); 41 | }); 42 | } 43 | } 44 | 45 | /** 46 | * 处理“派送中”状态的订单 47 | */ 48 | @Scheduled(cron = "0 0 1 * * ?") 49 | public void processDeliveryOrder(){ 50 | log.info("处理派送中订单:{}", new Date()); 51 | // select * from orders where status = 4 and order_time < 当前时间-1小时 52 | LocalDateTime time = LocalDateTime.now().plusMinutes(-60); 53 | List ordersList = orderMapper.getByStatusAndOrdertimeLT(Orders.DELIVERY_IN_PROGRESS, time); 54 | 55 | if(ordersList != null && ordersList.size() > 0){ 56 | ordersList.forEach(order -> { 57 | order.setStatus(Orders.COMPLETED); 58 | orderMapper.update(order); 59 | }); 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/task/WebSocketTask.java: -------------------------------------------------------------------------------- 1 | package com.sky.task; 2 | 3 | import com.sky.websocket.WebSocketServer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | import java.time.LocalDateTime; 8 | import java.time.format.DateTimeFormatter; 9 | 10 | @Component 11 | public class WebSocketTask { 12 | @Autowired 13 | private WebSocketServer webSocketServer; 14 | 15 | /** 16 | * 通过WebSocket每隔5秒向客户端发送消息 17 | */ 18 | @Scheduled(cron = "0/5 * * * * ?") 19 | public void sendMessageToClient() { 20 | webSocketServer.sendToAllClient("这是来自服务端的消息:" + DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now())); 21 | } 22 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/utils/IPAddressUtils.java: -------------------------------------------------------------------------------- 1 | package com.sky.utils; 2 | 3 | import lombok.extern.slf4j.Slf4j; 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 | public class IPAddressUtils { 16 | /** 17 | * 获取IP地址 18 | */ 19 | public static String getIpAdrress(HttpServletRequest request) { 20 | String ipAddress = request.getHeader("X-Forwarded-For"); 21 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 22 | ipAddress = request.getHeader("Proxy-Client-IP"); 23 | } 24 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 25 | ipAddress = request.getHeader("WL-Proxy-Client-IP"); 26 | } 27 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 28 | ipAddress = request.getRemoteAddr(); 29 | if ("127.0.0.1".equals(ipAddress) || "0:0:0:0:0:0:0:1".equals(ipAddress)) { 30 | // 根据网卡取本机配置的IP 31 | InetAddress inet = null; 32 | try { 33 | inet = InetAddress.getLocalHost(); 34 | } catch (Exception e) { 35 | log.error("根据网卡获取本机配置的IP异常=>", e.getMessage()); 36 | } 37 | if (inet.getHostAddress() != null) { 38 | ipAddress = inet.getHostAddress(); 39 | } 40 | } 41 | } 42 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 43 | if (ipAddress != null && ipAddress.length() > 15) { 44 | if (ipAddress.indexOf(",") > 0) { 45 | ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); 46 | } 47 | } 48 | return ipAddress; 49 | } 50 | } -------------------------------------------------------------------------------- /sky-server/src/main/java/com/sky/websocket/WebSocketServer.java: -------------------------------------------------------------------------------- 1 | package com.sky.websocket; 2 | 3 | import org.springframework.stereotype.Component; 4 | import javax.websocket.OnClose; 5 | import javax.websocket.OnMessage; 6 | import javax.websocket.OnOpen; 7 | import javax.websocket.Session; 8 | import javax.websocket.server.PathParam; 9 | import javax.websocket.server.ServerEndpoint; 10 | import java.util.Collection; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * WebSocket服务 16 | */ 17 | @Component 18 | @ServerEndpoint("/ws/{sid}") 19 | public class WebSocketServer { 20 | 21 | //存放会话对象 22 | private static Map sessionMap = new HashMap(); 23 | 24 | /** 25 | * 连接建立成功调用的方法 26 | */ 27 | @OnOpen 28 | public void onOpen(Session session, @PathParam("sid") String sid) { 29 | System.out.println("客户端:" + sid + "建立连接"); 30 | sessionMap.put(sid, session); 31 | } 32 | 33 | /** 34 | * 收到客户端消息后调用的方法 35 | * 36 | * @param message 客户端发送过来的消息 37 | */ 38 | @OnMessage 39 | public void onMessage(String message, @PathParam("sid") String sid) { 40 | System.out.println("收到来自客户端:" + sid + "的信息:" + message); 41 | } 42 | 43 | /** 44 | * 连接关闭调用的方法 45 | * 46 | * @param sid 47 | */ 48 | @OnClose 49 | public void onClose(@PathParam("sid") String sid) { 50 | System.out.println("连接断开:" + sid); 51 | sessionMap.remove(sid); 52 | } 53 | 54 | /** 55 | * 群发 56 | * 57 | * @param message 58 | */ 59 | public void sendToAllClient(String message) { 60 | Collection sessions = sessionMap.values(); 61 | for (Session session : sessions) { 62 | try { 63 | //服务器向客户端发送消息 64 | session.getBasicRemote().sendText(message); 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /sky-server/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | sky: 2 | datasource: 3 | driver-class-name: com.mysql.cj.jdbc.Driver 4 | host: localhost 5 | port: 3306 6 | database: sky_take_out 7 | username: root 8 | password: 9 | 10 | alioss: 11 | endpoint: 12 | access-key-id: 13 | access-key-secret: 14 | bucket-name: odentist-image-restore 15 | 16 | redis: 17 | host: localhost 18 | port: 6379 19 | # password: 123456 20 | database: 10 21 | wechat: 22 | appid: 23 | secret: 24 | mchid: 1561414331 25 | mchSerialNo: 4B3B3DC35414AD50B1B755BAF8DE9CC7CF407606 26 | privateKeyFilePath: D:\apiclient_key.pem 27 | apiV3Key: CZBK51236435wxpay435434323FFDuv3 28 | weChatPayCertFilePath: D:\wechatpay_166D96F876F45C7D07CE98952A96EC980368ACFC.pem 29 | notifyUrl: https://www.weixin.qq.com/wxpay/pay.php 30 | refundNotifyUrl: https://www.weixin.qq.com/wxpay/pay.php 31 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | profiles: 6 | active: dev 7 | main: 8 | allow-circular-references: true 9 | datasource: 10 | druid: 11 | driver-class-name: ${sky.datasource.driver-class-name} 12 | url: jdbc:mysql://${sky.datasource.host}:${sky.datasource.port}/${sky.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true 13 | username: ${sky.datasource.username} 14 | password: ${sky.datasource.password} 15 | redis: 16 | host: ${sky.redis.host} 17 | port: ${sky.redis.port} 18 | #password: ${sky.redis.password} 19 | database: ${sky.redis.database} 20 | 21 | mybatis: 22 | #mapper配置文件 23 | mapper-locations: classpath:mapper/*.xml 24 | type-aliases-package: com.sky.entity 25 | configuration: 26 | #开启驼峰命名 27 | map-underscore-to-camel-case: true 28 | 29 | logging: 30 | level: 31 | com: 32 | sky: 33 | mapper: debug 34 | service: info 35 | controller: info 36 | 37 | sky: 38 | jwt: 39 | # 设置jwt签名加密时使用的秘钥 40 | admin-secret-key: itcast 41 | # 设置jwt过期时间 42 | admin-ttl: 7200000 43 | # 设置前端传递过来的令牌名称 44 | admin-token-name: token 45 | user-secret-key: itheima 46 | user-ttl: 7200000 47 | user-token-name: authentication 48 | 49 | alioss: 50 | endpoint: ${sky.alioss.endpoint} 51 | access-key-id: ${sky.alioss.access-key-id} 52 | access-key-secret: ${sky.alioss.access-key-secret} 53 | bucket-name: ${sky.alioss.bucket-name} 54 | 55 | wechat: 56 | appid: ${sky.wechat.appid} 57 | secret: ${sky.wechat.secret} 58 | mchid: ${sky.wechat.mchid} 59 | mchSerialNo: ${sky.wechat.mchSerialNo} 60 | privateKeyFilePath: ${sky.wechat.privateKeyFilePath} 61 | apiV3Key: ${sky.wechat.apiV3Key} 62 | weChatPayCertFilePath: ${sky.wechat.weChatPayCertFilePath} 63 | notifyUrl: ${sky.wechat.notifyUrl} 64 | refundNotifyUrl: ${sky.wechat.refundNotifyUrl} 65 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/AddressBookMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | 21 | update address_book 22 | 23 | 24 | consignee = #{consignee}, 25 | 26 | 27 | sex = #{sex}, 28 | 29 | 30 | phone = #{phone}, 31 | 32 | 33 | detail = #{detail}, 34 | 35 | 36 | label = #{label}, 37 | 38 | 39 | is_default = #{isDefault}, 40 | 41 | 42 | where id = #{id} 43 | 44 | 45 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 20 | 21 | 22 | update category 23 | 24 | 25 | type = #{type}, 26 | 27 | 28 | name = #{name}, 29 | 30 | 31 | sort = #{sort}, 32 | 33 | 34 | status = #{status}, 35 | 36 | 37 | update_time = #{updateTime}, 38 | 39 | 40 | update_user = #{updateUser} 41 | 42 | 43 | where id = #{id} 44 | 45 | 46 | 54 | 55 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/DishFlavorMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | id,dish_id,name, 7 | value 8 | 9 | 10 | 11 | insert into dish_flavor (dish_id, name, value) values 12 | 13 | (#{flavor.dishId},#{flavor.name},#{flavor.value}) 14 | 15 | 16 | 17 | delete from dish_flavor where dish_id=#{id} 18 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/EmployeeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id,name,username, 22 | password,phone,sex, 23 | id_number,status,create_time, 24 | update_time,create_user,update_user 25 | 26 | 27 | 28 | update employee 29 | 30 | 31 | name = #{name,jdbcType=VARCHAR}, 32 | 33 | 34 | username = #{username,jdbcType=VARCHAR}, 35 | 36 | 37 | password = #{password,jdbcType=VARCHAR}, 38 | 39 | 40 | phone = #{phone,jdbcType=VARCHAR}, 41 | 42 | 43 | sex = #{sex,jdbcType=VARCHAR}, 44 | 45 | 46 | id_number = #{idNumber,jdbcType=VARCHAR}, 47 | 48 | 49 | status = #{status,jdbcType=INTEGER}, 50 | 51 | 52 | create_time = #{createTime,jdbcType=TIMESTAMP}, 53 | 54 | 55 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 56 | 57 | 58 | create_user = #{createUser,jdbcType=BIGINT}, 59 | 60 | 61 | update_user = #{updateUser,jdbcType=BIGINT}, 62 | 63 | 64 | where id = #{id,jdbcType=BIGINT} 65 | 66 | 67 | 77 | 83 | 84 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/OrderDetailMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | insert into order_detail 10 | ( name,image 11 | ,order_id,dish_id,setmeal_id 12 | ,dish_flavor,number,amount 13 | ) 14 | values 15 | 16 | (#{od.name,jdbcType=VARCHAR},#{od.image,jdbcType=VARCHAR} 17 | ,#{od.orderId,jdbcType=BIGINT},#{od.dishId,jdbcType=BIGINT},#{od.setmealId,jdbcType=BIGINT} 18 | ,#{od.dishFlavor,jdbcType=VARCHAR},#{od.number,jdbcType=INTEGER},#{od.amount,jdbcType=DECIMAL} 19 | ) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/SetmealDishMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 17 | 21 | 22 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/ShoppingCartMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | id,name,image, 8 | user_id,dish_id,setmeal_id, 9 | dish_flavor,number,amount, 10 | create_time 11 | 12 | 13 | insert into shopping_cart 14 | ( name,image 15 | ,user_id,dish_id,setmeal_id 16 | ,dish_flavor,number,amount 17 | ,create_time) 18 | values (#{name,jdbcType=VARCHAR},#{image,jdbcType=VARCHAR} 19 | ,#{userId,jdbcType=BIGINT},#{dishId,jdbcType=BIGINT},#{setmealId,jdbcType=BIGINT} 20 | ,#{dishFlavor,jdbcType=VARCHAR},#{number,jdbcType=INTEGER},#{amount,jdbcType=DECIMAL} 21 | ,#{createTime,jdbcType=TIMESTAMP}) 22 | 23 | 24 | update shopping_cart 25 | 26 | 27 | name = #{name,jdbcType=VARCHAR}, 28 | 29 | 30 | image = #{image,jdbcType=VARCHAR}, 31 | 32 | 33 | user_id = #{userId,jdbcType=BIGINT}, 34 | 35 | 36 | dish_id = #{dishId,jdbcType=BIGINT}, 37 | 38 | 39 | setmeal_id = #{setmealId,jdbcType=BIGINT}, 40 | 41 | 42 | dish_flavor = #{dishFlavor,jdbcType=VARCHAR}, 43 | 44 | 45 | number = #{number,jdbcType=INTEGER}, 46 | 47 | 48 | amount = #{amount,jdbcType=DECIMAL}, 49 | 50 | 51 | create_time = #{createTime,jdbcType=TIMESTAMP}, 52 | 53 | 54 | where id = #{id,jdbcType=BIGINT} 55 | 56 | 57 | delete from shopping_cart where user_id=#{userId} 58 | 59 | 60 | delete from shopping_cart 61 | 62 | 63 | and dish_id = #{dishId} 64 | 65 | 66 | and setmeal_id = #{setmealId} 67 | 68 | 69 | and dish_flavor = #{dishFlavor} 70 | 71 | 72 | 73 | 74 | 93 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | insert into user (openid, name, phone, sex, id_number, avatar, create_time) 8 | values (#{openid}, #{name}, #{phone}, #{sex}, #{idNumber}, #{avatar}, #{createTime}) 9 | 10 | 13 | 24 | 25 | -------------------------------------------------------------------------------- /sky-server/src/main/resources/template/运营数据报表模板.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ODentist/SkyTakeOut/7a5489f516b33d74bb9db9093c3c1216e80bdc14/sky-server/src/main/resources/template/运营数据报表模板.xlsx --------------------------------------------------------------------------------