46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/store/internal/dao"
|
|
"lone-services/services/store/internal/model"
|
|
|
|
"lone-services/rpc/store/pb"
|
|
"lone-services/services/store/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type NamesLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic {
|
|
return &NamesLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *NamesLogic) Names(in *store.EmptyRequest) (*store.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
w := modelbase.Params{Eq: map[string]string{"status": utils.StringStatusOk}}
|
|
var names []dao.StoreNames
|
|
err := model.StoreModel{}.Init().Items(w, &names)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
return l.ok(names)
|
|
}
|