feat: import services and standardize Go 1.26.5
This commit is contained in:
32
apps/ec/mall/internal/logic/freight/create.go
Normal file
32
apps/ec/mall/internal/logic/freight/create.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// Create 运费模板创建
|
||||
func Create(ctx context.Context, in *pb.FreightItem) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if in.GetTitle() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().Unix(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
33
apps/ec/mall/internal/logic/freight/delete.go
Normal file
33
apps/ec/mall/internal/logic/freight/delete.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// 运费模板删除
|
||||
func Delete(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
32
apps/ec/mall/internal/logic/freight/deny_region_create.go
Normal file
32
apps/ec/mall/internal/logic/freight/deny_region_create.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// CreateRegion 新建限制区域
|
||||
func DenyRegionCreate(ctx context.Context, in *pb.DenyRegionItem) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if in.GetTitle() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().Unix(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
32
apps/ec/mall/internal/logic/freight/deny_region_delete.go
Normal file
32
apps/ec/mall/internal/logic/freight/deny_region_delete.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 移除限制区域
|
||||
func DenyRegionDelete(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
28
apps/ec/mall/internal/logic/freight/deny_region_fetch.go
Normal file
28
apps/ec/mall/internal/logic/freight/deny_region_fetch.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// DenyRegionFetch 限制区域列表
|
||||
func DenyRegionFetch(ctx context.Context, in *pb.FetchRequest) (reply *pb.DenyRegionReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
apps/ec/mall/internal/logic/freight/deny_region_modify.go
Normal file
29
apps/ec/mall/internal/logic/freight/deny_region_modify.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// ModifyRegion 编辑限制区域
|
||||
func DenyRegionModify(ctx context.Context, in *pb.DenyRegionItem) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: valid code
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().Unix(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
33
apps/ec/mall/internal/logic/freight/deny_region_remove.go
Normal file
33
apps/ec/mall/internal/logic/freight/deny_region_remove.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// RemoveRegion 移除限制区域
|
||||
func DenyRegionRemove(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().Unix(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
27
apps/ec/mall/internal/logic/freight/detail.go
Normal file
27
apps/ec/mall/internal/logic/freight/detail.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// Detail 运费模板详情
|
||||
func Detail(ctx context.Context, in *pb.IdentRequest) (reply *pb.FreightItem, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
apps/ec/mall/internal/logic/freight/fetch.go
Normal file
29
apps/ec/mall/internal/logic/freight/fetch.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// Freight 运费模板列表
|
||||
func Fetch(ctx context.Context, in *pb.FetchRequest) (reply *pb.FreightReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
32
apps/ec/mall/internal/logic/freight/modify.go
Normal file
32
apps/ec/mall/internal/logic/freight/modify.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// Modify 运费模板修改
|
||||
func Modify(ctx context.Context, in *pb.FreightItem) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if in.GetTitle() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
40
apps/ec/mall/internal/logic/freight/remove.go
Normal file
40
apps/ec/mall/internal/logic/freight/remove.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package freight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-ec/mall/internal/impl"
|
||||
"git.apinb.com/bsm-ec/mall/internal/models"
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// FreightRemove 运费模板删除
|
||||
func Remove(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
err = impl.DBService.Where("id=? or identity=?", in.GetId(), in.GetIdentity()).Delete(&models.MallFreight{}).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user