feat: update bug fixing content website
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5eb8166d34
commit
5affb20eac
|
|
@ -11,6 +11,7 @@ type OurProductContent struct {
|
||||||
PrimaryTitle string `json:"primary_title" gorm:"type:varchar(255)"`
|
PrimaryTitle string `json:"primary_title" gorm:"type:varchar(255)"`
|
||||||
SecondaryTitle string `json:"secondary_title" gorm:"type:varchar(255)"`
|
SecondaryTitle string `json:"secondary_title" gorm:"type:varchar(255)"`
|
||||||
Description string `json:"description" gorm:"type:text"`
|
Description string `json:"description" gorm:"type:text"`
|
||||||
|
LinkURL string `json:"link_url" gorm:"type:text"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
IsActive *bool `json:"is_active" gorm:"default:true"`
|
IsActive *bool `json:"is_active" gorm:"default:true"`
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ type OurServiceContent struct {
|
||||||
PrimaryTitle string `json:"primary_title" gorm:"type:varchar(255)"`
|
PrimaryTitle string `json:"primary_title" gorm:"type:varchar(255)"`
|
||||||
SecondaryTitle string `json:"secondary_title" gorm:"type:varchar(255)"`
|
SecondaryTitle string `json:"secondary_title" gorm:"type:varchar(255)"`
|
||||||
Description string `json:"description" gorm:"type:text"`
|
Description string `json:"description" gorm:"type:text"`
|
||||||
|
LinkURL string `json:"link_url" gorm:"type:text"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
IsActive *bool `json:"is_active" gorm:"default:true"`
|
IsActive *bool `json:"is_active" gorm:"default:true"`
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
"web-qudo-be/app/database"
|
"web-qudo-be/app/database"
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
|
|
||||||
|
|
@ -58,7 +59,11 @@ func (r *heroContentImagesRepository) Update(id uuid.UUID, data *entity.HeroCont
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.HeroContentImages{}).
|
Model(&entity.HeroContentImages{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(map[string]interface{}{
|
||||||
|
"image_path": data.ImagePath,
|
||||||
|
"image_url": data.ImageURL,
|
||||||
|
"updated_at": time.Now(),
|
||||||
|
}).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update hero content image")
|
r.Log.Error().Err(err).Msg("failed update hero content image")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
"web-qudo-be/app/database"
|
"web-qudo-be/app/database"
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
|
|
||||||
|
|
@ -60,10 +61,23 @@ func (r *heroContentsRepository) Create(data *entity.HeroContents) (*entity.Hero
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *heroContentsRepository) Update(id uuid.UUID, data *entity.HeroContents) error {
|
func (r *heroContentsRepository) Update(id uuid.UUID, data *entity.HeroContents) error {
|
||||||
|
// map (not struct) so empty strings are persisted; GORM Updates(struct) skips zero values.
|
||||||
|
updates := map[string]interface{}{
|
||||||
|
"primary_title": data.PrimaryTitle,
|
||||||
|
"secondary_title": data.SecondaryTitle,
|
||||||
|
"description": data.Description,
|
||||||
|
"primary_cta": data.PrimaryCta,
|
||||||
|
"secondary_cta_text": data.SecondaryCtaText,
|
||||||
|
}
|
||||||
|
if data.IsActive != nil {
|
||||||
|
updates["is_active"] = data.IsActive
|
||||||
|
}
|
||||||
|
updates["updated_at"] = time.Now()
|
||||||
|
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.HeroContents{}).
|
Model(&entity.HeroContents{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(updates).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update hero content")
|
r.Log.Error().Err(err).Msg("failed update hero content")
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func (r *HeroContentsCreateRequest) ToEntity() *entity.HeroContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeroContentsUpdateRequest struct {
|
type HeroContentsUpdateRequest struct {
|
||||||
PrimaryTitle string `json:"primary_title"`
|
PrimaryTitle string `json:"primary_title" validate:"required"`
|
||||||
SecondaryTitle string `json:"secondary_title"`
|
SecondaryTitle string `json:"secondary_title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
PrimaryCTA string `json:"primary_cta"`
|
PrimaryCTA string `json:"primary_cta"`
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,18 @@ func (r *ourProductContentImagesRepository) Create(data *entity.OurProductConten
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ourProductContentImagesRepository) Update(id uuid.UUID, data *entity.OurProductContentImage) error {
|
func (r *ourProductContentImagesRepository) Update(id uuid.UUID, data *entity.OurProductContentImage) error {
|
||||||
|
updates := map[string]interface{}{
|
||||||
|
"image_path": data.ImagePath,
|
||||||
|
"image_url": data.ImageURL,
|
||||||
|
}
|
||||||
|
if data.IsThumbnail != nil {
|
||||||
|
updates["is_thumbnail"] = data.IsThumbnail
|
||||||
|
}
|
||||||
|
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.OurProductContentImage{}).
|
Model(&entity.OurProductContentImage{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(updates).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update our product content image")
|
r.Log.Error().Err(err).Msg("failed update our product content image")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
"web-qudo-be/app/database"
|
"web-qudo-be/app/database"
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
|
|
||||||
|
|
@ -74,10 +75,21 @@ func (r *ourProductContentRepository) Create(data *entity.OurProductContent) (*e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ourProductContentRepository) Update(id uuid.UUID, data *entity.OurProductContent) error {
|
func (r *ourProductContentRepository) Update(id uuid.UUID, data *entity.OurProductContent) error {
|
||||||
|
updates := map[string]interface{}{
|
||||||
|
"primary_title": data.PrimaryTitle,
|
||||||
|
"secondary_title": data.SecondaryTitle,
|
||||||
|
"description": data.Description,
|
||||||
|
"link_url": data.LinkURL,
|
||||||
|
"updated_at": time.Now(),
|
||||||
|
}
|
||||||
|
if data.IsActive != nil {
|
||||||
|
updates["is_active"] = data.IsActive
|
||||||
|
}
|
||||||
|
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.OurProductContent{}).
|
Model(&entity.OurProductContent{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(updates).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update our product content")
|
r.Log.Error().Err(err).Msg("failed update our product content")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ type OurProductContentCreateRequest struct {
|
||||||
PrimaryTitle string `json:"primary_title" form:"primary_title" validate:"required"`
|
PrimaryTitle string `json:"primary_title" form:"primary_title" validate:"required"`
|
||||||
SecondaryTitle string `json:"secondary_title" form:"secondary_title"`
|
SecondaryTitle string `json:"secondary_title" form:"secondary_title"`
|
||||||
Description string `json:"description" form:"description"`
|
Description string `json:"description" form:"description"`
|
||||||
|
LinkURL string `json:"link_url" form:"link_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OurProductContentCreateRequest) ToEntity() *entity.OurProductContent {
|
func (r *OurProductContentCreateRequest) ToEntity() *entity.OurProductContent {
|
||||||
|
|
@ -13,6 +14,7 @@ func (r *OurProductContentCreateRequest) ToEntity() *entity.OurProductContent {
|
||||||
PrimaryTitle: r.PrimaryTitle,
|
PrimaryTitle: r.PrimaryTitle,
|
||||||
SecondaryTitle: r.SecondaryTitle,
|
SecondaryTitle: r.SecondaryTitle,
|
||||||
Description: r.Description,
|
Description: r.Description,
|
||||||
|
LinkURL: r.LinkURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,6 +22,7 @@ type OurProductContentUpdateRequest struct {
|
||||||
PrimaryTitle string `json:"primary_title"`
|
PrimaryTitle string `json:"primary_title"`
|
||||||
SecondaryTitle string `json:"secondary_title"`
|
SecondaryTitle string `json:"secondary_title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
LinkURL string `json:"link_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OurProductContentUpdateRequest) ToEntity() *entity.OurProductContent {
|
func (r *OurProductContentUpdateRequest) ToEntity() *entity.OurProductContent {
|
||||||
|
|
@ -27,5 +30,6 @@ func (r *OurProductContentUpdateRequest) ToEntity() *entity.OurProductContent {
|
||||||
PrimaryTitle: r.PrimaryTitle,
|
PrimaryTitle: r.PrimaryTitle,
|
||||||
SecondaryTitle: r.SecondaryTitle,
|
SecondaryTitle: r.SecondaryTitle,
|
||||||
Description: r.Description,
|
Description: r.Description,
|
||||||
|
LinkURL: r.LinkURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,10 +52,18 @@ func (r *ourServiceContentImagesRepository) Create(data *entity.OurServiceConten
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ourServiceContentImagesRepository) Update(id uint, data *entity.OurServiceContentImage) error {
|
func (r *ourServiceContentImagesRepository) Update(id uint, data *entity.OurServiceContentImage) error {
|
||||||
|
updates := map[string]interface{}{
|
||||||
|
"image_path": data.ImagePath,
|
||||||
|
"image_url": data.ImageURL,
|
||||||
|
}
|
||||||
|
if data.IsThumbnail != nil {
|
||||||
|
updates["is_thumbnail"] = data.IsThumbnail
|
||||||
|
}
|
||||||
|
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.OurServiceContentImage{}).
|
Model(&entity.OurServiceContentImage{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(updates).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update our service content images")
|
r.Log.Error().Err(err).Msg("failed update our service content images")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
"web-qudo-be/app/database"
|
"web-qudo-be/app/database"
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
|
|
||||||
|
|
@ -71,10 +72,21 @@ func (r *ourServiceContentRepository) Create(data *entity.OurServiceContent) (*e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ourServiceContentRepository) Update(id uint, data *entity.OurServiceContent) error {
|
func (r *ourServiceContentRepository) Update(id uint, data *entity.OurServiceContent) error {
|
||||||
|
updates := map[string]interface{}{
|
||||||
|
"primary_title": data.PrimaryTitle,
|
||||||
|
"secondary_title": data.SecondaryTitle,
|
||||||
|
"description": data.Description,
|
||||||
|
"link_url": data.LinkURL,
|
||||||
|
"updated_at": time.Now(),
|
||||||
|
}
|
||||||
|
if data.IsActive != nil {
|
||||||
|
updates["is_active"] = data.IsActive
|
||||||
|
}
|
||||||
|
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.OurServiceContent{}).
|
Model(&entity.OurServiceContent{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(updates).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update our service content")
|
r.Log.Error().Err(err).Msg("failed update our service content")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ type OurServiceContentCreateRequest struct {
|
||||||
PrimaryTitle string `json:"primary_title" form:"primary_title" validate:"required"`
|
PrimaryTitle string `json:"primary_title" form:"primary_title" validate:"required"`
|
||||||
SecondaryTitle string `json:"secondary_title" form:"secondary_title"`
|
SecondaryTitle string `json:"secondary_title" form:"secondary_title"`
|
||||||
Description string `json:"description" form:"description"`
|
Description string `json:"description" form:"description"`
|
||||||
|
LinkURL string `json:"link_url" form:"link_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OurServiceContentCreateRequest) ToEntity() *entity.OurServiceContent {
|
func (r *OurServiceContentCreateRequest) ToEntity() *entity.OurServiceContent {
|
||||||
|
|
@ -13,6 +14,7 @@ func (r *OurServiceContentCreateRequest) ToEntity() *entity.OurServiceContent {
|
||||||
PrimaryTitle: r.PrimaryTitle,
|
PrimaryTitle: r.PrimaryTitle,
|
||||||
SecondaryTitle: r.SecondaryTitle,
|
SecondaryTitle: r.SecondaryTitle,
|
||||||
Description: r.Description,
|
Description: r.Description,
|
||||||
|
LinkURL: r.LinkURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,6 +22,7 @@ type OurServiceContentUpdateRequest struct {
|
||||||
PrimaryTitle string `json:"primary_title"`
|
PrimaryTitle string `json:"primary_title"`
|
||||||
SecondaryTitle string `json:"secondary_title"`
|
SecondaryTitle string `json:"secondary_title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
LinkURL string `json:"link_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OurServiceContentUpdateRequest) ToEntity() *entity.OurServiceContent {
|
func (r *OurServiceContentUpdateRequest) ToEntity() *entity.OurServiceContent {
|
||||||
|
|
@ -27,5 +30,6 @@ func (r *OurServiceContentUpdateRequest) ToEntity() *entity.OurServiceContent {
|
||||||
PrimaryTitle: r.PrimaryTitle,
|
PrimaryTitle: r.PrimaryTitle,
|
||||||
SecondaryTitle: r.SecondaryTitle,
|
SecondaryTitle: r.SecondaryTitle,
|
||||||
Description: r.Description,
|
Description: r.Description,
|
||||||
|
LinkURL: r.LinkURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
"web-qudo-be/app/database"
|
"web-qudo-be/app/database"
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
|
|
||||||
|
|
@ -59,7 +60,12 @@ func (r *partnerContentRepository) Update(id uuid.UUID, data *entity.PartnerCont
|
||||||
err := r.DB.DB.
|
err := r.DB.DB.
|
||||||
Model(&entity.PartnerContent{}).
|
Model(&entity.PartnerContent{}).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(map[string]interface{}{
|
||||||
|
"primary_title": data.PrimaryTitle,
|
||||||
|
"image_path": data.ImagePath,
|
||||||
|
"image_url": data.ImageURL,
|
||||||
|
"updated_at": time.Now(),
|
||||||
|
}).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error().Err(err).Msg("failed update partner content")
|
r.Log.Error().Err(err).Msg("failed update partner content")
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"web-qudo-be/app/database/entity"
|
"web-qudo-be/app/database/entity"
|
||||||
"web-qudo-be/app/module/popup_news_contents/request"
|
"web-qudo-be/app/module/popup_news_contents/request"
|
||||||
"web-qudo-be/utils/paginator"
|
"web-qudo-be/utils/paginator"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type popupNewsContentsRepository struct {
|
type popupNewsContentsRepository struct {
|
||||||
|
|
@ -70,11 +72,22 @@ func (_i *popupNewsContentsRepository) Create(data *entity.PopupNewsContents) er
|
||||||
// Update
|
// Update
|
||||||
func (_i *popupNewsContentsRepository) Update(id uint, data *entity.PopupNewsContents) error {
|
func (_i *popupNewsContentsRepository) Update(id uint, data *entity.PopupNewsContents) error {
|
||||||
return _i.DB.DB.Model(&entity.PopupNewsContents{}).
|
return _i.DB.DB.Model(&entity.PopupNewsContents{}).
|
||||||
Where(&entity.PopupNewsContents{ID: id}).
|
Where("id = ?", id).
|
||||||
Updates(data).Error
|
Updates(map[string]interface{}{
|
||||||
|
"primary_title": data.PrimaryTitle,
|
||||||
|
"secondary_title": data.SecondaryTitle,
|
||||||
|
"description": data.Description,
|
||||||
|
"primary_cta": data.PrimaryCTA,
|
||||||
|
"secondary_cta_text": data.SecondaryCTAText,
|
||||||
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete removes child images first so FK constraints do not block the parent delete.
|
||||||
func (_i *popupNewsContentsRepository) Delete(id uint) error {
|
func (_i *popupNewsContentsRepository) Delete(id uint) error {
|
||||||
return _i.DB.DB.Delete(&entity.PopupNewsContents{}, id).Error
|
return _i.DB.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err := tx.Where("popup_news_content_id = ?", id).Delete(&entity.PopupNewsContentImages{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Delete(&entity.PopupNewsContents{}, id).Error
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ idle-timeout = 5 # As seconds
|
||||||
print-routes = false
|
print-routes = false
|
||||||
prefork = false
|
prefork = false
|
||||||
# false: CMS preview URLs use http://localhost + port above. true: use domain (e.g. https://qudo.id/api).
|
# false: CMS preview URLs use http://localhost + port above. true: use domain (e.g. https://qudo.id/api).
|
||||||
production = true
|
production = false
|
||||||
body-limit = 1048576000 # "100 * 1024 * 1024"
|
body-limit = 1048576000 # "100 * 1024 * 1024"
|
||||||
|
|
||||||
[db.postgres]
|
[db.postgres]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue