init: init refactor
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
Name: plant-api
|
||||
Host: 0.0.0.0
|
||||
Port: 9004
|
||||
|
||||
Auth:
|
||||
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872
|
||||
AccessExpire: 7200
|
||||
|
||||
# MySQL
|
||||
DB:
|
||||
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
|
||||
|
||||
# Redis
|
||||
Cache:
|
||||
- Host: 127.0.0.1:6379
|
||||
Pass: sundynix
|
||||
Type: node
|
||||
|
||||
# RPC 依赖
|
||||
UserRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 192.168.100.127:2379
|
||||
Key: user.rpc
|
||||
|
||||
FileRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 192.168.100.127:2379
|
||||
Key: file.rpc
|
||||
|
||||
# 百度植物识别
|
||||
BaiduImgClassify:
|
||||
ApiKey: hpBfjwy8ifv3qswYGYjUCNKN
|
||||
SecretKey: i5aXZdM4XZVuDroBslL0f3uIuwbAyXFS
|
||||
|
||||
# 微信支付
|
||||
WechatPay:
|
||||
MchId: "1735188493"
|
||||
MchCertificateSerialNumber: "3725BFCA9CA3AF819AEC5D0CB7D3540BBC67F2CF"
|
||||
MchApiV3Key: "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6"
|
||||
PrivateKeyPath: "/Users/blizzard/privateFolder/cert/apiclient_key.pem"
|
||||
PublicKeyPath: "/Users/blizzard/privateFolder/cert/pub_key.pem"
|
||||
NotifyUrl: "https://prod.sundynix.cn/api/wechatpay/notify"
|
||||
@@ -0,0 +1,39 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Auth struct {
|
||||
AccessSecret string
|
||||
AccessExpire int64
|
||||
}
|
||||
DB struct {
|
||||
DataSource string
|
||||
}
|
||||
Cache []struct {
|
||||
Host string
|
||||
Pass string
|
||||
Type string
|
||||
}
|
||||
UserRpc zrpc.RpcClientConf
|
||||
FileRpc zrpc.RpcClientConf
|
||||
BaiduImgClassify struct {
|
||||
ApiKey string
|
||||
SecretKey string
|
||||
}
|
||||
WechatPay struct {
|
||||
MchId string
|
||||
MchCertificateSerialNumber string
|
||||
MchApiV3Key string
|
||||
PrivateKeyPath string
|
||||
PublicKeyPath string
|
||||
NotifyUrl string
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ai
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/ai"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// AI问答
|
||||
func AiChatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AiChatReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := ai.NewAiChatLogic(r.Context(), svcCtx)
|
||||
err := l.AiChat(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ai
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/ai"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 聊天历史
|
||||
func GetAiChatHistoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := ai.NewGetAiChatHistoryLogic(r.Context(), svcCtx)
|
||||
err := l.GetAiChatHistory()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package callback
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/callback"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 微信支付回调
|
||||
func WechatPayCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := callback.NewWechatPayCallbackLogic(r.Context(), svcCtx)
|
||||
err := l.WechatPayCallback()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/config"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 徽章配置列表
|
||||
func GetBadgeConfigListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.BadgeConfigListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := config.NewGetBadgeConfigListLogic(r.Context(), svcCtx)
|
||||
err := l.GetBadgeConfigList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/config"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 等级配置列表
|
||||
func GetLevelConfigListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.LevelConfigListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := config.NewGetLevelConfigListLogic(r.Context(), svcCtx)
|
||||
err := l.GetLevelConfigList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/exchange"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 兑换商品
|
||||
func CreateExchangeOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ExchangeOrderReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := exchange.NewCreateExchangeOrderLogic(r.Context(), svcCtx)
|
||||
err := l.CreateExchangeOrder(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/exchange"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 兑换商品列表
|
||||
func GetExchangeItemListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ExchangeItemListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := exchange.NewGetExchangeItemListLogic(r.Context(), svcCtx)
|
||||
err := l.GetExchangeItemList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 添加养护计划
|
||||
func AddCarePlanHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CarePlanReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewAddCarePlanLogic(r.Context(), svcCtx)
|
||||
err := l.AddCarePlan(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 添加养护记录
|
||||
func AddCareRecordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CareRecordReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewAddCareRecordLogic(r.Context(), svcCtx)
|
||||
err := l.AddCareRecord(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 添加成长记录
|
||||
func AddGrowthRecordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GrowthRecordReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewAddGrowthRecordLogic(r.Context(), svcCtx)
|
||||
err := l.AddGrowthRecord(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建植物
|
||||
func CreatePlantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreatePlantReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewCreatePlantLogic(r.Context(), svcCtx)
|
||||
err := l.CreatePlant(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除植物
|
||||
func DeletePlantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewDeletePlantLogic(r.Context(), svcCtx)
|
||||
err := l.DeletePlant(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 我的植物列表
|
||||
func GetMyPlantListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.PlantListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewGetMyPlantListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetMyPlantList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 植物详情
|
||||
func GetPlantDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdPathReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewGetPlantDetailLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetPlantDetail(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.OkWithData(w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/myPlant"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新植物
|
||||
func UpdatePlantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UpdatePlantReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := myPlant.NewUpdatePlantLogic(r.Context(), svcCtx)
|
||||
err := l.UpdatePlant(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ocr
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/ocr"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// OCR植物识别
|
||||
func OcrClassifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.OcrReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := ocr.NewOcrClassifyLogic(r.Context(), svcCtx)
|
||||
err := l.OcrClassify(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 评论帖子
|
||||
func CommentPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.PostCommentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewCommentPostLogic(r.Context(), svcCtx)
|
||||
err := l.CommentPost(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 发布帖子
|
||||
func CreatePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreatePostReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewCreatePostLogic(r.Context(), svcCtx)
|
||||
err := l.CreatePost(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除帖子
|
||||
func DeletePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewDeletePostLogic(r.Context(), svcCtx)
|
||||
err := l.DeletePost(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 帖子详情
|
||||
func GetPostDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdPathReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewGetPostDetailLogic(r.Context(), svcCtx)
|
||||
err := l.GetPostDetail(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 帖子列表
|
||||
func GetPostListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.PostListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewGetPostListLogic(r.Context(), svcCtx)
|
||||
err := l.GetPostList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/post"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 点赞帖子
|
||||
func LikePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := post.NewLikePostLogic(r.Context(), svcCtx)
|
||||
err := l.LikePost(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
ai "sundynix-micro-go/app/plant/api/internal/handler/ai"
|
||||
callback "sundynix-micro-go/app/plant/api/internal/handler/callback"
|
||||
config "sundynix-micro-go/app/plant/api/internal/handler/config"
|
||||
exchange "sundynix-micro-go/app/plant/api/internal/handler/exchange"
|
||||
myPlant "sundynix-micro-go/app/plant/api/internal/handler/myPlant"
|
||||
ocr "sundynix-micro-go/app/plant/api/internal/handler/ocr"
|
||||
post "sundynix-micro-go/app/plant/api/internal/handler/post"
|
||||
topic "sundynix-micro-go/app/plant/api/internal/handler/topic"
|
||||
userProfile "sundynix-micro-go/app/plant/api/internal/handler/userProfile"
|
||||
wiki "sundynix-micro-go/app/plant/api/internal/handler/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// AI问答
|
||||
Method: http.MethodPost,
|
||||
Path: "/ai/chat",
|
||||
Handler: ai.AiChatHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 聊天历史
|
||||
Method: http.MethodGet,
|
||||
Path: "/ai/history",
|
||||
Handler: ai.GetAiChatHistoryHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 微信支付回调
|
||||
Method: http.MethodPost,
|
||||
Path: "/callback/wechatpay",
|
||||
Handler: callback.WechatPayCallbackHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 徽章配置列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/config/badge/list",
|
||||
Handler: config.GetBadgeConfigListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 等级配置列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/config/level/list",
|
||||
Handler: config.GetLevelConfigListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 兑换商品列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/exchange/list",
|
||||
Handler: exchange.GetExchangeItemListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 兑换商品
|
||||
Method: http.MethodPost,
|
||||
Path: "/exchange/order",
|
||||
Handler: exchange.CreateExchangeOrderHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 植物详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/my/:id",
|
||||
Handler: myPlant.GetPlantDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加养护计划
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/carePlan",
|
||||
Handler: myPlant.AddCarePlanHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加养护记录
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/careRecord",
|
||||
Handler: myPlant.AddCareRecordHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建植物
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/create",
|
||||
Handler: myPlant.CreatePlantHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除植物
|
||||
Method: http.MethodDelete,
|
||||
Path: "/my/delete",
|
||||
Handler: myPlant.DeletePlantHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 添加成长记录
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/growthRecord",
|
||||
Handler: myPlant.AddGrowthRecordHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 我的植物列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/my/list",
|
||||
Handler: myPlant.GetMyPlantListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新植物
|
||||
Method: http.MethodPut,
|
||||
Path: "/my/update",
|
||||
Handler: myPlant.UpdatePlantHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// OCR植物识别
|
||||
Method: http.MethodPost,
|
||||
Path: "/ocr/classify",
|
||||
Handler: ocr.OcrClassifyHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 帖子详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/post/:id",
|
||||
Handler: post.GetPostDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 评论帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/comment",
|
||||
Handler: post.CommentPostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 发布帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/create",
|
||||
Handler: post.CreatePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除帖子
|
||||
Method: http.MethodDelete,
|
||||
Path: "/post/delete",
|
||||
Handler: post.DeletePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 点赞帖子
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/like",
|
||||
Handler: post.LikePostHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 帖子列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/post/list",
|
||||
Handler: post.GetPostListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 创建话题
|
||||
Method: http.MethodPost,
|
||||
Path: "/topic/create",
|
||||
Handler: topic.CreateTopicHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 删除话题
|
||||
Method: http.MethodDelete,
|
||||
Path: "/topic/delete",
|
||||
Handler: topic.DeleteTopicHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 话题列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/topic/list",
|
||||
Handler: topic.GetTopicListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取用户资料
|
||||
Method: http.MethodGet,
|
||||
Path: "/profile/info",
|
||||
Handler: userProfile.GetUserProfileHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新用户资料
|
||||
Method: http.MethodPut,
|
||||
Path: "/profile/update",
|
||||
Handler: userProfile.UpdateUserProfileHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 百科详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/wiki/:id",
|
||||
Handler: wiki.GetWikiDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 创建百科分类
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/class/create",
|
||||
Handler: wiki.CreateWikiClassHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 百科分类列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/wiki/class/list",
|
||||
Handler: wiki.GetWikiClassListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 百科列表
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/list",
|
||||
Handler: wiki.GetWikiListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 收藏/取消收藏百科
|
||||
Method: http.MethodPost,
|
||||
Path: "/wiki/star",
|
||||
Handler: wiki.ToggleWikiStarHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/api/plant"),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/topic"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建话题
|
||||
func CreateTopicHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TopicReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := topic.NewCreateTopicLogic(r.Context(), svcCtx)
|
||||
err := l.CreateTopic(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/topic"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 删除话题
|
||||
func DeleteTopicHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := topic.NewDeleteTopicLogic(r.Context(), svcCtx)
|
||||
err := l.DeleteTopic(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/topic"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 话题列表
|
||||
func GetTopicListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := topic.NewGetTopicListLogic(r.Context(), svcCtx)
|
||||
err := l.GetTopicList()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package userProfile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/userProfile"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 获取用户资料
|
||||
func GetUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := userProfile.NewGetUserProfileLogic(r.Context(), svcCtx)
|
||||
err := l.GetUserProfile()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package userProfile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/userProfile"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 更新用户资料
|
||||
func UpdateUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UpdateProfileReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := userProfile.NewUpdateUserProfileLogic(r.Context(), svcCtx)
|
||||
err := l.UpdateUserProfile(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 创建百科分类
|
||||
func CreateWikiClassHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.WikiClassReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := wiki.NewCreateWikiClassLogic(r.Context(), svcCtx)
|
||||
err := l.CreateWikiClass(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 百科分类列表
|
||||
func GetWikiClassListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := wiki.NewGetWikiClassListLogic(r.Context(), svcCtx)
|
||||
err := l.GetWikiClassList()
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 百科详情
|
||||
func GetWikiDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdPathReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := wiki.NewGetWikiDetailLogic(r.Context(), svcCtx)
|
||||
err := l.GetWikiDetail(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 百科列表
|
||||
func GetWikiListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.WikiListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := wiki.NewGetWikiListLogic(r.Context(), svcCtx)
|
||||
err := l.GetWikiList(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"sundynix-micro-go/app/plant/api/internal/logic/wiki"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
"sundynix-micro-go/common/response"
|
||||
)
|
||||
|
||||
// 收藏/取消收藏百科
|
||||
func ToggleWikiStarHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.IdReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
l := wiki.NewToggleWikiStarLogic(r.Context(), svcCtx)
|
||||
err := l.ToggleWikiStar(&req)
|
||||
if err != nil {
|
||||
response.Fail(w, err.Error())
|
||||
} else {
|
||||
response.Ok(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AiChatLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// AI问答
|
||||
func NewAiChatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AiChatLogic {
|
||||
return &AiChatLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AiChatLogic) AiChat(req *types.AiChatReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
)
|
||||
|
||||
type GetAiChatHistoryLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 聊天历史
|
||||
func NewGetAiChatHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAiChatHistoryLogic {
|
||||
return &GetAiChatHistoryLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAiChatHistoryLogic) GetAiChatHistory() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package callback
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
)
|
||||
|
||||
type WechatPayCallbackLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 微信支付回调
|
||||
func NewWechatPayCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WechatPayCallbackLogic {
|
||||
return &WechatPayCallbackLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *WechatPayCallbackLogic) WechatPayCallback() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetBadgeConfigListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 徽章配置列表
|
||||
func NewGetBadgeConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBadgeConfigListLogic {
|
||||
return &GetBadgeConfigListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetBadgeConfigListLogic) GetBadgeConfigList(req *types.BadgeConfigListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetLevelConfigListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 等级配置列表
|
||||
func NewGetLevelConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLevelConfigListLogic {
|
||||
return &GetLevelConfigListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetLevelConfigListLogic) GetLevelConfigList(req *types.LevelConfigListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateExchangeOrderLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 兑换商品
|
||||
func NewCreateExchangeOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExchangeOrderLogic {
|
||||
return &CreateExchangeOrderLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateExchangeOrderLogic) CreateExchangeOrder(req *types.ExchangeOrderReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetExchangeItemListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 兑换商品列表
|
||||
func NewGetExchangeItemListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExchangeItemListLogic {
|
||||
return &GetExchangeItemListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetExchangeItemListLogic) GetExchangeItemList(req *types.ExchangeItemListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type AddCarePlanLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddCarePlanLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCarePlanLogic {
|
||||
return &AddCarePlanLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *AddCarePlanLogic) AddCarePlan(req *types.CarePlanReq) error {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
plan := plantModel.SundynixCarePlan{
|
||||
UserID: userId, PlantID: req.PlantId, Name: req.Name,
|
||||
TargetAction: req.TargetAction, Period: req.Period, Icon: req.Icon,
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&plan).Error; err != nil {
|
||||
return fmt.Errorf("创建养护计划失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type AddCareRecordLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddCareRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCareRecordLogic {
|
||||
return &AddCareRecordLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *AddCareRecordLogic) AddCareRecord(req *types.CareRecordReq) error {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
record := plantModel.SundynixCareRecord{
|
||||
UserID: userId, PlantID: req.PlantId, PlanID: req.PlanId,
|
||||
Name: req.Action, Remark: req.Note,
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&record).Error; err != nil {
|
||||
return fmt.Errorf("创建养护记录失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type AddGrowthRecordLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddGrowthRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddGrowthRecordLogic {
|
||||
return &AddGrowthRecordLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *AddGrowthRecordLogic) AddGrowthRecord(req *types.GrowthRecordReq) error {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
record := plantModel.SundynixGrowthRecord{
|
||||
PlantID: req.PlantId, UserID: userId, Content: req.Content,
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&record).Error; err != nil {
|
||||
return fmt.Errorf("创建成长记录失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreatePlantLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePlantLogic {
|
||||
return &CreatePlantLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *CreatePlantLogic) CreatePlant(req *types.CreatePlantReq) error {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
plantTime, _ := time.Parse("2006-01-02", req.PlantTime)
|
||||
plant := plantModel.SundynixMyPlant{
|
||||
UserID: userId, Name: req.Name, PlantTime: plantTime, Placement: req.Placement,
|
||||
PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight,
|
||||
PlantingMaterial: req.PlantingMaterial, Status: 1,
|
||||
}
|
||||
if err := l.svcCtx.DB.Create(&plant).Error; err != nil {
|
||||
l.Errorf("创建植物失败: %v", err)
|
||||
return fmt.Errorf("创建植物失败")
|
||||
}
|
||||
if len(req.ImgIds) > 0 {
|
||||
for _, imgID := range req.ImgIds {
|
||||
l.svcCtx.DB.Create(&plantModel.SundynixMyPlantOss{MyPlantID: plant.ID, OssID: imgID})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type DeletePlantLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeletePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePlantLogic {
|
||||
return &DeletePlantLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeletePlantLogic) DeletePlant(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&plantModel.SundynixMyPlant{}).Error; err != nil {
|
||||
return fmt.Errorf("删除植物失败")
|
||||
}
|
||||
// 清理关联数据
|
||||
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCarePlan{})
|
||||
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCareRecord{})
|
||||
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCareTask{})
|
||||
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixGrowthRecord{})
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type GetMyPlantListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetMyPlantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMyPlantListLogic {
|
||||
return &GetMyPlantListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetMyPlantListLogic) GetMyPlantList(req *types.PlantListReq) (resp interface{}, err error) {
|
||||
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
||||
var plants []plantModel.SundynixMyPlant
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&plantModel.SundynixMyPlant{}).Where("user_id = ?", userId)
|
||||
if req.Name != "" {
|
||||
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&plants).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询植物列表失败")
|
||||
}
|
||||
return map[string]interface{}{"list": plants, "total": total, "current": current, "size": pageSize}, nil
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type GetPlantDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetPlantDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPlantDetailLogic {
|
||||
return &GetPlantDetailLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetPlantDetailLogic) GetPlantDetail(req *types.IdPathReq) (resp interface{}, err error) {
|
||||
var plant plantModel.SundynixMyPlant
|
||||
if err := l.svcCtx.DB.Where("id = ?", req.Id).First(&plant).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, fmt.Errorf("植物不存在")
|
||||
}
|
||||
return nil, fmt.Errorf("查询植物失败")
|
||||
}
|
||||
// 查询关联图片ID
|
||||
var ossIds []string
|
||||
l.svcCtx.DB.Model(&plantModel.SundynixMyPlantOss{}).Where("sundynix_my_plant_id = ?", plant.ID).Pluck("sundynix_oss_id", &ossIds)
|
||||
// 查询养护计划
|
||||
var plans []plantModel.SundynixCarePlan
|
||||
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Find(&plans)
|
||||
// 查询成长记录
|
||||
var records []plantModel.SundynixGrowthRecord
|
||||
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Order("created_at DESC").Limit(10).Find(&records)
|
||||
|
||||
return map[string]interface{}{
|
||||
"plant": plant, "imgIds": ossIds, "carePlans": plans, "growthRecords": records,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package myPlant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
)
|
||||
|
||||
type UpdatePlantLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePlantLogic {
|
||||
return &UpdatePlantLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdatePlantLogic) UpdatePlant(req *types.UpdatePlantReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.Name != "" {
|
||||
updates["name"] = req.Name
|
||||
}
|
||||
if req.Status > 0 {
|
||||
updates["status"] = req.Status
|
||||
}
|
||||
if req.Placement != "" {
|
||||
updates["placement"] = req.Placement
|
||||
}
|
||||
if req.PotMaterial != "" {
|
||||
updates["pot_material"] = req.PotMaterial
|
||||
}
|
||||
if req.PotSize != "" {
|
||||
updates["pot_size"] = req.PotSize
|
||||
}
|
||||
if req.Sunlight != "" {
|
||||
updates["sunlight"] = req.Sunlight
|
||||
}
|
||||
if req.PlantingMaterial != "" {
|
||||
updates["planting_material"] = req.PlantingMaterial
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
if err := l.svcCtx.DB.Model(&plantModel.SundynixMyPlant{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
return fmt.Errorf("更新植物失败")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package ocr
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type OcrClassifyLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// OCR植物识别
|
||||
func NewOcrClassifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OcrClassifyLogic {
|
||||
return &OcrClassifyLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OcrClassifyLogic) OcrClassify(req *types.OcrReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CommentPostLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 评论帖子
|
||||
func NewCommentPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentPostLogic {
|
||||
return &CommentPostLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CommentPostLogic) CommentPost(req *types.PostCommentReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreatePostLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 发布帖子
|
||||
func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePostLogic {
|
||||
return &CreatePostLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeletePostLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 删除帖子
|
||||
func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePostLogic {
|
||||
return &DeletePostLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeletePostLogic) DeletePost(req *types.IdsReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPostDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 帖子详情
|
||||
func NewGetPostDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostDetailLogic {
|
||||
return &GetPostDetailLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostDetailLogic) GetPostDetail(req *types.IdPathReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPostListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 帖子列表
|
||||
func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostListLogic {
|
||||
return &GetPostListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostListLogic) GetPostList(req *types.PostListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type LikePostLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 点赞帖子
|
||||
func NewLikePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikePostLogic {
|
||||
return &LikePostLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LikePostLogic) LikePost(req *types.IdReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateTopicLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 创建话题
|
||||
func NewCreateTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTopicLogic {
|
||||
return &CreateTopicLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateTopicLogic) CreateTopic(req *types.TopicReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteTopicLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 删除话题
|
||||
func NewDeleteTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTopicLogic {
|
||||
return &DeleteTopicLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteTopicLogic) DeleteTopic(req *types.IdsReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package topic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
)
|
||||
|
||||
type GetTopicListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 话题列表
|
||||
func NewGetTopicListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTopicListLogic {
|
||||
return &GetTopicListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetTopicListLogic) GetTopicList() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package userProfile
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
)
|
||||
|
||||
type GetUserProfileLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 获取用户资料
|
||||
func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic {
|
||||
return &GetUserProfileLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetUserProfileLogic) GetUserProfile() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package userProfile
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateUserProfileLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 更新用户资料
|
||||
func NewUpdateUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserProfileLogic {
|
||||
return &UpdateUserProfileLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateUserProfileLogic) UpdateUserProfile(req *types.UpdateProfileReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateWikiClassLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 创建百科分类
|
||||
func NewCreateWikiClassLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWikiClassLogic {
|
||||
return &CreateWikiClassLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateWikiClassLogic) CreateWikiClass(req *types.WikiClassReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
)
|
||||
|
||||
type GetWikiClassListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 百科分类列表
|
||||
func NewGetWikiClassListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiClassListLogic {
|
||||
return &GetWikiClassListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWikiClassListLogic) GetWikiClassList() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWikiDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 百科详情
|
||||
func NewGetWikiDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiDetailLogic {
|
||||
return &GetWikiDetailLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWikiDetailLogic) GetWikiDetail(req *types.IdPathReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWikiListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 百科列表
|
||||
func NewGetWikiListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiListLogic {
|
||||
return &GetWikiListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWikiListLogic) GetWikiList(req *types.WikiListReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ToggleWikiStarLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 收藏/取消收藏百科
|
||||
func NewToggleWikiStarLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ToggleWikiStarLogic {
|
||||
return &ToggleWikiStarLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ToggleWikiStarLogic) ToggleWikiStar(req *types.IdReq) error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package svc
|
||||
|
||||
import (
|
||||
"sundynix-micro-go/app/file/rpc/fileservice"
|
||||
"sundynix-micro-go/app/plant/api/internal/config"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
"sundynix-micro-go/app/user/rpc/userservice"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
UserRpc userservice.UserService
|
||||
FileRpc fileservice.FileService
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
|
||||
if err != nil {
|
||||
logx.Errorf("连接数据库失败: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 自动迁移
|
||||
if err := db.AutoMigrate(
|
||||
&plantModel.SundynixPlantUserProfile{},
|
||||
&plantModel.SundynixMyPlant{},
|
||||
&plantModel.SundynixCarePlan{},
|
||||
&plantModel.SundynixCareRecord{},
|
||||
&plantModel.SundynixCareTask{},
|
||||
&plantModel.SundynixGrowthRecord{},
|
||||
&plantModel.SundynixWiki{},
|
||||
&plantModel.SundynixWikiClass{},
|
||||
&plantModel.SundynixPost{},
|
||||
&plantModel.SundynixPostComment{},
|
||||
&plantModel.SundynixPostLike{},
|
||||
&plantModel.SundynixPostTopic{},
|
||||
&plantModel.SundynixUserStar{},
|
||||
&plantModel.SundynixExchangeItem{},
|
||||
&plantModel.SundynixExchangeOrder{},
|
||||
&plantModel.SundynixLevelConfig{},
|
||||
&plantModel.SundynixBadgeConfig{},
|
||||
&plantModel.SundynixUserBadge{},
|
||||
&plantModel.SundynixAiChatHistory{},
|
||||
); err != nil {
|
||||
logx.Errorf("数据库迁移失败: %v", err)
|
||||
}
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
DB: db,
|
||||
UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)),
|
||||
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.1
|
||||
|
||||
package types
|
||||
|
||||
type AiChatReq struct {
|
||||
Question string `json:"question"`
|
||||
}
|
||||
|
||||
type BadgeConfigListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Dimension string `json:"dimension,optional"`
|
||||
}
|
||||
|
||||
type CarePlanReq struct {
|
||||
PlantId string `json:"plantId"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon,optional"`
|
||||
TargetAction string `json:"targetAction"`
|
||||
Period int `json:"period"`
|
||||
}
|
||||
|
||||
type CareRecordReq struct {
|
||||
PlantId string `json:"plantId"`
|
||||
PlanId string `json:"planId"`
|
||||
Action string `json:"action"`
|
||||
Note string `json:"note,optional"`
|
||||
}
|
||||
|
||||
type CreatePlantReq struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
type CreatePostReq struct {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Location string `json:"location,optional"`
|
||||
ImgIds []string `json:"imgIds,optional"`
|
||||
TopicId string `json:"topicId,optional"`
|
||||
}
|
||||
|
||||
type ExchangeItemListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
}
|
||||
|
||||
type ExchangeOrderReq struct {
|
||||
ItemId string `json:"itemId"`
|
||||
}
|
||||
|
||||
type GrowthRecordReq struct {
|
||||
PlantId string `json:"plantId"`
|
||||
Content string `json:"content,optional"`
|
||||
ImgIds []string `json:"imgIds,optional"`
|
||||
}
|
||||
|
||||
type IdPathReq struct {
|
||||
Id string `path:"id"`
|
||||
}
|
||||
|
||||
type IdReq struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type IdsReq struct {
|
||||
Ids []string `json:"ids"`
|
||||
}
|
||||
|
||||
type LevelConfigListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
}
|
||||
|
||||
type OcrReq struct {
|
||||
ImageUrl string `json:"imageUrl"`
|
||||
}
|
||||
|
||||
type PageReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Keyword string `json:"keyword,optional"`
|
||||
}
|
||||
|
||||
type PlantListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
}
|
||||
|
||||
type PostCommentReq struct {
|
||||
PostId string `json:"postId"`
|
||||
Content string `json:"content"`
|
||||
ParentId string `json:"parentId,optional"`
|
||||
}
|
||||
|
||||
type PostListReq struct {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Keyword string `json:"keyword,optional"`
|
||||
TopicId string `json:"topicId,optional"`
|
||||
}
|
||||
|
||||
type TopicReq struct {
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon,optional"`
|
||||
Desc string `json:"desc,optional"`
|
||||
}
|
||||
|
||||
type UpdatePlantReq struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
type UpdateProfileReq struct {
|
||||
Nickname string `json:"nickname,optional"`
|
||||
AvatarId string `json:"avatarId,optional"`
|
||||
}
|
||||
|
||||
type WikiClassReq struct {
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon,optional"`
|
||||
}
|
||||
|
||||
type WikiListReq struct {
|
||||
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"`
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
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
|
||||
put /my/update (UpdatePlantReq)
|
||||
|
||||
@doc "删除植物"
|
||||
@handler DeletePlant
|
||||
delete /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
|
||||
delete /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
|
||||
delete /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
|
||||
put /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)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/config"
|
||||
"sundynix-micro-go/app/plant/api/internal/handler"
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/plant-api.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf)
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
handler.RegisterHandlers(server, ctx)
|
||||
|
||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||
server.Start()
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"sundynix-micro-go/common/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ========== 用户扩展表(plant业务特有字段) ==========
|
||||
|
||||
// SundynixPlantUserProfile 植物服务用户扩展表
|
||||
type SundynixPlantUserProfile struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;uniqueIndex;column:user_id" json:"userId"`
|
||||
NickName string `gorm:"size:100;column:nick_name" json:"nickName"`
|
||||
AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"`
|
||||
LevelID string `gorm:"size:50;column:level_id" json:"levelId"`
|
||||
CurrentSunlight int64 `gorm:"not null;default:0;column:current_sunlight" json:"currentSunlight"`
|
||||
TotalSunlight int64 `gorm:"not null;default:0;column:total_sunlight" json:"totalSunlight"`
|
||||
PlantCount int64 `gorm:"not null;default:0;column:plant_count" json:"plantCount"`
|
||||
CareCount int64 `gorm:"not null;default:0;column:care_count" json:"careCount"`
|
||||
PostCount int64 `gorm:"not null;default:0;column:post_count" json:"postCount"`
|
||||
WaterCount int64 `gorm:"not null;default:0;column:water_count" json:"waterCount"`
|
||||
FertilizeCount int64 `gorm:"not null;default:0;column:fertilize_count" json:"fertilizeCount"`
|
||||
RepotCount int64 `gorm:"not null;default:0;column:repot_count" json:"repotCount"`
|
||||
PruneCount int64 `gorm:"not null;default:0;column:prune_count" json:"pruneCount"`
|
||||
PhotoCount int64 `gorm:"not null;default:0;column:photo_count" json:"photoCount"`
|
||||
}
|
||||
|
||||
func (SundynixPlantUserProfile) TableName() string {
|
||||
return "sundynix_plant_user_profile"
|
||||
}
|
||||
|
||||
// ========== 我的植物 ==========
|
||||
|
||||
// SundynixMyPlant 我的植物
|
||||
type SundynixMyPlant struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
Name string `gorm:"size:20;column:name" json:"name"`
|
||||
PlantTime time.Time `gorm:"column:plant_time" json:"plantTime"`
|
||||
Status int `gorm:"column:status" json:"status"`
|
||||
Placement string `gorm:"size:50;column:placement" json:"placement"`
|
||||
PotMaterial string `gorm:"size:50;column:pot_material" json:"potMaterial"`
|
||||
PotSize string `gorm:"size:50;column:pot_size" json:"potSize"`
|
||||
Sunlight string `gorm:"size:50;column:sunlight" json:"sunlight"`
|
||||
PlantingMaterial string `gorm:"size:50;column:planting_material" json:"plantingMaterial"`
|
||||
}
|
||||
|
||||
func (SundynixMyPlant) TableName() string {
|
||||
return "sundynix_my_plant"
|
||||
}
|
||||
|
||||
// SundynixMyPlantOss 植物图片关联表
|
||||
type SundynixMyPlantOss struct {
|
||||
MyPlantID string `gorm:"size:50;primaryKey;column:sundynix_my_plant_id" json:"myPlantId"`
|
||||
OssID string `gorm:"size:50;primaryKey;column:sundynix_oss_id" json:"ossId"`
|
||||
}
|
||||
|
||||
func (SundynixMyPlantOss) TableName() string {
|
||||
return "sundynix_my_plant_oss"
|
||||
}
|
||||
|
||||
// ========== 养护计划/记录 ==========
|
||||
|
||||
// SundynixCarePlan 养护计划
|
||||
type SundynixCarePlan struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;column:user_id" json:"userId"`
|
||||
PlantID string `gorm:"size:50;index;column:plant_id" json:"plantId"`
|
||||
Icon string `gorm:"type:text;column:icon" json:"icon"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
Period int `gorm:"column:period" json:"period"`
|
||||
TargetAction string `gorm:"size:32;index;column:target_action" json:"targetAction"`
|
||||
}
|
||||
|
||||
func (SundynixCarePlan) TableName() string {
|
||||
return "sundynix_care_plan"
|
||||
}
|
||||
|
||||
// SundynixCareRecord 养护记录
|
||||
type SundynixCareRecord struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;column:user_id" json:"userId"`
|
||||
PlantID string `gorm:"size:50;index;column:plant_id" json:"plantId"`
|
||||
PlanID string `gorm:"size:50;index;column:plan_id" json:"planId"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
Remark string `gorm:"size:200;column:remark" json:"remark"`
|
||||
Icon string `gorm:"type:text;column:icon" json:"icon"`
|
||||
}
|
||||
|
||||
func (SundynixCareRecord) TableName() string {
|
||||
return "sundynix_care_record"
|
||||
}
|
||||
|
||||
// SundynixCareTask 养护任务
|
||||
type SundynixCareTask struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;column:user_id" json:"userId"`
|
||||
PlantID string `gorm:"size:50;index;column:plant_id" json:"plantId"`
|
||||
PlanID string `gorm:"size:50;index;column:plan_id" json:"planId"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
Icon string `gorm:"type:text;column:icon" json:"icon"`
|
||||
TargetAction string `gorm:"size:32;column:target_action" json:"targetAction"`
|
||||
DueDate time.Time `gorm:"column:due_date" json:"dueDate"`
|
||||
Status int `gorm:"default:1;column:status" json:"status"`
|
||||
}
|
||||
|
||||
func (SundynixCareTask) TableName() string {
|
||||
return "sundynix_care_task"
|
||||
}
|
||||
|
||||
// SundynixGrowthRecord 成长记录
|
||||
type SundynixGrowthRecord struct {
|
||||
model.BaseModel
|
||||
PlantID string `gorm:"size:50;index;column:plant_id" json:"plantId"`
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
Tag string `gorm:"size:50;column:tag" json:"tag"`
|
||||
Desc string `gorm:"size:200;column:desc" json:"desc"`
|
||||
Content string `gorm:"size:200;column:content" json:"content"`
|
||||
}
|
||||
|
||||
func (SundynixGrowthRecord) TableName() string {
|
||||
return "sundynix_growth_record"
|
||||
}
|
||||
|
||||
// ========== 百科 ==========
|
||||
|
||||
// SundynixWiki 植物百科
|
||||
type SundynixWiki struct {
|
||||
model.BaseModel
|
||||
IsHot int `gorm:"column:is_hot" json:"isHot"`
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
LatinName string `gorm:"size:100;column:latin_name" json:"latinName"`
|
||||
Aliases string `gorm:"size:100;column:aliases" json:"aliases"`
|
||||
DistributionArea string `gorm:"type:text;column:distribution_area" json:"distributionArea"`
|
||||
Genus string `gorm:"size:20;column:genus" json:"genus"`
|
||||
Difficulty int `gorm:"column:difficulty" json:"difficulty"`
|
||||
LifeCycle string `gorm:"type:text;column:life_cycle" json:"lifeCycle"`
|
||||
GrowthHabit string `gorm:"type:text;column:growth_habit" json:"growthHabit"`
|
||||
ReproductionMethod string `gorm:"size:200;column:reproduction_method" json:"reproductionMethod"`
|
||||
PestsDiseases string `gorm:"size:200;column:pests_diseases" json:"pestsDiseases"`
|
||||
LightIntensity string `gorm:"size:50;column:light_intensity" json:"lightIntensity"`
|
||||
LightType string `gorm:"size:50;column:light_type" json:"lightType"`
|
||||
OptimalTempPeriod string `gorm:"size:30;column:optimal_temp_period" json:"optimalTempPeriod"`
|
||||
Stem string `gorm:"size:200;column:stem" json:"stem"`
|
||||
FoliageType string `gorm:"size:200;column:foliage_type" json:"foliageType"`
|
||||
FoliageColor string `gorm:"size:200;column:foliage_color" json:"foliageColor"`
|
||||
FoliageShape string `gorm:"size:200;column:foliage_shape" json:"foliageShape"`
|
||||
Height int `gorm:"column:height" json:"height"`
|
||||
FloweringPeriod string `gorm:"size:100;column:flowering_period" json:"floweringPeriod"`
|
||||
FloweringColor string `gorm:"size:100;column:flowering_color" json:"floweringColor"`
|
||||
FloweringShape string `gorm:"size:100;column:flowering_shape" json:"floweringShape"`
|
||||
FlowerDiameter int `gorm:"column:flower_diameter" json:"flowerDiameter"`
|
||||
Fruit string `gorm:"size:200;column:fruit" json:"fruit"`
|
||||
}
|
||||
|
||||
func (SundynixWiki) TableName() string {
|
||||
return "sundynix_wiki"
|
||||
}
|
||||
|
||||
// SundynixWikiClass 百科分类
|
||||
type SundynixWikiClass struct {
|
||||
model.BaseModel
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
OssID string `gorm:"size:50;column:oss_id" json:"ossId"`
|
||||
}
|
||||
|
||||
func (SundynixWikiClass) TableName() string {
|
||||
return "sundynix_wiki_class"
|
||||
}
|
||||
|
||||
// SundynixUserStar 用户收藏
|
||||
type SundynixUserStar struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
TargetID string `gorm:"size:50;index;column:target_id" json:"targetId"`
|
||||
Type string `gorm:"size:20;column:type" json:"type"` // wiki/post
|
||||
}
|
||||
|
||||
func (SundynixUserStar) TableName() string {
|
||||
return "sundynix_user_star"
|
||||
}
|
||||
|
||||
// ========== 社区 ==========
|
||||
|
||||
// SundynixPost 社区帖子
|
||||
type SundynixPost struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
Title string `gorm:"size:100;column:title" json:"title"`
|
||||
Content string `gorm:"size:500;column:content" json:"content"`
|
||||
ViewCount int `gorm:"default:0;column:view_count" json:"viewCount"`
|
||||
CommentCount int `gorm:"default:0;column:comment_count" json:"commentCount"`
|
||||
LikeCount int `gorm:"default:0;column:like_count" json:"likeCount"`
|
||||
StarCount int `gorm:"default:0;column:star_count" json:"starCount"`
|
||||
Location string `gorm:"size:100;column:location" json:"location"`
|
||||
HasReviewed int `gorm:"default:0;column:has_reviewed" json:"hasReviewed"`
|
||||
}
|
||||
|
||||
func (SundynixPost) TableName() string {
|
||||
return "sundynix_post"
|
||||
}
|
||||
|
||||
// SundynixPostComment 帖子评论
|
||||
type SundynixPostComment struct {
|
||||
model.BaseModel
|
||||
PostID string `gorm:"size:50;index;column:post_id" json:"postId"`
|
||||
UserID string `gorm:"size:50;column:user_id" json:"userId"`
|
||||
Content string `gorm:"size:500;column:content" json:"content"`
|
||||
ParentID string `gorm:"size:50;column:parent_id" json:"parentId"`
|
||||
}
|
||||
|
||||
func (SundynixPostComment) TableName() string {
|
||||
return "sundynix_post_comment"
|
||||
}
|
||||
|
||||
// SundynixPostLike 帖子点赞
|
||||
type SundynixPostLike struct {
|
||||
model.BaseModel
|
||||
PostID string `gorm:"size:50;index;column:post_id" json:"postId"`
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
}
|
||||
|
||||
func (SundynixPostLike) TableName() string {
|
||||
return "sundynix_post_like"
|
||||
}
|
||||
|
||||
// SundynixPostTopic 话题
|
||||
type SundynixPostTopic struct {
|
||||
model.BaseModel
|
||||
Name string `gorm:"size:50;column:name" json:"name"`
|
||||
PostCount int `gorm:"default:0;column:post_count" json:"postCount"`
|
||||
}
|
||||
|
||||
func (SundynixPostTopic) TableName() string {
|
||||
return "sundynix_post_topic"
|
||||
}
|
||||
|
||||
// ========== 积分商城 ==========
|
||||
|
||||
// SundynixExchangeItem 兑换商品
|
||||
type SundynixExchangeItem struct {
|
||||
model.BaseModel
|
||||
Name string `gorm:"size:100;column:name" json:"name"`
|
||||
Desc string `gorm:"size:200;column:desc" json:"desc"`
|
||||
ImgID string `gorm:"size:50;column:img_id" json:"imgId"`
|
||||
Cost int64 `gorm:"column:cost" json:"cost"`
|
||||
Stock int `gorm:"column:stock" json:"stock"`
|
||||
Status int `gorm:"default:1;column:status" json:"status"`
|
||||
}
|
||||
|
||||
func (SundynixExchangeItem) TableName() string {
|
||||
return "sundynix_exchange_item"
|
||||
}
|
||||
|
||||
// SundynixExchangeOrder 兑换订单
|
||||
type SundynixExchangeOrder struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
ItemID string `gorm:"size:50;column:item_id" json:"itemId"`
|
||||
Cost int64 `gorm:"column:cost" json:"cost"`
|
||||
Status int `gorm:"default:0;column:status" json:"status"`
|
||||
Address string `gorm:"size:200;column:address" json:"address"`
|
||||
}
|
||||
|
||||
func (SundynixExchangeOrder) TableName() string {
|
||||
return "sundynix_exchange_order"
|
||||
}
|
||||
|
||||
// ========== 等级/徽章配置 ==========
|
||||
|
||||
// SundynixLevelConfig 等级配置
|
||||
type SundynixLevelConfig struct {
|
||||
model.BaseModel
|
||||
Level int `gorm:"column:level" json:"level"`
|
||||
Title string `gorm:"size:50;column:title" json:"title"`
|
||||
MinSunlight int64 `gorm:"column:min_sunlight" json:"minSunlight"`
|
||||
Perks string `gorm:"size:200;column:perks" json:"perks"`
|
||||
}
|
||||
|
||||
func (SundynixLevelConfig) TableName() string {
|
||||
return "sundynix_level_config"
|
||||
}
|
||||
|
||||
// SundynixBadgeConfig 徽章配置
|
||||
type SundynixBadgeConfig struct {
|
||||
model.BaseModel
|
||||
Name string `gorm:"size:64;column:name" json:"name"`
|
||||
Description string `gorm:"size:255;column:description" json:"description"`
|
||||
IconID string `gorm:"size:50;column:icon_id" json:"iconId"`
|
||||
Dimension string `gorm:"size:32;index;column:dimension" json:"dimension"`
|
||||
GroupID string `gorm:"size:64;index;column:group_id" json:"groupId"`
|
||||
Tier int `gorm:"default:1;column:tier" json:"tier"`
|
||||
TargetAction string `gorm:"size:32;index;column:target_action" json:"targetAction"`
|
||||
Threshold int64 `gorm:"column:threshold" json:"threshold"`
|
||||
Comparator string `gorm:"size:10;default:'>=';column:comparator" json:"comparator"`
|
||||
RewardSunlight int64 `gorm:"column:reward_sunlight" json:"rewardSunlight"`
|
||||
Sort int `gorm:"default:1;column:sort" json:"sort"`
|
||||
}
|
||||
|
||||
func (SundynixBadgeConfig) TableName() string {
|
||||
return "sundynix_badge_config"
|
||||
}
|
||||
|
||||
// SundynixUserBadge 用户徽章
|
||||
type SundynixUserBadge struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
BadgeID string `gorm:"size:50;index;column:badge_id" json:"badgeId"`
|
||||
}
|
||||
|
||||
func (SundynixUserBadge) TableName() string {
|
||||
return "sundynix_user_badge"
|
||||
}
|
||||
|
||||
// SundynixAiChatHistory AI聊天历史
|
||||
type SundynixAiChatHistory struct {
|
||||
model.BaseModel
|
||||
UserID string `gorm:"size:50;index;column:user_id" json:"userId"`
|
||||
Role string `gorm:"size:20;column:role" json:"role"`
|
||||
Content string `gorm:"type:text;column:content" json:"content"`
|
||||
}
|
||||
|
||||
func (SundynixAiChatHistory) TableName() string {
|
||||
return "sundynix_ai_chat_history"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
Name: plant.rpc
|
||||
ListenOn: 0.0.0.0:8080
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: plant.rpc
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
package config
|
||||
|
||||
import "github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
type Config struct {
|
||||
zrpc.RpcServerConf
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddCarePlanLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddCarePlanLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCarePlanLogic {
|
||||
return &AddCarePlanLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 养护
|
||||
func (l *AddCarePlanLogic) AddCarePlan(in *plant.AddCarePlanReq) (*plant.AddCarePlanResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.AddCarePlanResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddCareRecordLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddCareRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCareRecordLogic {
|
||||
return &AddCareRecordLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AddCareRecordLogic) AddCareRecord(in *plant.AddCareRecordReq) (*plant.AddCareRecordResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.AddCareRecordResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddGrowthRecordLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddGrowthRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddGrowthRecordLogic {
|
||||
return &AddGrowthRecordLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AddGrowthRecordLogic) AddGrowthRecord(in *plant.AddGrowthRecordReq) (*plant.AddGrowthRecordResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.AddGrowthRecordResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CommentPostLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCommentPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentPostLogic {
|
||||
return &CommentPostLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CommentPostLogic) CommentPost(in *plant.CommentPostReq) (*plant.CommentPostResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CommentPostResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateExchangeOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateExchangeOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExchangeOrderLogic {
|
||||
return &CreateExchangeOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateExchangeOrderLogic) CreateExchangeOrder(in *plant.CreateExchangeOrderReq) (*plant.CreateExchangeOrderResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CreateExchangeOrderResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreatePlantLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePlantLogic {
|
||||
return &CreatePlantLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 植物
|
||||
func (l *CreatePlantLogic) CreatePlant(in *plant.CreatePlantReq) (*plant.CreatePlantResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CreatePlantResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreatePostLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePostLogic {
|
||||
return &CreatePostLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 社区
|
||||
func (l *CreatePostLogic) CreatePost(in *plant.CreatePostReq) (*plant.CreatePostResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CreatePostResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateTopicLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTopicLogic {
|
||||
return &CreateTopicLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateTopicLogic) CreateTopic(in *plant.CreateTopicReq) (*plant.CreateTopicResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CreateTopicResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateWikiClassLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateWikiClassLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWikiClassLogic {
|
||||
return &CreateWikiClassLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateWikiClassLogic) CreateWikiClass(in *plant.CreateWikiClassReq) (*plant.CreateWikiClassResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.CreateWikiClassResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeletePlantLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeletePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePlantLogic {
|
||||
return &DeletePlantLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeletePlantLogic) DeletePlant(in *plant.DeletePlantReq) (*plant.DeletePlantResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.DeletePlantResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeletePostLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePostLogic {
|
||||
return &DeletePostLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeletePostLogic) DeletePost(in *plant.DeletePostReq) (*plant.DeletePostResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.DeletePostResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteTopicLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTopicLogic {
|
||||
return &DeleteTopicLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteTopicLogic) DeleteTopic(in *plant.DeleteTopicReq) (*plant.DeleteTopicResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.DeleteTopicResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetBadgeConfigListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetBadgeConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBadgeConfigListLogic {
|
||||
return &GetBadgeConfigListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetBadgeConfigListLogic) GetBadgeConfigList(in *plant.GetBadgeConfigListReq) (*plant.GetBadgeConfigListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetBadgeConfigListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetExchangeItemListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetExchangeItemListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExchangeItemListLogic {
|
||||
return &GetExchangeItemListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 兑换
|
||||
func (l *GetExchangeItemListLogic) GetExchangeItemList(in *plant.GetExchangeItemListReq) (*plant.GetExchangeItemListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetExchangeItemListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetLevelConfigListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetLevelConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLevelConfigListLogic {
|
||||
return &GetLevelConfigListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 配置
|
||||
func (l *GetLevelConfigListLogic) GetLevelConfigList(in *plant.GetLevelConfigListReq) (*plant.GetLevelConfigListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetLevelConfigListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPlantDetailLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetPlantDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPlantDetailLogic {
|
||||
return &GetPlantDetailLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPlantDetailLogic) GetPlantDetail(in *plant.GetPlantDetailReq) (*plant.GetPlantDetailResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetPlantDetailResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPlantListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetPlantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPlantListLogic {
|
||||
return &GetPlantListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPlantListLogic) GetPlantList(in *plant.GetPlantListReq) (*plant.GetPlantListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetPlantListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPostDetailLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetPostDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostDetailLogic {
|
||||
return &GetPostDetailLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostDetailLogic) GetPostDetail(in *plant.GetPostDetailReq) (*plant.GetPostDetailResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetPostDetailResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPostListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostListLogic {
|
||||
return &GetPostListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPostListLogic) GetPostList(in *plant.GetPostListReq) (*plant.GetPostListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetPostListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetTopicListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetTopicListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTopicListLogic {
|
||||
return &GetTopicListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 话题
|
||||
func (l *GetTopicListLogic) GetTopicList(in *plant.Empty) (*plant.GetTopicListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetTopicListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetUserProfileLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic {
|
||||
return &GetUserProfileLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 用户Profile
|
||||
func (l *GetUserProfileLogic) GetUserProfile(in *plant.GetUserProfileReq) (*plant.GetUserProfileResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetUserProfileResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWikiClassListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetWikiClassListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiClassListLogic {
|
||||
return &GetWikiClassListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWikiClassListLogic) GetWikiClassList(in *plant.Empty) (*plant.GetWikiClassListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetWikiClassListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWikiDetailLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetWikiDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiDetailLogic {
|
||||
return &GetWikiDetailLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWikiDetailLogic) GetWikiDetail(in *plant.GetWikiDetailReq) (*plant.GetWikiDetailResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetWikiDetailResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWikiListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetWikiListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWikiListLogic {
|
||||
return &GetWikiListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 百科
|
||||
func (l *GetWikiListLogic) GetWikiList(in *plant.GetWikiListReq) (*plant.GetWikiListResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.GetWikiListResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type IncrUserCounterLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewIncrUserCounterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IncrUserCounterLogic {
|
||||
return &IncrUserCounterLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *IncrUserCounterLogic) IncrUserCounter(in *plant.IncrUserCounterReq) (*plant.IncrUserCounterResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.IncrUserCounterResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
||||
"sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type LikePostLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewLikePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikePostLogic {
|
||||
return &LikePostLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LikePostLogic) LikePost(in *plant.LikePostReq) (*plant.LikePostResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &plant.LikePostResp{}, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user