feat: 添加毛隅管理模块的后台接口与菜单权限
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hotgo/api/admin/maoyucontent"
|
||||
"hotgo/api/admin/maoyupet"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// 毛隅管理页面控制器:内容治理 + 萌宠管理,业务经 maoyu-server 内部接口处理。
|
||||
|
||||
var (
|
||||
MaoyuContent = cMaoyuContent{}
|
||||
MaoyuPet = cMaoyuPet{}
|
||||
)
|
||||
|
||||
type (
|
||||
cMaoyuContent struct{}
|
||||
cMaoyuPet struct{}
|
||||
)
|
||||
|
||||
// ---- 内容治理 ----
|
||||
|
||||
func (*cMaoyuContent) Dashboard(ctx context.Context, req *maoyucontent.MaoyuContentDashboardReq) (res *maoyucontent.MaoyuContentDashboardRes, err error) {
|
||||
data, err := service.SysMaoyuContent().Dashboard(ctx, &req.MaoyuDashboardInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyucontent.MaoyuContentDashboardRes{MaoyuDashboardModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) List(ctx context.Context, req *maoyucontent.MaoyuContentListReq) (res *maoyucontent.MaoyuContentListRes, err error) {
|
||||
list, total, err := service.SysMaoyuContent().List(ctx, req.CultivateContentListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.CultivateContentListModel{}
|
||||
}
|
||||
res = &maoyucontent.MaoyuContentListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) View(ctx context.Context, req *maoyucontent.MaoyuContentViewReq) (res *maoyucontent.MaoyuContentViewRes, err error) {
|
||||
data, err := service.SysMaoyuContent().View(ctx, req.CultivateContentViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyucontent.MaoyuContentViewRes{CultivateContentViewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) Review(ctx context.Context, req *maoyucontent.MaoyuContentReviewReq) (res *maoyucontent.MaoyuContentReviewRes, err error) {
|
||||
err = service.SysMaoyuContent().Review(ctx, req.CultivateContentReviewInp)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) BatchReview(ctx context.Context, req *maoyucontent.MaoyuContentBatchReviewReq) (res *maoyucontent.MaoyuContentBatchReviewRes, err error) {
|
||||
data, err := service.SysMaoyuContent().BatchReview(ctx, req.CultivateContentBatchReviewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyucontent.MaoyuContentBatchReviewRes{CultivateContentBatchReviewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) ReportList(ctx context.Context, req *maoyucontent.MaoyuReportListReq) (res *maoyucontent.MaoyuReportListRes, err error) {
|
||||
list, total, err := service.SysMaoyuContent().ReportList(ctx, req.CultivateReportListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.CultivateReportListModel{}
|
||||
}
|
||||
res = &maoyucontent.MaoyuReportListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) ReportView(ctx context.Context, req *maoyucontent.MaoyuReportViewReq) (res *maoyucontent.MaoyuReportViewRes, err error) {
|
||||
data, err := service.SysMaoyuContent().ReportView(ctx, req.CultivateReportViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyucontent.MaoyuReportViewRes{CultivateReportViewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) ReportHandle(ctx context.Context, req *maoyucontent.MaoyuReportHandleReq) (res *maoyucontent.MaoyuReportHandleRes, err error) {
|
||||
err = service.SysMaoyuContent().ReportHandle(ctx, req.CultivateReportHandleInp)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuContent) LogList(ctx context.Context, req *maoyucontent.MaoyuLogListReq) (res *maoyucontent.MaoyuLogListRes, err error) {
|
||||
list, total, err := service.SysMaoyuContent().LogList(ctx, req.CultivateOperationLogListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.CultivateOperationLogListModel{}
|
||||
}
|
||||
res = &maoyucontent.MaoyuLogListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
// ---- 萌宠管理 ----
|
||||
|
||||
func (*cMaoyuPet) ActionConfigList(ctx context.Context, req *maoyupet.MaoyuActionConfigListReq) (res *maoyupet.MaoyuActionConfigListRes, err error) {
|
||||
list, total, err := service.SysMaoyuPet().ActionConfigList(ctx, req.MaoyuActionConfigListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.MaoyuActionConfigListModel{}
|
||||
}
|
||||
res = &maoyupet.MaoyuActionConfigListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) ActionConfigView(ctx context.Context, req *maoyupet.MaoyuActionConfigViewReq) (res *maoyupet.MaoyuActionConfigViewRes, err error) {
|
||||
data, err := service.SysMaoyuPet().ActionConfigView(ctx, req.MaoyuActionConfigViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyupet.MaoyuActionConfigViewRes{MaoyuActionConfigViewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) ActionConfigEdit(ctx context.Context, req *maoyupet.MaoyuActionConfigEditReq) (res *maoyupet.MaoyuActionConfigEditRes, err error) {
|
||||
err = service.SysMaoyuPet().ActionConfigEdit(ctx, req.MaoyuActionConfigEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) ActionConfigStatus(ctx context.Context, req *maoyupet.MaoyuActionConfigStatusReq) (res *maoyupet.MaoyuActionConfigStatusRes, err error) {
|
||||
err = service.SysMaoyuPet().ActionConfigStatus(ctx, req.MaoyuActionConfigStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) PetList(ctx context.Context, req *maoyupet.MaoyuPetListReq) (res *maoyupet.MaoyuPetListRes, err error) {
|
||||
list, total, err := service.SysMaoyuPet().PetList(ctx, req.MaoyuPetListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.MaoyuPetListModel{}
|
||||
}
|
||||
res = &maoyupet.MaoyuPetListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) PetView(ctx context.Context, req *maoyupet.MaoyuPetViewReq) (res *maoyupet.MaoyuPetViewRes, err error) {
|
||||
data, err := service.SysMaoyuPet().PetView(ctx, req.MaoyuPetViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyupet.MaoyuPetViewRes{MaoyuPetViewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) JobList(ctx context.Context, req *maoyupet.MaoyuJobListReq) (res *maoyupet.MaoyuJobListRes, err error) {
|
||||
list, total, err := service.SysMaoyuPet().JobList(ctx, req.MaoyuJobListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.MaoyuJobListModel{}
|
||||
}
|
||||
res = &maoyupet.MaoyuJobListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) JobView(ctx context.Context, req *maoyupet.MaoyuJobViewReq) (res *maoyupet.MaoyuJobViewRes, err error) {
|
||||
data, err := service.SysMaoyuPet().JobView(ctx, req.MaoyuJobViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &maoyupet.MaoyuJobViewRes{MaoyuJobViewModel: data}, nil
|
||||
}
|
||||
|
||||
func (*cMaoyuPet) NoticeList(ctx context.Context, req *maoyupet.MaoyuNoticeListReq) (res *maoyupet.MaoyuNoticeListRes, err error) {
|
||||
list, total, err := service.SysMaoyuPet().NoticeList(ctx, req.MaoyuNoticeListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if list == nil {
|
||||
list = []*sysin.MaoyuNoticeListModel{}
|
||||
}
|
||||
res = &maoyupet.MaoyuNoticeListRes{List: list}
|
||||
res.PageRes.Pack(req, total)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/maoyuadmin"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// 毛隅内容治理:概览、动态/评论审核、举报、操作日志。
|
||||
// 与养成内容治理同一套页面协议,业务数据经 maoyu-server 内部接口处理,Manager 不直连毛隅业务库。
|
||||
|
||||
func init() { service.RegisterSysMaoyuContent(NewSysMaoyuContent()) }
|
||||
|
||||
type sSysMaoyuContent struct{}
|
||||
|
||||
func NewSysMaoyuContent() *sSysMaoyuContent { return &sSysMaoyuContent{} }
|
||||
|
||||
// maoyuAdminScope 从管理员登录态构造毛隅内部接口调用范围。
|
||||
func maoyuAdminScope(ctx context.Context) (maoyuadmin.Scope, error) {
|
||||
tenant, err := resolveImAdminTenant(ctx, cultivateTenantID(ctx))
|
||||
if err != nil {
|
||||
return maoyuadmin.Scope{}, err
|
||||
}
|
||||
operatorID := contexts.GetUserId(ctx)
|
||||
if operatorID <= 0 {
|
||||
return maoyuadmin.Scope{}, gerror.New("当前管理员身份无效")
|
||||
}
|
||||
return maoyuadmin.Scope{
|
||||
TenantID: tenant.Id, TenantCode: tenant.Code, OperatorID: operatorID,
|
||||
RoleKey: contexts.GetRoleKey(ctx), RequestID: gctx.CtxId(ctx),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) client(ctx context.Context) *maoyuadmin.Client {
|
||||
return maoyuadmin.DefaultClient(ctx)
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) Dashboard(ctx context.Context, _ *sysin.MaoyuDashboardInp) (*sysin.MaoyuDashboardModel, error) {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.MaoyuDashboardModel)
|
||||
if err = s.client(ctx).Get(ctx, scope, "/dashboard", nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) List(ctx context.Context, in *sysin.CultivateContentListInp) (list []*sysin.CultivateContentListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "object_type", in.ObjectType)
|
||||
cultivateSetQuery(values, "author_id", in.AuthorId)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "keyword", strings.TrimSpace(in.Keyword))
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.CultivateContentListModel]
|
||||
if err = s.client(ctx).Get(ctx, scope, "/content-reviews", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.CultivateContentListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) View(ctx context.Context, in *sysin.CultivateContentViewInp) (*sysin.CultivateContentViewModel, error) {
|
||||
if err := in.Filter(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.CultivateContentViewModel)
|
||||
path := "/content-reviews/" + url.PathEscape(in.ObjectType) + "/" + url.PathEscape(in.Id)
|
||||
if err = s.client(ctx).Get(ctx, scope, path, nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) Review(ctx context.Context, in *sysin.CultivateContentReviewInp) error {
|
||||
if err := in.Filter(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := "/content-reviews/" + url.PathEscape(in.ObjectType) + "/" + url.PathEscape(in.Id) + "/actions"
|
||||
return s.client(ctx).Post(ctx, scope, path, map[string]any{"action": in.Action, "reason": strings.TrimSpace(in.Reason)}, nil)
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) BatchReview(ctx context.Context, in *sysin.CultivateContentBatchReviewInp) (*sysin.CultivateContentBatchReviewModel, error) {
|
||||
if err := in.Filter(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.CultivateContentBatchReviewModel)
|
||||
err = s.client(ctx).Post(ctx, scope, "/content-reviews/batch-actions", map[string]any{
|
||||
"object_type": in.ObjectType, "ids": in.Ids, "action": in.Action, "reason": strings.TrimSpace(in.Reason),
|
||||
}, result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) ReportList(ctx context.Context, in *sysin.CultivateReportListInp) (list []*sysin.CultivateReportListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "object_type", in.ObjectType)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "reporter_id", in.ReporterId)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.CultivateReportListModel]
|
||||
if err = s.client(ctx).Get(ctx, scope, "/reports", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.CultivateReportListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) ReportView(ctx context.Context, in *sysin.CultivateReportViewInp) (*sysin.CultivateReportViewModel, error) {
|
||||
if err := in.Filter(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.CultivateReportViewModel)
|
||||
if err = s.client(ctx).Get(ctx, scope, "/reports/"+url.PathEscape(in.Id), nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) ReportHandle(ctx context.Context, in *sysin.CultivateReportHandleInp) error {
|
||||
if err := in.Filter(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.client(ctx).Post(ctx, scope, "/reports/"+url.PathEscape(in.Id)+"/actions", map[string]any{
|
||||
"action": in.Action, "handle_result": in.HandleResult, "content_action": in.ContentAction,
|
||||
"user_action": in.UserAction, "reason": in.Reason,
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuContent) LogList(ctx context.Context, in *sysin.CultivateOperationLogListInp) (list []*sysin.CultivateOperationLogListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "operator_id", in.OperatorId)
|
||||
cultivateSetQuery(values, "operation_type", in.OperationType)
|
||||
cultivateSetQuery(values, "target_type", in.TargetType)
|
||||
cultivateSetQuery(values, "target_id", in.TargetId)
|
||||
cultivateSetQuery(values, "request_id", in.RequestId)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.CultivateOperationLogListModel]
|
||||
if err = s.client(ctx).Get(ctx, scope, "/operation-logs", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.CultivateOperationLogListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"hotgo/internal/library/maoyuadmin"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// 毛隅萌宠管理:互动动作配置(新增/编辑/启用停用)、宠物档案(只读)、场景生成任务(只读)、互动通知(只读)。
|
||||
|
||||
func init() { service.RegisterSysMaoyuPet(NewSysMaoyuPet()) }
|
||||
|
||||
type sSysMaoyuPet struct{}
|
||||
|
||||
func NewSysMaoyuPet() *sSysMaoyuPet { return &sSysMaoyuPet{} }
|
||||
|
||||
func (s *sSysMaoyuPet) ActionConfigList(ctx context.Context, in *sysin.MaoyuActionConfigListInp) (list []*sysin.MaoyuActionConfigListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "keyword", in.Keyword)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "version", in.Version)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.MaoyuActionConfigListModel]
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/action-configs", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.MaoyuActionConfigListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) ActionConfigView(ctx context.Context, in *sysin.MaoyuActionConfigViewInp) (*sysin.MaoyuActionConfigViewModel, error) {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.MaoyuActionConfigViewModel)
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/action-configs/"+url.PathEscape(in.Id), nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) ActionConfigEdit(ctx context.Context, in *sysin.MaoyuActionConfigEditInp) error {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
body := map[string]any{
|
||||
"action_name": in.ActionName, "daily_limit": in.DailyLimit, "cooldown_seconds": in.CooldownSeconds,
|
||||
"mutex_group": in.MutexGroup, "asset_key": in.AssetKey, "effect_config": in.EffectConfig, "sort_no": in.SortNo,
|
||||
}
|
||||
if id := strings.TrimSpace(in.Id); id != "" {
|
||||
return maoyuadmin.DefaultClient(ctx).Put(ctx, scope, "/action-configs/"+url.PathEscape(id), body, nil)
|
||||
}
|
||||
body["action_code"] = in.ActionCode
|
||||
return maoyuadmin.DefaultClient(ctx).Post(ctx, scope, "/action-configs", body, nil)
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) ActionConfigStatus(ctx context.Context, in *sysin.MaoyuActionConfigStatusInp) error {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return maoyuadmin.DefaultClient(ctx).Post(ctx, scope, "/action-configs/"+url.PathEscape(in.Id)+"/status", map[string]any{
|
||||
"reason": strings.TrimSpace(in.Reason),
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) PetList(ctx context.Context, in *sysin.MaoyuPetListInp) (list []*sysin.MaoyuPetListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "user_id", in.UserId)
|
||||
cultivateSetQuery(values, "pet_type", in.PetType)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "keyword", in.Keyword)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.MaoyuPetListModel]
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/pets", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.MaoyuPetListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) PetView(ctx context.Context, in *sysin.MaoyuPetViewInp) (*sysin.MaoyuPetViewModel, error) {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.MaoyuPetViewModel)
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/pets/"+url.PathEscape(in.Id), nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) JobList(ctx context.Context, in *sysin.MaoyuJobListInp) (list []*sysin.MaoyuJobListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "pet_id", in.PetId)
|
||||
cultivateSetQuery(values, "user_id", in.UserId)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "error_code", in.ErrorCode)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.MaoyuJobListModel]
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/generation-jobs", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.MaoyuJobListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) JobView(ctx context.Context, in *sysin.MaoyuJobViewInp) (*sysin.MaoyuJobViewModel, error) {
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := new(sysin.MaoyuJobViewModel)
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/generation-jobs/"+url.PathEscape(in.Id), nil, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *sSysMaoyuPet) NoticeList(ctx context.Context, in *sysin.MaoyuNoticeListInp) (list []*sysin.MaoyuNoticeListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
scope, err := maoyuAdminScope(ctx)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
normalizeCultivatePage(&in.PageReq)
|
||||
values := cultivatePageValues(in.Page, in.PerPage)
|
||||
cultivateSetQuery(values, "recipient_id", in.RecipientId)
|
||||
cultivateSetQuery(values, "actor_id", in.ActorId)
|
||||
cultivateSetQuery(values, "event_type", in.EventType)
|
||||
cultivateSetQuery(values, "status", in.Status)
|
||||
cultivateSetQuery(values, "post_id", in.PostId)
|
||||
setTimeRange(values, in.CreatedAt)
|
||||
var page maoyuadmin.Page[*sysin.MaoyuNoticeListModel]
|
||||
if err = maoyuadmin.DefaultClient(ctx).Get(ctx, scope, "/interaction-notices", values, &page); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if page.Items == nil {
|
||||
page.Items = []*sysin.MaoyuNoticeListModel{}
|
||||
}
|
||||
return page.Items, page.Total, nil
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
|
||||
"hotgo/internal/model/input/form"
|
||||
)
|
||||
|
||||
// 毛隅管理页面输入输出:概览、互动动作配置、宠物档案、场景生成任务、互动通知。
|
||||
// 内容审核、举报、操作日志协议与养成一致,直接复用 Cultivate* 输入输出,仅路由前缀不同。
|
||||
|
||||
type MaoyuDashboardInp struct{}
|
||||
type MaoyuDashboardModel struct {
|
||||
PetCount int64 `json:"petCount"`
|
||||
ActivePetCount int64 `json:"activePetCount"`
|
||||
BuildingPetCount int64 `json:"buildingPetCount"`
|
||||
JobRunningCount int64 `json:"jobRunningCount"`
|
||||
JobSucceededCount int64 `json:"jobSucceededCount"`
|
||||
JobFailedCount int64 `json:"jobFailedCount"`
|
||||
NoticeCount int64 `json:"noticeCount"`
|
||||
UnreadNoticeCount int64 `json:"unreadNoticeCount"`
|
||||
PostCount int64 `json:"postCount"`
|
||||
PublicPostCount int64 `json:"publicPostCount"`
|
||||
FriendsPostCount int64 `json:"friendsPostCount"`
|
||||
PrivatePostCount int64 `json:"privatePostCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
TakenDownCount int64 `json:"takenDownCount"`
|
||||
PendingAuditCount int64 `json:"pendingAuditCount"`
|
||||
ApprovedAuditCount int64 `json:"approvedAuditCount"`
|
||||
RejectedAuditCount int64 `json:"rejectedAuditCount"`
|
||||
PendingReportCount int64 `json:"pendingReportCount"`
|
||||
ProcessingCount int64 `json:"processingReportCount"`
|
||||
ProcessedCount int64 `json:"processedReportCount"`
|
||||
}
|
||||
|
||||
type MaoyuActionConfigListInp struct {
|
||||
form.PageReq
|
||||
Keyword string `json:"keyword"`
|
||||
Status string `json:"status" v:"in:,enabled,disabled#动作状态不正确"`
|
||||
Version string `json:"version"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (in *MaoyuActionConfigListInp) Filter(ctx context.Context) (err error) {
|
||||
if in.CreatedAt != nil && len(in.CreatedAt) == 2 && !in.CreatedAt[0].IsZero() && !in.CreatedAt[1].IsZero() {
|
||||
in.CreatedAt = []*gtime.Time{in.CreatedAt[0].StartOfDay(), in.CreatedAt[1].EndOfDay()}
|
||||
} else {
|
||||
in.CreatedAt = nil
|
||||
}
|
||||
in.Keyword = strings.TrimSpace(in.Keyword)
|
||||
return nil
|
||||
}
|
||||
|
||||
type MaoyuActionConfigListModel struct {
|
||||
Id string `json:"id"`
|
||||
ActionCode string `json:"actionCode"`
|
||||
ActionName string `json:"actionName"`
|
||||
Enabled bool `json:"enabled"`
|
||||
DailyLimit int `json:"dailyLimit"`
|
||||
CooldownSeconds int `json:"cooldownSeconds"`
|
||||
MutexGroup string `json:"mutexGroup"`
|
||||
AssetKey string `json:"assetKey"`
|
||||
EffectConfig map[string]any `json:"effectConfig"`
|
||||
ConfigVersion string `json:"configVersion"`
|
||||
SortNo int `json:"sortNo"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type MaoyuActionConfigViewInp struct {
|
||||
Id string `json:"id" v:"required#动作配置ID不能为空"`
|
||||
}
|
||||
type MaoyuActionConfigViewModel struct{ MaoyuActionConfigListModel }
|
||||
|
||||
type MaoyuActionConfigEditInp struct {
|
||||
Id string `json:"id"`
|
||||
ActionCode string `json:"actionCode" v:"required|max-length:24|regex:^[a-z][a-z0-9_]*$#动作编码不能为空|动作编码过长|动作编码仅支持小写字母、数字和下划线"`
|
||||
ActionName string `json:"actionName" v:"required|max-length:64#动作名称不能为空|动作名称过长"`
|
||||
DailyLimit int `json:"dailyLimit" v:"min:0#每日次数不能为负"`
|
||||
CooldownSeconds int `json:"cooldownSeconds" v:"min:0#冷却时间不能为负"`
|
||||
MutexGroup string `json:"mutexGroup" v:"max-length:32#互斥组过长"`
|
||||
AssetKey string `json:"assetKey" v:"required|max-length:64#素材键不能为空|素材键过长"`
|
||||
EffectConfig map[string]any `json:"effectConfig"`
|
||||
SortNo int `json:"sortNo"`
|
||||
}
|
||||
type MaoyuActionConfigStatusInp struct {
|
||||
Id string `json:"id" v:"required#动作配置ID不能为空"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type MaoyuPetListInp struct {
|
||||
form.PageReq
|
||||
UserId string `json:"userId"`
|
||||
PetType string `json:"petType"`
|
||||
Status string `json:"status" v:"in:,creating,active,deleted#宠物状态不正确"`
|
||||
Keyword string `json:"keyword"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (in *MaoyuPetListInp) Filter(ctx context.Context) (err error) {
|
||||
if in.CreatedAt != nil && len(in.CreatedAt) == 2 && !in.CreatedAt[0].IsZero() && !in.CreatedAt[1].IsZero() {
|
||||
in.CreatedAt = []*gtime.Time{in.CreatedAt[0].StartOfDay(), in.CreatedAt[1].EndOfDay()}
|
||||
} else {
|
||||
in.CreatedAt = nil
|
||||
}
|
||||
in.Keyword = strings.TrimSpace(in.Keyword)
|
||||
return nil
|
||||
}
|
||||
|
||||
type MaoyuPetListModel struct {
|
||||
Id string `json:"id"`
|
||||
UserId string `json:"userId"`
|
||||
PetType string `json:"petType"`
|
||||
CustomTypeName string `json:"customTypeName"`
|
||||
PetName string `json:"petName"`
|
||||
BirthDate string `json:"birthDate"`
|
||||
AgeEstimated bool `json:"ageEstimated"`
|
||||
WeightValue string `json:"weightValue"`
|
||||
WeightUnit string `json:"weightUnit"`
|
||||
AvatarFileId string `json:"avatarFileId"`
|
||||
Status string `json:"status"`
|
||||
CurrentSceneId string `json:"currentSceneId"`
|
||||
Version uint `json:"version"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
type MaoyuPetViewInp struct {
|
||||
Id string `json:"id" v:"required#宠物ID不能为空"`
|
||||
}
|
||||
type MaoyuPetViewModel struct{ MaoyuPetListModel }
|
||||
|
||||
type MaoyuJobListInp struct {
|
||||
form.PageReq
|
||||
PetId string `json:"petId"`
|
||||
UserId string `json:"userId"`
|
||||
Status string `json:"status" v:"in:,queued,prechecking,generating,reviewing,succeeded,failed,canceled#任务状态不正确"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (in *MaoyuJobListInp) Filter(ctx context.Context) (err error) {
|
||||
if in.CreatedAt != nil && len(in.CreatedAt) == 2 && !in.CreatedAt[0].IsZero() && !in.CreatedAt[1].IsZero() {
|
||||
in.CreatedAt = []*gtime.Time{in.CreatedAt[0].StartOfDay(), in.CreatedAt[1].EndOfDay()}
|
||||
} else {
|
||||
in.CreatedAt = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MaoyuJobListModel struct {
|
||||
Id string `json:"id"`
|
||||
UserId string `json:"userId"`
|
||||
PetId string `json:"petId"`
|
||||
Status string `json:"status"`
|
||||
Stage string `json:"stage"`
|
||||
Progress int `json:"progress"`
|
||||
ProgressMode string `json:"progressMode"`
|
||||
InputFileId string `json:"inputFileId"`
|
||||
ResultSceneId string `json:"resultSceneId"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
Provider string `json:"provider"`
|
||||
StartedAt string `json:"startedAt"`
|
||||
FinishedAt string `json:"finishedAt"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
type MaoyuJobViewInp struct {
|
||||
Id string `json:"id" v:"required#任务ID不能为空"`
|
||||
}
|
||||
type MaoyuJobViewModel struct{ MaoyuJobListModel }
|
||||
|
||||
type MaoyuNoticeListInp struct {
|
||||
form.PageReq
|
||||
RecipientId string `json:"recipientId"`
|
||||
ActorId string `json:"actorId"`
|
||||
EventType string `json:"eventType" v:"in:,post_liked,comment_liked,post_commented#通知类型不正确"`
|
||||
Status string `json:"status" v:"in:,unread,read#通知状态不正确"`
|
||||
PostId string `json:"postId"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (in *MaoyuNoticeListInp) Filter(ctx context.Context) (err error) {
|
||||
if in.CreatedAt != nil && len(in.CreatedAt) == 2 && !in.CreatedAt[0].IsZero() && !in.CreatedAt[1].IsZero() {
|
||||
in.CreatedAt = []*gtime.Time{in.CreatedAt[0].StartOfDay(), in.CreatedAt[1].EndOfDay()}
|
||||
} else {
|
||||
in.CreatedAt = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MaoyuNoticeListModel struct {
|
||||
Id string `json:"id"`
|
||||
RecipientId string `json:"recipientId"`
|
||||
ActorId string `json:"actorId"`
|
||||
EventType string `json:"eventType"`
|
||||
EventKey string `json:"eventKey"`
|
||||
PostId string `json:"postId"`
|
||||
CommentId string `json:"commentId"`
|
||||
TargetFileId string `json:"targetFileId"`
|
||||
Status string `json:"status"`
|
||||
OccurredAt string `json:"occurredAt"`
|
||||
ReadAt string `json:"readAt"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package genrouter
|
||||
|
||||
import "hotgo/internal/controller/admin/sys"
|
||||
|
||||
func init() {
|
||||
LoginRequiredRouter = append(LoginRequiredRouter, sys.MaoyuContent, sys.MaoyuPet)
|
||||
}
|
||||
@@ -189,6 +189,28 @@ type (
|
||||
ReportHandle(ctx context.Context, in *sysin.CultivateReportHandleInp) error
|
||||
LogList(ctx context.Context, in *sysin.CultivateOperationLogListInp) (list []*sysin.CultivateOperationLogListModel, totalCount int, err error)
|
||||
}
|
||||
ISysMaoyuContent interface {
|
||||
Dashboard(ctx context.Context, in *sysin.MaoyuDashboardInp) (*sysin.MaoyuDashboardModel, error)
|
||||
List(ctx context.Context, in *sysin.CultivateContentListInp) (list []*sysin.CultivateContentListModel, totalCount int, err error)
|
||||
View(ctx context.Context, in *sysin.CultivateContentViewInp) (*sysin.CultivateContentViewModel, error)
|
||||
Review(ctx context.Context, in *sysin.CultivateContentReviewInp) error
|
||||
BatchReview(ctx context.Context, in *sysin.CultivateContentBatchReviewInp) (*sysin.CultivateContentBatchReviewModel, error)
|
||||
ReportList(ctx context.Context, in *sysin.CultivateReportListInp) (list []*sysin.CultivateReportListModel, totalCount int, err error)
|
||||
ReportView(ctx context.Context, in *sysin.CultivateReportViewInp) (*sysin.CultivateReportViewModel, error)
|
||||
ReportHandle(ctx context.Context, in *sysin.CultivateReportHandleInp) error
|
||||
LogList(ctx context.Context, in *sysin.CultivateOperationLogListInp) (list []*sysin.CultivateOperationLogListModel, totalCount int, err error)
|
||||
}
|
||||
ISysMaoyuPet interface {
|
||||
ActionConfigList(ctx context.Context, in *sysin.MaoyuActionConfigListInp) (list []*sysin.MaoyuActionConfigListModel, totalCount int, err error)
|
||||
ActionConfigView(ctx context.Context, in *sysin.MaoyuActionConfigViewInp) (*sysin.MaoyuActionConfigViewModel, error)
|
||||
ActionConfigEdit(ctx context.Context, in *sysin.MaoyuActionConfigEditInp) error
|
||||
ActionConfigStatus(ctx context.Context, in *sysin.MaoyuActionConfigStatusInp) error
|
||||
PetList(ctx context.Context, in *sysin.MaoyuPetListInp) (list []*sysin.MaoyuPetListModel, totalCount int, err error)
|
||||
PetView(ctx context.Context, in *sysin.MaoyuPetViewInp) (*sysin.MaoyuPetViewModel, error)
|
||||
JobList(ctx context.Context, in *sysin.MaoyuJobListInp) (list []*sysin.MaoyuJobListModel, totalCount int, err error)
|
||||
JobView(ctx context.Context, in *sysin.MaoyuJobViewInp) (*sysin.MaoyuJobViewModel, error)
|
||||
NoticeList(ctx context.Context, in *sysin.MaoyuNoticeListInp) (list []*sysin.MaoyuNoticeListModel, totalCount int, err error)
|
||||
}
|
||||
ISysImTenant interface {
|
||||
// Model IM租户ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
@@ -967,6 +989,28 @@ func SysCultivateContent() ISysCultivateContent {
|
||||
|
||||
func RegisterSysCultivateContent(i ISysCultivateContent) { localSysCultivateContent = i }
|
||||
|
||||
var localSysMaoyuContent ISysMaoyuContent
|
||||
|
||||
func SysMaoyuContent() ISysMaoyuContent {
|
||||
if localSysMaoyuContent == nil {
|
||||
panic("implement not found for interface ISysMaoyuContent, forgot register?")
|
||||
}
|
||||
return localSysMaoyuContent
|
||||
}
|
||||
|
||||
func RegisterSysMaoyuContent(i ISysMaoyuContent) { localSysMaoyuContent = i }
|
||||
|
||||
var localSysMaoyuPet ISysMaoyuPet
|
||||
|
||||
func SysMaoyuPet() ISysMaoyuPet {
|
||||
if localSysMaoyuPet == nil {
|
||||
panic("implement not found for interface ISysMaoyuPet, forgot register?")
|
||||
}
|
||||
return localSysMaoyuPet
|
||||
}
|
||||
|
||||
func RegisterSysMaoyuPet(i ISysMaoyuPet) { localSysMaoyuPet = i }
|
||||
|
||||
func SysImTenant() ISysImTenant {
|
||||
if localSysImTenant == nil {
|
||||
panic("implement not found for interface ISysImTenant, forgot register?")
|
||||
|
||||
Reference in New Issue
Block a user