refactor: 清理订单相关字段并优化代码结构
移除OrderRequest中冗余的时间字段 将SecurityConfig中的/api/**路径设为公开 为RolesServiceImpl添加创建时间设置 优化OrdersController中订单更新逻辑 调整ShopController的导入顺序和日志信息
This commit is contained in:
@@ -77,7 +77,8 @@ public class SecurityConfig {
|
|||||||
.requestMatchers("/api/products/**").permitAll()
|
.requestMatchers("/api/products/**").permitAll()
|
||||||
// 公开获取店铺商品列表接口,不需要认证
|
// 公开获取店铺商品列表接口,不需要认证
|
||||||
.requestMatchers("/api/shop/**").permitAll()
|
.requestMatchers("/api/shop/**").permitAll()
|
||||||
|
// 公开api接口,不需要认证
|
||||||
|
.requestMatchers("/api/**").permitAll()
|
||||||
// 其他所有请求都需要认证
|
// 其他所有请求都需要认证
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ public class OrdersController {
|
|||||||
logger.info("更新订单信息请求,订单信息:{}", orderRequest);
|
logger.info("更新订单信息请求,订单信息:{}", orderRequest);
|
||||||
Orders orders = new Orders(orderRequest.getId(), orderRequest.getOrderNo(), orderRequest.getUserId(),
|
Orders orders = new Orders(orderRequest.getId(), orderRequest.getOrderNo(), orderRequest.getUserId(),
|
||||||
orderRequest.getShopId(), orderRequest.getTotalAmount(), orderRequest.getActualAmount(),
|
orderRequest.getShopId(), orderRequest.getTotalAmount(), orderRequest.getActualAmount(),
|
||||||
orderRequest.getShippingFee(), orderRequest.getOrderStatus(), orderRequest.getShippingAddress(),
|
null, orderRequest.getOrderStatus(), orderRequest.getShippingAddress(),
|
||||||
orderRequest.getReceiverName(), orderRequest.getReceiverPhone(), orderRequest.getPaymentMethod(),
|
orderRequest.getReceiverName(), orderRequest.getReceiverPhone(), orderRequest.getPaymentMethod(),
|
||||||
orderRequest.getPaymentTime(), orderRequest.getShippingTime(), orderRequest.getDeliveryTime(),
|
orderRequest.getPaymentTime(), null, null,
|
||||||
orderRequest.getCompleteTime(), orderRequest.getRemark(), null, null);
|
null, orderRequest.getRemark(), null, null);
|
||||||
return ordersService.updateOrder(orders);
|
return ordersService.updateOrder(orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.qf.backend.controller;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -10,18 +11,15 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.qf.backend.entity.Product.Products;
|
|
||||||
import com.qf.backend.entity.Shop.Shops;
|
|
||||||
import com.qf.backend.service.Shop.ShopsService;
|
|
||||||
import com.qf.backend.dto.Result;
|
import com.qf.backend.dto.Result;
|
||||||
import com.qf.backend.dto.request.ShopRequest;
|
import com.qf.backend.dto.request.ShopRequest;
|
||||||
import com.qf.backend.entity.Shop.Shops;
|
|
||||||
import com.qf.backend.service.Shop.ShopsService;
|
|
||||||
import com.qf.backend.service.Products.ProductsService;
|
|
||||||
import com.qf.backend.dto.response.ShopResponse;
|
|
||||||
import com.qf.backend.dto.response.ProductsResponse;
|
import com.qf.backend.dto.response.ProductsResponse;
|
||||||
|
import com.qf.backend.dto.response.ShopResponse;
|
||||||
|
import com.qf.backend.entity.Product.Products;
|
||||||
|
import com.qf.backend.entity.Shop.Shops;
|
||||||
|
import com.qf.backend.service.Products.ProductsService;
|
||||||
|
import com.qf.backend.service.Shop.ShopsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取店铺信息接口
|
* 获取店铺信息接口
|
||||||
@@ -37,13 +35,13 @@ public class ShopController {
|
|||||||
private ProductsService productsService;
|
private ProductsService productsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取店铺信息
|
* 根据店铺Id获取店铺信息
|
||||||
* @param shopRequest 店铺请求
|
* @param shopRequest 店铺请求
|
||||||
* @return 店铺信息
|
* @return 店铺信息
|
||||||
*/
|
*/
|
||||||
@PostMapping("/info")
|
@PostMapping("/info")
|
||||||
public Result<Shops> getShopInfo(@RequestBody ShopRequest shopRequest) {
|
public Result<Shops> getShopInfo(@RequestBody ShopRequest shopRequest) {
|
||||||
logger.info("获取店铺信息请求,店铺ID:{}", shopRequest.getId());
|
logger.info("根据店铺Id获取店铺信息请求,店铺ID:{}", shopRequest.getId());
|
||||||
return shopsService.getShopById(shopRequest.getId());
|
return shopsService.getShopById(shopRequest.getId());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ public class OrderRequest {
|
|||||||
private String receiverPhone; // 收件人电话
|
private String receiverPhone; // 收件人电话
|
||||||
private String paymentMethod; // 支付方式
|
private String paymentMethod; // 支付方式
|
||||||
private Date paymentTime; // 支付时间
|
private Date paymentTime; // 支付时间
|
||||||
private Date shippingTime; // 发货时间
|
|
||||||
private Date deliveryTime; // 送达时间
|
|
||||||
private Date completeTime; // 完成时间
|
|
||||||
private String remark; // 备注
|
private String remark; // 备注
|
||||||
private List<OrderItems> orderItems; // 订单项列表
|
private List<OrderItems> orderItems; // 订单项列表
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package com.qf.backend.service.impl.User;
|
package com.qf.backend.service.impl.User;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -74,7 +75,8 @@ public class RolesServiceImpl extends ServiceImpl<RolesMapper, Roles> implements
|
|||||||
if (existingRole != null) {
|
if (existingRole != null) {
|
||||||
throw new BusinessException(ErrorCode.BUSINESS_ERROR, "角色名称已存在: " + roles.getRoleName());
|
throw new BusinessException(ErrorCode.BUSINESS_ERROR, "角色名称已存在: " + roles.getRoleName());
|
||||||
}
|
}
|
||||||
|
// 设置创建时间为当前时间
|
||||||
|
roles.setCreatedAt(new Date());
|
||||||
int result = rolesMapper.insert(roles);
|
int result = rolesMapper.insert(roles);
|
||||||
if (result <= 0) {
|
if (result <= 0) {
|
||||||
throw new BusinessException(ErrorCode.BUSINESS_ERROR, "创建角色失败");
|
throw new BusinessException(ErrorCode.BUSINESS_ERROR, "创建角色失败");
|
||||||
|
|||||||
Reference in New Issue
Block a user