feat: analysis admin
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package analysisadminlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
"lone-services/services/analysis/internal/dao"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/model"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
"lone-services/services/analysis/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UserDetailLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDetailLogic {
|
||||
return &UserDetailLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UserDetailLogic) UserDetail(in *analysis.AdminUserDetailReq) (*analysis.Response, error) {
|
||||
var req validator.AdminUserDetailValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return outParams(msg), nil
|
||||
}
|
||||
if _, fail := common.RequireAdmin(l.ctx); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
var detail dao.Image
|
||||
err := model.ImageModel{}.Init().GetOne(modelbase.Params{
|
||||
Eq: map[string]string{"id": strconv.FormatInt(req.Id, utils.NumberTen)},
|
||||
}, &detail)
|
||||
if err != nil {
|
||||
l.Errorf("admin user detail: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if detail.Id <= utils.NumberZero {
|
||||
return common.OkResponse(nil), nil
|
||||
}
|
||||
return common.OkResponse(buildImageDetail(&detail)), nil
|
||||
}
|
||||
Reference in New Issue
Block a user