add hero section
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
eeb167af3b
commit
a2f9c3423b
|
|
@ -0,0 +1,94 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"web-qudo-be/app/module/hero_section/service"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type HeroSectionController struct {
|
||||
Service *service.HeroSectionService
|
||||
}
|
||||
|
||||
type Controller struct {
|
||||
HeroSection *HeroSectionController
|
||||
}
|
||||
|
||||
func NewController(service *service.HeroSectionService) *Controller {
|
||||
return &Controller{
|
||||
HeroSection: &HeroSectionController{
|
||||
Service: service,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GET
|
||||
func (c *HeroSectionController) Get(ctx *fiber.Ctx) error {
|
||||
data, err := c.Service.Get(ctx.Context())
|
||||
if err != nil {
|
||||
return ctx.Status(500).JSON(fiber.Map{
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"data": data,
|
||||
})
|
||||
}
|
||||
|
||||
// CREATE
|
||||
func (c *HeroSectionController) Create(ctx *fiber.Ctx) error {
|
||||
err := c.Service.Create(ctx.Context(), ctx)
|
||||
if err != nil {
|
||||
return ctx.Status(500).JSON(fiber.Map{
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "Hero section created successfully",
|
||||
})
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
func (c *HeroSectionController) Update(ctx *fiber.Ctx) error {
|
||||
id, err := strconv.Atoi(ctx.Params("id"))
|
||||
if err != nil {
|
||||
return ctx.Status(400).JSON(fiber.Map{
|
||||
"message": "Invalid ID",
|
||||
})
|
||||
}
|
||||
|
||||
err = c.Service.Update(ctx.Context(), id, ctx)
|
||||
if err != nil {
|
||||
return ctx.Status(500).JSON(fiber.Map{
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "Hero section updated successfully",
|
||||
})
|
||||
}
|
||||
|
||||
// DELETE
|
||||
func (c *HeroSectionController) Delete(ctx *fiber.Ctx) error {
|
||||
id, err := strconv.Atoi(ctx.Params("id"))
|
||||
if err != nil {
|
||||
return ctx.Status(400).JSON(fiber.Map{
|
||||
"message": "Invalid ID",
|
||||
})
|
||||
}
|
||||
|
||||
err = c.Service.Delete(ctx.Context(), id)
|
||||
if err != nil {
|
||||
return ctx.Status(500).JSON(fiber.Map{
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "Hero section deleted successfully",
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package hero_section
|
||||
|
||||
import (
|
||||
"web-qudo-be/app/module/hero_section/controller"
|
||||
"web-qudo-be/app/module/hero_section/repository"
|
||||
"web-qudo-be/app/module/hero_section/service"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
type HeroSectionRouter struct {
|
||||
App fiber.Router
|
||||
Controller *controller.Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
var NewHeroSectionModule = fx.Options(
|
||||
fx.Provide(repository.NewHeroSectionRepository),
|
||||
fx.Provide(service.NewHeroSectionService),
|
||||
fx.Provide(controller.NewController),
|
||||
fx.Provide(NewHeroSectionRouter),
|
||||
)
|
||||
|
||||
func NewHeroSectionRouter(fiber *fiber.App, controller *controller.Controller) *HeroSectionRouter {
|
||||
return &HeroSectionRouter{
|
||||
App: fiber,
|
||||
Controller: controller,
|
||||
}
|
||||
}
|
||||
|
||||
func (_i *HeroSectionRouter) RegisterHeroSectionRoutes() {
|
||||
heroController := _i.Controller.HeroSection
|
||||
|
||||
_i.App.Route("/hero-section", func(router fiber.Router) {
|
||||
router.Get("/", heroController.Get)
|
||||
router.Post("/", heroController.Create)
|
||||
router.Put("/:id", heroController.Update)
|
||||
router.Delete("/:id", heroController.Delete)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package mapper
|
||||
|
||||
import "web-qudo-be/app/module/hero_section/response"
|
||||
|
||||
func ToHeroSectionResponse(data map[string]interface{}) response.HeroSectionResponse {
|
||||
return response.HeroSectionResponse{
|
||||
ID: data["id"].(int),
|
||||
PrimaryTitle: data["primary_title"].(string),
|
||||
SecondaryTitle: data["secondary_title"].(string),
|
||||
Description: data["description"].(string),
|
||||
PrimaryCTA: data["primary_cta"].(string),
|
||||
SecondaryCTAText: data["secondary_cta_text"].(string),
|
||||
ImagePath: data["image_path"].(string),
|
||||
ImageURL: data["image_url"].(string),
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type HeroSectionRepository struct {
|
||||
DB *sql.DB
|
||||
}
|
||||
|
||||
func NewHeroSectionRepository(db *sql.DB) *HeroSectionRepository {
|
||||
return &HeroSectionRepository{DB: db}
|
||||
}
|
||||
|
||||
func (r *HeroSectionRepository) Get(ctx context.Context) (map[string]interface{}, error) {
|
||||
query := `
|
||||
SELECT hc.id, hc.primary_title, hc.secondary_title, hc.description,
|
||||
hc.primary_cta, hc.secondary_cta_text,
|
||||
hci.image_path, hci.image_url
|
||||
FROM hero_content hc
|
||||
LEFT JOIN hero_content_image hci ON hc.id = hci.hero_content_id
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
row := r.DB.QueryRowContext(ctx, query)
|
||||
|
||||
var result map[string]interface{} = make(map[string]interface{})
|
||||
var id int
|
||||
var primaryTitle, secondaryTitle, description, primaryCTA, secondaryCTA string
|
||||
var imagePath, imageUrl sql.NullString
|
||||
|
||||
err := row.Scan(&id, &primaryTitle, &secondaryTitle, &description,
|
||||
&primaryCTA, &secondaryCTA, &imagePath, &imageUrl)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result["id"] = id
|
||||
result["primary_title"] = primaryTitle
|
||||
result["secondary_title"] = secondaryTitle
|
||||
result["description"] = description
|
||||
result["primary_cta"] = primaryCTA
|
||||
result["secondary_cta_text"] = secondaryCTA
|
||||
result["image_path"] = imagePath.String
|
||||
result["image_url"] = imageUrl.String
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *HeroSectionRepository) Create(ctx context.Context, data map[string]interface{}) (int, error) {
|
||||
query := `
|
||||
INSERT INTO hero_content
|
||||
(primary_title, secondary_title, description, primary_cta, secondary_cta_text)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
result, err := r.DB.ExecContext(
|
||||
ctx,
|
||||
query,
|
||||
data["primary_title"],
|
||||
data["secondary_title"],
|
||||
data["description"],
|
||||
data["primary_cta"],
|
||||
data["secondary_cta_text"],
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(id), nil
|
||||
}
|
||||
|
||||
func (r *HeroSectionRepository) Update(ctx context.Context, id int, data map[string]interface{}) error {
|
||||
query := `
|
||||
UPDATE hero_content SET
|
||||
primary_title = ?,
|
||||
secondary_title = ?,
|
||||
description = ?,
|
||||
primary_cta = ?,
|
||||
secondary_cta_text = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
_, err := r.DB.ExecContext(
|
||||
ctx,
|
||||
query,
|
||||
data["primary_title"],
|
||||
data["secondary_title"],
|
||||
data["description"],
|
||||
data["primary_cta"],
|
||||
data["secondary_cta_text"],
|
||||
id,
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *HeroSectionRepository) Delete(ctx context.Context, id int) error {
|
||||
query := `DELETE FROM hero_content WHERE id = ?`
|
||||
|
||||
_, err := r.DB.ExecContext(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package request
|
||||
|
||||
type HeroSectionRequest struct {
|
||||
PrimaryTitle string `json:"primary_title"`
|
||||
SecondaryTitle string `json:"secondary_title"`
|
||||
Description string `json:"description"`
|
||||
PrimaryCTA string `json:"primary_cta"`
|
||||
SecondaryCTA string `json:"secondary_cta_text"`
|
||||
ImagePath string `json:"image_path"`
|
||||
ImageURL string `json:"image_url"`
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package response
|
||||
|
||||
type HeroSectionResponse struct {
|
||||
ID int `json:"id"`
|
||||
PrimaryTitle string `json:"primary_title"`
|
||||
SecondaryTitle string `json:"secondary_title"`
|
||||
Description string `json:"description"`
|
||||
PrimaryCTA string `json:"primary_cta"`
|
||||
SecondaryCTAText string `json:"secondary_cta_text"`
|
||||
ImagePath string `json:"image_path"`
|
||||
ImageURL string `json:"image_url"`
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"web-qudo-be/app/module/hero_section/repository"
|
||||
hero_section_image_service "web-qudo-be/app/module/hero_section_image/service"
|
||||
)
|
||||
|
||||
type HeroSectionService struct {
|
||||
Repo *repository.HeroSectionRepository
|
||||
ImageService *hero_section_image_service.HeroSectionImageService
|
||||
}
|
||||
|
||||
func NewHeroSectionService(
|
||||
repo *repository.HeroSectionRepository,
|
||||
imageService *hero_section_image_service.HeroSectionImageService,
|
||||
) *HeroSectionService {
|
||||
return &HeroSectionService{
|
||||
Repo: repo,
|
||||
ImageService: imageService,
|
||||
}
|
||||
}
|
||||
|
||||
// GET
|
||||
func (s *HeroSectionService) Get(ctx context.Context) (interface{}, error) {
|
||||
data, err := s.Repo.Get(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ambil image (optional)
|
||||
if id, ok := data["id"].(int); ok {
|
||||
image, _ := s.ImageService.GetByHeroID(ctx, id)
|
||||
data["image"] = image
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// CREATE
|
||||
func (s *HeroSectionService) Create(ctx context.Context, c *fiber.Ctx) error {
|
||||
type request struct {
|
||||
PrimaryTitle string `json:"primary_title"`
|
||||
SecondaryTitle string `json:"secondary_title"`
|
||||
Description string `json:"description"`
|
||||
PrimaryCTA string `json:"primary_cta"`
|
||||
SecondaryCTAText string `json:"secondary_cta_text"`
|
||||
}
|
||||
|
||||
req := new(request)
|
||||
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// insert hero_content
|
||||
heroID, err := s.Repo.Create(ctx, map[string]interface{}{
|
||||
"primary_title": req.PrimaryTitle,
|
||||
"secondary_title": req.SecondaryTitle,
|
||||
"description": req.Description,
|
||||
"primary_cta": req.PrimaryCTA,
|
||||
"secondary_cta_text": req.SecondaryCTAText,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// OPTIONAL: upload image kalau ada
|
||||
file, err := c.FormFile("image")
|
||||
if err == nil {
|
||||
path := "./uploads/" + file.Filename
|
||||
c.SaveFile(file, path)
|
||||
|
||||
url := "/uploads/" + file.Filename
|
||||
|
||||
_ = s.ImageService.Upload(ctx, heroID, path, url)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
func (s *HeroSectionService) Update(ctx context.Context, id int, c *fiber.Ctx) error {
|
||||
type request struct {
|
||||
PrimaryTitle string `json:"primary_title"`
|
||||
SecondaryTitle string `json:"secondary_title"`
|
||||
Description string `json:"description"`
|
||||
PrimaryCTA string `json:"primary_cta"`
|
||||
SecondaryCTAText string `json:"secondary_cta_text"`
|
||||
}
|
||||
|
||||
req := new(request)
|
||||
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := s.Repo.Update(ctx, id, map[string]interface{}{
|
||||
"primary_title": req.PrimaryTitle,
|
||||
"secondary_title": req.SecondaryTitle,
|
||||
"description": req.Description,
|
||||
"primary_cta": req.PrimaryCTA,
|
||||
"secondary_cta_text": req.SecondaryCTAText,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update image kalau ada upload baru
|
||||
file, err := c.FormFile("image")
|
||||
if err == nil {
|
||||
path := "./uploads/" + file.Filename
|
||||
c.SaveFile(file, path)
|
||||
|
||||
url := "/uploads/" + file.Filename
|
||||
|
||||
_ = s.ImageService.Upload(ctx, id, path, url)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DELETE
|
||||
func (s *HeroSectionService) Delete(ctx context.Context, id int) error {
|
||||
return s.Repo.Delete(ctx, id)
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"web-qudo-be/app/module/hero_section_image/service"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type HeroSectionImageController struct {
|
||||
Service *service.HeroSectionImageService
|
||||
}
|
||||
|
||||
type Controller struct {
|
||||
HeroSectionImage *HeroSectionImageController
|
||||
}
|
||||
|
||||
func NewController(service *service.HeroSectionImageService) *Controller {
|
||||
return &Controller{
|
||||
HeroSectionImage: &HeroSectionImageController{
|
||||
Service: service,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GET by hero_id
|
||||
func (c *HeroSectionImageController) GetByHeroID(ctx *fiber.Ctx) error {
|
||||
heroId, err := strconv.Atoi(ctx.Params("heroId"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := c.Service.GetByHeroID(ctx.Context(), heroId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"data": data,
|
||||
})
|
||||
}
|
||||
|
||||
// CREATE (UPLOAD)
|
||||
func (c *HeroSectionImageController) Upload(ctx *fiber.Ctx) error {
|
||||
heroId, err := strconv.Atoi(ctx.Params("heroId"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := ctx.FormFile("image")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := "./uploads/" + file.Filename
|
||||
ctx.SaveFile(file, path)
|
||||
|
||||
url := "/uploads/" + file.Filename
|
||||
|
||||
err = c.Service.Upload(ctx.Context(), heroId, path, url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "uploaded",
|
||||
})
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
func (c *HeroSectionImageController) Update(ctx *fiber.Ctx) error {
|
||||
id, err := strconv.Atoi(ctx.Params("id"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := ctx.FormFile("image")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := "./uploads/" + file.Filename
|
||||
ctx.SaveFile(file, path)
|
||||
|
||||
url := "/uploads/" + file.Filename
|
||||
|
||||
err = c.Service.Update(ctx.Context(), id, path, url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "updated",
|
||||
})
|
||||
}
|
||||
|
||||
// DELETE
|
||||
func (c *HeroSectionImageController) Delete(ctx *fiber.Ctx) error {
|
||||
id, err := strconv.Atoi(ctx.Params("id"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.Service.Delete(ctx.Context(), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(fiber.Map{
|
||||
"message": "deleted",
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package hero_section_image
|
||||
|
||||
import (
|
||||
"web-qudo-be/app/module/hero_section_image/controller"
|
||||
"web-qudo-be/app/module/hero_section_image/repository"
|
||||
"web-qudo-be/app/module/hero_section_image/service"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
type HeroSectionImageRouter struct {
|
||||
App fiber.Router
|
||||
Controller *controller.Controller
|
||||
}
|
||||
|
||||
var NewHeroSectionImageModule = fx.Options(
|
||||
fx.Provide(repository.NewHeroSectionImageRepository),
|
||||
fx.Provide(service.NewHeroSectionImageService),
|
||||
fx.Provide(controller.NewController),
|
||||
fx.Provide(NewHeroSectionImageRouter),
|
||||
)
|
||||
|
||||
func NewHeroSectionImageRouter(fiber *fiber.App, controller *controller.Controller) *HeroSectionImageRouter {
|
||||
return &HeroSectionImageRouter{
|
||||
App: fiber,
|
||||
Controller: controller,
|
||||
}
|
||||
}
|
||||
|
||||
func (_i *HeroSectionImageRouter) RegisterHeroSectionImageRoutes() {
|
||||
ctrl := _i.Controller.HeroSectionImage
|
||||
|
||||
_i.App.Route("/hero-section-image", func(r fiber.Router) {
|
||||
r.Post("/:heroId", ctrl.Upload)
|
||||
r.Put("/:id", ctrl.Update)
|
||||
r.Delete("/:id", ctrl.Delete)
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type HeroSectionImageRepository struct {
|
||||
DB *sql.DB
|
||||
}
|
||||
|
||||
func NewHeroSectionImageRepository(db *sql.DB) *HeroSectionImageRepository {
|
||||
return &HeroSectionImageRepository{DB: db}
|
||||
}
|
||||
|
||||
func (r *HeroSectionImageRepository) Create(ctx context.Context, heroId int, path, url string) error {
|
||||
query := `
|
||||
INSERT INTO hero_content_image (hero_content_id, image_path, image_url)
|
||||
VALUES (?, ?, ?)
|
||||
`
|
||||
_, err := r.DB.ExecContext(ctx, query, heroId, path, url)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *HeroSectionImageRepository) FindByHeroID(ctx context.Context, heroId int) (map[string]string, error) {
|
||||
query := `
|
||||
SELECT image_path, image_url
|
||||
FROM hero_content_image
|
||||
WHERE hero_content_id = ?
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
row := r.DB.QueryRowContext(ctx, query, heroId)
|
||||
|
||||
var path, url string
|
||||
err := row.Scan(&path, &url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return map[string]string{
|
||||
"image_path": path,
|
||||
"image_url": url,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
func (r *HeroSectionImageRepository) Update(ctx context.Context, id int, path, url string) error {
|
||||
query := `UPDATE hero_content_image SET image_path = ?, image_url = ? WHERE id = ?`
|
||||
_, err := r.DB.ExecContext(ctx, query, path, url, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// DELETE
|
||||
func (r *HeroSectionImageRepository) Delete(ctx context.Context, id int) error {
|
||||
query := `DELETE FROM hero_content_image WHERE id = ?`
|
||||
_, err := r.DB.ExecContext(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"web-qudo-be/app/module/hero_section_image/repository"
|
||||
)
|
||||
|
||||
type HeroSectionImageService struct {
|
||||
Repo *repository.HeroSectionImageRepository
|
||||
}
|
||||
|
||||
func NewHeroSectionImageService(repo *repository.HeroSectionImageRepository) *HeroSectionImageService {
|
||||
return &HeroSectionImageService{Repo: repo}
|
||||
}
|
||||
|
||||
// GET by hero_id
|
||||
func (s *HeroSectionImageService) GetByHeroID(ctx context.Context, heroId int) (interface{}, error) {
|
||||
return s.Repo.FindByHeroID(ctx, heroId)
|
||||
}
|
||||
|
||||
// CREATE (UPLOAD)
|
||||
func (s *HeroSectionImageService) Upload(ctx context.Context, heroId int, path, url string) error {
|
||||
return s.Repo.Create(ctx, heroId, path, url)
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
func (s *HeroSectionImageService) Update(ctx context.Context, id int, path, url string) error {
|
||||
return s.Repo.Update(ctx, id, path, url)
|
||||
}
|
||||
|
||||
// DELETE
|
||||
func (s *HeroSectionImageService) Delete(ctx context.Context, id int) error {
|
||||
return s.Repo.Delete(ctx, id)
|
||||
}
|
||||
|
|
@ -21,6 +21,8 @@ import (
|
|||
"web-qudo-be/app/module/custom_static_pages"
|
||||
"web-qudo-be/app/module/districts"
|
||||
"web-qudo-be/app/module/feedbacks"
|
||||
"web-qudo-be/app/module/hero_section"
|
||||
"web-qudo-be/app/module/hero_section_image"
|
||||
"web-qudo-be/app/module/magazine_files"
|
||||
"web-qudo-be/app/module/magazines"
|
||||
"web-qudo-be/app/module/master_menus"
|
||||
|
|
@ -60,6 +62,8 @@ type Router struct {
|
|||
CitiesRouter *cities.CitiesRouter
|
||||
ClientApprovalSettingsRouter *client_approval_settings.ClientApprovalSettingsRouter
|
||||
ClientsRouter *clients.ClientsRouter
|
||||
HeroSectionRouter *hero_section.HeroSectionRouter
|
||||
HeroSectionImageRouter *hero_section_image.HeroSectionImageRouter
|
||||
CustomStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter
|
||||
DistrictsRouter *districts.DistrictsRouter
|
||||
FeedbacksRouter *feedbacks.FeedbacksRouter
|
||||
|
|
@ -97,6 +101,8 @@ func NewRouter(
|
|||
citiesRouter *cities.CitiesRouter,
|
||||
clientApprovalSettingsRouter *client_approval_settings.ClientApprovalSettingsRouter,
|
||||
clientsRouter *clients.ClientsRouter,
|
||||
heroSectionRouter *hero_section.HeroSectionRouter,
|
||||
heroSectionImageRouter *hero_section_image.HeroSectionImageRouter,
|
||||
customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter,
|
||||
districtsRouter *districts.DistrictsRouter,
|
||||
feedbacksRouter *feedbacks.FeedbacksRouter,
|
||||
|
|
@ -132,6 +138,8 @@ func NewRouter(
|
|||
CitiesRouter: citiesRouter,
|
||||
ClientApprovalSettingsRouter: clientApprovalSettingsRouter,
|
||||
ClientsRouter: clientsRouter,
|
||||
HeroSectionRouter: heroSectionRouter,
|
||||
HeroSectionImageRouter: heroSectionImageRouter,
|
||||
CustomStaticPagesRouter: customStaticPagesRouter,
|
||||
DistrictsRouter: districtsRouter,
|
||||
FeedbacksRouter: feedbacksRouter,
|
||||
|
|
@ -177,6 +185,8 @@ func (r *Router) Register() {
|
|||
r.CitiesRouter.RegisterCitiesRoutes()
|
||||
r.ClientApprovalSettingsRouter.RegisterClientApprovalSettingsRoutes()
|
||||
r.ClientsRouter.RegisterClientsRoutes()
|
||||
r.HeroSectionRouter.RegisterHeroSectionRoutes()
|
||||
r.HeroSectionImageRouter.RegisterHeroSectionImageRoutes()
|
||||
r.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes()
|
||||
r.DistrictsRouter.RegisterDistrictsRoutes()
|
||||
r.FeedbacksRouter.RegisterFeedbacksRoutes()
|
||||
|
|
@ -192,3 +202,4 @@ func (r *Router) Register() {
|
|||
r.UsersRouter.RegisterUsersRoutes()
|
||||
r.UserRolesRouter.RegisterUserRolesRoutes()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9615,7 +9615,7 @@ const docTemplate = `{
|
|||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting all Clients gogo",
|
||||
"description": "API for getting all Clients",
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
|
|
@ -9705,7 +9705,7 @@ const docTemplate = `{
|
|||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create Clients gogo",
|
||||
"description": "API for create Clients",
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
|
|
@ -10994,6 +10994,217 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/hero-section": {
|
||||
"get": {
|
||||
"description": "Get hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Get Hero Section",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Create hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Create Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Insert the X-Client-Key",
|
||||
"name": "X-Client-Key",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "primary_title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "secondary_title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "description",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "primary_cta",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "secondary_cta_text",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section/{id}": {
|
||||
"put": {
|
||||
"description": "Update hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Update Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Delete hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Delete Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section-image/{heroId}": {
|
||||
"get": {
|
||||
"description": "Get images by hero ID",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Get Hero Images",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "heroId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Upload hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Upload Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "heroId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "image",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section-image/{id}": {
|
||||
"put": {
|
||||
"description": "Update hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Update Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "image",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Delete hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Delete Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/magazine-files": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -9302,7 +9302,7 @@
|
|||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting all Clients gogo",
|
||||
"description": "API for getting all Clients",
|
||||
"tags": ["Clients"],
|
||||
"summary": "Get all Clients",
|
||||
"parameters": [
|
||||
|
|
@ -10637,6 +10637,395 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/hero-section": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Get Hero Section",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for create hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Create Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Insert the X-Client-Key",
|
||||
"name": "X-Client-Key",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "primary_title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "secondary_title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "description",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "primary_cta",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "secondary_cta_text",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for update hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Update Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for delete hero section",
|
||||
"tags": ["Hero Section"],
|
||||
"summary": "Delete Hero Section",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section-image/{heroId}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for getting hero images by hero ID",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Get Hero Images",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "heroId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for upload hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Upload Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "heroId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "image",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hero-section-image/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for update hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Update Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "image",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for delete hero image",
|
||||
"tags": ["Hero Section Image"],
|
||||
"summary": "Delete Image",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/magazine-files": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -7609,7 +7609,7 @@ paths:
|
|||
- ClientApprovalSettings
|
||||
/clients:
|
||||
get:
|
||||
description: API for getting all Clients gogo
|
||||
description: API for getting all Clients
|
||||
parameters:
|
||||
- in: query
|
||||
name: createdBy
|
||||
|
|
@ -7664,7 +7664,7 @@ paths:
|
|||
tags:
|
||||
- Clients
|
||||
post:
|
||||
description: API for create Clients gogo
|
||||
description: API for create Clients
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
|
|
|
|||
12
main.go
12
main.go
|
|
@ -24,6 +24,8 @@ import (
|
|||
"web-qudo-be/app/module/custom_static_pages"
|
||||
"web-qudo-be/app/module/districts"
|
||||
"web-qudo-be/app/module/feedbacks"
|
||||
"web-qudo-be/app/module/hero_section"
|
||||
"web-qudo-be/app/module/hero_section_image"
|
||||
"web-qudo-be/app/module/magazine_files"
|
||||
"web-qudo-be/app/module/magazines"
|
||||
"web-qudo-be/app/module/master_menus"
|
||||
|
|
@ -68,6 +70,14 @@ func main() {
|
|||
// smtp config
|
||||
fx.Provide(config.NewSmtpConfig),
|
||||
|
||||
// database
|
||||
fx.Provide(database.NewDB),
|
||||
|
||||
// modules
|
||||
hero_section.NewHeroSectionModule,
|
||||
hero_section_image.NewHeroSectionImageModule,
|
||||
|
||||
|
||||
// provide modules
|
||||
activity_logs.NewActivityLogsModule,
|
||||
advertisement.NewAdvertisementModule,
|
||||
|
|
@ -89,6 +99,8 @@ func main() {
|
|||
custom_static_pages.NewCustomStaticPagesModule,
|
||||
districts.NewDistrictsModule,
|
||||
feedbacks.NewFeedbacksModule,
|
||||
hero_section.NewHeroSectionModule,
|
||||
hero_section_image.NewHeroSectionImageModule,
|
||||
magazines.NewMagazinesModule,
|
||||
magazine_files.NewMagazineFilesModule,
|
||||
master_menus.NewMasterMenusModule,
|
||||
|
|
|
|||
Loading…
Reference in New Issue