45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
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 GroupNamesLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewGroupNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNamesLogic {
|
|
return &GroupNamesLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GroupNamesLogic) GroupNames(in *factory.EmptyRequest) (*factory.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
w := modelbase.Params{Eq: map[string]string{"id": utils.StringStatusOk}}
|
|
var names []dao.GroupName
|
|
err := model.GroupModel{}.Init().Items(w, &names)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
return l.ok(names)
|
|
}
|