factory worker post
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/rpc/factory/pb"
|
||||
"lone-services/services/factory/internal/dao"
|
||||
"lone-services/services/factory/internal/model"
|
||||
"lone-services/services/factory/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type PostItemsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewPostItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostItemsLogic {
|
||||
return &PostItemsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *PostItemsLogic) PostItems(in *factory.EmptyRequest) (*factory.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
var info []dao.PostInfo
|
||||
w := modelbase.Params{
|
||||
Order: "id desc",
|
||||
}
|
||||
|
||||
err := model.PostModel{}.Init().Items(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
return l.ok(info)
|
||||
}
|
||||
Reference in New Issue
Block a user