syntax = "v1" info ( title: "植物业务服务API" desc: "我的植物、百科、社区、OCR、兑换、AI等HTTP接口" author: "sundynix" version: "v1.0.0" ) type ( // ---------- 通用 ---------- IdReq { Id string `json:"id"` } IdPathReq { Id string `path:"id"` } IdsReq { Ids []string `json:"ids"` } PageReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Keyword string `json:"keyword,optional"` } // ---------- 我的植物 ---------- CreatePlantReq { Name string `json:"name"` PlantTime string `json:"plantTime"` Status int `json:"status,optional"` Placement string `json:"placement,optional"` PotMaterial string `json:"potMaterial,optional"` PotSize string `json:"potSize,optional"` Sunlight string `json:"sunlight,optional"` PlantingMaterial string `json:"plantingMaterial,optional"` ImgIds []string `json:"imgIds,optional"` } UpdatePlantReq { Id string `json:"id"` Name string `json:"name,optional"` Status int `json:"status,optional"` Placement string `json:"placement,optional"` PotMaterial string `json:"potMaterial,optional"` PotSize string `json:"potSize,optional"` Sunlight string `json:"sunlight,optional"` PlantingMaterial string `json:"plantingMaterial,optional"` ImgIds []string `json:"imgIds,optional"` } PlantListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Name string `json:"name,optional"` } // ---------- 养护计划 ---------- CarePlanReq { PlantId string `json:"plantId"` Name string `json:"name"` Icon string `json:"icon,optional"` TargetAction string `json:"targetAction"` Period int `json:"period"` } // ---------- 养护记录 ---------- CareRecordReq { PlantId string `json:"plantId"` PlanId string `json:"planId"` Action string `json:"action"` Note string `json:"note,optional"` } // ---------- 成长记录 ---------- GrowthRecordReq { PlantId string `json:"plantId"` Content string `json:"content,optional"` ImgIds []string `json:"imgIds,optional"` } // ---------- 百科 ---------- WikiListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Name string `json:"name,optional"` ClassId string `json:"classId,optional"` IsHot int `json:"isHot,optional"` } WikiClassReq { Name string `json:"name"` Icon string `json:"icon,optional"` } // ---------- 帖子 ---------- CreatePostReq { Title string `json:"title"` Content string `json:"content"` Location string `json:"location,optional"` ImgIds []string `json:"imgIds,optional"` TopicId string `json:"topicId,optional"` } PostListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Keyword string `json:"keyword,optional"` TopicId string `json:"topicId,optional"` } PostCommentReq { PostId string `json:"postId"` Content string `json:"content"` ParentId string `json:"parentId,optional"` } // ---------- 话题 ---------- TopicReq { Name string `json:"name"` Icon string `json:"icon,optional"` Desc string `json:"desc,optional"` } // ---------- OCR ---------- OcrReq { ImageUrl string `json:"imageUrl"` } // ---------- 兑换 ---------- ExchangeItemListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` } ExchangeOrderReq { ItemId string `json:"itemId"` } // ---------- AI ---------- AiChatReq { Question string `json:"question"` } // ---------- 用户资料 ---------- UpdateProfileReq { Nickname string `json:"nickname,optional"` AvatarId string `json:"avatarId,optional"` } // ---------- 等级/徽章配置 ---------- LevelConfigListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` } BadgeConfigListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Dimension string `json:"dimension,optional"` } ) // ========== 无需鉴权 ========== @server ( prefix: /api/plant group: callback ) service plant-api { @doc "微信支付回调" @handler WechatPayCallback post /callback/wechatpay } // ========== 需要鉴权 ========== @server ( prefix: /api/plant group: myPlant jwt: Auth ) service plant-api { @doc "创建植物" @handler CreatePlant post /my/create (CreatePlantReq) @doc "更新植物" @handler UpdatePlant post /my/update (UpdatePlantReq) @doc "删除植物" @handler DeletePlant post /my/delete (IdsReq) @doc "我的植物列表" @handler GetMyPlantList post /my/list (PlantListReq) @doc "植物详情" @handler GetPlantDetail get /my/:id (IdPathReq) @doc "添加养护计划" @handler AddCarePlan post /my/carePlan (CarePlanReq) @doc "添加养护记录" @handler AddCareRecord post /my/careRecord (CareRecordReq) @doc "添加成长记录" @handler AddGrowthRecord post /my/growthRecord (GrowthRecordReq) } @server ( prefix: /api/plant group: wiki jwt: Auth ) service plant-api { @doc "百科列表" @handler GetWikiList post /wiki/list (WikiListReq) @doc "百科详情" @handler GetWikiDetail get /wiki/:id (IdPathReq) @doc "百科分类列表" @handler GetWikiClassList get /wiki/class/list @doc "创建百科分类" @handler CreateWikiClass post /wiki/class/create (WikiClassReq) @doc "收藏/取消收藏百科" @handler ToggleWikiStar post /wiki/star (IdReq) } @server ( prefix: /api/plant group: post jwt: Auth ) service plant-api { @doc "发布帖子" @handler CreatePost post /post/create (CreatePostReq) @doc "帖子列表" @handler GetPostList post /post/list (PostListReq) @doc "帖子详情" @handler GetPostDetail get /post/:id (IdPathReq) @doc "删除帖子" @handler DeletePost post /post/delete (IdsReq) @doc "评论帖子" @handler CommentPost post /post/comment (PostCommentReq) @doc "点赞帖子" @handler LikePost post /post/like (IdReq) } @server ( prefix: /api/plant group: topic jwt: Auth ) service plant-api { @doc "话题列表" @handler GetTopicList get /topic/list @doc "创建话题" @handler CreateTopic post /topic/create (TopicReq) @doc "删除话题" @handler DeleteTopic post /topic/delete (IdsReq) } @server ( prefix: /api/plant group: ocr jwt: Auth ) service plant-api { @doc "OCR植物识别" @handler OcrClassify post /ocr/classify (OcrReq) } @server ( prefix: /api/plant group: exchange jwt: Auth ) service plant-api { @doc "兑换商品列表" @handler GetExchangeItemList post /exchange/list (ExchangeItemListReq) @doc "兑换商品" @handler CreateExchangeOrder post /exchange/order (ExchangeOrderReq) } @server ( prefix: /api/plant group: ai jwt: Auth ) service plant-api { @doc "AI问答" @handler AiChat post /ai/chat (AiChatReq) @doc "聊天历史" @handler GetAiChatHistory get /ai/history } @server ( prefix: /api/plant group: userProfile jwt: Auth ) service plant-api { @doc "获取用户资料" @handler GetUserProfile get /profile/info @doc "更新用户资料" @handler UpdateUserProfile post /profile/update (UpdateProfileReq) } @server ( prefix: /api/plant group: config jwt: Auth ) service plant-api { @doc "等级配置列表" @handler GetLevelConfigList post /config/level/list (LevelConfigListReq) @doc "徽章配置列表" @handler GetBadgeConfigList post /config/badge/list (BadgeConfigListReq) }