feat(locations): allowing AI to attach it to the image

This commit is contained in:
2025-03-22 17:47:02 +00:00
parent dfb4b34de3
commit 13e5ed9f9e
4 changed files with 66 additions and 29 deletions

View File

@@ -73,26 +73,15 @@ func (m LocationModel) Save(ctx context.Context, locations []model.Locations) ([
return insertedLocation, err
}
func (m LocationModel) SaveToImage(ctx context.Context, imageId uuid.UUID, locations []model.Locations) error {
if len(locations) == 0 {
return nil
}
location, err := m.Save(ctx, locations)
if err != nil {
return err
}
// TODO: doesnt work if array is more than 1. BIG TODO
func (m LocationModel) SaveToImage(ctx context.Context, imageId uuid.UUID, locationId uuid.UUID) (model.ImageLocations, error) {
insertImageLocationStmt := ImageLocations.
INSERT(ImageLocations.ImageID, ImageLocations.LocationID).
VALUES(imageId, location[0].ID)
VALUES(imageId, locationId)
_, err = insertImageLocationStmt.ExecContext(ctx, m.dbPool)
imageLocation := model.ImageLocations{}
_, err := insertImageLocationStmt.ExecContext(ctx, m.dbPool)
return err
return imageLocation, err
}
func NewLocationModel(db *sql.DB) LocationModel {