feat: internal product items

This commit is contained in:
zzw
2026-10-09 13:21:59 +08:00
parent 5b1b6d7daa
commit 174b585c8a
27 changed files with 735 additions and 315 deletions
+13
View File
@@ -0,0 +1,13 @@
package dao
const (
// type: 1联系方式 2小程序门店关于我们 3小程序门店合作声明 4用户服务协议 5隐私政策 6打印机数据 7APP服务协议 8APP隐私政策
DocumentStatusNormal int32 = 1
DocumentStatusDisabled int32 = 2
)
type DocumentInfo struct {
Id int64 `gorm:"column:id" json:"id"`
Type int32 `gorm:"column:type" json:"type"`
Content string `gorm:"column:content" json:"content"`
}
@@ -0,0 +1,55 @@
package logic
import (
"context"
"strconv"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
chore "lone-services/rpc/chore/pb"
"lone-services/services/chore/internal/dao"
"lone-services/services/chore/internal/model"
"lone-services/services/chore/internal/svc"
"lone-services/services/chore/validator"
"github.com/zeromicro/go-zero/core/logx"
)
type DocumentLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
BaseLogic
}
func NewDocumentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocumentLogic {
return &DocumentLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DocumentLogic) Document(in *chore.DocumentReq) (*chore.Response, error) {
var v validator.DocumentValidator
if fail := l.checkParams(in, &v); fail != nil {
return fail, nil
}
var info dao.DocumentInfo
err := model.DocumentModel{}.Init().GetOne(modelbase.Params{
Eq: map[string]string{
"type": strconv.Itoa(int(in.Type)),
"status": strconv.Itoa(int(dao.DocumentStatusNormal)),
},
}, &info)
if err != nil {
l.Errorf("document get: %v", err)
return l.fail(utils.Fail)
}
if info.Id < utils.NumberOne {
return l.fail(utils.ErrorNotFund)
}
return l.ok(info)
}
+16 -9
View File
@@ -7,7 +7,7 @@ import (
"lone-services/pkg/rpcclient"
"lone-services/pkg/utils"
chore "lone-services/rpc/chore/pb"
user "lone-services/rpc/user/pb"
product "lone-services/rpc/product/pb"
"lone-services/services/chore/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
@@ -32,9 +32,9 @@ func NewTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestLogic {
}
func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
// cli, err := rpcclient.Get(l.svcCtx.ProductSvcName)
cli, err := rpcclient.Get(l.svcCtx.ProductSvcName)
// cli, err := rpcclient.Get(l.svcCtx.SaleSvcName)
cli, err := rpcclient.Get(l.svcCtx.UserSvcName)
// cli, err := rpcclient.Get(l.svcCtx.UserSvcName)
if err != nil {
l.Errorf("get rpc: %v", err)
@@ -114,12 +114,12 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
// Mobile: in.GetChar(),
// })
res, err := user.NewUserClient(cli.Conn()).InternalCheckUpdate(l.ctx, &user.InternalCheckUpdateReq{
BizId: int64(in.GetId()),
SubjectType: "user",
Mobile: in.GetChar(),
})
fmt.Println(res.GetResult())
// res, err := user.NewUserClient(cli.Conn()).InternalCheckUpdate(l.ctx, &user.InternalCheckUpdateReq{
// BizId: int64(in.GetId()),
// SubjectType: "user",
// Mobile: in.GetChar(),
// })
// fmt.Println(res.GetResult())
// res, err := user.NewUserClient(cli.Conn()).InternalCreate(l.ctx, &user.InternalCreateReq{
// BizId: 10086,
@@ -129,6 +129,13 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
// Identifier: in.GetChar(),
// Secret: "123123",
// })
res, err := product.NewProductClient(cli.Conn()).InternalItems(l.ctx, &product.InternalItemsReq{
Status: []uint32{},
Type: []uint32{},
})
fmt.Println(res.GetItems())
if err != nil {
l.Errorf("XXXXXX: %v", err)
return failResponse(utils.ErrorInternalServer), nil
+16
View File
@@ -0,0 +1,16 @@
package model
import "lone-services/pkg/modelbase"
type DocumentModel struct {
modelbase.Base
}
func (m DocumentModel) TableName() string {
return modelbase.Prefix() + "document"
}
func (m DocumentModel) Init() DocumentModel {
m.Table = m.TableName()
return m
}
@@ -105,6 +105,11 @@ func (s *ChoreServer) SystemItems(ctx context.Context, in *chore.EmptyReq) (*cho
return l.SystemItems(in)
}
func (s *ChoreServer) Document(ctx context.Context, in *chore.DocumentReq) (*chore.Response, error) {
l := logic.NewDocumentLogic(ctx, s.svcCtx)
return l.Document(in)
}
func (s *ChoreServer) RegionsByIds(ctx context.Context, in *chore.RegionsByIdsReq) (*chore.RegionsByIdsData, error) {
l := logic.NewRegionsByIdsLogic(ctx, s.svcCtx)
return l.RegionsByIds(in)