56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/pkg/validate"
|
|
"lone-services/services/factory/internal/dao"
|
|
"lone-services/services/factory/internal/model"
|
|
"strconv"
|
|
|
|
"lone-services/rpc/factory/pb"
|
|
"lone-services/services/factory/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GroupInfoLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewGroupInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupInfoLogic {
|
|
return &GroupInfoLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GroupInfoLogic) GroupInfo(in *factory.IdRequest) (*factory.Response, error) {
|
|
var v validate.InfoValidator
|
|
if fail := l.checkParams(in, &v); fail != nil {
|
|
return fail, nil
|
|
}
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info dao.GroupInfo
|
|
modelObj := model.GroupModel{}.Init()
|
|
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
|
err := modelObj.GetOne(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
if info.Id < utils.NumberOne {
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
return l.ok(info)
|
|
}
|