修复SetStatus的bug
This commit is contained in:
parent
152e18b0e5
commit
2c0cd12a15
|
@ -9,4 +9,4 @@ Auth:
|
|||
RefreshAfter: 60
|
||||
|
||||
Stripe:
|
||||
SK: "123"
|
||||
SK: "sk_test_51IisojHygnIJZeghPVSBhkwySfcyDV4SoAduIxu3J7bvSJ9cZMD96LY1LO6SpdbYquLJX5oKvgEBB67KT9pecfCy00iEC4pp9y"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
|
@ -35,7 +34,7 @@ func (l *AcceptCookieLogic) AcceptCookie(req *types.Request, userinfo *auth.User
|
|||
return resp.SetStatus(basic.CodeGuestDupErr)
|
||||
}
|
||||
|
||||
m := gmodel.NewFsGuestModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsGuest
|
||||
token, err := m.GenerateGuestID(l.ctx, &l.svcCtx.Config.Auth.AccessSecret)
|
||||
if err != nil {
|
||||
return resp.SetStatus(basic.CodeGuestGenErr)
|
||||
|
|
|
@ -39,8 +39,8 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
|||
return resp.SetStatus(basic.CodeSafeValueRangeErr) // IsDefault值超出范围, 返回安全值范围错误
|
||||
}
|
||||
|
||||
m := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn) // 创建地址模型
|
||||
var status int64 = 1 // 默认地址状态为1(正常)
|
||||
m := l.svcCtx.AllModels.FsAddress // 创建地址模型
|
||||
var status int64 = 1 // 默认地址状态为1(正常)
|
||||
|
||||
// 如果ID为0, 表示新增地址
|
||||
if req.Id == 0 {
|
||||
|
|
|
@ -3,7 +3,6 @@ package logic
|
|||
import (
|
||||
"context"
|
||||
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -32,7 +31,7 @@ func (l *UserAddressListLogic) UserAddressList(req *types.Request, userinfo *aut
|
|||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
m := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsAddress
|
||||
|
||||
data, err := m.GetUserAllAddress(l.ctx, userinfo.UserId)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,7 +2,6 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -32,7 +31,7 @@ func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request, userinfo *auth.Us
|
|||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
m := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsUser
|
||||
|
||||
user, err := m.FindUserById(l.ctx, userinfo.UserId)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -29,7 +28,7 @@ func NewUserFontsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFon
|
|||
}
|
||||
|
||||
func (l *UserFontsLogic) UserFonts(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
data, err := gmodel.NewFsFontModel(l.svcCtx.MysqlConn).FindAllOrderSortByDesc(l.ctx)
|
||||
data, err := l.svcCtx.AllModels.FsFont.FindAllOrderSortByDesc(l.ctx)
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
|
|
|
@ -3,7 +3,6 @@ package logic
|
|||
import (
|
||||
"context"
|
||||
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -33,7 +32,7 @@ func (l *UserGetTypeLogic) UserGetType(req *types.Request, userinfo *auth.UserIn
|
|||
}
|
||||
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
data, err := gmodel.NewFsCanteenTypeModel(l.svcCtx.MysqlConn).FindAllGetType(l.ctx)
|
||||
data, err := l.svcCtx.AllModels.FsCanteenType.FindAllGetType(l.ctx)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -31,7 +30,7 @@ func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLog
|
|||
|
||||
func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin) (resp *basic.Response, jwtToken string) {
|
||||
// 创建一个 FsUserModel 对象 m 并实例化之,该对象用于操作 MySQL 数据库中的用户数据表。
|
||||
m := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsUser
|
||||
|
||||
// 在用户数据表中根据登录名(email)查找用户记录,并返回 UserModel 类型的结构体对象 userModel。
|
||||
user, err := m.FindUserByEmail(l.ctx, req.Name)
|
||||
|
|
|
@ -48,7 +48,7 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||
}
|
||||
|
||||
m := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsOrder
|
||||
order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
|
@ -125,7 +125,7 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
})
|
||||
// ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
pay := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
pay := l.svcCtx.AllModels.FsPay
|
||||
|
||||
// 查询支付信息
|
||||
pays, err := pay.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
|
@ -145,7 +145,7 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
// }
|
||||
// return ResponseError(500, "Cancellation failure")
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
return resp.SetStatus(basic.CodePayCancelNotOk)
|
||||
}
|
||||
|
||||
// func (l *OrderLogic) CancelOrder(req *types.RequestCancelOrder, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
|
|
|
@ -33,7 +33,7 @@ func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoFo
|
|||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
m := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
|
||||
m := l.svcCtx.AllModels.FsUser
|
||||
err := m.UpdateUserBasicInfoById(l.ctx, userinfo.UserId, &gmodel.UserBasicInfoForSave{
|
||||
FirstName: req.FirstName,
|
||||
LastName: req.LastName,
|
||||
|
|
|
@ -96,64 +96,3 @@ func (l *UserStatusConfigLogic) UserStatusConfig(req *types.Request, userinfo *a
|
|||
|
||||
return resp.SetStatus(basic.CodeOK, data)
|
||||
}
|
||||
|
||||
// [
|
||||
// //返回订单每个状态值
|
||||
// //搜索下拉列表
|
||||
// 'search_list' => [
|
||||
// ['key' => -1, "name" => 'All'],
|
||||
// ['key' => 1, "name" => 'Order Has Been Placed'],
|
||||
// ['key' => 2, "name" => 'In Production'],
|
||||
// ['key' => 3, "name" => 'Shipped'],
|
||||
// ['key' => 4, "name" => 'Inventory'],
|
||||
// ['key' => 8, "name" => 'Ready for Shipment'],
|
||||
// ['key' => 5, "name" => 'Completed'],
|
||||
// // ['key' => 6, "name" => 'Refund Under Review'],
|
||||
// ['key' => 7, "name" => 'Transaction Closed'],
|
||||
// ],
|
||||
// //直邮单状态
|
||||
// 'order_status' => [
|
||||
// ['key' => 1, "name" => 'Order Has Been Placed', 'button' => ['download_invoice', 'cancel', 'again', 'toPay']],
|
||||
// ['key' => 2, "name" => 'In Production', 'button' => ['download_invoice', 'again', 'toPay']],
|
||||
// ['key' => 3, "name" => 'Shipped', 'button' => ['download_invoice', 'again', 'view_logistics']],
|
||||
// ['key' => 5, "name" => 'Completed', 'button' => ['download_invoice', 'again', 'view_logistics', 'delete']],
|
||||
// // ['key' => 6, "name" => 'Refund Under Review', 'button' => ['again', 'delete']],
|
||||
// ['key' => 7, "name" => 'Transaction Closed', 'button' => ['again', 'delete']],
|
||||
// ],
|
||||
// //云仓单状态
|
||||
// 'Inventory_status' => [
|
||||
// ['key' => 1, "name" => 'Order Has Been Placed', 'button' => ['download_invoice', 'cancel', 'again', 'toPay']],
|
||||
// ['key' => 2, "name" => 'In Production', 'button' => ['download_invoice', 'again', 'toPay']],
|
||||
// ['key' => 4, "name" => 'Inventory', 'button' => ['download_invoice', 'again', 'go_cloud', 'toPay']],
|
||||
// ['key' => 8, "name" => 'Ready for Shipment', 'button' => ['download_invoice', 'again', 'go_cloud', 'delete']],
|
||||
// // ['key' => 6, "name" => 'Refund Under Review', 'button' => ['again', 'delete']],
|
||||
// ['key' => 7, "name" => 'Transaction Closed', 'button' => ['again', 'delete']],
|
||||
// ],
|
||||
// //订单物流状态
|
||||
// 'order_logistics_status' => Order::$statusFontLogisticOrder,
|
||||
// //订单物流状态
|
||||
// 'Inventory_logistics_status' => Order::$statusFontLogisticInventory,
|
||||
// //返回订单时间筛选项
|
||||
// 'time' => [
|
||||
// ['key' => 0, 'name' => 'All'],
|
||||
// ['key' => 1, 'name' => 'within a month'],
|
||||
// ['key' => 2, 'name' => 'within a quarter'],
|
||||
// ['key' => 3, 'name' => 'Within half a year'],
|
||||
// ['key' => 4, 'name' => 'Within a year'],
|
||||
// ],
|
||||
// //退款原因说明项
|
||||
// 'refund_reason' => [
|
||||
// ['key' => 1, 'name' => 'I don\'t want it anymore'],
|
||||
// ['key' => 2, 'name' => 'no reason'],
|
||||
// ['key' => 3, 'name' => 'other'],
|
||||
// ],
|
||||
// //物流状态筛选项
|
||||
// 'logistics_status' => [
|
||||
// ['key' => -1, "name" => 'All'],
|
||||
// ['key' => 1, "name" => 'Draw', 'button' => []],
|
||||
// ['key' => 2, "name" => 'Shipping', 'button' => []],
|
||||
// // ['key' => Deliver::STATUS_PORT, "name" => 'To the port', 'button' => []],
|
||||
// ['key' => 3, "name" => 'UPS pick up', 'button' => ['check_detail']],
|
||||
// ['key' => 4, "name" => 'Arrival', 'button' => []],
|
||||
// ]
|
||||
// ];
|
||||
|
|
|
@ -22,7 +22,9 @@ var (
|
|||
CodeOrderNotFoundErr = &StatusResponse{5030, "the order not found"} //未找到订单
|
||||
CodeOrderNotCancelledErr = &StatusResponse{5031, "The current order cannot be cancelled"} // 当前订单无法取消
|
||||
|
||||
CodePayNotFoundErr = &StatusResponse{5020, "The pay not found"} // 支付信息无法查询
|
||||
CodePayNotFoundErr = &StatusResponse{5020, "The pay not found"} // 支付信息无法查询
|
||||
CodePayCancelOk = &StatusResponse{5021, "Cancel successfully"} // 支付取消
|
||||
CodePayCancelNotOk = &StatusResponse{5022, "Cancel failure"} // 支付取消
|
||||
|
||||
CodeGuestDupErr = &StatusResponse{5010, "the user is already a guest user and does not need to apply again"} // 用户已经是访客用户,不需要重复申请
|
||||
CodeGuestGenErr = &StatusResponse{5011, "serialization failed for guest_id of the visitor"} // 访客ID序列化失败
|
||||
|
@ -96,11 +98,16 @@ func (resp *Response) SetStatusWithMessage(sr *StatusResponse, msg string, data
|
|||
Code: sr.Code,
|
||||
Message: msg,
|
||||
}
|
||||
if len(data) == 1 {
|
||||
|
||||
switch len(data) {
|
||||
case 0:
|
||||
// 0 直接返回
|
||||
case 1:
|
||||
newResp.Data = data[0]
|
||||
} else {
|
||||
default:
|
||||
panic("data只接收一个 data")
|
||||
}
|
||||
|
||||
return newResp
|
||||
}
|
||||
|
||||
|
@ -109,10 +116,13 @@ func (resp *Response) SetStatusAddMessage(sr *StatusResponse, msg string, data .
|
|||
Code: sr.Code,
|
||||
Message: sr.Message + ":" + msg,
|
||||
}
|
||||
if len(data) == 1 {
|
||||
switch len(data) {
|
||||
case 0:
|
||||
// 0 直接返回
|
||||
case 1:
|
||||
newResp.Data = data[0]
|
||||
} else {
|
||||
panic("data只接收一个")
|
||||
default:
|
||||
panic("data只接收一个 data")
|
||||
}
|
||||
return newResp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user