feat: 重新设置代码格式

This commit is contained in:
bunny 2024-03-16 21:54:38 +08:00
parent 74fafe91a6
commit 77bf47834c
76 changed files with 405 additions and 334 deletions

View File

@ -40,6 +40,11 @@
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
</dependency> </dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--支持配置属性类yml文件中可以提示配置项--> <!--支持配置属性类yml文件中可以提示配置项-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,21 @@
package com.sky.common.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
@Slf4j
public class AddResourceConfiguration extends WebMvcConfigurationSupport {
/**
* 设置静态资源映射
*
* @param registry ResourceHandlerRegistry
*/
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/");
}
}

View File

@ -24,6 +24,8 @@ public class Knife4jConfiguration {
*/ */
@Bean @Bean
public Docket docketAdmin() { public Docket docketAdmin() {
log.info("A管理端接口");
// 添加作者 // 添加作者
Contact contact = new Contact("Bunny", "1319900154@qq.com", "1319900154@qq.com"); Contact contact = new Contact("Bunny", "1319900154@qq.com", "1319900154@qq.com");
// API文档 // API文档
@ -35,6 +37,8 @@ public class Knife4jConfiguration {
@Bean @Bean
public Docket docketUser() { public Docket docketUser() {
log.info("B用户端接口");
ApiInfo apiInfo = new ApiInfoBuilder().title("苍穹外卖项目接口文档").version("2.0").description("苍穹外卖项目接口文档").build(); ApiInfo apiInfo = new ApiInfoBuilder().title("苍穹外卖项目接口文档").version("2.0").description("苍穹外卖项目接口文档").build();
return new Docket(DocumentationType.SWAGGER_2).groupName("B用户端接口") return new Docket(DocumentationType.SWAGGER_2).groupName("B用户端接口")
.apiInfo(apiInfo).select().apis(RequestHandlerSelectors.basePackage("com.sky.controller.user")) .apiInfo(apiInfo).select().apis(RequestHandlerSelectors.basePackage("com.sky.controller.user"))
@ -43,6 +47,8 @@ public class Knife4jConfiguration {
@Bean @Bean
public Docket docketNotify() { public Docket docketNotify() {
log.info("Pay支付接口");
ApiInfo apiInfo = new ApiInfoBuilder().title("苍穹外卖项目接口文档").version("2.0").description("苍穹外卖项目接口文档").build(); ApiInfo apiInfo = new ApiInfoBuilder().title("苍穹外卖项目接口文档").version("2.0").description("苍穹外卖项目接口文档").build();
return new Docket(DocumentationType.SWAGGER_2).groupName("Pay支付接口") return new Docket(DocumentationType.SWAGGER_2).groupName("Pay支付接口")
.apiInfo(apiInfo).select().apis(RequestHandlerSelectors.basePackage("com.sky.controller.notify")) .apiInfo(apiInfo).select().apis(RequestHandlerSelectors.basePackage("com.sky.controller.notify"))

View File

@ -1,13 +1,16 @@
package com.sky.common.config; package com.sky.common.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@Configuration @Configuration
public class RestTemplateConfig { @Slf4j
public class RestTemplateConfiguration {
@Bean @Bean
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
log.info("注入restTemplate");
return new RestTemplate(); return new RestTemplate();
} }
} }

View File

@ -3,24 +3,22 @@ package com.sky.common.config;
import com.sky.common.interceptor.JwtTokenAdminInterceptor; import com.sky.common.interceptor.JwtTokenAdminInterceptor;
import com.sky.common.interceptor.JwtTokenUserInterceptor; import com.sky.common.interceptor.JwtTokenUserInterceptor;
import com.sky.common.json.JacksonObjectMapper; import com.sky.common.json.JacksonObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.util.List; import java.util.List;
@Configuration @Configuration
@RequiredArgsConstructor
@Slf4j @Slf4j
public class WebMvcConfiguration extends WebMvcConfigurationSupport { public class WebMvcConfiguration extends WebMvcConfigurationSupport {
@Autowired private final JwtTokenAdminInterceptor jwtTokenAdminInterceptor;
JwtTokenAdminInterceptor jwtTokenAdminInterceptor; private final JwtTokenUserInterceptor jwtTokenUserInterceptor;
@Autowired
JwtTokenUserInterceptor jwtTokenUserInterceptor;
/** /**
* 注册自定义拦截器 * 注册自定义拦截器
@ -52,15 +50,4 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
// 将自己的消息转化器加入容器中 // 将自己的消息转化器加入容器中
converters.add(0, converter); converters.add(0, converter);
} }
/**
* 设置静态资源映射
*
* @param registry ResourceHandlerRegistry
*/
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/");
}
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 账号被锁定异常 * 账号被锁定异常
*/ */
public class AccountLockedException extends BaseException{ @Slf4j
public class AccountLockedException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class AccountLockedException extends BaseException{
public AccountLockedException(String message) { public AccountLockedException(String message) {
super(message); super(message);
log.error("账号被锁定异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 账号不存在异常 * 账号不存在异常
*/ */
public class AccountNotFoundException extends BaseException{ @Slf4j
public class AccountNotFoundException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class AccountNotFoundException extends BaseException{
public AccountNotFoundException(String message) { public AccountNotFoundException(String message) {
super(message); super(message);
log.error("账号不存在异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 地址信息异常 * 地址信息异常
*/ */
public class AddressBookBusinessException extends BaseException{ @Slf4j
public class AddressBookBusinessException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class AddressBookBusinessException extends BaseException{
public AddressBookBusinessException(String message) { public AddressBookBusinessException(String message) {
super(message); super(message);
log.error("账号不存在异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 业务异常 * 业务异常
*/ */
public class BaseException extends RuntimeException{ @Slf4j
public class BaseException extends RuntimeException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -11,7 +14,9 @@ public class BaseException extends RuntimeException{
*/ */
public BaseException() { public BaseException() {
} }
public BaseException(String message) { public BaseException(String message) {
super(message); super(message);
log.error("业务异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 不允许删除异常 * 不允许删除异常
*/ */
public class DeletionNotAllowedException extends BaseException{ @Slf4j
public class DeletionNotAllowedException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class DeletionNotAllowedException extends BaseException{
public DeletionNotAllowedException(String message) { public DeletionNotAllowedException(String message) {
super(message); super(message);
log.error("不允许删除异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 登录失败 * 登录失败
*/ */
public class LoginFailedException extends BaseException{ @Slf4j
public class LoginFailedException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class LoginFailedException extends BaseException{
public LoginFailedException(String message) { public LoginFailedException(String message) {
super(message); super(message);
log.error("登录失败:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 订单业务异常 * 订单业务异常
*/ */
public class OrderBusinessException extends BaseException{ @Slf4j
public class OrderBusinessException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class OrderBusinessException extends BaseException{
public OrderBusinessException(String message) { public OrderBusinessException(String message) {
super(message); super(message);
log.error("订单业务异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 密码修改失败异常 * 密码修改失败异常
*/ */
public class PasswordEditFailedException extends BaseException{ @Slf4j
public class PasswordEditFailedException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class PasswordEditFailedException extends BaseException{
public PasswordEditFailedException(String message) { public PasswordEditFailedException(String message) {
super(message); super(message);
log.error("密码修改失败异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 密码错误异常 * 密码错误异常
*/ */
public class PasswordErrorException extends BaseException{ @Slf4j
public class PasswordErrorException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class PasswordErrorException extends BaseException{
public PasswordErrorException(String message) { public PasswordErrorException(String message) {
super(message); super(message);
log.error("密码错误异常:{}", message);
} }
} }

View File

@ -1,10 +1,17 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/**
* RestTemplateException异常
*/
@Slf4j
public class RestTemplateException extends BaseException { public class RestTemplateException extends BaseException {
public RestTemplateException() { public RestTemplateException() {
} }
public RestTemplateException(String message) { public RestTemplateException(String message) {
super(message); super(message);
log.error("RestTemplateException异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 套餐启用失败异常 * 套餐启用失败异常
*/ */
public class SetMealEnableFailedException extends BaseException{ @Slf4j
public class SetMealEnableFailedException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class SetMealEnableFailedException extends BaseException{
public SetMealEnableFailedException(String message) { public SetMealEnableFailedException(String message) {
super(message); super(message);
log.error("套餐启用失败异常:{}", message);
} }
} }

View File

@ -1,9 +1,12 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 购物车异常 * 购物车异常
*/ */
public class ShoppingCartBusinessException extends BaseException{ @Slf4j
public class ShoppingCartBusinessException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be * detail message. The cause is not initialized, and may subsequently be
@ -14,5 +17,6 @@ public class ShoppingCartBusinessException extends BaseException{
public ShoppingCartBusinessException(String message) { public ShoppingCartBusinessException(String message) {
super(message); super(message);
log.error("购物车异常:{}", message);
} }
} }

View File

@ -1,8 +1,11 @@
package com.sky.common.exception; package com.sky.common.exception;
import lombok.extern.slf4j.Slf4j;
/** /**
* 用户未登录异常 * 用户未登录异常
*/ */
@Slf4j
public class UserNotLoginException extends BaseException { public class UserNotLoginException extends BaseException {
/** /**
* Constructs a new runtime exception with {@code null} as its * Constructs a new runtime exception with {@code null} as its
@ -14,5 +17,6 @@ public class UserNotLoginException extends BaseException {
public UserNotLoginException(String message) { public UserNotLoginException(String message) {
super(message); super(message);
log.error("用户未登录异常:{}", message);
} }
} }

View File

@ -21,10 +21,13 @@ public class GlobalExceptionHandler {
// 处理SQL异常 // 处理SQL异常
public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) { public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) {
log.error("处理SQL异常:{}", exception.getMessage());
String message = exception.getMessage(); String message = exception.getMessage();
if (message.contains("Duplicate entry")) { if (message.contains("Duplicate entry")) {
String[] split = message.split(" "); // 截取用户名
String username = split[2]; String username = message.split(" ")[2];
// 错误信息
String errorMessage = username + MessageConstant.ALREADY_EXISTS; String errorMessage = username + MessageConstant.ALREADY_EXISTS;
return Result.error(errorMessage); return Result.error(errorMessage);
} else { } else {

View File

@ -5,9 +5,9 @@ import com.sky.common.context.BaseContext;
import com.sky.common.properties.JwtProperties; import com.sky.common.properties.JwtProperties;
import com.sky.common.utils.JwtUtil; import com.sky.common.utils.JwtUtil;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
@ -19,12 +19,12 @@ import javax.servlet.http.HttpServletResponse;
* 管理端用户判断 * 管理端用户判断
*/ */
@Component @Component
@RequiredArgsConstructor
@Slf4j @Slf4j
public class JwtTokenAdminInterceptor implements HandlerInterceptor { public class JwtTokenAdminInterceptor implements HandlerInterceptor {
@Autowired private final JwtProperties jwtProperties;
JwtProperties jwtProperties;
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception { public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) {
// 判断当前兰街道的是Controller的方法还是其它资源 // 判断当前兰街道的是Controller的方法还是其它资源
if (!(handler instanceof HandlerMethod)) { if (!(handler instanceof HandlerMethod)) {
// 拦截到的不是动态方法直接放行 // 拦截到的不是动态方法直接放行
@ -32,6 +32,7 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
} }
// 1. 从请求头中获取令牌 // 1. 从请求头中获取令牌
String token = request.getHeader(jwtProperties.getAdminTokenName()); String token = request.getHeader(jwtProperties.getAdminTokenName());
// 2. 拦截令牌 // 2. 拦截令牌
log.info("jwt校验{}", token); log.info("jwt校验{}", token);

View File

@ -6,8 +6,8 @@ import com.sky.common.properties.JwtProperties;
import com.sky.common.utils.JwtUtil; import com.sky.common.utils.JwtUtil;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
import lombok.NonNull; import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
@ -19,10 +19,10 @@ import javax.servlet.http.HttpServletResponse;
* 客户端登录判断 * 客户端登录判断
*/ */
@Component @Component
@RequiredArgsConstructor
@Slf4j @Slf4j
public class JwtTokenUserInterceptor implements HandlerInterceptor { public class JwtTokenUserInterceptor implements HandlerInterceptor {
@Autowired private final JwtProperties jwtProperties;
JwtProperties jwtProperties;
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception { public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception {
// 判断当前拦截到的是Controller方法还是其它资源 // 判断当前拦截到的是Controller方法还是其它资源

View File

@ -1,6 +1,5 @@
package com.sky.common.json; package com.sky.common.json;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;

View File

@ -13,7 +13,7 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class PageResult implements Serializable { public class PageResult<T> implements Serializable {
private long total; // 总记录数 private long total; // 总记录数
private List records; // 当前页数据集合 private List<T> records; // 当前页数据集合
} }

View File

@ -29,10 +29,6 @@ public class HttpClientUtil {
/** /**
* 发送GET方式请求 * 发送GET方式请求
*
* @param url
* @param paramMap
* @return
*/ */
public static String doGet(String url, Map<String, String> paramMap) { public static String doGet(String url, Map<String, String> paramMap) {
// 创建Httpclient对象 // 创建Httpclient对象
@ -76,11 +72,6 @@ public class HttpClientUtil {
/** /**
* 发送POST方式请求 * 发送POST方式请求
*
* @param url
* @param paramMap
* @return
* @throws IOException
*/ */
public static String doPost(String url, Map<String, String> paramMap) throws IOException { public static String doPost(String url, Map<String, String> paramMap) throws IOException {
// 创建Httpclient对象 // 创建Httpclient对象
@ -124,11 +115,6 @@ public class HttpClientUtil {
/** /**
* 发送POST方式请求 * 发送POST方式请求
*
* @param url
* @param paramMap
* @return
* @throws IOException
*/ */
public static String doPost4Json(String url, Map<String, String> paramMap) throws IOException { public static String doPost4Json(String url, Map<String, String> paramMap) throws IOException {
// 创建Httpclient对象 // 创建Httpclient对象

View File

@ -8,8 +8,8 @@ public final class MD5 {
public static String encrypt(String strSrc) { public static String encrypt(String strSrc) {
try { try {
char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f' }; '9', 'a', 'b', 'c', 'd', 'e', 'f'};
byte[] bytes = strSrc.getBytes(); byte[] bytes = strSrc.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes); md.update(bytes);
@ -17,8 +17,7 @@ public final class MD5 {
int j = bytes.length; int j = bytes.length;
char[] chars = new char[j * 2]; char[] chars = new char[j * 2];
int k = 0; int k = 0;
for (int i = 0; i < bytes.length; i++) { for (byte b : bytes) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf]; chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf]; chars[k++] = hexChars[b & 0xf];
} }

View File

@ -3,20 +3,18 @@ package com.sky.common.utils;
import com.sky.common.properties.MinioProperties; import com.sky.common.properties.MinioProperties;
import io.minio.*; import io.minio.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.InputStream; import java.io.InputStream;
@Component @Component
@RequiredArgsConstructor
@Slf4j @Slf4j
public class MinioUtils { public class MinioUtils {
@Resource private final MinioClient minioClient;
private MinioClient minioClient; private final MinioProperties minioProperties;
@Resource
private MinioProperties minioProperties;
/** /**
* 判断桶是否存在 * 判断桶是否存在

View File

@ -0,0 +1,20 @@
package com.sky.common.utils;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Set;
@Component
@RequiredArgsConstructor
public class RedisUtil {
private static final RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
public static void cleanCache(String key) {
Set<Object> keys = redisTemplate.keys(key);
if (keys != null) {
redisTemplate.delete(keys);
}
}
}

View File

@ -1,6 +1,6 @@
package com.sky.common.utils; package com.sky.common.utils;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -9,9 +9,9 @@ import org.springframework.web.client.RestTemplate;
import java.io.Serializable; import java.io.Serializable;
@Component @Component
public class RestTemplateUtils<T> implements Serializable { @RequiredArgsConstructor
@Autowired public class RestTemplateUtil<T> implements Serializable {
RestTemplate restTemplate; private final RestTemplate restTemplate;
public ResponseEntity<?> requestGet(String url, T t) { public ResponseEntity<?> requestGet(String url, T t) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();

View File

@ -5,6 +5,7 @@ import com.sky.common.context.BaseContext;
import com.sky.common.properties.WeChatProperties; import com.sky.common.properties.WeChatProperties;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder; import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
@ -14,7 +15,6 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
@ -33,16 +33,13 @@ import java.util.UUID;
* 微信支付工具类 * 微信支付工具类
*/ */
@Component @Component
@RequiredArgsConstructor
public class WeChatPayUtil { public class WeChatPayUtil {
// 微信支付下单接口地址 // 微信支付下单接口地址
public static final String JSAPI = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"; public static final String JSAPI = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";
// 申请退款接口地址 // 申请退款接口地址
public static final String REFUNDS = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"; public static final String REFUNDS = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds";
private final WeChatProperties weChatProperties;
@Autowired
private WeChatProperties weChatProperties;
/** /**
* 获取调用微信接口的客户端工具对象 * 获取调用微信接口的客户端工具对象

View File

@ -1,22 +1,21 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryDTO implements Serializable { public class CategoryDTO implements Serializable {
// 主键
//主键
private Long id; private Long id;
// 类型 1 菜品分类 2 套餐分类
//类型 1 菜品分类 2 套餐分类
private Integer type; private Integer type;
// 分类名称
//分类名称
private String name; private String name;
// 排序
//排序
private Integer sort; private Integer sort;
} }

View File

@ -1,22 +1,21 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryPageQueryDTO implements Serializable { public class CategoryPageQueryDTO implements Serializable {
// 页码
//页码
private int page; private int page;
// 每页记录数
//每页记录数
private int pageSize; private int pageSize;
// 分类名称
//分类名称
private String name; private String name;
// 分类类型 1菜品分类 2套餐分类
//分类类型 1菜品分类 2套餐分类
private Integer type; private Integer type;
} }

View File

@ -13,9 +13,6 @@ import java.time.LocalDateTime;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class DataOverViewQueryDTO implements Serializable { public class DataOverViewQueryDTO implements Serializable {
private LocalDateTime begin; private LocalDateTime begin;
private LocalDateTime end; private LocalDateTime end;
} }

View File

@ -1,7 +1,9 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import com.sky.pojo.entity.DishFlavor; import com.sky.pojo.entity.DishFlavor;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -9,6 +11,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class DishDTO implements Serializable { public class DishDTO implements Serializable {
private Long id; private Long id;
// 菜品名称 // 菜品名称

View File

@ -1,22 +1,20 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class DishPageQueryDTO implements Serializable { public class DishPageQueryDTO implements Serializable {
private int page; private int page;
private int pageSize; private int pageSize;
private String name; private String name;
// 分类id
//分类id
private Integer categoryId; private Integer categoryId;
// 状态 0表示禁用 1表示启用
//状态 0表示禁用 1表示启用
private Integer status; private Integer status;
} }

View File

@ -1,22 +1,19 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class EmployeeDTO implements Serializable { public class EmployeeDTO implements Serializable {
private Long id; private Long id;
private String username; private String username;
private String name; private String name;
private String phone; private String phone;
private String sex; private String sex;
private String idNumber; private String idNumber;
} }

View File

@ -2,11 +2,15 @@ package com.sky.pojo.dto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "员工登录时传递的数据模型") @ApiModel(description = "员工登录时传递的数据模型")
public class EmployeeLoginDTO implements Serializable { public class EmployeeLoginDTO implements Serializable {

View File

@ -1,15 +1,19 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class EmployeePageQueryDTO implements Serializable { public class EmployeePageQueryDTO implements Serializable {
//员工姓名 // 员工姓名
private String name; private String name;
//页码 // 页码
private int page; private int page;
//每页显示记录数 // 每页显示记录数
private int pageSize; private int pageSize;
} }

View File

@ -1,14 +1,16 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersCancelDTO implements Serializable { public class OrdersCancelDTO implements Serializable {
private Long id; private Long id;
//订单取消原因 // 订单取消原因
private String cancelReason; private String cancelReason;
} }

View File

@ -1,10 +1,14 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
public class OrdersConfirmDTO implements Serializable { public class OrdersConfirmDTO implements Serializable {
private Long id; private Long id;
// 订单状态 1待付款 2待接单 3 已接单 4 派送中 5 已完成 6 已取消 7 退款 // 订单状态 1待付款 2待接单 3 已接单 4 派送中 5 已完成 6 已取消 7 退款

View File

@ -1,56 +1,45 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import com.sky.pojo.entity.OrderDetail; import com.sky.pojo.entity.OrderDetail;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersDTO implements Serializable { public class OrdersDTO implements Serializable {
private Long id; private Long id;
// 订单号
//订单号
private String number; private String number;
// 订单状态 1待付款2待派送3已派送4已完成5已取消
//订单状态 1待付款2待派送3已派送4已完成5已取消
private Integer status; private Integer status;
// 下单用户id
//下单用户id
private Long userId; private Long userId;
// 地址id
//地址id
private Long addressBookId; private Long addressBookId;
// 下单时间
//下单时间
private LocalDateTime orderTime; private LocalDateTime orderTime;
// 结账时间
//结账时间
private LocalDateTime checkoutTime; private LocalDateTime checkoutTime;
// 支付方式 1微信2支付宝
//支付方式 1微信2支付宝
private Integer payMethod; private Integer payMethod;
// 实收金额
//实收金额
private BigDecimal amount; private BigDecimal amount;
// 备注
//备注
private String remark; private String remark;
// 用户名
//用户名
private String userName; private String userName;
// 手机号
//手机号
private String phone; private String phone;
// 地址
//地址
private String address; private String address;
// 收货人
//收货人
private String consignee; private String consignee;
private List<OrderDetail> orderDetails; private List<OrderDetail> orderDetails;
} }

View File

@ -1,30 +1,25 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersPageQueryDTO implements Serializable { public class OrdersPageQueryDTO implements Serializable {
private int page; private int page;
private int pageSize; private int pageSize;
private String number; private String number;
private String phone;
private String phone;
private Integer status; private Integer status;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime beginTime; private LocalDateTime beginTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime; private LocalDateTime endTime;
private Long userId; private Long userId;
} }

View File

@ -1,14 +1,17 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersPaymentDTO implements Serializable { public class OrdersPaymentDTO implements Serializable {
// 订单号 // 订单号
private String orderNumber; private String orderNumber;
// 付款方式 // 付款方式
private Integer payMethod; private Integer payMethod;
} }

View File

@ -1,15 +1,16 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersRejectionDTO implements Serializable { public class OrdersRejectionDTO implements Serializable {
private Long id; private Long id;
// 订单拒绝原因
//订单拒绝原因
private String rejectionReason; private String rejectionReason;
} }

View File

@ -1,31 +1,35 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class OrdersSubmitDTO implements Serializable { public class OrdersSubmitDTO implements Serializable {
//地址簿id // 地址簿id
private Long addressBookId; private Long addressBookId;
//付款方式 // 付款方式
private int payMethod; private int payMethod;
//备注 // 备注
private String remark; private String remark;
//预计送达时间 // 预计送达时间
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime estimatedDeliveryTime; private LocalDateTime estimatedDeliveryTime;
//配送状态 1立即送出 0选择具体时间 // 配送状态 1立即送出 0选择具体时间
private Integer deliveryStatus; private Integer deliveryStatus;
//餐具数量 // 餐具数量
private Integer tablewareNumber; private Integer tablewareNumber;
//餐具数量状态 1按餐量提供 0选择具体数量 // 餐具数量状态 1按餐量提供 0选择具体数量
private Integer tablewareStatus; private Integer tablewareStatus;
//打包费 // 打包费
private Integer packAmount; private Integer packAmount;
//总金额 // 总金额
private BigDecimal amount; private BigDecimal amount;
} }

View File

@ -1,19 +1,19 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class PasswordEditDTO implements Serializable { public class PasswordEditDTO implements Serializable {
// 员工id
//员工id
private Long empId; private Long empId;
// 旧密码
//旧密码
private String oldPassword; private String oldPassword;
// 新密码
//新密码
private String newPassword; private String newPassword;
} }

View File

@ -1,7 +1,9 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import com.sky.pojo.entity.SetmealDish; import com.sky.pojo.entity.SetmealDish;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -9,27 +11,22 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class SetmealDTO implements Serializable { public class SetmealDTO implements Serializable {
private Long id; private Long id;
// 分类id // 分类id
private Long categoryId; private Long categoryId;
// 套餐名称 // 套餐名称
private String name; private String name;
// 套餐价格 // 套餐价格
private BigDecimal price; private BigDecimal price;
// 状态 0:停用 1:启用 // 状态 0:停用 1:启用
private Integer status; private Integer status;
// 描述信息 // 描述信息
private String description; private String description;
// 图片 // 图片
private String image; private String image;
// 套餐菜品关系 // 套餐菜品关系
private List<SetmealDish> setmealDishes = new ArrayList<>(); private List<SetmealDish> setmealDishes = new ArrayList<>();
} }

View File

@ -1,22 +1,20 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class SetmealPageQueryDTO implements Serializable { public class SetmealPageQueryDTO implements Serializable {
private int page; private int page;
private int pageSize; private int pageSize;
private String name; private String name;
// 分类id
//分类id
private Integer categoryId; private Integer categoryId;
// 状态 0表示禁用 1表示启用
//状态 0表示禁用 1表示启用
private Integer status; private Integer status;
} }

View File

@ -1,10 +1,14 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class ShoppingCartDTO implements Serializable { public class ShoppingCartDTO implements Serializable {
private Long dishId; private Long dishId;
private Long setmealId; private Long setmealId;

View File

@ -1,6 +1,8 @@
package com.sky.pojo.dto; package com.sky.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
@ -8,8 +10,8 @@ import java.io.Serializable;
* C端用户登录 * C端用户登录
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class UserLoginDTO implements Serializable { public class UserLoginDTO implements Serializable {
private String code; private String code;
} }

20
sky-server/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM openjdk:18
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# 设置时区,构建镜像时执行的命令
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
# 设定工作目录
WORKDIR /home/bunny
# 复制jar包
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
#启动容器时的进程
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080

View File

@ -1,5 +0,0 @@
FROM openjdk:8-jdk-alpine
ADD *.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

View File

@ -9,8 +9,8 @@ import com.sky.pojo.entity.Category;
import com.sky.service.CategoryService; import com.sky.service.CategoryService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -20,13 +20,12 @@ import java.util.List;
* 分类管理 * 分类管理
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/admin/category") @RequestMapping("/admin/category")
@Api(tags = "分类相关接口") @Api(tags = "分类相关接口")
@Slf4j @Slf4j
public class CategoryController { public class CategoryController {
private final CategoryService categoryService;
@Autowired
private CategoryService categoryService;
@PostMapping @PostMapping
@ApiOperation("新增分类") @ApiOperation("新增分类")
@ -38,9 +37,9 @@ public class CategoryController {
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("分类分页查询") @ApiOperation("分类分页查询")
public Result<PageResult> page(CategoryPageQueryDTO categoryPageQueryDTO) { public Result<PageResult<Category>> page(CategoryPageQueryDTO categoryPageQueryDTO) {
log.info("分页查询:{}", categoryPageQueryDTO); log.info("分页查询:{}", categoryPageQueryDTO);
PageResult pageResult = categoryService.pageQuery(categoryPageQueryDTO); PageResult<Category> pageResult = categoryService.pageQuery(categoryPageQueryDTO);
return Result.success(pageResult); return Result.success(pageResult);
} }

View File

@ -6,8 +6,8 @@ import com.sky.common.result.Result;
import com.sky.service.MinioService; import com.sky.service.MinioService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -16,12 +16,12 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/admin/common") @RequestMapping("/admin/common")
@Api(tags = "通用接口") @Api(tags = "通用接口")
@Slf4j @Slf4j
public class CommonController { public class CommonController {
@Autowired private final MinioService minioService;
private MinioService minioService;
@ApiOperation(value = "文件上传") @ApiOperation(value = "文件上传")
@PostMapping("/upload") @PostMapping("/upload")

View File

@ -3,6 +3,7 @@ package com.sky.controller.admin;
import com.sky.common.result.PageResult; import com.sky.common.result.PageResult;
import com.sky.common.result.Result; import com.sky.common.result.Result;
import com.sky.common.utils.RedisUtil;
import com.sky.pojo.dto.DishDTO; import com.sky.pojo.dto.DishDTO;
import com.sky.pojo.dto.DishPageQueryDTO; import com.sky.pojo.dto.DishPageQueryDTO;
import com.sky.pojo.entity.Dish; import com.sky.pojo.entity.Dish;
@ -10,49 +11,45 @@ import com.sky.pojo.vo.DishVO;
import com.sky.service.DishService; import com.sky.service.DishService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Set;
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/admin/dish") @RequestMapping("/admin/dish")
@Api(tags = "菜品相关接口") @Api(tags = "菜品相关接口")
@Slf4j @Slf4j
public class DishController { public class DishController {
@Autowired private final DishService dishService;
DishService dishService;
@Autowired
RedisTemplate redisTemplate;
@PostMapping @PostMapping
@ApiOperation("新增菜品") @ApiOperation("新增菜品")
public Result save(@RequestBody DishDTO dishDTO) { public Result<DishDTO> save(@RequestBody DishDTO dishDTO) {
log.info("新增菜品:{}", dishDTO); log.info("新增菜品:{}", dishDTO);
// 删除redis中缓存 // 删除redis中缓存
cleanCache("dish_" + dishDTO.getCategoryId()); RedisUtil.cleanCache("dish_" + dishDTO.getCategoryId());
dishService.saveWithFlavor(dishDTO); dishService.saveWithFlavor(dishDTO);
return Result.success(); return Result.success();
} }
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("菜品分页查询") @ApiOperation("菜品分页查询")
public Result<PageResult> page(DishPageQueryDTO dishPageQueryDTO) { public Result<PageResult<DishVO>> page(DishPageQueryDTO dishPageQueryDTO) {
log.info("菜品分页查询:{}", dishPageQueryDTO); log.info("菜品分页查询:{}", dishPageQueryDTO);
PageResult pageResult = dishService.pageQuery(dishPageQueryDTO); PageResult<DishVO> pageResult = dishService.pageQuery(dishPageQueryDTO);
return Result.success(pageResult); return Result.success(pageResult);
} }
@DeleteMapping @DeleteMapping
@ApiOperation("菜品批量删除") @ApiOperation("菜品批量删除")
public Result delete(@RequestParam List<Long> ids) { public Result<String> delete(@RequestParam List<Long> ids) {
log.info("菜品批量删除:{}", ids); log.info("菜品批量删除:{}", ids);
dishService.deleteBatch(ids); dishService.deleteBatch(ids);
// 将菜品数据删除 // 将菜品数据删除
cleanCache("dish_*"); RedisUtil.cleanCache("dish_*");
return Result.success(); return Result.success();
} }
@ -66,36 +63,29 @@ public class DishController {
@PutMapping @PutMapping
@ApiOperation("修改菜品") @ApiOperation("修改菜品")
public Result update(@RequestBody DishDTO dto) { public Result<DishDTO> update(@RequestBody DishDTO dto) {
log.info("修改菜品:{}", dto); log.info("修改菜品:{}", dto);
dishService.updateWithFlavor(dto); dishService.updateWithFlavor(dto);
// 将菜品数据删除 // 将菜品数据删除
cleanCache("dish_*"); RedisUtil.cleanCache("dish_*");
return Result.success(); return Result.success();
} }
@PostMapping("status/{status}") @PostMapping("status/{status}")
@ApiOperation("菜品起售、停售") @ApiOperation("菜品起售、停售")
public Result status(@PathVariable Integer status, Long id) { public Result<String> status(@PathVariable Integer status, Long id) {
log.info("菜品起售、停售:{}菜品id{}", status, id); log.info("菜品起售、停售:{}菜品id{}", status, id);
dishService.updateWithStatus(status, id); dishService.updateWithStatus(status, id);
// 将菜品数据删除 // 将菜品数据删除
cleanCache("dish_*"); RedisUtil.cleanCache("dish_*");
return Result.success(); return Result.success();
} }
@GetMapping("list") @GetMapping("list")
@ApiOperation("根据分类id查询菜品") @ApiOperation("根据分类id查询菜品")
public Result list(Long categoryId) { public Result<List<Dish>> list(Long categoryId) {
log.info("根据分类id查询菜品{}", categoryId); log.info("根据分类id查询菜品{}", categoryId);
List<Dish> dishVOList = dishService.getByCategoryId(categoryId); List<Dish> dishVOList = dishService.getByCategoryId(categoryId);
return Result.success(dishVOList); return Result.success(dishVOList);
} }
private void cleanCache(String key) {
Set keys = redisTemplate.keys(key);
if (keys != null) {
redisTemplate.delete(keys);
}
}
} }

View File

@ -28,8 +28,8 @@ public class OrderController {
@GetMapping("/conditionSearch") @GetMapping("/conditionSearch")
@ApiOperation(value = "订单搜索") @ApiOperation(value = "订单搜索")
public Result<PageResult> conditionSearch(OrdersPageQueryDTO dto) { public Result<PageResult<OrderVO>> conditionSearch(OrdersPageQueryDTO dto) {
PageResult pageResult = orderService.conditionSearch(dto); PageResult<OrderVO> pageResult = orderService.conditionSearch(dto);
return Result.success(pageResult); return Result.success(pageResult);
} }
@ -49,35 +49,35 @@ public class OrderController {
@PutMapping("/confirm") @PutMapping("/confirm")
@ApiOperation("接单") @ApiOperation("接单")
public Result confirm(@RequestBody OrdersConfirmDTO dto) { public Result<String> confirm(@RequestBody OrdersConfirmDTO dto) {
orderService.confirm(dto); orderService.confirm(dto);
return Result.success(); return Result.success();
} }
@PutMapping("/rejection") @PutMapping("/rejection")
@ApiOperation("拒单") @ApiOperation("拒单")
public Result rejection(@RequestBody OrdersRejectionDTO dto) { public Result<String> rejection(@RequestBody OrdersRejectionDTO dto) {
orderService.rejection(dto); orderService.rejection(dto);
return Result.success(); return Result.success();
} }
@PutMapping("/cancel") @PutMapping("/cancel")
@ApiOperation("取消订单") @ApiOperation("取消订单")
public Result cancelBusiness(@RequestBody OrdersCancelDTO dto) throws Exception { public Result<String> cancelBusiness(@RequestBody OrdersCancelDTO dto) throws Exception {
orderService.cancelBusiness(dto); orderService.cancelBusiness(dto);
return Result.success(); return Result.success();
} }
@PutMapping("/delivery/{id}") @PutMapping("/delivery/{id}")
@ApiOperation("派送订单") @ApiOperation("派送订单")
public Result delivery(@PathVariable("id") Long id) { public Result<String> delivery(@PathVariable("id") Long id) {
orderService.delivery(id); orderService.delivery(id);
return Result.success(); return Result.success();
} }
@PutMapping("/complete/{id}") @PutMapping("/complete/{id}")
@ApiOperation("完成订单") @ApiOperation("完成订单")
public Result complete(@PathVariable("id") Long id) { public Result<String> complete(@PathVariable("id") Long id) {
orderService.complete(id); orderService.complete(id);
return Result.success(); return Result.success();
} }

View File

@ -8,8 +8,8 @@ import com.sky.pojo.vo.UserReportVO;
import com.sky.service.ReportService; import com.sky.service.ReportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -19,12 +19,12 @@ import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate; import java.time.LocalDate;
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/admin/report") @RequestMapping("/admin/report")
@Slf4j @Slf4j
@Api(tags = "统计报表相关接口") @Api(tags = "统计报表相关接口")
public class ReportController { public class ReportController {
@Autowired private final ReportService reportService;
private ReportService reportService;
@GetMapping("/turnoverStatistics") @GetMapping("/turnoverStatistics")
@ApiOperation(value = "营业额数据统计") @ApiOperation(value = "营业额数据统计")

View File

@ -25,15 +25,15 @@ public class SetMealController {
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页查询") @ApiOperation("分页查询")
public Result page(SetmealPageQueryDTO dto) { public Result<PageResult<SetmealVO>> page(SetmealPageQueryDTO dto) {
log.info("分页查询:{}", dto); log.info("分页查询:{}", dto);
PageResult pageResult = setmealService.pageQuery(dto); PageResult<SetmealVO> pageResult = setmealService.pageQuery(dto);
return Result.success(pageResult); return Result.success(pageResult);
} }
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("根据id查询套餐") @ApiOperation("根据id查询套餐")
public Result page4Id(@PathVariable Long id) { public Result<SetmealVO> page4Id(@PathVariable Long id) {
log.info("根据id查询套餐{}", id); log.info("根据id查询套餐{}", id);
SetmealVO setmealVO = setmealService.page4Id(id); SetmealVO setmealVO = setmealService.page4Id(id);
return Result.success(setmealVO); return Result.success(setmealVO);
@ -42,7 +42,7 @@ public class SetMealController {
@PutMapping() @PutMapping()
@ApiOperation("修改套餐") @ApiOperation("修改套餐")
@CacheEvict(cacheNames = "setmealCache", allEntries = true) @CacheEvict(cacheNames = "setmealCache", allEntries = true)
public Result update(@RequestBody SetmealDTO setmealDTO) { public Result<String> update(@RequestBody SetmealDTO setmealDTO) {
log.info("修改套餐:{}", setmealDTO); log.info("修改套餐:{}", setmealDTO);
setmealService.update(setmealDTO); setmealService.update(setmealDTO);
return Result.success(); return Result.success();
@ -51,7 +51,7 @@ public class SetMealController {
@PostMapping("") @PostMapping("")
@ApiOperation("新增套餐") @ApiOperation("新增套餐")
@CacheEvict(cacheNames = "setmealCache", key = "#setmealDTO.categoryId") @CacheEvict(cacheNames = "setmealCache", key = "#setmealDTO.categoryId")
public Result setmeal(@RequestBody SetmealDTO setmealDTO) { public Result<String> setmeal(@RequestBody SetmealDTO setmealDTO) {
log.info("新增套餐:{}", setmealDTO); log.info("新增套餐:{}", setmealDTO);
setmealService.insert(setmealDTO); setmealService.insert(setmealDTO);
return Result.success(); return Result.success();
@ -60,7 +60,7 @@ public class SetMealController {
@PostMapping("status/{status}") @PostMapping("status/{status}")
@ApiOperation("套餐起售、停售") @ApiOperation("套餐起售、停售")
@CacheEvict(cacheNames = "setmealCache", allEntries = true) @CacheEvict(cacheNames = "setmealCache", allEntries = true)
public Result updateStatus(@PathVariable Integer status, Long id) { public Result<String> updateStatus(@PathVariable Integer status, Long id) {
log.info("套餐起售、停售,状态:{}id{}", status, id); log.info("套餐起售、停售,状态:{}id{}", status, id);
setmealService.updateStatus(status, id); setmealService.updateStatus(status, id);
return Result.success(); return Result.success();
@ -69,7 +69,7 @@ public class SetMealController {
@DeleteMapping("") @DeleteMapping("")
@ApiOperation("批量删除套餐") @ApiOperation("批量删除套餐")
@CacheEvict(cacheNames = "setmealCache", allEntries = true) @CacheEvict(cacheNames = "setmealCache", allEntries = true)
public Result delete(@RequestParam List<Long> ids) { public Result<String> delete(@RequestParam List<Long> ids) {
log.info("批量删除套餐:{}", ids); log.info("批量删除套餐:{}", ids);
setmealService.delete(ids); setmealService.delete(ids);
return Result.success(); return Result.success();

View File

@ -4,23 +4,23 @@ import com.sky.common.constant.MessageConstant;
import com.sky.common.result.Result; import com.sky.common.result.Result;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController("adminShopController") @RestController("adminShopController")
@RequiredArgsConstructor
@RequestMapping("/admin/shop") @RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口") @Api(tags = "店铺相关接口")
@Slf4j @Slf4j
public class ShopController { public class ShopController {
public static final String KEY = "SHOP_STATUS"; public static final String KEY = "SHOP_STATUS";
@Autowired private final RedisTemplate<Object, Object> redisTemplate;
private RedisTemplate redisTemplate;
@PutMapping("/{status}") @PutMapping("/{status}")
@ApiOperation("设置店铺的营业状态") @ApiOperation("设置店铺的营业状态")
public Result setStatus(@PathVariable Integer status) { public Result<String> setStatus(@PathVariable Integer status) {
log.info("设置店铺的营业状态为:{}", status == 1 ? "营业中" : "打烊中"); log.info("设置店铺的营业状态为:{}", status == 1 ? "营业中" : "打烊中");
redisTemplate.opsForValue().set(KEY, status); redisTemplate.opsForValue().set(KEY, status);
return Result.success(); return Result.success();

View File

@ -8,8 +8,8 @@ import com.sky.pojo.vo.SetmealOverViewVO;
import com.sky.service.WorkspaceService; import com.sky.service.WorkspaceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -21,19 +21,14 @@ import java.time.LocalTime;
* 工作台 * 工作台
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/admin/workspace") @RequestMapping("/admin/workspace")
@Slf4j @Slf4j
@Api(tags = "工作台相关接口") @Api(tags = "工作台相关接口")
public class WorkSpaceController { public class WorkSpaceController {
@Autowired private final WorkspaceService workspaceService;
private WorkspaceService workspaceService;
/**
* 工作台今日数据查询
*
* @return
*/
@GetMapping("/businessData") @GetMapping("/businessData")
@ApiOperation("工作台今日数据查询") @ApiOperation("工作台今日数据查询")
public Result<BusinessDataVO> businessData() { public Result<BusinessDataVO> businessData() {
@ -46,33 +41,18 @@ public class WorkSpaceController {
return Result.success(businessDataVO); return Result.success(businessDataVO);
} }
/**
* 查询订单管理数据
*
* @return
*/
@GetMapping("/overviewOrders") @GetMapping("/overviewOrders")
@ApiOperation("查询订单管理数据") @ApiOperation("查询订单管理数据")
public Result<OrderOverViewVO> orderOverView() { public Result<OrderOverViewVO> orderOverView() {
return Result.success(workspaceService.getOrderOverView()); return Result.success(workspaceService.getOrderOverView());
} }
/**
* 查询菜品总览
*
* @return
*/
@GetMapping("/overviewDishes") @GetMapping("/overviewDishes")
@ApiOperation("查询菜品总览") @ApiOperation("查询菜品总览")
public Result<DishOverViewVO> dishOverView() { public Result<DishOverViewVO> dishOverView() {
return Result.success(workspaceService.getDishOverView()); return Result.success(workspaceService.getDishOverView());
} }
/**
* 查询套餐总览
*
* @return
*/
@GetMapping("/overviewSetmeals") @GetMapping("/overviewSetmeals")
@ApiOperation("查询套餐总览") @ApiOperation("查询套餐总览")
public Result<SetmealOverViewVO> setmealOverView() { public Result<SetmealOverViewVO> setmealOverView() {

View File

@ -7,9 +7,9 @@ import com.sky.common.properties.WeChatProperties;
import com.sky.service.OrderService; import com.sky.service.OrderService;
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -24,13 +24,12 @@ import java.util.UUID;
* 支付回调相关接口 * 支付回调相关接口
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/notify") @RequestMapping("/notify")
@Slf4j @Slf4j
public class PayNotifyController { public class PayNotifyController {
@Autowired private final OrderService orderService;
private OrderService orderService; private final WeChatProperties weChatProperties;
@Autowired
private WeChatProperties weChatProperties;
/** /**
* 支付成功回调 * 支付成功回调

View File

@ -6,18 +6,17 @@ import com.sky.pojo.entity.AddressBook;
import com.sky.service.AddressBookService; import com.sky.service.AddressBookService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/user/addressBook") @RequestMapping("/user/addressBook")
@Api(tags = "C端地址簿接口") @Api(tags = "C端地址簿接口")
public class AddressBookController { public class AddressBookController {
private final AddressBookService addressBookService;
@Autowired
private AddressBookService addressBookService;
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询当前登录用户的所有地址信息") @ApiOperation("查询当前登录用户的所有地址信息")

View File

@ -5,7 +5,7 @@ import com.sky.pojo.entity.Category;
import com.sky.service.CategoryService; import com.sky.service.CategoryService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -13,12 +13,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController("userCategoryController") @RestController("userCategoryController")
@RequiredArgsConstructor
@RequestMapping("/user/category") @RequestMapping("/user/category")
@Api(tags = "C端-分类接口") @Api(tags = "C端-分类接口")
public class CategoryController { public class CategoryController {
private final CategoryService categoryService;
@Autowired
private CategoryService categoryService;
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询分类") @ApiOperation("查询分类")

View File

@ -8,8 +8,8 @@ import com.sky.pojo.vo.DishVO;
import com.sky.service.DishService; import com.sky.service.DishService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -19,13 +19,12 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@RestController("userDishController") @RestController("userDishController")
@RequiredArgsConstructor
@RequestMapping("/user/dish") @RequestMapping("/user/dish")
@Slf4j @Slf4j
@Api(tags = "C端-菜品浏览接口") @Api(tags = "C端-菜品浏览接口")
public class DishController { public class DishController {
@Autowired private final RedisTemplate<Object, Object> redisTemplate;
RedisTemplate redisTemplate;
@Autowired
DishService dishService; DishService dishService;
@GetMapping("/list") @GetMapping("/list")

View File

@ -10,20 +10,20 @@ import com.sky.pojo.vo.OrderVO;
import com.sky.service.OrderService; import com.sky.service.OrderService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
/** /**
* 订单 * 订单
*/ */
@RestController("userOrderController") @RestController("userOrderController")
@RequiredArgsConstructor
@RequestMapping("/user/order") @RequestMapping("/user/order")
@Slf4j @Slf4j
@Api(tags = "C端订单接口") @Api(tags = "C端订单接口")
public class OrderController { public class OrderController {
@Autowired private final OrderService orderService;
private OrderService orderService;
@PostMapping("/submit") @PostMapping("/submit")
@ApiOperation("用户下单") @ApiOperation("用户下单")

View File

@ -7,7 +7,7 @@ import com.sky.pojo.vo.DishItemVO;
import com.sky.service.SetmealService; import com.sky.service.SetmealService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -17,11 +17,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController("userSetmealController") @RestController("userSetmealController")
@RequiredArgsConstructor
@RequestMapping("/user/setmeal") @RequestMapping("/user/setmeal")
@Api(tags = "C端-套餐浏览接口") @Api(tags = "C端-套餐浏览接口")
public class SetmealController { public class SetmealController {
@Autowired private final SetmealService setmealService;
private SetmealService setmealService;
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("根据分类id查询套餐") @ApiOperation("根据分类id查询套餐")

View File

@ -45,5 +45,4 @@ public interface AddressBookMapper {
*/ */
@Delete("delete from address_book where id = #{id}") @Delete("delete from address_book where id = #{id}")
void deleteById(Long id); void deleteById(Long id);
} }

View File

@ -18,7 +18,7 @@ public interface CategoryService {
/** /**
* 分页查询 * 分页查询
*/ */
PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO); PageResult<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);
/** /**
* 根据id删除分类 * 根据id删除分类

View File

@ -23,7 +23,7 @@ public interface DishService {
* @param dishPageQueryDTO 菜品分页查询-前端参数 * @param dishPageQueryDTO 菜品分页查询-前端参数
* @return 封装分页查询结果 * @return 封装分页查询结果
*/ */
PageResult pageQuery(DishPageQueryDTO dishPageQueryDTO); PageResult<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);
/** /**
* 菜品批量删除 * 菜品批量删除

View File

@ -86,7 +86,7 @@ public interface OrderService {
* @param dto 订单详情 * @param dto 订单详情
* @return 分页数据 * @return 分页数据
*/ */
PageResult conditionSearch(OrdersPageQueryDTO dto); PageResult<OrderVO> conditionSearch(OrdersPageQueryDTO dto);
/** /**
* 各个状态的订单数量统计 * 各个状态的订单数量统计

View File

@ -17,7 +17,7 @@ public interface SetmealService {
* @param dto 前端请求 * @param dto 前端请求
* @return PageResult * @return PageResult
*/ */
PageResult pageQuery(SetmealPageQueryDTO dto); PageResult<SetmealVO> pageQuery(SetmealPageQueryDTO dto);
/** /**
* 根据id查询套餐 * 根据id查询套餐

View File

@ -14,9 +14,9 @@ import com.sky.pojo.dto.CategoryDTO;
import com.sky.pojo.dto.CategoryPageQueryDTO; import com.sky.pojo.dto.CategoryPageQueryDTO;
import com.sky.pojo.entity.Category; import com.sky.pojo.entity.Category;
import com.sky.service.CategoryService; import com.sky.service.CategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -26,14 +26,12 @@ import java.util.List;
* 分类业务层 * 分类业务层
*/ */
@Service @Service
@RequiredArgsConstructor
@Slf4j @Slf4j
public class CategoryServiceImpl implements CategoryService { public class CategoryServiceImpl implements CategoryService {
@Autowired private final CategoryMapper categoryMapper;
private CategoryMapper categoryMapper; private final DishMapper dishMapper;
@Autowired private final SetmealMapper setmealMapper;
private DishMapper dishMapper;
@Autowired
private SetmealMapper setmealMapper;
/** /**
* 新增分类 * 新增分类
@ -42,21 +40,19 @@ public class CategoryServiceImpl implements CategoryService {
Category category = new Category(); Category category = new Category();
// 属性拷贝 // 属性拷贝
BeanUtils.copyProperties(categoryDTO, category); BeanUtils.copyProperties(categoryDTO, category);
// 分类状态默认为禁用状态0 // 分类状态默认为禁用状态0
category.setStatus(StatusConstant.DISABLE); category.setStatus(StatusConstant.DISABLE);
categoryMapper.insert(category); categoryMapper.insert(category);
} }
/** /**
* 分页查询 * 分页查询
*/ */
public PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO) { public PageResult<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO) {
PageHelper.startPage(categoryPageQueryDTO.getPage(), categoryPageQueryDTO.getPageSize()); PageHelper.startPage(categoryPageQueryDTO.getPage(), categoryPageQueryDTO.getPageSize());
// 下一条sql进行分页自动加入limit关键字分页 // 下一条sql进行分页自动加入limit关键字分页
Page<Category> page = categoryMapper.pageQuery(categoryPageQueryDTO); Page<Category> page = categoryMapper.pageQuery(categoryPageQueryDTO);
return new PageResult(page.getTotal(), page.getResult()); return new PageResult<>(page.getTotal(), page.getResult());
} }
/** /**

View File

@ -17,9 +17,9 @@ import com.sky.pojo.entity.DishFlavor;
import com.sky.pojo.entity.Setmeal; import com.sky.pojo.entity.Setmeal;
import com.sky.pojo.vo.DishVO; import com.sky.pojo.vo.DishVO;
import com.sky.service.DishService; import com.sky.service.DishService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -28,16 +28,13 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Service @Service
@RequiredArgsConstructor
@Slf4j @Slf4j
public class DishServiceImpl implements DishService { public class DishServiceImpl implements DishService {
@Autowired private final DishMapper dishMapper;
DishMapper dishMapper; private final DishFlavorMapper dishFlavorMapper;
@Autowired private final SetMealDishMapper setMealDishMapper;
DishFlavorMapper dishFlavorMapper; private final SetmealMapper setmealMapper;
@Autowired
SetMealDishMapper setMealDishMapper;
@Autowired
SetmealMapper setmealMapper;
/** /**
@ -70,10 +67,10 @@ public class DishServiceImpl implements DishService {
* @return 封装分页查询结果 * @return 封装分页查询结果
*/ */
@Override @Override
public PageResult pageQuery(DishPageQueryDTO dto) { public PageResult<DishVO> pageQuery(DishPageQueryDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getPageSize()); PageHelper.startPage(dto.getPage(), dto.getPageSize());
Page<DishVO> page = dishMapper.pageQuery(dto); Page<DishVO> page = dishMapper.pageQuery(dto);
return new PageResult(page.getTotal(), page.getResult()); return new PageResult<>(page.getTotal(), page.getResult());
} }
/** /**

View File

@ -174,7 +174,7 @@ public class OrderServiceImpl implements OrderService {
orderMapper.update(orders); orderMapper.update(orders);
// 通过客户端浏览器推送消息 // 通过客户端浏览器推送消息
HashMap map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("type", 1);// 1 来单提醒 2 客户催单 map.put("type", 1);// 1 来单提醒 2 客户催单
map.put("orderId", ordersDB.getId()); map.put("orderId", ordersDB.getId());
map.put("content", "订单号" + outTradeNo); map.put("content", "订单号" + outTradeNo);
@ -199,7 +199,7 @@ public class OrderServiceImpl implements OrderService {
ordersPageQueryDTO.setUserId(BaseContext.getUserId()); ordersPageQueryDTO.setUserId(BaseContext.getUserId());
// 分页条件查询 // 分页条件查询
Page<Orders> page = orderMapper.pageQuery(ordersPageQueryDTO); Page<Orders> page = orderMapper.pageQuery(ordersPageQueryDTO);
List<OrderVO> list = new ArrayList(); List<OrderVO> list = new ArrayList<>();
// 查询出订单明细并封装入OrderVO进行响应 // 查询出订单明细并封装入OrderVO进行响应
if (page != null && page.getTotal() > 0) { if (page != null && page.getTotal() > 0) {
@ -216,7 +216,7 @@ public class OrderServiceImpl implements OrderService {
list.add(orderVO); list.add(orderVO);
} }
} }
return new PageResult(page.getTotal(), list); return new PageResult<>(page.getTotal(), list);
} }
@ -346,12 +346,12 @@ public class OrderServiceImpl implements OrderService {
* @return 分页数据 * @return 分页数据
*/ */
@Override @Override
public PageResult conditionSearch(OrdersPageQueryDTO dto) { public PageResult<OrderVO> conditionSearch(OrdersPageQueryDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getPageSize()); PageHelper.startPage(dto.getPage(), dto.getPageSize());
Page<Orders> page = orderMapper.pageQuery(dto); Page<Orders> page = orderMapper.pageQuery(dto);
// 部分订单状态需要额外返回订单菜品信息将Orders转化为OrderVO // 部分订单状态需要额外返回订单菜品信息将Orders转化为OrderVO
List<OrderVO> orderVOList = orderServiceImplUtils.getOrderVOList(page); List<OrderVO> orderVOList = orderServiceImplUtils.getOrderVOList(page);
return new PageResult(page.getTotal(), orderVOList); return new PageResult<>(page.getTotal(), orderVOList);
} }
/** /**

View File

@ -41,13 +41,13 @@ public class SetmealServiceImpl implements SetmealService {
* @return PageResult * @return PageResult
*/ */
@Override @Override
public PageResult pageQuery(SetmealPageQueryDTO dto) { public PageResult<SetmealVO> pageQuery(SetmealPageQueryDTO dto) {
int pageSize = dto.getPageSize(); int pageSize = dto.getPageSize();
int page = dto.getPage(); int page = dto.getPage();
PageHelper.startPage(page, pageSize); PageHelper.startPage(page, pageSize);
Page<SetmealVO> setmealVOPage = setmealMapper.pageQuery(dto); Page<SetmealVO> setmealVOPage = setmealMapper.pageQuery(dto);
return new PageResult(setmealVOPage.getTotal(), setmealVOPage.getResult()); return new PageResult<>(setmealVOPage.getTotal(), setmealVOPage.getResult());
} }
/** /**

View File

@ -0,0 +1,16 @@
-----------------▄██-█▄---------
-----------------███▄██▄--------
-----------------███████--------
-----------------▀███████-------
-------------------██████▄▄-----
-------------------█████████▄---
-------------------██████▄████--
-------▄███████████████████████-
-----▄███████████████████████▀--
---▄██████████████████████------
---███████████████████████------
---███████████████████████------
-▄▄██████████████████████▀------
-█████████████████▀█████--------
-▀██████████████▀▀-▀█████▄------
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------

View File

@ -140,6 +140,7 @@
from orders from orders
where id = #{id}; where id = #{id};
</select> </select>
<select id="countStatus" resultType="java.lang.Integer"> <select id="countStatus" resultType="java.lang.Integer">
select count(*) select count(*)
from orders from orders