Compare commits
4 Commits
main
...
Branch/lyh
| Author | SHA1 | Date |
|---|---|---|
|
|
0a96466be2 | 1 year ago |
|
|
8f9e83d920 | 1 year ago |
|
|
61ed258bfb | 1 year ago |
|
|
f1eb0fac88 | 1 year ago |
@ -0,0 +1,30 @@
|
||||
package com.sky.vo; // 定义了类的包名,通常用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成全参数的构造方法
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成 Builder 模式的链式构造方法
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于生成 getter/setter 方法以及 toString、equals 和 hashCode 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参的构造方法
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,用于将对象序列化成字节流
|
||||
|
||||
/**
|
||||
* 数据概览
|
||||
*/ // 类的文档注释,描述了这个类的作用
|
||||
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动生成 getter/setter 方法以及 toString、equals 和 hashCode 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动生成 Builder 模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动生成无参的构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动生成全参数的构造方法
|
||||
public class BusinessDataVO implements Serializable { // 声明了一个名为 BusinessDataVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
private Double turnover; // 成员变量,表示营业额,类型为 Double
|
||||
|
||||
private Integer validOrderCount; // 成员变量,表示有效订单数,类型为 Integer
|
||||
|
||||
private Double orderCompletionRate; // 成员变量,表示订单完成率,类型为 Double
|
||||
|
||||
private Double unitPrice; // 成员变量,表示平均客单价,类型为 Double
|
||||
|
||||
private Integer newUsers; // 成员变量,表示新增用户数,类型为 Integer
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,28 @@
|
||||
package com.sky.vo; // 定义了类的包名,通常用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成全参数的构造方法
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成 Builder 模式的链式构造方法
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于生成 getter/setter 方法以及 toString、equals 和 hashCode 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参的构造方法
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,用于将对象序列化成字节流
|
||||
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动生成 getter/setter 方法以及 toString、equals 和 hashCode 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动生成 Builder 模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动生成无参的构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动生成全参数的构造方法
|
||||
public class DishItemVO implements Serializable { // 声明了一个名为 DishItemVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
//菜品名称
|
||||
private String name; // 成员变量,表示菜品的名称,类型为 String
|
||||
|
||||
//份数
|
||||
private Integer copies; // 成员变量,表示菜品的份数,类型为 Integer
|
||||
|
||||
//菜品图片
|
||||
private String image; // 成员变量,表示菜品的图片链接,类型为 String
|
||||
|
||||
//菜品描述
|
||||
private String description; // 成员变量,表示菜品的描述信息,类型为 String
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,25 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成包含所有属性的构造函数
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成建造者模式的构造函数
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参构造函数
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
|
||||
/**
|
||||
* 菜品总览
|
||||
*/ // 类的文档注释,描述了这个类的作用和功能
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动为类生成建造者模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动为类生成无参构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动为类生成包含所有属性的构造方法
|
||||
public class DishOverViewVO implements Serializable { // 声明了一个名为 DishOverViewVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
// 已启售数量
|
||||
private Integer sold; // 成员变量,表示已经启售的菜品数量,类型为 Integer
|
||||
|
||||
// 已停售数量
|
||||
private Integer discontinued; // 成员变量,表示已经停售的菜品数量,类型为 Integer
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,31 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import io.swagger.annotations.ApiModel; // 导入 Swagger 的 @ApiModel 注解,用于描述模型信息
|
||||
import io.swagger.annotations.ApiModelProperty; // 导入 Swagger 的 @ApiModelProperty 注解,用于描述模型属性信息
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成包含所有属性的构造函数
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成建造者模式的构造函数
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参构造函数
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动为类生成建造者模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动为类生成无参构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动为类生成包含所有属性的构造方法
|
||||
@ApiModel(description = "员工登录返回的数据格式") // 使用 Swagger 的 @ApiModel 注解,描述这个 VO 对象是员工登录返回的数据格式
|
||||
public class EmployeeLoginVO implements Serializable { // 声明了一个名为 EmployeeLoginVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
@ApiModelProperty("主键值") // 使用 Swagger 的 @ApiModelProperty 注解,描述这个属性是主键值
|
||||
private Long id; // 成员变量,表示员工的唯一标识符,类型为 Long
|
||||
|
||||
@ApiModelProperty("用户名") // 使用 Swagger 的 @ApiModelProperty 注解,描述这个属性是用户名
|
||||
private String userName; // 成员变量,表示员工的用户名,类型为 String
|
||||
|
||||
@ApiModelProperty("姓名") // 使用 Swagger 的 @ApiModelProperty 注解,描述这个属性是姓名
|
||||
private String name; // 成员变量,表示员工的姓名,类型为 String
|
||||
|
||||
@ApiModelProperty("jwt令牌") // 使用 Swagger 的 @ApiModelProperty 注解,描述这个属性是 JWT 令牌
|
||||
private String token; // 成员变量,表示员工登录后获得的 JWT 令牌,类型为 String
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,34 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成包含所有属性的构造函数
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成建造者模式的构造函数
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参构造函数
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
|
||||
/**
|
||||
* 订单概览数据
|
||||
*/ // 类的文档注释,描述了这个类的作用和功能
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动为类生成建造者模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动为类生成无参构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动为类生成包含所有属性的构造方法
|
||||
public class OrderOverViewVO implements Serializable { // 声明了一个名为 OrderOverViewVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
//待接单数量
|
||||
private Integer waitingOrders; // 成员变量,表示待接单的数量,类型为 Integer
|
||||
|
||||
//待派送数量
|
||||
private Integer deliveredOrders; // 成员变量,表示待派送的数量,类型为 Integer
|
||||
|
||||
//已完成数量
|
||||
private Integer completedOrders; // 成员变量,表示已完成的数量,类型为 Integer
|
||||
|
||||
//已取消数量
|
||||
private Integer cancelledOrders; // 成员变量,表示已取消的数量,类型为 Integer
|
||||
|
||||
//全部订单
|
||||
private Integer allOrders; // 成员变量,表示全部订单的数量,类型为 Integer
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,28 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成包含所有属性的构造函数
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成建造者模式的构造函数
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参构造函数
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
import java.time.LocalDateTime; // 导入 Java 8 的日期时间类,用于处理日期和时间
|
||||
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动为类生成建造者模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动为类生成无参构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动为类生成包含所有属性的构造方法
|
||||
public class OrderPaymentVO implements Serializable { // 声明了一个名为 OrderPaymentVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
private String nonceStr; // 成员变量,表示随机字符串,用于支付过程中的随机性保护
|
||||
//随机字符串
|
||||
private String paySign; // 成员变量,表示签名,用于验证支付请求的安全性
|
||||
//签名
|
||||
private String timeStamp; // 成员变量,表示时间戳,用于记录支付请求的时间
|
||||
//时间戳
|
||||
private String signType; // 成员变量,表示签名算法,用于指定签名的加密方式
|
||||
//签名算法
|
||||
private String packageStr; // 成员变量,表示统一下单接口返回的 prepay_id 参数值,用于后续支付流程
|
||||
//统一下单接口返回的 prepay_id 参数值
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,18 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
public class OrderStatisticsVO implements Serializable { // 声明了一个名为 OrderStatisticsVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
//待接单数量
|
||||
private Integer toBeConfirmed; // 成员变量,表示待接单的数量,类型为 Integer
|
||||
|
||||
//待派送数量
|
||||
private Integer confirmed; // 成员变量,表示已经确认但尚未开始派送的订单数量,类型为 Integer
|
||||
|
||||
//派送中数量
|
||||
private Integer deliveryInProgress; // 成员变量,表示正在派送中的订单数量,类型为 Integer
|
||||
|
||||
} // 类定义结束
|
||||
@ -0,0 +1,25 @@
|
||||
package com.sky.vo; // 定义了类的包名,用于组织和管理类文件
|
||||
|
||||
import lombok.AllArgsConstructor; // 导入 Lombok 库提供的 @AllArgsConstructor 注解,用于生成包含所有属性的构造函数
|
||||
import lombok.Builder; // 导入 Lombok 库提供的 @Builder 注解,用于生成建造者模式的构造函数
|
||||
import lombok.Data; // 导入 Lombok 库提供的 @Data 注解,用于自动生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
import lombok.NoArgsConstructor; // 导入 Lombok 库提供的 @NoArgsConstructor 注解,用于生成无参构造函数
|
||||
|
||||
import java.io.Serializable; // 导入 Java 序列化接口,使得对象可以被序列化和反序列化
|
||||
|
||||
/**
|
||||
* 套餐总览
|
||||
*/ // 类的文档注释,描述了这个类的作用和功能,即提供套餐的总览信息
|
||||
@Data // 使用 Lombok 的 @Data 注解,自动为类生成 getter、setter、equals、hashCode 和 toString 方法
|
||||
@Builder // 使用 Lombok 的 @Builder 注解,自动为类生成建造者模式的链式构造方法
|
||||
@NoArgsConstructor // 使用 Lombok 的 @NoArgsConstructor 注解,自动为类生成无参构造方法
|
||||
@AllArgsConstructor // 使用 Lombok 的 @AllArgsConstructor 注解,自动为类生成包含所有属性的构造方法
|
||||
public class SetmealOverViewVO implements Serializable { // 声明了一个名为 SetmealOverViewVO 的类,实现了 Serializable 接口,用于对象的序列化
|
||||
|
||||
// 已启售数量
|
||||
private Integer sold; // 成员变量,表示已经启售的套餐数量,类型为 Integer
|
||||
|
||||
// 已停售数量
|
||||
private Integer discontinued; // 成员变量,表示已经停售的套餐数量,类型为 Integer
|
||||
|
||||
} // 类定义结束
|
||||
@ -1,10 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Zeppelin 忽略的文件
|
||||
/ZeppelinRemoteNotebooks/
|
||||
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="springcache-demo" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="springcache-demo" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,53 +0,0 @@
|
||||
package com.itheima.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
|
||||
/**
|
||||
* 生成接口文档配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Docket docket(){
|
||||
log.info("准备生成接口文档...");
|
||||
|
||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||
.title("接口文档")
|
||||
.version("2.0")
|
||||
.description("接口文档")
|
||||
.build();
|
||||
|
||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo)
|
||||
.select()
|
||||
//指定生成接口需要扫描的包
|
||||
.apis(RequestHandlerSelectors.basePackage("com.itheima.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
|
||||
return docket;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置静态资源映射
|
||||
* @param registry
|
||||
*/
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
log.info("开始设置静态资源映射...");
|
||||
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.itheima.mapper;
|
||||
|
||||
import com.itheima.entity.User;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper{
|
||||
|
||||
@Insert("insert into user(name,age) values (#{name},#{age})")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "id")
|
||||
void insert(User user);
|
||||
|
||||
@Delete("delete from user where id = #{id}")
|
||||
void deleteById(Long id);
|
||||
|
||||
@Delete("delete from user")
|
||||
void deleteAll();
|
||||
|
||||
@Select("select * from user where id = #{id}")
|
||||
User getById(Long id);
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
# 定义服务的配置项
|
||||
server:
|
||||
# 设置服务的端口号为8888
|
||||
port: 8888
|
||||
spring:
|
||||
# 数据源配置
|
||||
datasource:
|
||||
# 配置Druid连接池
|
||||
druid:
|
||||
# 指定JDBC驱动类名
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 指定数据库连接URL
|
||||
url: jdbc:mysql://localhost:3306/spring_cache_demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
# 指定数据库用户名
|
||||
username: root
|
||||
# 指定数据库密码
|
||||
password: root
|
||||
# Redis配置
|
||||
redis:
|
||||
# 指定Redis服务器地址
|
||||
host: localhost
|
||||
# 指定Redis服务器端口
|
||||
port: 6379
|
||||
# 指定Redis密码
|
||||
password: 123456
|
||||
# 指定Redis数据库索引
|
||||
database: 1
|
||||
# 日志配置
|
||||
logging:
|
||||
# 设置日志级别
|
||||
level:
|
||||
# 设置com.itheima包下的mapper日志级别为debug
|
||||
com:
|
||||
itheima:
|
||||
mapper: debug
|
||||
# 设置com.itheima包下的service日志级别为info
|
||||
service: info
|
||||
# 设置com.itheima包下的controller日志级别为info
|
||||
controller: info
|
||||
@ -1,21 +0,0 @@
|
||||
server:
|
||||
port: 8888
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/spring_cache_demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: root
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password: 123456
|
||||
database: 1
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
itheima:
|
||||
mapper: debug
|
||||
service: info
|
||||
controller: info
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>sky-take-out</artifactId>
|
||||
<groupId>com.sky</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>sky-server</artifactId>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sky</groupId>
|
||||
<artifactId>sky-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sky</groupId>
|
||||
<artifactId>sky-pojo</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,284 @@
|
||||
package com.sky.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
// Page class from PageHelper, used for pagination results.
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
// PageHelper class, used to start pagination by configuring the page size and number.
|
||||
|
||||
import com.sky.constant.MessageConstant;
|
||||
// MessageConstant holds predefined messages like error messages.
|
||||
|
||||
import com.sky.constant.StatusConstant;
|
||||
// StatusConstant defines the status values such as ENABLE and DISABLE for different entities.
|
||||
|
||||
import com.sky.dto.SetmealDTO;
|
||||
// SetmealDTO is a Data Transfer Object used for handling Setmeal data during creation or updates.
|
||||
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
// SetmealPageQueryDTO holds the query parameters required for paging through the setmeal records.
|
||||
|
||||
import com.sky.entity.Dish;
|
||||
// Dish entity represents a dish in the system, typically part of a setmeal.
|
||||
|
||||
import com.sky.entity.Setmeal;
|
||||
// Setmeal entity represents the main set meal item in the system.
|
||||
|
||||
import com.sky.entity.SetmealDish;
|
||||
// SetmealDish represents the many-to-many relationship between Setmeal and Dish entities.
|
||||
|
||||
import com.sky.exception.DeletionNotAllowedException;
|
||||
// Custom exception thrown when deletion of a setmeal is not allowed.
|
||||
|
||||
import com.sky.exception.SetmealEnableFailedException;
|
||||
// Custom exception thrown when enabling a setmeal fails due to the status of its associated dishes.
|
||||
|
||||
import com.sky.mapper.DishMapper;
|
||||
// DishMapper interface for accessing Dish-related database operations.
|
||||
|
||||
import com.sky.mapper.SetmealDishMapper;
|
||||
// SetmealDishMapper interface for accessing Setmeal-Dish relationship database operations.
|
||||
|
||||
import com.sky.mapper.SetmealMapper;
|
||||
// SetmealMapper interface for accessing Setmeal-related database operations.
|
||||
|
||||
import com.sky.result.PageResult;
|
||||
// PageResult is a helper class used to encapsulate paginated results.
|
||||
|
||||
import com.sky.service.SetmealService;
|
||||
// SetmealService interface that defines business logic for managing setmeals.
|
||||
|
||||
import com.sky.vo.DishItemVO;
|
||||
// DishItemVO represents a view object for dish details in a setmeal.
|
||||
|
||||
import com.sky.vo.SetmealVO;
|
||||
// SetmealVO represents a view object for setmeal details including associated dishes.
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
// Lombok annotation to enable logging in the class.
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
// BeanUtils is used to copy properties between beans or DTOs and entities.
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
// Autowired annotation is used for dependency injection of required beans.
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
// Service annotation marks this class as a service component in Spring's context.
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// Transactional annotation ensures that methods are executed within a transaction context.
|
||||
|
||||
import java.util.List;
|
||||
// Importing List, a collection type that holds a list of items.
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
// Marks this class as a service in the Spring context and enables logging.
|
||||
|
||||
public class SetmealServiceImpl implements SetmealService {
|
||||
// Implementation of the SetmealService interface where business logic related to setmeals is defined.
|
||||
|
||||
@Autowired
|
||||
private SetmealMapper setmealMapper;
|
||||
// Automatically injects the SetmealMapper to handle database operations related to Setmeal.
|
||||
|
||||
@Autowired
|
||||
private SetmealDishMapper setmealDishMapper;
|
||||
// Automatically injects the SetmealDishMapper to handle database operations related to Setmeal-Dish relationships.
|
||||
|
||||
@Autowired
|
||||
private DishMapper dishMapper;
|
||||
// Automatically injects the DishMapper to handle database operations related to dishes.
|
||||
|
||||
/**
|
||||
* 新增套餐
|
||||
* @param setmealDTO
|
||||
* The method to add a new Setmeal along with associated dishes.
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
// The @Transactional annotation ensures the method runs within a transaction, so all operations are committed or rolled back together.
|
||||
public void saveWithDish(SetmealDTO setmealDTO) {
|
||||
Setmeal setmeal = new Setmeal();
|
||||
// Creates a new instance of Setmeal entity to store the incoming setmeal data.
|
||||
|
||||
BeanUtils.copyProperties(setmealDTO, setmeal);
|
||||
// Copies the properties from SetmealDTO to the Setmeal entity.
|
||||
|
||||
setmealMapper.insert(setmeal);
|
||||
// Inserts the new Setmeal into the database using the setmealMapper.
|
||||
|
||||
Long id = setmeal.getId();
|
||||
// Retrieves the id of the newly inserted Setmeal (auto-generated by the database).
|
||||
|
||||
List<SetmealDish> setmealDishes = setmealDTO.getSetmealDishes();
|
||||
// Retrieves the list of SetmealDish objects (dishes associated with the setmeal).
|
||||
|
||||
setmealDishes.forEach(setmealDish -> setmealDish.setSetmealId(id));
|
||||
// Sets the Setmeal ID for each SetmealDish to associate the dishes with the newly created setmeal.
|
||||
|
||||
setmealDishMapper.insertBatch(setmealDishes);
|
||||
// Inserts the list of SetmealDish entities in a batch into the Setmeal-Dish relationship table.
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param setmealPageQueryDTO
|
||||
* The method to query Setmeals with pagination.
|
||||
*/
|
||||
@Override
|
||||
public PageResult pageQuery(SetmealPageQueryDTO setmealPageQueryDTO) {
|
||||
PageHelper.startPage(setmealPageQueryDTO.getPage(), setmealPageQueryDTO.getPageSize());
|
||||
// Configures PageHelper to handle pagination by starting the page with the given page number and page size.
|
||||
|
||||
Page<SetmealVO> page = setmealMapper.pageQuery(setmealPageQueryDTO);
|
||||
// Executes the query for setmeals using the SetmealMapper, applying pagination.
|
||||
|
||||
return new PageResult(page.getTotal(), page.getResult());
|
||||
// Returns the paginated result, including total count and the current page's results.
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除套餐
|
||||
* @param ids
|
||||
* The method to delete a batch of Setmeals by their IDs.
|
||||
*/
|
||||
@Override
|
||||
public void deleteBatch(List<Long> ids) {
|
||||
// Iterates over the list of ids to check if any of the Setmeals are currently enabled.
|
||||
ids.forEach(id -> {
|
||||
Setmeal setmeal = setmealMapper.getById(id);
|
||||
// Retrieves the Setmeal by its ID to check its status.
|
||||
|
||||
if (StatusConstant.ENABLE == setmeal.getStatus()) {
|
||||
// If the Setmeal is enabled, throw an exception because enabled setmeals cannot be deleted.
|
||||
throw new DeletionNotAllowedException(MessageConstant.SETMEAL_ON_SALE);
|
||||
}
|
||||
});
|
||||
|
||||
// If the Setmeals are not enabled, proceed to delete them.
|
||||
ids.forEach(id -> {
|
||||
setmealMapper.deleteById(id);
|
||||
// Deletes the Setmeal from the Setmeal table by its ID.
|
||||
|
||||
setmealDishMapper.deleteBySetmaleId(id);
|
||||
// Deletes the relationship between the Setmeal and its dishes from the Setmeal-Dish relationship table.
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询套餐
|
||||
* @param id
|
||||
* The method to retrieve a Setmeal by its ID along with its associated dishes.
|
||||
*/
|
||||
@Override
|
||||
public SetmealVO getByIdWithDish(Long id) {
|
||||
SetmealVO setmealVO = new SetmealVO();
|
||||
// Creates a new SetmealVO to store the retrieved setmeal data.
|
||||
|
||||
Setmeal setmeal = setmealMapper.getById(id);
|
||||
// Retrieves the Setmeal entity by its ID from the database.
|
||||
|
||||
BeanUtils.copyProperties(setmeal, setmealVO);
|
||||
// Copies the properties of the Setmeal entity into the SetmealVO.
|
||||
|
||||
List<SetmealDish> setmealDishList = setmealDishMapper.getBySetmealId(id);
|
||||
// Retrieves the list of SetmealDish entities that associate dishes with this Setmeal.
|
||||
|
||||
setmealVO.setSetmealDishes(setmealDishList);
|
||||
// Sets the list of associated dishes in the SetmealVO.
|
||||
|
||||
return setmealVO;
|
||||
// Returns the SetmealVO with both setmeal and its associated dishes.
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改套餐
|
||||
* @param setmealDTO
|
||||
* The method to update an existing Setmeal and its associated dishes.
|
||||
*/
|
||||
@Override
|
||||
public void update(SetmealDTO setmealDTO) {
|
||||
Setmeal setmeal = new Setmeal();
|
||||
// Creates a new Setmeal entity to store the updated data.
|
||||
|
||||
BeanUtils.copyProperties(setmealDTO, setmeal);
|
||||
// Copies the updated properties from the SetmealDTO to the Setmeal entity.
|
||||
|
||||
setmealMapper.update(setmeal);
|
||||
// Updates the Setmeal record in the database with the new data.
|
||||
|
||||
Long id = setmealDTO.getId();
|
||||
// Retrieves the Setmeal ID from the DTO.
|
||||
|
||||
setmealDishMapper.deleteBySetmaleId(id);
|
||||
// Deletes the previous relationships between the Setmeal and its dishes from the Setmeal-Dish table.
|
||||
|
||||
List<SetmealDish> setmealDishes = setmealDTO.getSetmealDishes();
|
||||
// Retrieves the updated list of SetmealDish entities from the DTO.
|
||||
|
||||
setmealDishes.forEach(setmealDish -> setmealDish.setSetmealId(id));
|
||||
// Sets the Setmeal ID for each SetmealDish to associate them with the updated Setmeal.
|
||||
|
||||
setmealDishMapper.insertBatch(setmealDishes);
|
||||
// Inserts the updated SetmealDish records into the Setmeal-Dish relationship table.
|
||||
}
|
||||
|
||||
/**
|
||||
* 套餐起售停售
|
||||
* @param status
|
||||
* @param id
|
||||
* The method to enable or disable a Setmeal.
|
||||
*/
|
||||
@Override
|
||||
public void startOrStop(Integer status, Long id) {
|
||||
if (status == StatusConstant.ENABLE) {
|
||||
// If the status is ENABLE, we need to ensure that all dishes in the setmeal are enabled.
|
||||
|
||||
List<Dish> dishList = dishMapper.getBySetmealId(id);
|
||||
// Retrieves the list of dishes associated with the setmeal.
|
||||
|
||||
if (dishList != null && !dishList.isEmpty()) {
|
||||
// If there are dishes associated with the setmeal.
|
||||
dishList.forEach(dish -> {
|
||||
if (StatusConstant.DISABLE == dish.getStatus()) {
|
||||
// If any dish is disabled, throw an exception.
|
||||
throw new SetmealEnableFailedException(MessageConstant.SETMEAL_ENABLE_FAILED);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Setmeal setmeal = Setmeal.builder()
|
||||
.id(id)
|
||||
.status(status)
|
||||
.build();
|
||||
// Builds a Setmeal object with the provided ID and status.
|
||||
|
||||
setmealMapper.update(setmeal);
|
||||
// Updates the Setmeal record in the database to reflect the new status (enabled or disabled).
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param setmeal
|
||||
* The method to query Setmeals based on certain criteria.
|
||||
*/
|
||||
@Override
|
||||
public List<Setmeal> list(Setmeal setmeal) {
|
||||
return setmealMapper.list(setmeal);
|
||||
// Returns a list of Setmeals that match the given criteria.
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询菜品选项
|
||||
* @param id
|
||||
* The method to get dish options associated with a Setmeal.
|
||||
*/
|
||||
@Override
|
||||
public List<DishItemVO> getDishItemById(Long id) {
|
||||
return setmealMapper.getDishItemBySetmealId(id);
|
||||
// Retrieves the list of dish items associated with the given Setmeal ID.
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.sky.websocket;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WebSocket服务
|
||||
*/
|
||||
@Component
|
||||
@ServerEndpoint("/ws/{sid}")
|
||||
public class WebSocketServer {
|
||||
//存放会话对象
|
||||
private static Map<String, Session> sessionMap = new HashMap();
|
||||
|
||||
/**
|
||||
* 连接建立成功调用的方法
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("sid") String sid) {
|
||||
System.out.println("客户端:" + sid + "建立连接");
|
||||
sessionMap.put(sid, session);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到客户端消息后调用的方法
|
||||
*
|
||||
* @param message 客户端发送过来的消息
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage(String message, @PathParam("sid") String sid) {
|
||||
System.out.println("收到来自客户端:" + sid + "的信息:" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接关闭调用的方法
|
||||
*
|
||||
* @param sid
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose(@PathParam("sid") String sid) {
|
||||
System.out.println("连接断开:" + sid);
|
||||
sessionMap.remove(sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void sendToAllClient(String message) {
|
||||
Collection<Session> sessions = sessionMap.values();
|
||||
for (Session session : sessions) {
|
||||
try {
|
||||
//服务器向客户端发送消息
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue