refactor: remove redundant name fields from order service

This commit is contained in:
zetaloop
2026-04-22 22:28:41 +08:00
parent b3db04c9cc
commit 2d45d7e3cb
21 changed files with 179 additions and 1062 deletions
@@ -49,18 +49,13 @@ func (l *AddOrdersLogic) AddOrders(in *pb.AddOrdersReq) (*pb.AddOrdersResp, erro
creator := l.svcCtx.OrderModelsRW.Orders.Create().
SetID(orderID).
SetConsumerID(in.ConsumerId).
SetConsumerName(in.ConsumerName).
SetPlayerID(in.PlayerId).
SetPlayerName(in.PlayerName).
SetServiceSnapshot(serviceSnapshot).
SetTotalPrice(totalPrice)
if in.ShopId != nil {
creator = creator.SetShopID(*in.ShopId)
}
if in.ShopName != nil {
creator = creator.SetShopName(*in.ShopName)
}
if in.Status != nil && *in.Status != "" {
creator = creator.SetStatus(*in.Status)
}
-5
View File
@@ -53,9 +53,7 @@ func toPBOrder(item *models.Orders) *pb.Orders {
result := &pb.Orders{
Id: item.ID,
ConsumerId: item.ConsumerID,
ConsumerName: item.ConsumerName,
PlayerId: item.PlayerID,
PlayerName: item.PlayerName,
ServiceSnapshot: serviceSnapshot,
Status: item.Status,
TotalPrice: item.TotalPrice.String(),
@@ -67,9 +65,6 @@ func toPBOrder(item *models.Orders) *pb.Orders {
if item.ShopID != nil {
result.ShopId = item.ShopID
}
if item.ShopName != nil {
result.ShopName = item.ShopName
}
if item.Note != nil {
result.Note = item.Note
}
@@ -42,21 +42,12 @@ func (l *SearchOrdersLogic) SearchOrders(in *pb.SearchOrdersReq) (*pb.SearchOrde
if in.ConsumerId != nil {
preds = append(preds, orders.ConsumerIDEQ(*in.ConsumerId))
}
if in.ConsumerName != nil && *in.ConsumerName != "" {
preds = append(preds, orders.ConsumerNameContainsFold(*in.ConsumerName))
}
if in.PlayerId != nil {
preds = append(preds, orders.PlayerIDEQ(*in.PlayerId))
}
if in.PlayerName != nil && *in.PlayerName != "" {
preds = append(preds, orders.PlayerNameContainsFold(*in.PlayerName))
}
if in.ShopId != nil {
preds = append(preds, orders.ShopIDEQ(*in.ShopId))
}
if in.ShopName != nil && *in.ShopName != "" {
preds = append(preds, orders.ShopNameContainsFold(*in.ShopName))
}
if in.Status != nil && *in.Status != "" {
preds = append(preds, orders.StatusEQ(*in.Status))
}
@@ -32,21 +32,12 @@ func (l *UpdateOrdersLogic) UpdateOrders(in *pb.UpdateOrdersReq) (*pb.UpdateOrde
if in.ConsumerId != nil {
updater = updater.SetConsumerID(*in.ConsumerId)
}
if in.ConsumerName != nil {
updater = updater.SetConsumerName(*in.ConsumerName)
}
if in.PlayerId != nil {
updater = updater.SetPlayerID(*in.PlayerId)
}
if in.PlayerName != nil {
updater = updater.SetPlayerName(*in.PlayerName)
}
if in.ShopId != nil {
updater = updater.SetShopID(*in.ShopId)
}
if in.ShopName != nil {
updater = updater.SetShopName(*in.ShopName)
}
if in.ServiceSnapshot != nil {
snapshot, err := parseJSONMap(*in.ServiceSnapshot)
if err != nil {