同一时长可按 ios、android、web 分别定价;health.wyrs.com 对齐已入库的 health.wyrs365.com。
91 lines
2.0 KiB
Go
91 lines
2.0 KiB
Go
package clienthandler
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
clientlogic "spark-server/internal/module/client/logic"
|
|
"spark-server/internal/transport/http/respond"
|
|
)
|
|
|
|
type Handler struct {
|
|
svc *clientlogic.Service
|
|
}
|
|
|
|
func New(svc *clientlogic.Service) *Handler {
|
|
return &Handler{svc: svc}
|
|
}
|
|
|
|
func (h *Handler) LegalAgreements(c *gin.Context) {
|
|
out, err := h.svc.LegalAgreements(c.Request.Context())
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|
|
|
|
func (h *Handler) SubmitFeedback(c *gin.Context) {
|
|
var in clientlogic.FeedbackInput
|
|
if err := respond.BindJSON(c, &in); err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
out, err := h.svc.SubmitFeedback(c.Request.Context(), in)
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|
|
|
|
func (h *Handler) SubscriptionPlans(c *gin.Context) {
|
|
pkg := strings.TrimSpace(c.Query("packageName"))
|
|
if pkg == "" {
|
|
pkg = strings.TrimSpace(c.Query("package_name"))
|
|
}
|
|
if pkg == "" {
|
|
pkg = strings.TrimSpace(c.GetHeader("X-Wyrs-Package"))
|
|
}
|
|
platform := strings.TrimSpace(c.Query("platform"))
|
|
if platform == "" {
|
|
platform = strings.TrimSpace(c.GetHeader("X-Wyrs-Platform"))
|
|
}
|
|
out, err := h.svc.SubscriptionPlans(c.Request.Context(), pkg, platform)
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|
|
|
|
func (h *Handler) SetPassword(c *gin.Context) {
|
|
var in clientlogic.SetPasswordInput
|
|
if err := respond.BindJSON(c, &in); err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
if err := h.svc.SetPassword(c.Request.Context(), in); err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, gin.H{})
|
|
}
|
|
|
|
func (h *Handler) DeveloperApps(c *gin.Context) {
|
|
source := c.Query("appCode")
|
|
if source == "" {
|
|
source = c.Query("sourceAppCode")
|
|
}
|
|
if source == "" {
|
|
source = "sleepheart"
|
|
}
|
|
out, err := h.svc.DeveloperApps(c.Request.Context(), source, c.Query("packageName"))
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|