feat: 初始化后端项目基础架构
添加项目基础配置文件和目录结构 实现用户、角色、权限等核心模块的实体类、Mapper接口和服务层 配置数据库连接和MyBatis-Plus支持 添加统一响应格式和异常处理机制
This commit is contained in:
15
src/main/java/com/qf/backend/BackendApplication.java
Normal file
15
src/main/java/com/qf/backend/BackendApplication.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.qf.backend;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.qf.backend.mapper")
|
||||
public class BackendApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BackendApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
98
src/main/java/com/qf/backend/common/Result.java
Normal file
98
src/main/java/com/qf/backend/common/Result.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.qf.backend.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一响应格式
|
||||
* 根据项目文档6.2节统一响应格式定义
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 状态信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 构造私有方法
|
||||
*/
|
||||
private Result() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 成功响应(无数据)
|
||||
*/
|
||||
public static <T> Result<T> success() {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(200);
|
||||
result.setMessage("success");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功响应(有数据)
|
||||
*/
|
||||
public static <T> Result<T> success(T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(200);
|
||||
result.setMessage("success");
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应
|
||||
*/
|
||||
public static <T> Result<T> fail(int code, String message) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应(带数据)
|
||||
*/
|
||||
public static <T> Result<T> fail(int code, String message, T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
// getters setters
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
87
src/main/java/com/qf/backend/common/ResultUtils.java
Normal file
87
src/main/java/com/qf/backend/common/ResultUtils.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.qf.backend.common;
|
||||
|
||||
import com.qf.backend.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* 响应结果工具类
|
||||
* 提供各种响应结果的快速创建方法
|
||||
*/
|
||||
public class ResultUtils {
|
||||
|
||||
/**
|
||||
* 成功响应(无数据)
|
||||
*/
|
||||
public static <T> Result<T> success() {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功响应(有数据)
|
||||
*/
|
||||
public static <T> Result<T> success(T data) {
|
||||
return Result.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应(使用错误码)
|
||||
*/
|
||||
public static <T> Result<T> fail(ErrorCode errorCode) {
|
||||
return Result.fail(errorCode.getCode(), errorCode.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应(使用错误码和自定义消息)
|
||||
*/
|
||||
public static <T> Result<T> fail(ErrorCode errorCode, String message) {
|
||||
return Result.fail(errorCode.getCode(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应(使用错误码和数据)
|
||||
*/
|
||||
public static <T> Result<T> fail(ErrorCode errorCode, T data) {
|
||||
return Result.fail(errorCode.getCode(), errorCode.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应(自定义状态码和消息)
|
||||
*/
|
||||
public static <T> Result<T> fail(int code, String message) {
|
||||
return Result.fail(code, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数错误响应
|
||||
*/
|
||||
public static <T> Result<T> paramError(String message) {
|
||||
return Result.fail(ErrorCode.PARAM_ERROR.getCode(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未授权响应
|
||||
*/
|
||||
public static <T> Result<T> unauthorized() {
|
||||
return Result.fail(ErrorCode.UNAUTHORIZED.getCode(), ErrorCode.UNAUTHORIZED.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止访问响应
|
||||
*/
|
||||
public static <T> Result<T> forbidden() {
|
||||
return Result.fail(ErrorCode.FORBIDDEN.getCode(), ErrorCode.FORBIDDEN.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源不存在响应
|
||||
*/
|
||||
public static <T> Result<T> notFound(String message) {
|
||||
return Result.fail(ErrorCode.NOT_FOUND.getCode(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务器错误响应
|
||||
*/
|
||||
public static <T> Result<T> serverError() {
|
||||
return Result.fail(ErrorCode.SYSTEM_ERROR.getCode(), ErrorCode.SYSTEM_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
34
src/main/java/com/qf/backend/entity/OrderItems.java
Normal file
34
src/main/java/com/qf/backend/entity/OrderItems.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单商品项表
|
||||
*/
|
||||
@Data
|
||||
@TableName("order_items")
|
||||
public class OrderItems {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long orderId;
|
||||
private Long productId;
|
||||
private Long skuId;
|
||||
private String productName;
|
||||
private String skuSpecs;
|
||||
private String productImage;
|
||||
private BigDecimal price;
|
||||
private Integer quantity;
|
||||
private BigDecimal subtotal;
|
||||
private Integer itemStatus; // 0: 正常, 1: 已退款, 2: 退款中
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
26
src/main/java/com/qf/backend/entity/OrderStatusHistory.java
Normal file
26
src/main/java/com/qf/backend/entity/OrderStatusHistory.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单状态历史表
|
||||
*/
|
||||
@Data
|
||||
@TableName("order_status_history")
|
||||
public class OrderStatusHistory {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long orderId;
|
||||
private Integer previousStatus;
|
||||
private Integer currentStatus;
|
||||
private String changeReason;
|
||||
private String operator;
|
||||
private Date changeTime;
|
||||
private Date createdAt;
|
||||
}
|
||||
40
src/main/java/com/qf/backend/entity/Orders.java
Normal file
40
src/main/java/com/qf/backend/entity/Orders.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单主表
|
||||
*/
|
||||
@Data
|
||||
@TableName("orders")
|
||||
public class Orders {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String orderNo;
|
||||
private Long userId;
|
||||
private Long shopId;
|
||||
private BigDecimal totalAmount;
|
||||
private BigDecimal actualAmount;
|
||||
private BigDecimal shippingFee;
|
||||
private Integer orderStatus; // 0: 待付款, 1: 待发货, 2: 待收货, 3: 已完成, 4: 已取消, 5: 已退款
|
||||
private String shippingAddress;
|
||||
private String receiverName;
|
||||
private String receiverPhone;
|
||||
private String paymentMethod; // 支付方式
|
||||
private Date paymentTime;
|
||||
private Date shippingTime;
|
||||
private Date deliveryTime;
|
||||
private Date completeTime;
|
||||
private String remark;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
32
src/main/java/com/qf/backend/entity/Payments.java
Normal file
32
src/main/java/com/qf/backend/entity/Payments.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("payments")
|
||||
public class Payments {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String paymentNo;
|
||||
private Long orderId;
|
||||
private Long userId;
|
||||
private BigDecimal amount;
|
||||
private String paymentMethod; // 支付方式
|
||||
private String transactionId; // 第三方交易流水号
|
||||
private Integer paymentStatus; // 0: 待支付, 1: 支付成功, 2: 支付失败, 3: 已退款
|
||||
private String paymentUrl; // 支付链接
|
||||
private Date expireTime;
|
||||
private Date paymentTime;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
26
src/main/java/com/qf/backend/entity/Permissions.java
Normal file
26
src/main/java/com/qf/backend/entity/Permissions.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 权限信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("permissions")
|
||||
public class Permissions {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String permissionName;
|
||||
private String permissionCode;
|
||||
private String description;
|
||||
private String module;
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品属性值表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_attribute_values")
|
||||
public class ProductAttributeValues {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long productId;
|
||||
private Long attributeId;
|
||||
private String attributeValue;
|
||||
private Integer sort;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
25
src/main/java/com/qf/backend/entity/ProductAttributes.java
Normal file
25
src/main/java/com/qf/backend/entity/ProductAttributes.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品属性表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_attributes")
|
||||
public class ProductAttributes {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String attributeName;
|
||||
private Long categoryId;
|
||||
private Integer attributeType; // 0: 规格属性, 1: 销售属性
|
||||
private Integer sort;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
28
src/main/java/com/qf/backend/entity/ProductCategories.java
Normal file
28
src/main/java/com/qf/backend/entity/ProductCategories.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品分类表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_categories")
|
||||
public class ProductCategories {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String categoryName;
|
||||
private Long parentId; // 父分类ID,顶级分类为0
|
||||
private Integer level; // 分类级别:1、2、3
|
||||
private String icon;
|
||||
private String banner;
|
||||
private Integer sort;
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
24
src/main/java/com/qf/backend/entity/ProductImages.java
Normal file
24
src/main/java/com/qf/backend/entity/ProductImages.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品图片表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_images")
|
||||
public class ProductImages {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long productId;
|
||||
private String imageUrl;
|
||||
private Integer sort;
|
||||
private Integer isMain; // 0: 非主图, 1: 主图
|
||||
private Date createdAt;
|
||||
}
|
||||
28
src/main/java/com/qf/backend/entity/ProductInventories.java
Normal file
28
src/main/java/com/qf/backend/entity/ProductInventories.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 库存信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_inventories")
|
||||
public class ProductInventories {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long skuId;
|
||||
private Integer currentStock;
|
||||
private Integer safetyStock;
|
||||
private Integer lockStock; // 锁定库存
|
||||
private Date lastUpdateTime;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
31
src/main/java/com/qf/backend/entity/ProductSkus.java
Normal file
31
src/main/java/com/qf/backend/entity/ProductSkus.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品SKU表
|
||||
*/
|
||||
@Data
|
||||
@TableName("product_skus")
|
||||
public class ProductSkus {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long productId;
|
||||
private String skuCode;
|
||||
private String skuSpecs; // SKU规格信息,JSON格式存储
|
||||
private BigDecimal price;
|
||||
private Integer stock;
|
||||
private String image;
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
32
src/main/java/com/qf/backend/entity/Products.java
Normal file
32
src/main/java/com/qf/backend/entity/Products.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品基本信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("products")
|
||||
public class Products {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String productName;
|
||||
private Long shopId;
|
||||
private Long categoryId;
|
||||
private String description;
|
||||
private BigDecimal originalPrice;
|
||||
private BigDecimal currentPrice;
|
||||
private Integer salesVolume;
|
||||
private Integer status; // 0: 下架, 1: 上架
|
||||
private String mainImage;
|
||||
private Integer isDeleted; // 0: 未删除, 1: 已删除
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
36
src/main/java/com/qf/backend/entity/Refunds.java
Normal file
36
src/main/java/com/qf/backend/entity/Refunds.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 退款信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("refunds")
|
||||
public class Refunds {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String refundNo;
|
||||
private Long orderId;
|
||||
private Long orderItemId;
|
||||
private Long userId;
|
||||
private Long shopId;
|
||||
private BigDecimal refundAmount;
|
||||
private String refundReason;
|
||||
private String refundType; // 退款类型
|
||||
private Integer refundStatus; // 0: 申请中, 1: 退款成功, 2: 退款失败, 3: 已拒绝
|
||||
private String refundAccount;
|
||||
private String transactionId;
|
||||
private Date applyTime;
|
||||
private Date processTime;
|
||||
private String processRemark;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
22
src/main/java/com/qf/backend/entity/RolePermissions.java
Normal file
22
src/main/java/com/qf/backend/entity/RolePermissions.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-权限关联表
|
||||
*/
|
||||
@Data
|
||||
@TableName("role_permissions")
|
||||
public class RolePermissions {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long roleId;
|
||||
private Long permissionId;
|
||||
private Date createdAt;
|
||||
}
|
||||
25
src/main/java/com/qf/backend/entity/Roles.java
Normal file
25
src/main/java/com/qf/backend/entity/Roles.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("roles")
|
||||
public class Roles {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String roleName;
|
||||
private String description;
|
||||
private Integer roleType; // 0: 默认用户, 1: 店主, 2: 管理员
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
27
src/main/java/com/qf/backend/entity/ShopCategories.java
Normal file
27
src/main/java/com/qf/backend/entity/ShopCategories.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺分类表
|
||||
*/
|
||||
@Data
|
||||
@TableName("shop_categories")
|
||||
public class ShopCategories {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String categoryName;
|
||||
private Long parentId; // 父分类ID,顶级分类为0
|
||||
private Integer level; // 分类级别
|
||||
private String icon;
|
||||
private Integer sort;
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
28
src/main/java/com/qf/backend/entity/ShopRatings.java
Normal file
28
src/main/java/com/qf/backend/entity/ShopRatings.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺评分表
|
||||
*/
|
||||
@Data
|
||||
@TableName("shop_ratings")
|
||||
public class ShopRatings {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
private Long userId;
|
||||
private Long orderId;
|
||||
private Integer rating; // 评分:1-5星
|
||||
private String content;
|
||||
private String images; // 评价图片,JSON格式存储
|
||||
private Integer status; // 0: 待审核, 1: 已审核, 2: 已删除
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
37
src/main/java/com/qf/backend/entity/Shops.java
Normal file
37
src/main/java/com/qf/backend/entity/Shops.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("shops")
|
||||
public class Shops {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String shopName;
|
||||
private Long userId; // 店主用户ID
|
||||
private Long categoryId;
|
||||
private String shopLogo;
|
||||
private String coverImage;
|
||||
private String description;
|
||||
private String address;
|
||||
private String contactPhone;
|
||||
private String contactPerson;
|
||||
private BigDecimal rating; // 店铺评分
|
||||
private Integer salesVolume;
|
||||
private Integer status; // 0: 未审核, 1: 已审核, 2: 已关闭, 3: 审核失败
|
||||
private String businessLicense;
|
||||
private Date businessStartTime;
|
||||
private Date businessEndTime;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
30
src/main/java/com/qf/backend/entity/UserDetails.java
Normal file
30
src/main/java/com/qf/backend/entity/UserDetails.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户详细信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("user_details")
|
||||
public class UserDetails {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
private String realName;
|
||||
private String idCard;
|
||||
private String gender; //男、女、保密
|
||||
private Date birthday;
|
||||
private String address;
|
||||
private String province;
|
||||
private String city;
|
||||
private String district;
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
22
src/main/java/com/qf/backend/entity/UserRoles.java
Normal file
22
src/main/java/com/qf/backend/entity/UserRoles.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户-角色关联表
|
||||
*/
|
||||
@Data
|
||||
@TableName("user_roles")
|
||||
public class UserRoles {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
private Long roleId;
|
||||
private Date createdAt;
|
||||
}
|
||||
29
src/main/java/com/qf/backend/entity/Users.java
Normal file
29
src/main/java/com/qf/backend/entity/Users.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户基本信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("users")
|
||||
public class Users {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String email;
|
||||
private String phone;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private Integer status; // 0: 禁用, 1: 启用
|
||||
private Date createdAt;
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.qf.backend.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务异常类 用于封装业务逻辑中产生的异常
|
||||
*/
|
||||
@Getter
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
private final Object data;
|
||||
|
||||
/**
|
||||
* 使用错误码构造业务异常
|
||||
*
|
||||
* @param errorCode 错误码枚举
|
||||
*/
|
||||
public BusinessException(ErrorCode errorCode) {
|
||||
super(errorCode.getMessage());
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage();
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用错误码和自定义消息构造业务异常
|
||||
*
|
||||
* @param errorCode 错误码枚举
|
||||
* @param message 自定义错误消息
|
||||
*/
|
||||
public BusinessException(ErrorCode errorCode, String message) {
|
||||
super(message);
|
||||
this.code = errorCode.getCode();
|
||||
this.message = message;
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用错误码和附加数据构造业务异常
|
||||
*
|
||||
* @param errorCode 错误码枚举
|
||||
* @param data 附加数据
|
||||
*/
|
||||
public BusinessException(ErrorCode errorCode, Object data) {
|
||||
super(errorCode.getMessage());
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用错误码、自定义消息和附加数据构造业务异常
|
||||
*
|
||||
* @param errorCode 错误码枚举
|
||||
* @param message 自定义错误消息
|
||||
* @param data 附加数据
|
||||
*/
|
||||
public BusinessException(ErrorCode errorCode, String message, Object data) {
|
||||
super(message);
|
||||
this.code = errorCode.getCode();
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用错误码、自定义消息和原始异常构造业务异常
|
||||
*
|
||||
* @param errorCode 错误码枚举
|
||||
* @param message 自定义错误消息
|
||||
* @param cause 原始异常
|
||||
*/
|
||||
public BusinessException(ErrorCode errorCode, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = errorCode.getCode();
|
||||
this.message = message;
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
}
|
||||
55
src/main/java/com/qf/backend/exception/ErrorCode.java
Normal file
55
src/main/java/com/qf/backend/exception/ErrorCode.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.qf.backend.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 错误码定义
|
||||
* 根据项目文档6.3节状态码定义进行扩展
|
||||
*/
|
||||
@Getter
|
||||
public enum ErrorCode {
|
||||
// 成功状态码
|
||||
SUCCESS(200, "success"),
|
||||
|
||||
// 参数错误
|
||||
PARAM_ERROR(400, "请求参数错误"),
|
||||
MISSING_PARAM(4001, "缺少必要参数"),
|
||||
INVALID_PARAM(4002, "无效的参数值"),
|
||||
|
||||
// 认证授权错误
|
||||
UNAUTHORIZED(401, "未授权访问"),
|
||||
INVALID_TOKEN(4011, "无效的令牌"),
|
||||
TOKEN_EXPIRED(4012, "令牌已过期"),
|
||||
|
||||
// 权限错误
|
||||
FORBIDDEN(403, "禁止访问"),
|
||||
PERMISSION_DENIED(4031, "权限不足"),
|
||||
|
||||
// 资源错误
|
||||
NOT_FOUND(404, "资源不存在"),
|
||||
USER_NOT_FOUND(4041, "用户不存在"),
|
||||
PRODUCT_NOT_FOUND(4042, "商品不存在"),
|
||||
ORDER_NOT_FOUND(4043, "订单不存在"),
|
||||
SHOP_NOT_FOUND(4044, "店铺不存在"),
|
||||
|
||||
// 业务错误
|
||||
BUSINESS_ERROR(409, "业务逻辑错误"),
|
||||
USER_EXISTED(4091, "用户已存在"),
|
||||
PRODUCT_OFF_SHELF(4092, "商品已下架"),
|
||||
INSUFFICIENT_STOCK(4093, "库存不足"),
|
||||
ORDER_CANCELLED(4094, "订单已取消"),
|
||||
|
||||
// 服务器错误
|
||||
SYSTEM_ERROR(500, "服务器内部错误"),
|
||||
DATABASE_ERROR(5001, "数据库操作错误"),
|
||||
NETWORK_ERROR(5002, "网络请求错误"),
|
||||
UNKNOWN_ERROR(5003, "未知错误");
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
ErrorCode(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.qf.backend.exception;
|
||||
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.common.ResultUtils;
|
||||
|
||||
/**
|
||||
* 异常处理使用示例
|
||||
* 演示如何在业务代码中使用异常处理相关类
|
||||
*/
|
||||
public class ExceptionUsageExample {
|
||||
|
||||
/**
|
||||
* 示例1:抛出业务异常
|
||||
*/
|
||||
public void throwBusinessExceptionExample(Long userId) {
|
||||
// 业务逻辑判断
|
||||
if (userId == null || userId <= 0) {
|
||||
// 使用预定义错误码抛出业务异常
|
||||
throw new BusinessException(ErrorCode.PARAM_ERROR, "用户ID无效");
|
||||
}
|
||||
|
||||
// 模拟用户不存在的场景
|
||||
boolean userExists = false; // 假设从数据库查询
|
||||
if (!userExists) {
|
||||
throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 抛出带附加数据的异常
|
||||
Object additionalData = new Object(); // 可以是任何附加信息
|
||||
throw new BusinessException(ErrorCode.BUSINESS_ERROR, "业务逻辑错误", additionalData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例2:返回统一响应格式
|
||||
*/
|
||||
public Result<String> returnResultExample(boolean success) {
|
||||
if (success) {
|
||||
// 返回成功响应
|
||||
return ResultUtils.success("操作成功");
|
||||
} else {
|
||||
// 返回失败响应
|
||||
return ResultUtils.fail(ErrorCode.BUSINESS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例3:使用不同类型的错误响应
|
||||
*/
|
||||
public Result<?> useDifferentErrorResponses() {
|
||||
// 参数错误
|
||||
Result<?> paramError = ResultUtils.paramError("参数校验失败");
|
||||
|
||||
// 未授权错误
|
||||
Result<?> unauthorizedError = ResultUtils.unauthorized();
|
||||
|
||||
// 禁止访问错误
|
||||
Result<?> forbiddenError = ResultUtils.forbidden();
|
||||
|
||||
// 资源不存在错误
|
||||
Result<?> notFoundError = ResultUtils.notFound("请求的资源不存在");
|
||||
|
||||
// 服务器错误
|
||||
Result<?> serverError = ResultUtils.serverError();
|
||||
|
||||
return paramError; // 示例返回
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例4:在Service层使用异常处理
|
||||
*/
|
||||
public void serviceLayerExample(Long productId, int quantity) {
|
||||
// 校验参数
|
||||
if (productId == null || productId <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAM_ERROR, "商品ID无效");
|
||||
}
|
||||
|
||||
if (quantity <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAM_ERROR, "购买数量必须大于0");
|
||||
}
|
||||
|
||||
// 模拟业务逻辑检查
|
||||
boolean productExists = true; // 假设从数据库查询
|
||||
if (!productExists) {
|
||||
throw new BusinessException(ErrorCode.PRODUCT_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 模拟库存检查
|
||||
boolean hasStock = false; // 假设从数据库查询
|
||||
if (!hasStock) {
|
||||
throw new BusinessException(ErrorCode.INSUFFICIENT_STOCK);
|
||||
}
|
||||
|
||||
// 正常业务逻辑处理...
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例5:在Controller层使用统一响应
|
||||
*/
|
||||
public Result<?> controllerLayerExample(Long id) {
|
||||
try {
|
||||
// 调用业务逻辑
|
||||
Object result = new Object(); // 假设这是业务处理结果
|
||||
return ResultUtils.success(result);
|
||||
} catch (BusinessException e) {
|
||||
// 业务异常已经被GlobalExceptionHandler捕获,这里可以做额外处理
|
||||
// 例如记录日志等
|
||||
throw e; // 重新抛出,让全局异常处理器处理
|
||||
}
|
||||
// 系统异常也会被GlobalExceptionHandler自动捕获
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.qf.backend.exception;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.common.ResultUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
* 处理系统中所有的异常,提供统一的错误响应格式
|
||||
*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理业务异常
|
||||
*/
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public Result<?> handleBusinessException(BusinessException e, HttpServletRequest request) {
|
||||
log.warn("BusinessException: {} - Request: {}", e.getMessage(), request.getRequestURI());
|
||||
return ResultUtils.fail(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理参数验证异常(@Valid)
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<?> handleMethodArgumentNotValidException(MethodArgumentNotValidException e, HttpServletRequest request) {
|
||||
BindingResult bindingResult = e.getBindingResult();
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (FieldError fieldError : bindingResult.getFieldErrors()) {
|
||||
joiner.add(fieldError.getField() + ": " + fieldError.getDefaultMessage());
|
||||
}
|
||||
String errorMsg = joiner.toString();
|
||||
log.warn("MethodArgumentNotValidException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.paramError(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理参数绑定异常(@RequestParam)
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<?> handleBindException(BindException e, HttpServletRequest request) {
|
||||
BindingResult bindingResult = e.getBindingResult();
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (FieldError fieldError : bindingResult.getFieldErrors()) {
|
||||
joiner.add(fieldError.getField() + ": " + fieldError.getDefaultMessage());
|
||||
}
|
||||
String errorMsg = joiner.toString();
|
||||
log.warn("BindException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.paramError(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理缺少请求参数异常
|
||||
*/
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<?> handleMissingServletRequestParameterException(MissingServletRequestParameterException e, HttpServletRequest request) {
|
||||
String errorMsg = "缺少必要参数: " + e.getParameterName();
|
||||
log.warn("MissingServletRequestParameterException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.paramError(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理参数类型不匹配异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<?> handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
|
||||
String errorMsg = "参数类型错误: " + e.getName() + " 应为 " + Objects.requireNonNull(e.getRequiredType()).getSimpleName();
|
||||
log.warn("MethodArgumentTypeMismatchException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.paramError(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理HTTP消息不可读异常(如JSON格式错误)
|
||||
*/
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<?> handleHttpMessageNotReadableException(HttpMessageNotReadableException e, HttpServletRequest request) {
|
||||
String errorMsg = "请求体格式错误: " + e.getMostSpecificCause().getMessage();
|
||||
log.warn("HttpMessageNotReadableException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.paramError(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理不支持的HTTP方法异常
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
public Result<?> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
|
||||
String errorMsg = "不支持的HTTP方法: " + e.getMethod();
|
||||
log.warn("HttpRequestMethodNotSupportedException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.fail(HttpStatus.METHOD_NOT_ALLOWED.value(), errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理不支持的媒体类型异常
|
||||
*/
|
||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||
@ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
|
||||
public Result<?> handleHttpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e, HttpServletRequest request) {
|
||||
String errorMsg = "不支持的媒体类型: " + e.getContentType();
|
||||
log.warn("HttpMediaTypeNotSupportedException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.fail(HttpStatus.UNSUPPORTED_MEDIA_TYPE.value(), errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理404异常
|
||||
*/
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public Result<?> handleNoHandlerFoundException(NoHandlerFoundException e, HttpServletRequest request) {
|
||||
String errorMsg = "请求路径不存在: " + request.getRequestURI();
|
||||
log.warn("NoHandlerFoundException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
return ResultUtils.notFound(errorMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据库异常
|
||||
*/
|
||||
@ExceptionHandler(SQLException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public Result<?> handleSQLException(SQLException e, HttpServletRequest request) {
|
||||
log.error("SQLException: {} - Request: {}", e.getMessage(), request.getRequestURI(), e);
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理认证异常
|
||||
*/
|
||||
@ExceptionHandler(AuthenticationException.class)
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
public Result<?> handleAuthenticationException(AuthenticationException e, HttpServletRequest request) {
|
||||
String errorMsg = "认证失败: " + e.getMessage();
|
||||
log.warn("AuthenticationException: {} - Request: {}", errorMsg, request.getRequestURI());
|
||||
|
||||
if (e instanceof BadCredentialsException) {
|
||||
return ResultUtils.fail(ErrorCode.UNAUTHORIZED, "用户名或密码错误");
|
||||
} else if (e instanceof InsufficientAuthenticationException) {
|
||||
return ResultUtils.fail(ErrorCode.UNAUTHORIZED, "缺少认证信息");
|
||||
}
|
||||
|
||||
return ResultUtils.unauthorized();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理权限不足异常
|
||||
*/
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public Result<?> handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) {
|
||||
log.warn("AccessDeniedException: {} - Request: {}", e.getMessage(), request.getRequestURI());
|
||||
return ResultUtils.fail(ErrorCode.PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理其他所有未捕获的异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public Result<?> handleException(Exception e, HttpServletRequest request) {
|
||||
log.error("Unhandled Exception: {} - Request: {}", e.getMessage(), request.getRequestURI(), e);
|
||||
return ResultUtils.serverError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public Result<?> handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
log.error("RuntimeException: {} - Request: {}", e.getMessage(), request.getRequestURI(), e);
|
||||
|
||||
// 可以根据具体的运行时异常类型进行特殊处理
|
||||
if (e instanceof NullPointerException) {
|
||||
log.warn("NullPointerException occurred: {}", e.getMessage());
|
||||
return ResultUtils.fail(ErrorCode.SYSTEM_ERROR, "系统内部错误:空指针异常");
|
||||
}
|
||||
|
||||
return ResultUtils.serverError();
|
||||
}
|
||||
}
|
||||
30
src/main/java/com/qf/backend/mapper/OrderItemsMapper.java
Normal file
30
src/main/java/com/qf/backend/mapper/OrderItemsMapper.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.OrderItems;
|
||||
|
||||
/**
|
||||
* 订单商品项表 Mapper 接口
|
||||
*/
|
||||
public interface OrderItemsMapper extends BaseMapper<OrderItems> {
|
||||
QueryWrapper<OrderItems> qw = new QueryWrapper<>();
|
||||
/**
|
||||
* 根据订单ID查询订单项
|
||||
* @param orderId 订单ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
@Select("select * from order_items where order_id = #{orderId}")
|
||||
List<OrderItems> selectByOrderId(Long orderId);
|
||||
/**
|
||||
* 根据商品ID查询订单项
|
||||
* @param productId 商品ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
@Select("select * from order_items where product_id = #{productId}")
|
||||
List<OrderItems> selectByProductId(Long productId);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.OrderStatusHistory;
|
||||
|
||||
/**
|
||||
* 订单状态历史表 Mapper 接口
|
||||
*/
|
||||
public interface OrderStatusHistoryMapper extends BaseMapper<OrderStatusHistory> {
|
||||
}
|
||||
16
src/main/java/com/qf/backend/mapper/OrdersMapper.java
Normal file
16
src/main/java/com/qf/backend/mapper/OrdersMapper.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Orders;
|
||||
|
||||
/**
|
||||
* 订单主表 Mapper 接口
|
||||
*/
|
||||
public interface OrdersMapper extends BaseMapper<Orders> {
|
||||
/**
|
||||
* 根据订单号查询订单
|
||||
* @param orderNumber 订单号
|
||||
* @return 订单信息
|
||||
*/
|
||||
Orders selectByOrderNumber(String orderNumber);
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/PaymentsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/PaymentsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Payments;
|
||||
|
||||
/**
|
||||
* 支付信息表 Mapper 接口
|
||||
*/
|
||||
public interface PaymentsMapper extends BaseMapper<Payments> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/PermissionsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/PermissionsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Permissions;
|
||||
|
||||
/**
|
||||
* 权限信息表 Mapper 接口
|
||||
*/
|
||||
public interface PermissionsMapper extends BaseMapper<Permissions> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductAttributeValues;
|
||||
|
||||
/**
|
||||
* 商品属性值表 Mapper 接口
|
||||
*/
|
||||
public interface ProductAttributeValuesMapper extends BaseMapper<ProductAttributeValues> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductAttributes;
|
||||
|
||||
/**
|
||||
* 商品属性表 Mapper 接口
|
||||
*/
|
||||
public interface ProductAttributesMapper extends BaseMapper<ProductAttributes> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductCategories;
|
||||
|
||||
/**
|
||||
* 商品分类表 Mapper 接口
|
||||
*/
|
||||
public interface ProductCategoriesMapper extends BaseMapper<ProductCategories> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/ProductImagesMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/ProductImagesMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductImages;
|
||||
|
||||
/**
|
||||
* 商品图片表 Mapper 接口
|
||||
*/
|
||||
public interface ProductImagesMapper extends BaseMapper<ProductImages> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductInventories;
|
||||
|
||||
/**
|
||||
* 库存信息表 Mapper 接口
|
||||
*/
|
||||
public interface ProductInventoriesMapper extends BaseMapper<ProductInventories> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/ProductSkusMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/ProductSkusMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductSkus;
|
||||
|
||||
/**
|
||||
* 商品SKU表 Mapper 接口
|
||||
*/
|
||||
public interface ProductSkusMapper extends BaseMapper<ProductSkus> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/ProductsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/ProductsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Products;
|
||||
|
||||
/**
|
||||
* 商品基本信息表 Mapper 接口
|
||||
*/
|
||||
public interface ProductsMapper extends BaseMapper<Products> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/RefundsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/RefundsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Refunds;
|
||||
|
||||
/**
|
||||
* 退款信息表 Mapper 接口
|
||||
*/
|
||||
public interface RefundsMapper extends BaseMapper<Refunds> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.RolePermissions;
|
||||
|
||||
/**
|
||||
* 角色-权限关联表 Mapper 接口
|
||||
*/
|
||||
public interface RolePermissionsMapper extends BaseMapper<RolePermissions> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/RolesMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/RolesMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Roles;
|
||||
|
||||
/**
|
||||
* 角色信息表 Mapper 接口
|
||||
*/
|
||||
public interface RolesMapper extends BaseMapper<Roles> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ShopCategories;
|
||||
|
||||
/**
|
||||
* 店铺分类表 Mapper 接口
|
||||
*/
|
||||
public interface ShopCategoriesMapper extends BaseMapper<ShopCategories> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/ShopRatingsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/ShopRatingsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ShopRatings;
|
||||
|
||||
/**
|
||||
* 店铺评分表 Mapper 接口
|
||||
*/
|
||||
public interface ShopRatingsMapper extends BaseMapper<ShopRatings> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/ShopsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/ShopsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Shops;
|
||||
|
||||
/**
|
||||
* 店铺信息表 Mapper 接口
|
||||
*/
|
||||
public interface ShopsMapper extends BaseMapper<Shops> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/UserDetailsMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/UserDetailsMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.UserDetails;
|
||||
|
||||
/**
|
||||
* 用户详细信息表 Mapper 接口
|
||||
*/
|
||||
public interface UserDetailsMapper extends BaseMapper<UserDetails> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/UserRolesMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/UserRolesMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.UserRoles;
|
||||
|
||||
/**
|
||||
* 用户-角色关联表 Mapper 接口
|
||||
*/
|
||||
public interface UserRolesMapper extends BaseMapper<UserRoles> {
|
||||
}
|
||||
10
src/main/java/com/qf/backend/mapper/UsersMapper.java
Normal file
10
src/main/java/com/qf/backend/mapper/UsersMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Users;
|
||||
|
||||
/**
|
||||
* 用户基本信息表 Mapper 接口
|
||||
*/
|
||||
public interface UsersMapper extends BaseMapper<Users> {
|
||||
}
|
||||
83
src/main/java/com/qf/backend/service/OrderItemsService.java
Normal file
83
src/main/java/com/qf/backend/service/OrderItemsService.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.OrderItems;
|
||||
|
||||
/**
|
||||
* 订单项服务接口
|
||||
*/
|
||||
public interface OrderItemsService extends IService<OrderItems> {
|
||||
|
||||
/**
|
||||
* 根据订单ID查询订单项
|
||||
* @param orderId 订单ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
Result<List<OrderItems>> getOrderItemsByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 根据商品ID查询订单项
|
||||
* @param productId 商品ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
Result<List<OrderItems>> getOrderItemsByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 创建订单项
|
||||
* @param orderItems 订单项信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createOrderItem(OrderItems orderItems);
|
||||
|
||||
/**
|
||||
* 更新订单项信息
|
||||
* @param orderItems 订单项信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateOrderItem(OrderItems orderItems);
|
||||
|
||||
/**
|
||||
* 删除订单项
|
||||
* @param id 订单项ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteOrderItem(Long id);
|
||||
|
||||
/**
|
||||
* 根据订单项ID查询订单项
|
||||
* @param id 订单项ID
|
||||
* @return 订单项信息
|
||||
*/
|
||||
Result<OrderItems> getOrderItemById(Long id);
|
||||
|
||||
/**
|
||||
* 批量创建订单项
|
||||
* @param orderItemsList 订单项列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchCreateOrderItems(List<OrderItems> orderItemsList);
|
||||
|
||||
/**
|
||||
* 根据订单ID删除所有订单项
|
||||
* @param orderId 订单ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteOrderItemsByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 计算订单总金额
|
||||
* @param orderId 订单ID
|
||||
* @return 订单总金额
|
||||
*/
|
||||
Result<Double> calculateOrderTotal(Long orderId);
|
||||
|
||||
/**
|
||||
* 根据SKU ID查询订单项
|
||||
* @param skuId SKU ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
Result<List<OrderItems>> getOrderItemsBySkuId(Long skuId);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.OrderStatusHistory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单状态历史服务接口
|
||||
*/
|
||||
public interface OrderStatusHistoryService extends IService<OrderStatusHistory> {
|
||||
|
||||
/**
|
||||
* 根据订单ID查询状态历史
|
||||
* @param orderId 订单ID
|
||||
* @return 订单状态历史列表
|
||||
*/
|
||||
Result<List<OrderStatusHistory>> getHistoryByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 创建订单状态历史记录
|
||||
* @param orderStatusHistory 订单状态历史信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createStatusHistory(OrderStatusHistory orderStatusHistory);
|
||||
|
||||
/**
|
||||
* 更新订单状态历史信息
|
||||
* @param orderStatusHistory 订单状态历史信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateStatusHistory(OrderStatusHistory orderStatusHistory);
|
||||
|
||||
/**
|
||||
* 删除订单状态历史记录
|
||||
* @param id 记录ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteStatusHistory(Long id);
|
||||
|
||||
/**
|
||||
* 根据记录ID查询订单状态历史
|
||||
* @param id 记录ID
|
||||
* @return 订单状态历史信息
|
||||
*/
|
||||
Result<OrderStatusHistory> getStatusHistoryById(Long id);
|
||||
|
||||
/**
|
||||
* 批量创建订单状态历史记录
|
||||
* @param historyList 订单状态历史列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchCreateStatusHistory(List<OrderStatusHistory> historyList);
|
||||
|
||||
/**
|
||||
* 根据订单ID和状态查询历史记录
|
||||
* @param orderId 订单ID
|
||||
* @param status 订单状态
|
||||
* @return 订单状态历史列表
|
||||
*/
|
||||
Result<List<OrderStatusHistory>> getHistoryByOrderIdAndStatus(Long orderId, Integer status);
|
||||
|
||||
/**
|
||||
* 获取订单最新状态
|
||||
* @param orderId 订单ID
|
||||
* @return 最新订单状态历史信息
|
||||
*/
|
||||
Result<OrderStatusHistory> getLatestStatusHistory(Long orderId);
|
||||
|
||||
/**
|
||||
* 根据订单ID删除所有状态历史
|
||||
* @param orderId 订单ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteHistoryByOrderId(Long orderId);
|
||||
}
|
||||
85
src/main/java/com/qf/backend/service/OrdersService.java
Normal file
85
src/main/java/com/qf/backend/service/OrdersService.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.Orders;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单服务接口
|
||||
*/
|
||||
public interface OrdersService extends IService<Orders> {
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单
|
||||
* @param orderNumber 订单号
|
||||
* @return 订单信息
|
||||
*/
|
||||
Result<Orders> getOrderByNumber(String orderNumber);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询订单列表
|
||||
* @param userId 用户ID
|
||||
* @return 订单列表
|
||||
*/
|
||||
Result<List<Orders>> getOrdersByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param orders 订单信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createOrder(Orders orders);
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
* @param orders 订单信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateOrder(Orders orders);
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* @param id 订单ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteOrder(Long id);
|
||||
|
||||
/**
|
||||
* 根据订单ID查询订单
|
||||
* @param id 订单ID
|
||||
* @return 订单信息
|
||||
*/
|
||||
Result<Orders> getOrderById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询订单
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 订单列表
|
||||
*/
|
||||
Result<List<Orders>> listOrdersByPage(int page, int size);
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询订单
|
||||
* @param shopId 店铺ID
|
||||
* @return 订单列表
|
||||
*/
|
||||
Result<List<Orders>> getOrdersByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 更新订单状态
|
||||
* @param orderId 订单ID
|
||||
* @param status 订单状态
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateOrderStatus(Long orderId, Integer status);
|
||||
|
||||
/**
|
||||
* 根据订单状态查询订单
|
||||
* @param status 订单状态
|
||||
* @return 订单列表
|
||||
*/
|
||||
Result<List<Orders>> getOrdersByStatus(Integer status);
|
||||
}
|
||||
84
src/main/java/com/qf/backend/service/PaymentsService.java
Normal file
84
src/main/java/com/qf/backend/service/PaymentsService.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.entity.Payments;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付服务接口
|
||||
*/
|
||||
public interface PaymentsService extends IService<Payments> {
|
||||
|
||||
/**
|
||||
* 根据订单ID查询支付记录
|
||||
* @param orderId 订单ID
|
||||
* @return 支付记录
|
||||
*/
|
||||
Payments getPaymentByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 根据支付流水号查询支付记录
|
||||
* @param transactionId 支付流水号
|
||||
* @return 支付记录
|
||||
*/
|
||||
Payments getPaymentByTransactionId(String transactionId);
|
||||
|
||||
/**
|
||||
* 创建支付记录
|
||||
* @param payments 支付信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean createPayment(Payments payments);
|
||||
|
||||
/**
|
||||
* 更新支付信息
|
||||
* @param payments 支付信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updatePayment(Payments payments);
|
||||
|
||||
/**
|
||||
* 删除支付记录
|
||||
* @param id 支付ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deletePayment(Long id);
|
||||
|
||||
/**
|
||||
* 根据支付ID查询支付记录
|
||||
* @param id 支付ID
|
||||
* @return 支付记录
|
||||
*/
|
||||
Payments getPaymentById(Long id);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询支付记录
|
||||
* @param userId 用户ID
|
||||
* @return 支付记录列表
|
||||
*/
|
||||
List<Payments> getPaymentsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据支付状态查询支付记录
|
||||
* @param status 支付状态
|
||||
* @return 支付记录列表
|
||||
*/
|
||||
List<Payments> getPaymentsByStatus(Integer status);
|
||||
|
||||
/**
|
||||
* 更新支付状态
|
||||
* @param paymentId 支付ID
|
||||
* @param status 支付状态
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updatePaymentStatus(Long paymentId, Integer status);
|
||||
|
||||
/**
|
||||
* 分页查询支付记录
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 支付记录列表
|
||||
*/
|
||||
List<Payments> listPaymentsByPage(int page, int size);
|
||||
}
|
||||
74
src/main/java/com/qf/backend/service/PermissionsService.java
Normal file
74
src/main/java/com/qf/backend/service/PermissionsService.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.entity.Permissions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限服务接口
|
||||
*/
|
||||
public interface PermissionsService extends IService<Permissions> {
|
||||
|
||||
/**
|
||||
* 根据权限编码查询权限
|
||||
* @param permissionCode 权限编码
|
||||
* @return 权限信息
|
||||
*/
|
||||
Permissions getPermissionByCode(String permissionCode);
|
||||
|
||||
/**
|
||||
* 创建权限
|
||||
* @param permissions 权限信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean createPermission(Permissions permissions);
|
||||
|
||||
/**
|
||||
* 更新权限信息
|
||||
* @param permissions 权限信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updatePermission(Permissions permissions);
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
* @param id 权限ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deletePermission(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有权限
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<Permissions> listAllPermissions();
|
||||
|
||||
/**
|
||||
* 根据权限ID查询权限
|
||||
* @param id 权限ID
|
||||
* @return 权限信息
|
||||
*/
|
||||
Permissions getPermissionById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除权限
|
||||
* @param ids 权限ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean batchDeletePermissions(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询权限
|
||||
* @param menuId 菜单ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<Permissions> listPermissionsByMenuId(Long menuId);
|
||||
|
||||
/**
|
||||
* 根据权限类型查询权限
|
||||
* @param permissionType 权限类型
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<Permissions> listPermissionsByType(String permissionType);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductAttributeValues;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品属性值服务接口
|
||||
*/
|
||||
public interface ProductAttributeValuesService extends IService<ProductAttributeValues> {
|
||||
|
||||
/**
|
||||
* 根据商品ID查询属性值
|
||||
* @param productId 商品ID
|
||||
* @return 属性值列表
|
||||
*/
|
||||
Result<List<ProductAttributeValues>> getAttributeValuesByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 根据属性ID查询属性值
|
||||
* @param attributeId 属性ID
|
||||
* @return 属性值列表
|
||||
*/
|
||||
Result<List<ProductAttributeValues>> getAttributeValuesByAttributeId(Long attributeId);
|
||||
|
||||
/**
|
||||
* 创建属性值
|
||||
* @param productAttributeValues 属性值信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createAttributeValue(ProductAttributeValues productAttributeValues);
|
||||
|
||||
/**
|
||||
* 更新属性值信息
|
||||
* @param productAttributeValues 属性值信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateAttributeValue(ProductAttributeValues productAttributeValues);
|
||||
|
||||
/**
|
||||
* 删除属性值
|
||||
* @param id 属性值ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteAttributeValue(Long id);
|
||||
|
||||
/**
|
||||
* 根据属性值ID查询属性值
|
||||
* @param id 属性值ID
|
||||
* @return 属性值信息
|
||||
*/
|
||||
Result<ProductAttributeValues> getAttributeValueById(Long id);
|
||||
|
||||
/**
|
||||
* 批量创建商品属性值
|
||||
* @param attributeValues 属性值列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchCreateAttributeValues(List<ProductAttributeValues> attributeValues);
|
||||
|
||||
/**
|
||||
* 根据商品ID和属性ID查询属性值
|
||||
* @param productId 商品ID
|
||||
* @param attributeId 属性ID
|
||||
* @return 属性值信息
|
||||
*/
|
||||
Result<ProductAttributeValues> getAttributeValueByProductAndAttribute(Long productId, Long attributeId);
|
||||
|
||||
/**
|
||||
* 根据商品ID删除所有属性值
|
||||
* @param productId 商品ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteAttributeValuesByProductId(Long productId);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductAttributes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品属性服务接口
|
||||
*/
|
||||
public interface ProductAttributesService extends IService<ProductAttributes> {
|
||||
|
||||
/**
|
||||
* 根据分类ID查询属性
|
||||
* @param categoryId 分类ID
|
||||
* @return 属性列表
|
||||
*/
|
||||
Result<List<ProductAttributes>> getAttributesByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 根据属性名称查询属性
|
||||
* @param attributeName 属性名称
|
||||
* @return 属性列表
|
||||
*/
|
||||
Result<List<ProductAttributes>> getAttributesByName(String attributeName);
|
||||
|
||||
/**
|
||||
* 创建属性
|
||||
* @param productAttributes 属性信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createAttribute(ProductAttributes productAttributes);
|
||||
|
||||
/**
|
||||
* 更新属性信息
|
||||
* @param productAttributes 属性信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateAttribute(ProductAttributes productAttributes);
|
||||
|
||||
/**
|
||||
* 删除属性
|
||||
* @param id 属性ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteAttribute(Long id);
|
||||
|
||||
/**
|
||||
* 根据属性ID查询属性
|
||||
* @param id 属性ID
|
||||
* @return 属性信息
|
||||
*/
|
||||
Result<ProductAttributes> getAttributeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除属性
|
||||
* @param ids 属性ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchDeleteAttributes(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据属性类型查询属性
|
||||
* @param attributeType 属性类型
|
||||
* @return 属性列表
|
||||
*/
|
||||
Result<List<ProductAttributes>> getAttributesByType(String attributeType);
|
||||
|
||||
/**
|
||||
* 查询是否可搜索的属性
|
||||
* @param searchable 是否可搜索
|
||||
* @return 属性列表
|
||||
*/
|
||||
Result<List<ProductAttributes>> getAttributesBySearchable(Boolean searchable);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductCategories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类服务接口
|
||||
*/
|
||||
public interface ProductCategoriesService extends IService<ProductCategories> {
|
||||
|
||||
/**
|
||||
* 根据分类名称查询分类
|
||||
* @param categoryName 分类名称
|
||||
* @return 分类信息
|
||||
*/
|
||||
Result<ProductCategories> getCategoryByName(String categoryName);
|
||||
|
||||
/**
|
||||
* 根据父分类ID查询子分类
|
||||
* @param parentId 父分类ID
|
||||
* @return 子分类列表
|
||||
*/
|
||||
Result<List<ProductCategories>> getSubCategoriesByParentId(Long parentId);
|
||||
|
||||
/**
|
||||
* 创建分类
|
||||
* @param productCategories 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createCategory(ProductCategories productCategories);
|
||||
|
||||
/**
|
||||
* 更新分类信息
|
||||
* @param productCategories 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateCategory(ProductCategories productCategories);
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param id 分类ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteCategory(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有根分类(父分类ID为0或null的分类)
|
||||
* @return 根分类列表
|
||||
*/
|
||||
Result<List<ProductCategories>> listRootCategories();
|
||||
|
||||
/**
|
||||
* 根据分类ID查询分类
|
||||
* @param id 分类ID
|
||||
* @return 分类信息
|
||||
*/
|
||||
Result<ProductCategories> getCategoryById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除分类
|
||||
* @param ids 分类ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchDeleteCategories(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询所有分类(树形结构)
|
||||
* @return 分类树形列表
|
||||
*/
|
||||
Result<List<ProductCategories>> listAllCategoriesWithTree();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductImages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品图片服务接口
|
||||
*/
|
||||
public interface ProductImagesService extends IService<ProductImages> {
|
||||
|
||||
/**
|
||||
* 根据商品ID查询图片
|
||||
* @param productId 商品ID
|
||||
* @return 图片列表
|
||||
*/
|
||||
Result<List<ProductImages>> getImagesByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 根据商品ID查询主图
|
||||
* @param productId 商品ID
|
||||
* @return 主图信息
|
||||
*/
|
||||
Result<ProductImages> getMainImageByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 创建商品图片
|
||||
* @param productImages 图片信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createImage(ProductImages productImages);
|
||||
|
||||
/**
|
||||
* 更新图片信息
|
||||
* @param productImages 图片信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateImage(ProductImages productImages);
|
||||
|
||||
/**
|
||||
* 删除图片
|
||||
* @param id 图片ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteImage(Long id);
|
||||
|
||||
/**
|
||||
* 根据图片ID查询图片
|
||||
* @param id 图片ID
|
||||
* @return 图片信息
|
||||
*/
|
||||
Result<ProductImages> getImageById(Long id);
|
||||
|
||||
/**
|
||||
* 批量创建商品图片
|
||||
* @param images 图片列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchCreateImages(List<ProductImages> images);
|
||||
|
||||
/**
|
||||
* 根据商品ID删除所有图片
|
||||
* @param productId 商品ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteImagesByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 设置主图
|
||||
* @param productId 商品ID
|
||||
* @param imageId 图片ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> setMainImage(Long productId, Long imageId);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductInventories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品库存服务接口
|
||||
*/
|
||||
public interface ProductInventoriesService extends IService<ProductInventories> {
|
||||
|
||||
/**
|
||||
* 根据商品ID查询库存
|
||||
* @param productId 商品ID
|
||||
* @return 库存列表
|
||||
*/
|
||||
Result<List<ProductInventories>> getInventoriesByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 根据SKU ID查询库存
|
||||
* @param skuId SKU ID
|
||||
* @return 库存信息
|
||||
*/
|
||||
Result<ProductInventories> getInventoryBySkuId(Long skuId);
|
||||
|
||||
/**
|
||||
* 创建库存记录
|
||||
* @param productInventories 库存信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createInventory(ProductInventories productInventories);
|
||||
|
||||
/**
|
||||
* 更新库存信息
|
||||
* @param productInventories 库存信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateInventory(ProductInventories productInventories);
|
||||
|
||||
/**
|
||||
* 删除库存记录
|
||||
* @param id 库存ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteInventory(Long id);
|
||||
|
||||
/**
|
||||
* 根据库存ID查询库存
|
||||
* @param id 库存ID
|
||||
* @return 库存信息
|
||||
*/
|
||||
Result<ProductInventories> getInventoryById(Long id);
|
||||
|
||||
/**
|
||||
* 增加库存
|
||||
* @param skuId SKU ID
|
||||
* @param quantity 增加数量
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> increaseInventory(Long skuId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 减少库存
|
||||
* @param skuId SKU ID
|
||||
* @param quantity 减少数量
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> decreaseInventory(Long skuId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 检查库存是否充足
|
||||
* @param skuId SKU ID
|
||||
* @param quantity 需要的数量
|
||||
* @return 是否充足
|
||||
*/
|
||||
Result<Boolean> checkInventorySufficient(Long skuId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 批量更新库存
|
||||
* @param inventoryUpdates 库存更新列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchUpdateInventory(List<ProductInventories> inventoryUpdates);
|
||||
}
|
||||
84
src/main/java/com/qf/backend/service/ProductSkusService.java
Normal file
84
src/main/java/com/qf/backend/service/ProductSkusService.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ProductSkus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品SKU服务接口
|
||||
*/
|
||||
public interface ProductSkusService extends IService<ProductSkus> {
|
||||
|
||||
/**
|
||||
* 根据商品ID查询SKU
|
||||
* @param productId 商品ID
|
||||
* @return SKU列表
|
||||
*/
|
||||
Result<List<ProductSkus>> getSkusByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 根据SKU编码查询SKU
|
||||
* @param skuCode SKU编码
|
||||
* @return SKU信息
|
||||
*/
|
||||
Result<ProductSkus> getSkuByCode(String skuCode);
|
||||
|
||||
/**
|
||||
* 创建SKU
|
||||
* @param productSkus SKU信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createSku(ProductSkus productSkus);
|
||||
|
||||
/**
|
||||
* 更新SKU信息
|
||||
* @param productSkus SKU信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateSku(ProductSkus productSkus);
|
||||
|
||||
/**
|
||||
* 删除SKU
|
||||
* @param id SKU ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteSku(Long id);
|
||||
|
||||
/**
|
||||
* 根据SKU ID查询SKU
|
||||
* @param id SKU ID
|
||||
* @return SKU信息
|
||||
*/
|
||||
Result<ProductSkus> getSkuById(Long id);
|
||||
|
||||
/**
|
||||
* 批量创建SKU
|
||||
* @param skus SKU列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchCreateSkus(List<ProductSkus> skus);
|
||||
|
||||
/**
|
||||
* 根据商品ID删除所有SKU
|
||||
* @param productId 商品ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteSkusByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 更新SKU库存
|
||||
* @param skuId SKU ID
|
||||
* @param quantity 库存数量
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateSkuStock(Long skuId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 批量查询SKU
|
||||
* @param skuIds SKU ID列表
|
||||
* @return SKU列表
|
||||
*/
|
||||
Result<List<ProductSkus>> batchGetSkus(List<Long> skuIds);
|
||||
}
|
||||
87
src/main/java/com/qf/backend/service/ProductsService.java
Normal file
87
src/main/java/com/qf/backend/service/ProductsService.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.Products;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品服务接口
|
||||
*/
|
||||
public interface ProductsService extends IService<Products> {
|
||||
|
||||
/**
|
||||
* 根据商品名称查询商品
|
||||
* @param productName 商品名称
|
||||
* @return 商品列表
|
||||
*/
|
||||
Result<List<Products>> getProductsByName(String productName);
|
||||
|
||||
/**
|
||||
* 根据分类ID查询商品
|
||||
* @param categoryId 分类ID
|
||||
* @return 商品列表
|
||||
*/
|
||||
Result<List<Products>> getProductsByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
* @param products 商品信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createProduct(Products products);
|
||||
|
||||
/**
|
||||
* 更新商品信息
|
||||
* @param products 商品信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateProduct(Products products);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param id 商品ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteProduct(Long id);
|
||||
|
||||
/**
|
||||
* 根据商品ID查询商品
|
||||
* @param id 商品ID
|
||||
* @return 商品信息
|
||||
*/
|
||||
Result<Products> getProductById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询商品
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 商品列表
|
||||
*/
|
||||
Result<List<Products>> listProductsByPage(int page, int size);
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询商品
|
||||
* @param shopId 店铺ID
|
||||
* @return 商品列表
|
||||
*/
|
||||
Result<List<Products>> getProductsByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 批量上下架商品
|
||||
* @param ids 商品ID列表
|
||||
* @param status 状态(上架/下架)
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchUpdateProductStatus(List<Long> ids, Integer status);
|
||||
|
||||
/**
|
||||
* 搜索商品
|
||||
* @param keyword 关键词
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 商品列表
|
||||
*/
|
||||
Result<List<Products>> searchProducts(String keyword, int page, int size);
|
||||
}
|
||||
84
src/main/java/com/qf/backend/service/RefundsService.java
Normal file
84
src/main/java/com/qf/backend/service/RefundsService.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.entity.Refunds;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款服务接口
|
||||
*/
|
||||
public interface RefundsService extends IService<Refunds> {
|
||||
|
||||
/**
|
||||
* 根据订单ID查询退款记录
|
||||
* @param orderId 订单ID
|
||||
* @return 退款记录列表
|
||||
*/
|
||||
List<Refunds> getRefundsByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 根据退款单号查询退款记录
|
||||
* @param refundNumber 退款单号
|
||||
* @return 退款记录
|
||||
*/
|
||||
Refunds getRefundByNumber(String refundNumber);
|
||||
|
||||
/**
|
||||
* 创建退款记录
|
||||
* @param refunds 退款信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean createRefund(Refunds refunds);
|
||||
|
||||
/**
|
||||
* 更新退款信息
|
||||
* @param refunds 退款信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateRefund(Refunds refunds);
|
||||
|
||||
/**
|
||||
* 删除退款记录
|
||||
* @param id 退款ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteRefund(Long id);
|
||||
|
||||
/**
|
||||
* 根据退款ID查询退款记录
|
||||
* @param id 退款ID
|
||||
* @return 退款记录
|
||||
*/
|
||||
Refunds getRefundById(Long id);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询退款记录
|
||||
* @param userId 用户ID
|
||||
* @return 退款记录列表
|
||||
*/
|
||||
List<Refunds> getRefundsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据退款状态查询退款记录
|
||||
* @param status 退款状态
|
||||
* @return 退款记录列表
|
||||
*/
|
||||
List<Refunds> getRefundsByStatus(Integer status);
|
||||
|
||||
/**
|
||||
* 更新退款状态
|
||||
* @param refundId 退款ID
|
||||
* @param status 退款状态
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateRefundStatus(Long refundId, Integer status);
|
||||
|
||||
/**
|
||||
* 分页查询退款记录
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 退款记录列表
|
||||
*/
|
||||
List<Refunds> listRefundsByPage(int page, int size);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.entity.RolePermissions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色权限关联服务接口
|
||||
*/
|
||||
public interface RolePermissionsService extends IService<RolePermissions> {
|
||||
|
||||
/**
|
||||
* 根据角色ID查询角色权限关联
|
||||
* @param roleId 角色ID
|
||||
* @return 角色权限关联列表
|
||||
*/
|
||||
List<RolePermissions> getRolePermissionsByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据权限ID查询角色权限关联
|
||||
* @param permissionId 权限ID
|
||||
* @return 角色权限关联列表
|
||||
*/
|
||||
List<RolePermissions> getRolePermissionsByPermissionId(Long permissionId);
|
||||
|
||||
/**
|
||||
* 为角色添加权限
|
||||
* @param roleId 角色ID
|
||||
* @param permissionId 权限ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean addPermissionToRole(Long roleId, Long permissionId);
|
||||
|
||||
/**
|
||||
* 从角色移除权限
|
||||
* @param roleId 角色ID
|
||||
* @param permissionId 权限ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean removePermissionFromRole(Long roleId, Long permissionId);
|
||||
|
||||
/**
|
||||
* 批量为角色添加权限
|
||||
* @param roleId 角色ID
|
||||
* @param permissionIds 权限ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean batchAddPermissionsToRole(Long roleId, List<Long> permissionIds);
|
||||
|
||||
/**
|
||||
* 清空角色的所有权限
|
||||
* @param roleId 角色ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean clearRolePermissions(Long roleId);
|
||||
|
||||
/**
|
||||
* 检查角色是否拥有指定权限
|
||||
* @param roleId 角色ID
|
||||
* @param permissionId 权限ID
|
||||
* @return 是否拥有
|
||||
*/
|
||||
boolean checkRoleHasPermission(Long roleId, Long permissionId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询其拥有的权限ID列表
|
||||
* @param roleId 角色ID
|
||||
* @return 权限ID列表
|
||||
*/
|
||||
List<Long> listPermissionIdsByRoleId(Long roleId);
|
||||
}
|
||||
67
src/main/java/com/qf/backend/service/RolesService.java
Normal file
67
src/main/java/com/qf/backend/service/RolesService.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.entity.Roles;
|
||||
|
||||
/**
|
||||
* 角色服务接口
|
||||
*/
|
||||
public interface RolesService extends IService<Roles> {
|
||||
|
||||
/**
|
||||
* 根据角色名称查询角色
|
||||
* @param roleName 角色名称
|
||||
* @return 角色信息
|
||||
*/
|
||||
Roles getRoleByName(String roleName);
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
* @param roles 角色信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean createRole(Roles roles);
|
||||
|
||||
/**
|
||||
* 更新角色信息
|
||||
* @param roles 角色信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateRole(Roles roles);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
* @param id 角色ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteRole(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<Roles> listAllRoles();
|
||||
|
||||
/**
|
||||
* 根据角色ID查询角色
|
||||
* @param id 角色ID
|
||||
* @return 角色信息
|
||||
*/
|
||||
Roles getRoleById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除角色
|
||||
* @param ids 角色ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean batchDeleteRoles(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询其拥有的角色列表
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<Roles> listRolesByUserId(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ShopCategories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺分类服务接口
|
||||
*/
|
||||
public interface ShopCategoriesService extends IService<ShopCategories> {
|
||||
|
||||
/**
|
||||
* 根据分类名称查询分类
|
||||
* @param categoryName 分类名称
|
||||
* @return 分类信息
|
||||
*/
|
||||
Result<ShopCategories> getCategoryByName(String categoryName);
|
||||
|
||||
/**
|
||||
* 根据父分类ID查询子分类
|
||||
* @param parentId 父分类ID
|
||||
* @return 子分类列表
|
||||
*/
|
||||
Result<List<ShopCategories>> getSubCategoriesByParentId(Long parentId);
|
||||
|
||||
/**
|
||||
* 创建分类
|
||||
* @param shopCategories 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createCategory(ShopCategories shopCategories);
|
||||
|
||||
/**
|
||||
* 更新分类信息
|
||||
* @param shopCategories 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateCategory(ShopCategories shopCategories);
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param id 分类ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteCategory(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有根分类(父分类ID为0或null的分类)
|
||||
* @return 根分类列表
|
||||
*/
|
||||
Result<List<ShopCategories>> listRootCategories();
|
||||
|
||||
/**
|
||||
* 根据分类ID查询分类
|
||||
* @param id 分类ID
|
||||
* @return 分类信息
|
||||
*/
|
||||
Result<ShopCategories> getCategoryById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除分类
|
||||
* @param ids 分类ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchDeleteCategories(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询所有分类(树形结构)
|
||||
* @return 分类树形列表
|
||||
*/
|
||||
Result<List<ShopCategories>> listAllCategoriesWithTree();
|
||||
}
|
||||
94
src/main/java/com/qf/backend/service/ShopRatingsService.java
Normal file
94
src/main/java/com/qf/backend/service/ShopRatingsService.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.ShopRatings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺评分服务接口
|
||||
*/
|
||||
public interface ShopRatingsService extends IService<ShopRatings> {
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询评分
|
||||
* @param shopId 店铺ID
|
||||
* @return 评分列表
|
||||
*/
|
||||
Result<List<ShopRatings>> getRatingsByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询评分
|
||||
* @param userId 用户ID
|
||||
* @return 评分列表
|
||||
*/
|
||||
Result<List<ShopRatings>> getRatingsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 创建评分
|
||||
* @param shopRatings 评分信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createRating(ShopRatings shopRatings);
|
||||
|
||||
/**
|
||||
* 更新评分信息
|
||||
* @param shopRatings 评分信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateRating(ShopRatings shopRatings);
|
||||
|
||||
/**
|
||||
* 删除评分
|
||||
* @param id 评分ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteRating(Long id);
|
||||
|
||||
/**
|
||||
* 根据评分ID查询评分
|
||||
* @param id 评分ID
|
||||
* @return 评分信息
|
||||
*/
|
||||
Result<ShopRatings> getRatingById(Long id);
|
||||
|
||||
/**
|
||||
* 获取店铺平均评分
|
||||
* @param shopId 店铺ID
|
||||
* @return 平均评分
|
||||
*/
|
||||
Result<Double> getAverageRatingByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 获取店铺评分数量
|
||||
* @param shopId 店铺ID
|
||||
* @return 评分数量
|
||||
*/
|
||||
Result<Integer> getRatingCountByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 根据评分星级查询店铺评分
|
||||
* @param shopId 店铺ID
|
||||
* @param rating 评分星级
|
||||
* @return 评分列表
|
||||
*/
|
||||
Result<List<ShopRatings>> getRatingsByShopIdAndRating(Long shopId, Integer rating);
|
||||
|
||||
/**
|
||||
* 检查用户是否已对店铺评分
|
||||
* @param shopId 店铺ID
|
||||
* @param userId 用户ID
|
||||
* @return 是否已评分
|
||||
*/
|
||||
Result<Boolean> checkUserHasRated(Long shopId, Long userId);
|
||||
|
||||
/**
|
||||
* 分页查询店铺评分
|
||||
* @param shopId 店铺ID
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 评分列表
|
||||
*/
|
||||
Result<List<ShopRatings>> listRatingsByShopIdAndPage(Long shopId, int page, int size);
|
||||
}
|
||||
87
src/main/java/com/qf/backend/service/ShopsService.java
Normal file
87
src/main/java/com/qf/backend/service/ShopsService.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.Shops;
|
||||
|
||||
/**
|
||||
* 店铺服务接口
|
||||
*/
|
||||
public interface ShopsService extends IService<Shops> {
|
||||
|
||||
/**
|
||||
* 根据店铺名称查询店铺
|
||||
* @param shopName 店铺名称
|
||||
* @return 店铺列表
|
||||
*/
|
||||
Result<List<Shops>> getShopsByName(String shopName);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询店铺
|
||||
* @param userId 用户ID
|
||||
* @return 店铺信息
|
||||
*/
|
||||
Result<Shops> getShopByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 创建店铺
|
||||
* @param shops 店铺信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createShop(Shops shops);
|
||||
|
||||
/**
|
||||
* 更新店铺信息
|
||||
* @param shops 店铺信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateShop(Shops shops);
|
||||
|
||||
/**
|
||||
* 删除店铺
|
||||
* @param id 店铺ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteShop(Long id);
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询店铺
|
||||
* @param id 店铺ID
|
||||
* @return 店铺信息
|
||||
*/
|
||||
Result<Shops> getShopById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询店铺
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 店铺列表
|
||||
*/
|
||||
Result<List<Shops>> listShopsByPage(int page, int size);
|
||||
|
||||
/**
|
||||
* 根据店铺分类ID查询店铺
|
||||
* @param categoryId 分类ID
|
||||
* @return 店铺列表
|
||||
*/
|
||||
Result<List<Shops>> getShopsByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 更新店铺状态
|
||||
* @param shopId 店铺ID
|
||||
* @param status 店铺状态
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateShopStatus(Long shopId, Integer status);
|
||||
|
||||
/**
|
||||
* 搜索店铺
|
||||
* @param keyword 关键词
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 店铺列表
|
||||
*/
|
||||
Result<List<Shops>> searchShops(String keyword, int page, int size);
|
||||
}
|
||||
55
src/main/java/com/qf/backend/service/UserDetailsService.java
Normal file
55
src/main/java/com/qf/backend/service/UserDetailsService.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.UserDetails;
|
||||
|
||||
/**
|
||||
* 用户详情服务接口
|
||||
*/
|
||||
public interface UserDetailsService extends IService<UserDetails> {
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户详情
|
||||
* @param userId 用户ID
|
||||
* @return 用户详情信息
|
||||
*/
|
||||
Result<UserDetails> getUserDetailsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 创建用户详情
|
||||
* @param userDetails 用户详情信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createUserDetails(UserDetails userDetails);
|
||||
|
||||
/**
|
||||
* 更新用户详情
|
||||
* @param userDetails 用户详情信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateUserDetails(UserDetails userDetails);
|
||||
|
||||
/**
|
||||
* 根据用户ID删除用户详情
|
||||
* @param userId 用户ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteUserDetailsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户详情ID查询
|
||||
* @param id 用户详情ID
|
||||
* @return 用户详情信息
|
||||
*/
|
||||
Result<UserDetails> getUserDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 更新用户联系方式
|
||||
* @param userId 用户ID
|
||||
* @param phone 手机号
|
||||
* @param email 邮箱
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateContactInfo(Long userId, String phone, String email);
|
||||
}
|
||||
66
src/main/java/com/qf/backend/service/UserRolesService.java
Normal file
66
src/main/java/com/qf/backend/service/UserRolesService.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.UserRoles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户角色关联服务接口
|
||||
*/
|
||||
public interface UserRolesService extends IService<UserRoles> {
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户角色关联
|
||||
* @param userId 用户ID
|
||||
* @return 用户角色关联列表
|
||||
*/
|
||||
Result<List<UserRoles>> getUserRolesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询用户角色关联
|
||||
* @param roleId 角色ID
|
||||
* @return 用户角色关联列表
|
||||
*/
|
||||
Result<List<UserRoles>> getUserRolesByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 为用户添加角色
|
||||
* @param userId 用户ID
|
||||
* @param roleId 角色ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> addRoleToUser(Long userId, Long roleId);
|
||||
|
||||
/**
|
||||
* 从用户移除角色
|
||||
* @param userId 用户ID
|
||||
* @param roleId 角色ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> removeRoleFromUser(Long userId, Long roleId);
|
||||
|
||||
/**
|
||||
* 批量为用户添加角色
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> batchAddRolesToUser(Long userId, List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 清空用户的所有角色
|
||||
* @param userId 用户ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> clearUserRoles(Long userId);
|
||||
|
||||
/**
|
||||
* 检查用户是否拥有指定角色
|
||||
* @param userId 用户ID
|
||||
* @param roleId 角色ID
|
||||
* @return 是否拥有
|
||||
*/
|
||||
Result<Boolean> checkUserHasRole(Long userId, Long roleId);
|
||||
}
|
||||
77
src/main/java/com/qf/backend/service/UsersService.java
Normal file
77
src/main/java/com/qf/backend/service/UsersService.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.qf.backend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.entity.Users;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务接口
|
||||
*/
|
||||
public interface UsersService extends IService<Users> {
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
* @param username 用户名
|
||||
* @return 用户信息
|
||||
*/
|
||||
Result<Users> getUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 根据邮箱查询用户
|
||||
* @param email 邮箱
|
||||
* @return 用户信息
|
||||
*/
|
||||
Result<Users> getUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
* @param users 用户信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> createUser(Users users);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param users 用户信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updateUser(Users users);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
* @param id 用户ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> deleteUser(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有用户
|
||||
* @return 用户列表
|
||||
*/
|
||||
Result<List<Users>> listAllUsers();
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
* @param page 当前页码
|
||||
* @param size 每页数量
|
||||
* @return 用户列表
|
||||
*/
|
||||
Result<List<Users>> listUsersByPage(int page, int size);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户
|
||||
* @param id 用户ID
|
||||
* @return 用户信息
|
||||
*/
|
||||
Result<Users> getUserById(Long id);
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
* @param id 用户ID
|
||||
* @param newPassword 新密码
|
||||
* @return 是否成功
|
||||
*/
|
||||
Result<Boolean> updatePassword(Long id, String newPassword);
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.qf.backend.service.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.common.ResultUtils;
|
||||
import com.qf.backend.entity.OrderItems;
|
||||
import com.qf.backend.exception.ErrorCode;
|
||||
import com.qf.backend.mapper.OrderItemsMapper;
|
||||
import com.qf.backend.service.OrderItemsService;
|
||||
|
||||
@Service
|
||||
public class OrderItemsServiceImpl implements OrderItemsService {
|
||||
|
||||
@Autowired
|
||||
private OrderItemsMapper orderItemsMapper;
|
||||
|
||||
@Override
|
||||
public Result<List<OrderItems>> getOrderItemsByOrderId(Long orderId) {
|
||||
try {
|
||||
List<OrderItems> orderItems = orderItemsMapper.selectByOrderId(orderId);
|
||||
if (orderItems == null || orderItems.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(orderItems);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Result<List<OrderItems>> getOrderItemsByProductId(Long productId) {
|
||||
try {
|
||||
List<OrderItems> orderItems = orderItemsMapper.selectByProductId(productId);
|
||||
if (orderItems == null || orderItems.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(orderItems);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public BaseMapper<OrderItems> getBaseMapper() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getBaseMapper'");
|
||||
}
|
||||
@Override
|
||||
public Class<OrderItems> getEntityClass() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getEntityClass'");
|
||||
}
|
||||
@Override
|
||||
public Map<String, Object> getMap(Wrapper<OrderItems> queryWrapper) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getMap'");
|
||||
}
|
||||
@Override
|
||||
public <V> V getObj(Wrapper<OrderItems> queryWrapper, Function<? super Object, V> mapper) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getObj'");
|
||||
}
|
||||
@Override
|
||||
public OrderItems getOne(Wrapper<OrderItems> queryWrapper, boolean throwEx) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOne'");
|
||||
}
|
||||
@Override
|
||||
public Optional<OrderItems> getOneOpt(Wrapper<OrderItems> queryWrapper, boolean throwEx) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOneOpt'");
|
||||
}
|
||||
@Override
|
||||
public boolean saveBatch(Collection<OrderItems> entityList, int batchSize) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'saveBatch'");
|
||||
}
|
||||
@Override
|
||||
public boolean saveOrUpdate(OrderItems entity) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'saveOrUpdate'");
|
||||
}
|
||||
@Override
|
||||
public boolean saveOrUpdateBatch(Collection<OrderItems> entityList, int batchSize) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'saveOrUpdateBatch'");
|
||||
}
|
||||
@Override
|
||||
public boolean updateBatchById(Collection<OrderItems> entityList, int batchSize) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateBatchById'");
|
||||
}
|
||||
@Override
|
||||
public Result<Boolean> createOrderItem(OrderItems orderItems) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'createOrderItem'");
|
||||
}
|
||||
@Override
|
||||
public Result<Boolean> updateOrderItem(OrderItems orderItems) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateOrderItem'");
|
||||
}
|
||||
@Override
|
||||
public Result<Boolean> deleteOrderItem(Long id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'deleteOrderItem'");
|
||||
}
|
||||
@Override
|
||||
public Result<OrderItems> getOrderItemById(Long id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrderItemById'");
|
||||
}
|
||||
@Override
|
||||
public Result<Boolean> batchCreateOrderItems(List<OrderItems> orderItemsList) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'batchCreateOrderItems'");
|
||||
}
|
||||
@Override
|
||||
public Result<Boolean> deleteOrderItemsByOrderId(Long orderId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'deleteOrderItemsByOrderId'");
|
||||
}
|
||||
@Override
|
||||
public Result<Double> calculateOrderTotal(Long orderId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'calculateOrderTotal'");
|
||||
}
|
||||
@Override
|
||||
public Result<List<OrderItems>> getOrderItemsBySkuId(Long skuId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrderItemsBySkuId'");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.qf.backend.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.common.ResultUtils;
|
||||
import com.qf.backend.entity.Orders;
|
||||
import com.qf.backend.exception.ErrorCode;
|
||||
import com.qf.backend.mapper.OrdersMapper;
|
||||
import com.qf.backend.service.OrdersService;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
|
||||
@Service
|
||||
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
|
||||
@Autowired
|
||||
private OrdersMapper ordersMapper;
|
||||
@Autowired
|
||||
private Logger logger;
|
||||
|
||||
@Override
|
||||
public Result<Orders> getOrderByNumber(String orderNumber) {
|
||||
logger.info("根据订单号查询订单: {}", orderNumber);
|
||||
try {
|
||||
Orders orders = ordersMapper.selectByOrderNumber(orderNumber);
|
||||
if (orders == null) {
|
||||
logger.warn("订单号 {} 不存在", orderNumber);
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(orders);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.ORDER_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Orders>> getOrdersByUserId(Long userId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrdersByUserId'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> createOrder(Orders orders) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'createOrder'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> updateOrder(Orders orders) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateOrder'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> deleteOrder(Long id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'deleteOrder'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Orders> getOrderById(Long id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrderById'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Orders>> listOrdersByPage(int page, int size) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'listOrdersByPage'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Orders>> getOrdersByShopId(Long shopId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrdersByShopId'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> updateOrderStatus(Long orderId, Integer status) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateOrderStatus'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Orders>> getOrdersByStatus(Integer status) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrdersByStatus'");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user