2024-09-04 23:04:04 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gitea.timerzz.com/kedaya_haitao/common/pkg/web"
|
2024-09-13 21:23:03 +08:00
|
|
|
"gitea.timerzz.com/kedaya_haitao/profitRate/rate"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
2024-09-04 23:04:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProfitRate struct {
|
2024-09-13 21:23:03 +08:00
|
|
|
ctl *rate.Controller
|
2024-09-04 23:04:04 +08:00
|
|
|
}
|
|
|
|
|
2024-09-13 21:23:03 +08:00
|
|
|
func NewProfitRate(ctl *rate.Controller) *ProfitRate {
|
2024-09-04 23:04:04 +08:00
|
|
|
return &ProfitRate{
|
2024-09-13 21:23:03 +08:00
|
|
|
ctl: ctl,
|
2024-09-04 23:04:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProfitRate) Registry(r fiber.Router) {
|
|
|
|
api := r.Group("/api/v2")
|
2024-09-13 21:23:03 +08:00
|
|
|
api.Post("article/profit_rate/:id", s.Rate)
|
2024-09-04 23:04:04 +08:00
|
|
|
}
|
|
|
|
|
2024-09-13 21:23:03 +08:00
|
|
|
func (s *ProfitRate) Rate(c fiber.Ctx) error {
|
|
|
|
id := c.Params("id")
|
|
|
|
if err := s.ctl.Rate(c.Context(), id); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return c.JSON(web.NewResponse("ok"))
|
2024-09-04 23:04:04 +08:00
|
|
|
}
|