fix: remove auth in ads log
This commit is contained in:
parent
d7fa8496b0
commit
b0099dac1e
@ -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"`
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -10,7 +10,7 @@ type accessor struct {
|
||||
}
|
||||
|
||||
type Log interface {
|
||||
CreateLogAds(adsID, userID string) error
|
||||
CreateLogAds(string) error
|
||||
GetAllLogAds(string) ([]adsdomain.Ads, error)
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ type impl struct {
|
||||
}
|
||||
|
||||
type Log interface {
|
||||
CreateLogAds(adsID, userID string) error
|
||||
CreateLogAds(string) error
|
||||
GetAllLogAds(string) ([]adsdomain.Ads, error)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user