diff --git a/database/log_ads_model.go b/database/log_ads_model.go index 5c007fc..119b030 100644 --- a/database/log_ads_model.go +++ b/database/log_ads_model.go @@ -3,9 +3,9 @@ package database import "time" type LogAds struct { - ID string `gorm:"primaryKey;not null" json:"id"` - AdsID string `gorm:"not null" json:"ads_id"` - UserID string `gorm:"not null" json:"user_id"` + ID string `gorm:"primaryKey;not null" json:"id"` + AdsID string `gorm:"not null" json:"ads_id"` + // UserID string `gorm:"default:null" json:"user_id"` CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"` } diff --git a/internal/accessor/log/create_log_ads.go b/internal/accessor/log/create_log_ads.go index 8eff037..cb933dd 100644 --- a/internal/accessor/log/create_log_ads.go +++ b/internal/accessor/log/create_log_ads.go @@ -6,11 +6,10 @@ import ( "github.com/google/uuid" ) -func (a *accessor) CreateLogAds(adsID, userID string) error { +func (a *accessor) CreateLogAds(adsID string) error { spec := database.LogAds{ - ID: uuid.NewString(), - AdsID: adsID, - UserID: userID, + ID: uuid.NewString(), + AdsID: adsID, } if err := a.db.Create(&spec).Error; err != nil { return err diff --git a/internal/accessor/log/impl.go b/internal/accessor/log/impl.go index 900d654..8bd07cd 100644 --- a/internal/accessor/log/impl.go +++ b/internal/accessor/log/impl.go @@ -10,7 +10,7 @@ type accessor struct { } type Log interface { - CreateLogAds(adsID, userID string) error + CreateLogAds(string) error GetAllLogAds(string) ([]adsdomain.Ads, error) } diff --git a/internal/api/http/logs/create_log_ads.go b/internal/api/http/logs/create_log_ads.go index 79d5eb8..171519c 100644 --- a/internal/api/http/logs/create_log_ads.go +++ b/internal/api/http/logs/create_log_ads.go @@ -1,7 +1,6 @@ package logshttp import ( - authmiddleware "legalgo-BE-go/internal/api/http/middleware/auth" logsdomain "legalgo-BE-go/internal/domain/logs" logssvc "legalgo-BE-go/internal/services/logs" usersvc "legalgo-BE-go/internal/services/user" @@ -17,21 +16,21 @@ func CreateLogAds( userSvc usersvc.User, logsSvc logssvc.Log, ) { - router.With(authmiddleware.Authorize()).Post("/logs/ads", func(w http.ResponseWriter, r *http.Request) { + router.Post("/logs/ads", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - userDetail, err := utils.GetTokenDetail(r) - if err != nil { - response.RespondJsonErrorWithCode( - ctx, - w, - err, - response.ErrUnauthorized.Code, - response.ErrUnauthorized.HttpCode, - "unauthorized", - ) - return - } + // userDetail, err := utils.GetTokenDetail(r) + // if err != nil { + // response.RespondJsonErrorWithCode( + // ctx, + // w, + // err, + // response.ErrUnauthorized.Code, + // response.ErrUnauthorized.HttpCode, + // "unauthorized", + // ) + // return + // } var spec logsdomain.LogsRequest @@ -47,7 +46,7 @@ func CreateLogAds( return } - if err := logsSvc.CreateLogAds(spec.AdsID, userDetail.ID); err != nil { + if err := logsSvc.CreateLogAds(spec.AdsID); err != nil { response.RespondJsonErrorWithCode( ctx, w, diff --git a/internal/services/logs/create_logs_ads.go b/internal/services/logs/create_logs_ads.go index 8ada044..80a1f75 100644 --- a/internal/services/logs/create_logs_ads.go +++ b/internal/services/logs/create_logs_ads.go @@ -2,8 +2,8 @@ package logssvc import "fmt" -func (i *impl) CreateLogAds(adsID, userID string) error { - if err := i.logsRepo.CreateLogAds(adsID, userID); err != nil { +func (i *impl) CreateLogAds(adsID string) error { + if err := i.logsRepo.CreateLogAds(adsID); err != nil { return fmt.Errorf("failed to create ads log: %v", err) } diff --git a/internal/services/logs/impl.go b/internal/services/logs/impl.go index ff2d708..a921896 100644 --- a/internal/services/logs/impl.go +++ b/internal/services/logs/impl.go @@ -10,7 +10,7 @@ type impl struct { } type Log interface { - CreateLogAds(adsID, userID string) error + CreateLogAds(string) error GetAllLogAds(string) ([]adsdomain.Ads, error) }