Files
sundynix-micro-be/app/plant/api/plant.api
T
2026-05-23 13:55:05 +08:00

606 lines
15 KiB
Plaintext

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"`
}
// ---------- 完成任务 ----------
CompleteTaskApiReq {
TaskId string `json:"taskId"`
Remark string `json:"remark,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"`
}
CreateWikiReq {
Name string `json:"name"`
LatinName string `json:"latinName,optional"`
Aliases string `json:"aliases,optional"`
Genus string `json:"genus,optional"`
Difficulty int `json:"difficulty,optional"`
IsHot int `json:"isHot,optional"`
GrowthHabit string `json:"growthHabit,optional"`
LightIntensity string `json:"lightIntensity,optional"`
OptimalTempPeriod string `json:"optimalTempPeriod,optional"`
ClassId string `json:"classId,optional"`
DistributionArea string `json:"distributionArea,optional"`
LifeCycle string `json:"lifeCycle,optional"`
}
UpdateWikiReq {
Id string `json:"id"`
Name string `json:"name,optional"`
LatinName string `json:"latinName,optional"`
Aliases string `json:"aliases,optional"`
Genus string `json:"genus,optional"`
Difficulty int `json:"difficulty,optional"`
IsHot int `json:"isHot,optional"`
GrowthHabit string `json:"growthHabit,optional"`
LightIntensity string `json:"lightIntensity,optional"`
OptimalTempPeriod string `json:"optimalTempPeriod,optional"`
ClassId string `json:"classId,optional"`
DistributionArea string `json:"distributionArea,optional"`
LifeCycle string `json:"lifeCycle,optional"`
}
WikiClassReq {
Name string `json:"name"`
Icon string `json:"icon,optional"`
}
UpdateWikiClassReq {
Id string `json:"id"`
Name string `json:"name,optional"`
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"`
}
UpdateTopicReq {
Id string `json:"id"`
Name string `json:"name,optional"`
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"`
Status int `json:"status,optional"`
}
ExchangeOrderReq {
ItemId string `json:"itemId"`
}
CreateExchangeItemReq {
Name string `json:"name"`
Desc string `json:"desc,optional"`
ImgId string `json:"imgId,optional"`
Cost int64 `json:"cost"`
Stock int `json:"stock"`
}
UpdateExchangeItemReq {
Id string `json:"id"`
Name string `json:"name,optional"`
Desc string `json:"desc,optional"`
ImgId string `json:"imgId,optional"`
Cost int64 `json:"cost,optional"`
Stock int `json:"stock,optional"`
Status int `json:"status,optional"`
}
ExchangeOrderListReq {
Current int `json:"current,optional"`
PageSize int `json:"pageSize,optional"`
UserId string `json:"userId,optional"`
Status int `json:"status,optional"`
}
UpdateExchangeOrderReq {
Id string `json:"id"`
Status int `json:"status"`
}
// ---------- 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"`
}
CreateLevelConfigReq {
Level int `json:"level"`
Title string `json:"title"`
MinSunlight int64 `json:"minSunlight"`
Perks string `json:"perks,optional"`
}
UpdateLevelConfigReq {
Id string `json:"id"`
Level int `json:"level,optional"`
Title string `json:"title,optional"`
MinSunlight int64 `json:"minSunlight,optional"`
Perks string `json:"perks,optional"`
}
BadgeConfigListReq {
Current int `json:"current,optional"`
PageSize int `json:"pageSize,optional"`
Dimension string `json:"dimension,optional"`
}
CreateBadgeConfigReq {
Name string `json:"name"`
Description string `json:"description,optional"`
Dimension string `json:"dimension"`
GroupId string `json:"groupId,optional"`
Tier int `json:"tier,optional"`
TargetAction string `json:"targetAction"`
Threshold int64 `json:"threshold"`
RewardSunlight int64 `json:"rewardSunlight,optional"`
IconId string `json:"iconId,optional"`
Sort int `json:"sort,optional"`
}
UpdateBadgeConfigReq {
Id string `json:"id"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
Dimension string `json:"dimension,optional"`
GroupId string `json:"groupId,optional"`
Tier int `json:"tier,optional"`
TargetAction string `json:"targetAction,optional"`
Threshold int64 `json:"threshold,optional"`
RewardSunlight int64 `json:"rewardSunlight,optional"`
IconId string `json:"iconId,optional"`
Sort int `json:"sort,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 DeleteCarePlan
post /my/deletePlan (IdsReq)
@doc "今日养护任务"
@handler GetTodayTaskList
get /my/todayTask
@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 CreateWiki
post /wiki/create (CreateWikiReq)
@doc "更新百科"
@handler UpdateWiki
post /wiki/update (UpdateWikiReq)
@doc "删除百科"
@handler DeleteWiki
post /wiki/delete (IdsReq)
@doc "百科分类列表"
@handler GetWikiClassList
get /wiki/class/list
@doc "创建百科分类"
@handler CreateWikiClass
post /wiki/class/create (WikiClassReq)
@doc "更新百科分类"
@handler UpdateWikiClass
post /wiki/class/update (UpdateWikiClassReq)
@doc "删除百科分类"
@handler DeleteWikiClass
post /wiki/class/delete (IdsReq)
@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 GetMyPostList
post /post/my (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)
@doc "收藏帖子"
@handler StarPost
post /post/star (IdReq)
}
@server (
prefix: /api/plant
group: topic
jwt: Auth
)
service plant-api {
@doc "话题列表"
@handler GetTopicList
get /topic/list
@doc "话题详情"
@handler GetTopicDetail
get /topic/:id (IdPathReq)
@doc "创建话题"
@handler CreateTopic
post /topic/create (TopicReq)
@doc "更新话题"
@handler UpdateTopic
post /topic/update (UpdateTopicReq)
@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)
@doc "我的识别记录"
@handler GetMyClassifyLog
get /ocr/myLog
@doc "删除识别记录"
@handler DeleteClassifyLog
post /ocr/deleteLog (IdsReq)
}
@server (
prefix: /api/plant
group: exchange
jwt: Auth
)
service plant-api {
@doc "兑换商品列表"
@handler GetExchangeItemList
post /exchange/list (ExchangeItemListReq)
@doc "创建兑换商品"
@handler CreateExchangeItem
post /exchange/item/create (CreateExchangeItemReq)
@doc "更新兑换商品"
@handler UpdateExchangeItem
post /exchange/item/update (UpdateExchangeItemReq)
@doc "删除兑换商品"
@handler DeleteExchangeItem
post /exchange/item/delete (IdsReq)
@doc "发起兑换"
@handler CreateExchangeOrder
post /exchange/order (ExchangeOrderReq)
@doc "我的兑换记录"
@handler GetMyExchangeOrders
post /exchange/myOrders (ExchangeOrderListReq)
@doc "管理端订单列表"
@handler GetExchangeOrderList
post /exchange/order/list (ExchangeOrderListReq)
@doc "更新订单状态"
@handler UpdateExchangeOrder
post /exchange/order/update (UpdateExchangeOrderReq)
}
@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
@doc "删除聊天历史"
@handler DeleteAiChatHistory
post /ai/history/delete (IdsReq)
@doc "清空聊天历史"
@handler ClearAiChatHistory
post /ai/history/clear
@doc "今日AI额度"
@handler GetAiChatQuota
get /ai/quota
}
@server (
prefix: /api/plant
group: userProfile
jwt: Auth
)
service plant-api {
@doc "获取用户资料"
@handler GetUserProfile
get /profile/info
@doc "更新用户资料"
@handler UpdateUserProfile
post /profile/update (UpdateProfileReq)
@doc "我的徽章"
@handler GetMyBadges
get /profile/badge
@doc "我的收藏"
@handler GetMyStars
post /profile/star (PageReq)
}
@server (
prefix: /api/plant
group: config
jwt: Auth
)
service plant-api {
@doc "等级配置列表"
@handler GetLevelConfigList
post /config/level/list (LevelConfigListReq)
@doc "创建等级配置"
@handler CreateLevelConfig
post /config/level/create (CreateLevelConfigReq)
@doc "更新等级配置"
@handler UpdateLevelConfig
post /config/level/update (UpdateLevelConfigReq)
@doc "删除等级配置"
@handler DeleteLevelConfig
post /config/level/delete (IdsReq)
@doc "徽章配置列表"
@handler GetBadgeConfigList
post /config/badge/list (BadgeConfigListReq)
@doc "创建徽章配置"
@handler CreateBadgeConfig
post /config/badge/create (CreateBadgeConfigReq)
@doc "更新徽章配置"
@handler UpdateBadgeConfig
post /config/badge/update (UpdateBadgeConfigReq)
@doc "删除徽章配置"
@handler DeleteBadgeConfig
post /config/badge/delete (IdsReq)
}
// ========== 新增补全接口 ==========
@server (
prefix: /api/plant
group: complete
jwt: Auth
)
service plant-api {
@doc "完成养护任务"
@handler CompleteTask
post /my/completeTask (CompleteTaskApiReq)
@doc "兑换商品详情"
@handler GetExchangeItemDetail
get /exchange/item/:id (IdPathReq)
@doc "等级配置详情"
@handler GetLevelConfigDetail
get /config/level/:id (IdPathReq)
@doc "徽章配置树"
@handler GetBadgeConfigTree
get /config/badge/tree
@doc "百科分类详情"
@handler GetWikiClassDetail
get /wiki/class/:id (IdPathReq)
@doc "AI聊天历史"
@handler GetAiChatHistory
post /ai/history (PageReq)
}