feat: 新增养成管理后台

This commit is contained in:
richjohnrambo
2026-09-19 14:36:30 +08:00
parent 7c8b4d9b7c
commit f6766d3dbd
59 changed files with 3001 additions and 0 deletions
@@ -0,0 +1,29 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// AdminOperationLog is the golang structure of table cv_admin_operation_log for DAO operations like Where/Data.
type AdminOperationLog struct {
g.Meta `orm:"table:cv_admin_operation_log, do:true"`
Id any //
TenantId any //
OperatorId any //
OperationType any //
TargetType any //
TargetId any //
RequestId any //
BeforeSnapshot *gjson.Json //
AfterSnapshot *gjson.Json //
Reason any //
IpAddress any //
UserAgent any //
CreatedAt *gtime.Time //
}
@@ -0,0 +1,29 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// ContentAuditLog is the golang structure of table cv_content_audit_log for DAO operations like Where/Data.
type ContentAuditLog struct {
g.Meta `orm:"table:cv_content_audit_log, do:true"`
Id any //
TenantId any //
ObjectType any //
ObjectId any //
AuditRequestId any //
AuditSource any //
StatusBefore any //
StatusAfter any //
ResultCode any //
RiskLabels *gjson.Json //
OperatorId any //
OccurredAt *gtime.Time //
CreatedAt *gtime.Time //
}
+29
View File
@@ -0,0 +1,29 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FeedComment is the golang structure of table cv_feed_comment for DAO operations like Where/Data.
type FeedComment struct {
g.Meta `orm:"table:cv_feed_comment, do:true"`
Id any //
TenantId any //
PostId any //
AuthorId any //
ContentText any //
Status any //
AuditStatus any //
AuditRequestId any //
DeletedBy any //
DeleteReason any //
PublishedAt *gtime.Time //
DeletedAt *gtime.Time //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
+29
View File
@@ -0,0 +1,29 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FeedMedia is the golang structure of table cv_feed_media for DAO operations like Where/Data.
type FeedMedia struct {
g.Meta `orm:"table:cv_feed_media, do:true"`
Id any //
TenantId any //
PostId any //
UserId any //
MediaType any //
FileId any //
ThumbnailFileId any //
Width any //
Height any //
SortNo any //
AuditStatus any //
AuditRequestId any //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
+35
View File
@@ -0,0 +1,35 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FeedPost is the golang structure of table cv_feed_post for DAO operations like Where/Data.
type FeedPost struct {
g.Meta `orm:"table:cv_feed_post, do:true"`
Id any //
TenantId any //
AuthorId any //
ContentText any //
FlowerCode any //
SourceType any //
SourceId any //
Visibility any //
Status any //
AuditStatus any //
AuditRequestId any //
RejectReasonCode any //
LikeCount any //
CommentCount any //
Version any //
PublishedAt *gtime.Time //
DeletedAt *gtime.Time //
TakenDownAt *gtime.Time //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
+32
View File
@@ -0,0 +1,32 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FeedReport is the golang structure of table cv_feed_report for DAO operations like Where/Data.
type FeedReport struct {
g.Meta `orm:"table:cv_feed_report, do:true"`
Id any //
TenantId any //
ReporterId any //
ReportedUserId any //
ObjectType any //
ObjectId any //
ReasonCode any //
Description any //
EvidenceFileIds *gjson.Json //
SourcePage any //
Status any //
HandlerId any //
HandleResult any //
HandledAt *gtime.Time //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
@@ -0,0 +1,32 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FlowerCatalog is the golang structure of table cv_flower_catalog for DAO operations like Where/Data.
type FlowerCatalog struct {
g.Meta `orm:"table:cv_flower_catalog, do:true"`
Id any //
TenantId any //
FlowerCode any //
FlowerName any //
FlowerDesc any //
IconFileId any //
Status any //
ConfigVersion any //
DailyWaterLimit any //
DailyFertilizeLimit any //
ShareConfig *gjson.Json //
SortNo any //
OnlineAt *gtime.Time //
OfflineAt *gtime.Time //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
@@ -0,0 +1,32 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FlowerStageRule is the golang structure of table cv_flower_stage_rule for DAO operations like Where/Data.
type FlowerStageRule struct {
g.Meta `orm:"table:cv_flower_stage_rule, do:true"`
Id any //
TenantId any //
FlowerCatalogId any //
Stage any //
NextStage any //
RequiredPoints any //
WaterPoints any //
FertilizePoints any //
AllowedActions *gjson.Json //
ImageFileId any //
AnimationFileId any //
ProgressTextTemplate any //
CompletionText any //
SortNo any //
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}
@@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
// AdminOperationLog is the golang structure for table admin_operation_log.
type AdminOperationLog struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
OperatorId uint64 `json:"operatorId" orm:"operator_id" description:""`
OperationType string `json:"operationType" orm:"operation_type" description:""`
TargetType string `json:"targetType" orm:"target_type" description:""`
TargetId string `json:"targetId" orm:"target_id" description:""`
RequestId string `json:"requestId" orm:"request_id" description:""`
BeforeSnapshot *gjson.Json `json:"beforeSnapshot" orm:"before_snapshot" description:""`
AfterSnapshot *gjson.Json `json:"afterSnapshot" orm:"after_snapshot" description:""`
Reason string `json:"reason" orm:"reason" description:""`
IpAddress string `json:"ipAddress" orm:"ip_address" description:""`
UserAgent string `json:"userAgent" orm:"user_agent" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
}
@@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
// ContentAuditLog is the golang structure for table content_audit_log.
type ContentAuditLog struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
ObjectType string `json:"objectType" orm:"object_type" description:""`
ObjectId uint64 `json:"objectId" orm:"object_id" description:""`
AuditRequestId string `json:"auditRequestId" orm:"audit_request_id" description:""`
AuditSource string `json:"auditSource" orm:"audit_source" description:""`
StatusBefore string `json:"statusBefore" orm:"status_before" description:""`
StatusAfter string `json:"statusAfter" orm:"status_after" description:""`
ResultCode string `json:"resultCode" orm:"result_code" description:""`
RiskLabels *gjson.Json `json:"riskLabels" orm:"risk_labels" description:""`
OperatorId uint64 `json:"operatorId" orm:"operator_id" description:""`
OccurredAt *gtime.Time `json:"occurredAt" orm:"occurred_at" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
}
@@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// FeedComment is the golang structure for table feed_comment.
type FeedComment struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
PostId uint64 `json:"postId" orm:"post_id" description:""`
AuthorId uint64 `json:"authorId" orm:"author_id" description:""`
ContentText string `json:"contentText" orm:"content_text" description:""`
Status string `json:"status" orm:"status" description:""`
AuditStatus string `json:"auditStatus" orm:"audit_status" description:""`
AuditRequestId string `json:"auditRequestId" orm:"audit_request_id" description:""`
DeletedBy uint64 `json:"deletedBy" orm:"deleted_by" description:""`
DeleteReason string `json:"deleteReason" orm:"delete_reason" description:""`
PublishedAt *gtime.Time `json:"publishedAt" orm:"published_at" description:""`
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
@@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// FeedMedia is the golang structure for table feed_media.
type FeedMedia struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
PostId uint64 `json:"postId" orm:"post_id" description:""`
UserId uint64 `json:"userId" orm:"user_id" description:""`
MediaType string `json:"mediaType" orm:"media_type" description:""`
FileId string `json:"fileId" orm:"file_id" description:""`
ThumbnailFileId string `json:"thumbnailFileId" orm:"thumbnail_file_id" description:""`
Width uint `json:"width" orm:"width" description:""`
Height uint `json:"height" orm:"height" description:""`
SortNo uint `json:"sortNo" orm:"sort_no" description:""`
AuditStatus string `json:"auditStatus" orm:"audit_status" description:""`
AuditRequestId string `json:"auditRequestId" orm:"audit_request_id" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
+33
View File
@@ -0,0 +1,33 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// FeedPost is the golang structure for table feed_post.
type FeedPost struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
AuthorId uint64 `json:"authorId" orm:"author_id" description:""`
ContentText string `json:"contentText" orm:"content_text" description:""`
FlowerCode string `json:"flowerCode" orm:"flower_code" description:""`
SourceType string `json:"sourceType" orm:"source_type" description:""`
SourceId uint64 `json:"sourceId" orm:"source_id" description:""`
Visibility string `json:"visibility" orm:"visibility" description:""`
Status string `json:"status" orm:"status" description:""`
AuditStatus string `json:"auditStatus" orm:"audit_status" description:""`
AuditRequestId string `json:"auditRequestId" orm:"audit_request_id" description:""`
RejectReasonCode string `json:"rejectReasonCode" orm:"reject_reason_code" description:""`
LikeCount uint `json:"likeCount" orm:"like_count" description:""`
CommentCount uint `json:"commentCount" orm:"comment_count" description:""`
Version uint `json:"version" orm:"version" description:""`
PublishedAt *gtime.Time `json:"publishedAt" orm:"published_at" description:""`
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""`
TakenDownAt *gtime.Time `json:"takenDownAt" orm:"taken_down_at" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
@@ -0,0 +1,30 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
// FeedReport is the golang structure for table feed_report.
type FeedReport struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
ReporterId uint64 `json:"reporterId" orm:"reporter_id" description:""`
ReportedUserId uint64 `json:"reportedUserId" orm:"reported_user_id" description:""`
ObjectType string `json:"objectType" orm:"object_type" description:""`
ObjectId string `json:"objectId" orm:"object_id" description:""`
ReasonCode string `json:"reasonCode" orm:"reason_code" description:""`
Description string `json:"description" orm:"description" description:""`
EvidenceFileIds *gjson.Json `json:"evidenceFileIds" orm:"evidence_file_ids" description:""`
SourcePage string `json:"sourcePage" orm:"source_page" description:""`
Status string `json:"status" orm:"status" description:""`
HandlerId uint64 `json:"handlerId" orm:"handler_id" description:""`
HandleResult string `json:"handleResult" orm:"handle_result" description:""`
HandledAt *gtime.Time `json:"handledAt" orm:"handled_at" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
@@ -0,0 +1,30 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
// FlowerCatalog is the golang structure for table flower_catalog.
type FlowerCatalog struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
FlowerCode string `json:"flowerCode" orm:"flower_code" description:""`
FlowerName string `json:"flowerName" orm:"flower_name" description:""`
FlowerDesc string `json:"flowerDesc" orm:"flower_desc" description:""`
IconFileId string `json:"iconFileId" orm:"icon_file_id" description:""`
Status string `json:"status" orm:"status" description:""`
ConfigVersion string `json:"configVersion" orm:"config_version" description:""`
DailyWaterLimit uint `json:"dailyWaterLimit" orm:"daily_water_limit" description:""`
DailyFertilizeLimit uint `json:"dailyFertilizeLimit" orm:"daily_fertilize_limit" description:""`
ShareConfig *gjson.Json `json:"shareConfig" orm:"share_config" description:""`
SortNo int `json:"sortNo" orm:"sort_no" description:""`
OnlineAt *gtime.Time `json:"onlineAt" orm:"online_at" description:""`
OfflineAt *gtime.Time `json:"offlineAt" orm:"offline_at" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
@@ -0,0 +1,30 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
// FlowerStageRule is the golang structure for table flower_stage_rule.
type FlowerStageRule struct {
Id uint64 `json:"id" orm:"id" description:""`
TenantId uint64 `json:"tenantId" orm:"tenant_id" description:""`
FlowerCatalogId uint64 `json:"flowerCatalogId" orm:"flower_catalog_id" description:""`
Stage string `json:"stage" orm:"stage" description:""`
NextStage string `json:"nextStage" orm:"next_stage" description:""`
RequiredPoints uint `json:"requiredPoints" orm:"required_points" description:""`
WaterPoints uint `json:"waterPoints" orm:"water_points" description:""`
FertilizePoints uint `json:"fertilizePoints" orm:"fertilize_points" description:""`
AllowedActions *gjson.Json `json:"allowedActions" orm:"allowed_actions" description:""`
ImageFileId string `json:"imageFileId" orm:"image_file_id" description:""`
AnimationFileId string `json:"animationFileId" orm:"animation_file_id" description:""`
ProgressTextTemplate string `json:"progressTextTemplate" orm:"progress_text_template" description:""`
CompletionText string `json:"completionText" orm:"completion_text" description:""`
SortNo int `json:"sortNo" orm:"sort_no" description:""`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
}
@@ -0,0 +1,149 @@
package sysin
import (
"context"
"strconv"
"strings"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/model/input/form"
)
type CultivateContentListInp struct {
form.PageReq
ObjectType string `json:"objectType" d:"feed_post"`
AuthorId string `json:"authorId"`
Status string `json:"status"`
Keyword string `json:"keyword"`
CreatedAt []*gtime.Time `json:"createdAt"`
}
func (in *CultivateContentListInp) Filter(context.Context) error {
in.ObjectType = strings.TrimSpace(in.ObjectType)
if in.ObjectType != "feed_post" && in.ObjectType != "feed_comment" {
return gerror.New("内容类型不正确")
}
if in.AuthorId != "" {
if _, err := strconv.ParseUint(in.AuthorId, 10, 64); err != nil {
return gerror.New("作者ID不正确")
}
}
return nil
}
type CultivateContentListModel struct {
Id string `json:"id"`
ObjectType string `json:"objectType"`
PostId string `json:"postId"`
AuthorId string `json:"authorId"`
ContentText string `json:"contentText"`
FlowerCode string `json:"flowerCode"`
Visibility string `json:"visibility"`
Status string `json:"status"`
AuditStatus string `json:"auditStatus"`
RejectReason string `json:"rejectReason"`
LikeCount uint `json:"likeCount"`
CommentCount uint `json:"commentCount"`
CreatedAt *gtime.Time `json:"createdAt"`
UpdatedAt *gtime.Time `json:"updatedAt"`
}
type CultivateContentReviewInp struct {
ObjectType string `json:"objectType" v:"required|in:feed_post,feed_comment#内容类型不能为空|内容类型不正确"`
Id string `json:"id" v:"required#内容ID不能为空"`
Action string `json:"action" v:"required|in:approve,reject,take_down,restore#审核动作不能为空|审核动作不正确"`
Reason string `json:"reason"`
ObjectId uint64 `json:"-"`
}
func (in *CultivateContentReviewInp) Filter(context.Context) error {
id, err := strconv.ParseUint(strings.TrimSpace(in.Id), 10, 64)
if err != nil || id == 0 {
return gerror.New("内容ID不正确")
}
in.ObjectId = id
in.Reason = strings.TrimSpace(in.Reason)
if (in.Action == "reject" || in.Action == "take_down") && in.Reason == "" {
return gerror.New("拒绝或下架时必须填写原因")
}
return nil
}
type CultivateReportListInp struct {
form.PageReq
ObjectType string `json:"objectType"`
Status string `json:"status"`
ReporterId string `json:"reporterId"`
CreatedAt []*gtime.Time `json:"createdAt"`
}
func (in *CultivateReportListInp) Filter(context.Context) error {
if in.ReporterId != "" {
if _, err := strconv.ParseUint(in.ReporterId, 10, 64); err != nil {
return gerror.New("举报人ID不正确")
}
}
return nil
}
type CultivateReportListModel struct {
Id string `json:"id"`
ReporterId string `json:"reporterId"`
ReportedUserId string `json:"reportedUserId"`
ObjectType string `json:"objectType"`
ObjectId string `json:"objectId"`
ReasonCode string `json:"reasonCode"`
Description string `json:"description"`
EvidenceFileIds any `json:"evidenceFileIds"`
SourcePage string `json:"sourcePage"`
Status string `json:"status"`
HandlerId string `json:"handlerId"`
HandleResult string `json:"handleResult"`
HandledAt *gtime.Time `json:"handledAt"`
CreatedAt *gtime.Time `json:"createdAt"`
}
type CultivateReportHandleInp struct {
Id string `json:"id" v:"required#举报ID不能为空"`
Action string `json:"action" v:"required|in:processing,resolve,reject#处理动作不能为空|处理动作不正确"`
HandleResult string `json:"handleResult"`
ReportId uint64 `json:"-"`
}
func (in *CultivateReportHandleInp) Filter(context.Context) error {
id, err := strconv.ParseUint(strings.TrimSpace(in.Id), 10, 64)
if err != nil || id == 0 {
return gerror.New("举报ID不正确")
}
in.ReportId = id
in.HandleResult = strings.TrimSpace(in.HandleResult)
if in.Action != "processing" && in.HandleResult == "" {
return gerror.New("办结举报时必须填写处理结果")
}
return nil
}
type CultivateOperationLogListInp struct {
form.PageReq
OperatorId string `json:"operatorId"`
OperationType string `json:"operationType"`
TargetType string `json:"targetType"`
CreatedAt []*gtime.Time `json:"createdAt"`
}
func (*CultivateOperationLogListInp) Filter(context.Context) error { return nil }
type CultivateOperationLogListModel struct {
Id string `json:"id"`
OperatorId string `json:"operatorId"`
OperationType string `json:"operationType"`
TargetType string `json:"targetType"`
TargetId string `json:"targetId"`
RequestId string `json:"requestId"`
BeforeSnapshot any `json:"beforeSnapshot"`
AfterSnapshot any `json:"afterSnapshot"`
Reason string `json:"reason"`
CreatedAt *gtime.Time `json:"createdAt"`
}
@@ -0,0 +1,155 @@
package sysin
import (
"context"
"strings"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/model/input/form"
)
type CultivateStageRuleEditInp struct {
Id uint64 `json:"id"`
Stage string `json:"stage"`
NextStage string `json:"nextStage"`
RequiredPoints uint `json:"requiredPoints"`
WaterPoints uint `json:"waterPoints"`
FertilizePoints uint `json:"fertilizePoints"`
AllowedActions []string `json:"allowedActions"`
ImageFileId string `json:"imageFileId"`
AnimationFileId string `json:"animationFileId"`
ProgressTextTemplate string `json:"progressTextTemplate"`
CompletionText string `json:"completionText"`
SortNo int `json:"sortNo"`
}
type CultivateFlowerEditInp struct {
Id uint64 `json:"id"`
FlowerCode string `json:"flowerCode"`
FlowerName string `json:"flowerName"`
FlowerDesc string `json:"flowerDesc"`
IconFileId string `json:"iconFileId"`
Status string `json:"status"`
DailyWaterLimit uint `json:"dailyWaterLimit"`
DailyFertilizeLimit uint `json:"dailyFertilizeLimit"`
ShareConfig *gjson.Json `json:"shareConfig"`
SortNo int `json:"sortNo"`
StageRules []*CultivateStageRuleEditInp `json:"stageRules"`
}
func (in *CultivateFlowerEditInp) Filter(ctx context.Context) error {
in.FlowerCode = strings.TrimSpace(in.FlowerCode)
in.FlowerName = strings.TrimSpace(in.FlowerName)
if in.FlowerCode == "" || in.FlowerName == "" {
return gerror.New("花种编码和名称不能为空")
}
validStatus := map[string]bool{"online": true, "offline": true, "activity_only": true, "maintenance": true}
if !validStatus[in.Status] {
return gerror.New("花种状态不正确")
}
if len(in.StageRules) == 0 {
return gerror.New("至少配置一个成长阶段")
}
validStage := map[string]bool{"seed": true, "sprout": true, "bud": true, "bloom": true}
validAction := map[string]bool{"water": true, "fertilize": true}
seen := map[string]bool{}
for _, rule := range in.StageRules {
if rule == nil || !validStage[rule.Stage] {
return gerror.New("成长阶段不正确")
}
if seen[rule.Stage] {
return gerror.New("成长阶段不能重复")
}
seen[rule.Stage] = true
if rule.Stage != "bloom" && rule.RequiredPoints == 0 {
return gerror.New("非开花阶段升级阈值必须大于0")
}
if rule.NextStage != "" && !validStage[rule.NextStage] {
return gerror.New("下一阶段不正确")
}
if rule.Stage != "bloom" && len(rule.AllowedActions) == 0 {
return gerror.New("非开花阶段至少允许一种成长动作")
}
for _, action := range rule.AllowedActions {
if !validAction[action] {
return gerror.New("成长动作不正确")
}
}
}
stage := "seed"
visited := map[string]bool{}
for stage != "" {
if visited[stage] {
return gerror.New("成长阶段链不能形成循环")
}
visited[stage] = true
var next string
found := false
for _, r := range in.StageRules {
if r.Stage == stage {
next = r.NextStage
found = true
break
}
}
if !found {
return gerror.New("成长阶段链必须从 seed 连续配置")
}
stage = next
}
if !visited["bloom"] {
return gerror.New("成长阶段链必须以 bloom 结束")
}
return nil
}
type CultivateFlowerListInp struct {
form.PageReq
FlowerCode string `json:"flowerCode"`
FlowerName string `json:"flowerName"`
Status string `json:"status"`
ConfigVersion string `json:"configVersion"`
CreatedAt []*gtime.Time `json:"createdAt"`
}
func (*CultivateFlowerListInp) Filter(context.Context) error { return nil }
type CultivateFlowerListModel struct {
Id uint64 `json:"id"`
FlowerCode string `json:"flowerCode"`
FlowerName string `json:"flowerName"`
FlowerDesc string `json:"flowerDesc"`
IconFileId string `json:"iconFileId"`
Status string `json:"status"`
ConfigVersion string `json:"configVersion"`
DailyWaterLimit uint `json:"dailyWaterLimit"`
DailyFertilizeLimit uint `json:"dailyFertilizeLimit"`
SortNo int `json:"sortNo"`
StageCount int `json:"stageCount"`
CreatedAt *gtime.Time `json:"createdAt"`
UpdatedAt *gtime.Time `json:"updatedAt"`
}
type CultivateFlowerViewInp struct {
Id uint64 `json:"id" v:"required#ID不能为空"`
}
func (*CultivateFlowerViewInp) Filter(context.Context) error { return nil }
type CultivateFlowerViewModel struct {
CultivateFlowerEditInp
ConfigVersion string `json:"configVersion"`
CreatedAt *gtime.Time `json:"createdAt"`
UpdatedAt *gtime.Time `json:"updatedAt"`
}
type CultivateFlowerStatusInp struct {
Id uint64 `json:"id" v:"required#ID不能为空"`
Status string `json:"status" v:"required|in:online,offline,activity_only,maintenance#状态不能为空|状态不正确"`
Reason string `json:"reason"`
}
func (*CultivateFlowerStatusInp) Filter(context.Context) error { return nil }