Compare commits
2 Commits
master
...
cursor_loc
Author | SHA1 | Date | |
---|---|---|---|
28d8774280 | |||
3bd611a8a2 |
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.vscode/settings.json
vendored
Normal file → Executable file
0
.vscode/settings.json
vendored
Normal file → Executable file
20
api/BaseResponse.go
Normal file → Executable file
20
api/BaseResponse.go
Normal file → Executable file
@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
@ -48,6 +49,25 @@ func ValidationErrorResponse(err error) gin.H {
|
||||
}
|
||||
}
|
||||
|
||||
func ValidationErrorResponseV2(err error, s interface{}, tagName string) gin.H {
|
||||
var ves validator.ValidationErrors
|
||||
var temp []APIValidationError
|
||||
if errors.As(err, &ves) {
|
||||
out := make([]APIValidationError, len(ves))
|
||||
for i, ve := range ves {
|
||||
fieldName := ve.Field()
|
||||
field, _ := reflect.TypeOf(s).FieldByName(fieldName)
|
||||
tag := field.Tag.Get(tagName)
|
||||
out[i] = APIValidationError{tag, validationErrorMsg(tag, ve.Param(), ve.ActualTag(), ve.Type().Name())}
|
||||
}
|
||||
temp = out
|
||||
}
|
||||
return gin.H{
|
||||
"message": "Validation error",
|
||||
"errors": temp,
|
||||
}
|
||||
}
|
||||
|
||||
func ErrorResponse(err error, msg string) gin.H {
|
||||
return gin.H{
|
||||
"error": err.Error(),
|
||||
|
0
api/api.go
Normal file → Executable file
0
api/api.go
Normal file → Executable file
0
api/image.go
Normal file → Executable file
0
api/image.go
Normal file → Executable file
0
api/location.go
Normal file → Executable file
0
api/location.go
Normal file → Executable file
0
api/middleware.go
Normal file → Executable file
0
api/middleware.go
Normal file → Executable file
0
api/news_event.go
Normal file → Executable file
0
api/news_event.go
Normal file → Executable file
0
api/region.go
Normal file → Executable file
0
api/region.go
Normal file → Executable file
0
api/reviews.go
Normal file → Executable file
0
api/reviews.go
Normal file → Executable file
0
api/server.go
Normal file → Executable file
0
api/server.go
Normal file → Executable file
0
api/tags.go
Normal file → Executable file
0
api/tags.go
Normal file → Executable file
0
api/test/location_test.go
Normal file → Executable file
0
api/test/location_test.go
Normal file → Executable file
0
api/test/main_test.go
Normal file → Executable file
0
api/test/main_test.go
Normal file → Executable file
0
api/test/user_test.go
Normal file → Executable file
0
api/test/user_test.go
Normal file → Executable file
0
api/token.go
Normal file → Executable file
0
api/token.go
Normal file → Executable file
0
api/user.go
Normal file → Executable file
0
api/user.go
Normal file → Executable file
@ -1 +1 @@
|
||||
1.6.0
|
||||
1.8.0
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
3db8a6fc-efe2-4e2e-a2ca-2de2e6914f2a
|
||||
864514bc-7376-4dbe-83ac-1a1c43681252
|
Binary file not shown.
Binary file not shown.
0
db/csv_seeder/images.csv
Normal file → Executable file
0
db/csv_seeder/images.csv
Normal file → Executable file
0
db/csv_seeder/kabupaten.csv
Normal file → Executable file
0
db/csv_seeder/kabupaten.csv
Normal file → Executable file
0
db/csv_seeder/locations.csv
Normal file → Executable file
0
db/csv_seeder/locations.csv
Normal file → Executable file
0
db/csv_seeder/provinsi.csv
Normal file → Executable file
0
db/csv_seeder/provinsi.csv
Normal file → Executable file
0
db/csv_seeder/regions.csv
Normal file → Executable file
0
db/csv_seeder/regions.csv
Normal file → Executable file
0
db/csv_seeder/reviews.csv
Normal file → Executable file
0
db/csv_seeder/reviews.csv
Normal file → Executable file
0
db/csv_seeder/tags.csv
Normal file → Executable file
0
db/csv_seeder/tags.csv
Normal file → Executable file
0
db/csv_seeder/user.csv
Normal file → Executable file
0
db/csv_seeder/user.csv
Normal file → Executable file
0
db/migrations/000001_init_schema.down.sql
Normal file → Executable file
0
db/migrations/000001_init_schema.down.sql
Normal file → Executable file
0
db/migrations/000001_init_schema.up.sql
Normal file → Executable file
0
db/migrations/000001_init_schema.up.sql
Normal file → Executable file
0
db/migrations/000002_add_approvedby_in_locations_table.down.sql
Normal file → Executable file
0
db/migrations/000002_add_approvedby_in_locations_table.down.sql
Normal file → Executable file
0
db/migrations/000002_add_approvedby_in_locations_table.up.sql
Normal file → Executable file
0
db/migrations/000002_add_approvedby_in_locations_table.up.sql
Normal file → Executable file
0
db/migrations/000003_create_user_activities.down.sql
Normal file → Executable file
0
db/migrations/000003_create_user_activities.down.sql
Normal file → Executable file
0
db/migrations/000003_create_user_activities.up.sql
Normal file → Executable file
0
db/migrations/000003_create_user_activities.up.sql
Normal file → Executable file
0
db/migrations/000004_create_images_table.down.sql
Normal file → Executable file
0
db/migrations/000004_create_images_table.down.sql
Normal file → Executable file
0
db/migrations/000004_create_images_table.up.sql
Normal file → Executable file
0
db/migrations/000004_create_images_table.up.sql
Normal file → Executable file
0
db/migrations/000005_alter_tags_column_approvedby_nullable.down.sql
Normal file → Executable file
0
db/migrations/000005_alter_tags_column_approvedby_nullable.down.sql
Normal file → Executable file
0
db/migrations/000005_alter_tags_column_approvedby_nullable.up.sql
Normal file → Executable file
0
db/migrations/000005_alter_tags_column_approvedby_nullable.up.sql
Normal file → Executable file
0
db/migrations/000006_create_user_sessions_table.down.sql
Normal file → Executable file
0
db/migrations/000006_create_user_sessions_table.down.sql
Normal file → Executable file
0
db/migrations/000006_create_user_sessions_table.up.sql
Normal file → Executable file
0
db/migrations/000006_create_user_sessions_table.up.sql
Normal file → Executable file
0
db/migrations/000007_create_user_follow_table.down.sql
Normal file → Executable file
0
db/migrations/000007_create_user_follow_table.down.sql
Normal file → Executable file
0
db/migrations/000007_create_user_follow_table.up.sql
Normal file → Executable file
0
db/migrations/000007_create_user_follow_table.up.sql
Normal file → Executable file
0
db/migrations/000008_alter_users_add_about_column.down.sql
Normal file → Executable file
0
db/migrations/000008_alter_users_add_about_column.down.sql
Normal file → Executable file
0
db/migrations/000008_alter_users_add_about_column.up.sql
Normal file → Executable file
0
db/migrations/000008_alter_users_add_about_column.up.sql
Normal file → Executable file
0
db/migrations/000009_alter_users_add_website_column.down.sql
Normal file → Executable file
0
db/migrations/000009_alter_users_add_website_column.down.sql
Normal file → Executable file
0
db/migrations/000009_alter_users_add_website_column.up.sql
Normal file → Executable file
0
db/migrations/000009_alter_users_add_website_column.up.sql
Normal file → Executable file
0
db/migrations/000010_create_news_event_table.down.sql
Normal file → Executable file
0
db/migrations/000010_create_news_event_table.down.sql
Normal file → Executable file
0
db/migrations/000010_create_news_event_table.up.sql
Normal file → Executable file
0
db/migrations/000010_create_news_event_table.up.sql
Normal file → Executable file
15
db/mock/store.go
Normal file → Executable file
15
db/mock/store.go
Normal file → Executable file
@ -187,6 +187,21 @@ func (mr *MockStoreMockRecorder) GetCountImageByLocation(arg0, arg1 any) *gomock
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCountImageByLocation", reflect.TypeOf((*MockStore)(nil).GetCountImageByLocation), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetCountLocations mocks base method.
|
||||
func (m *MockStore) GetCountLocations(arg0 context.Context, arg1 db.GetCountLocationsParams) (int32, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetCountLocations", arg0, arg1)
|
||||
ret0, _ := ret[0].(int32)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetCountLocations indicates an expected call of GetCountLocations.
|
||||
func (mr *MockStoreMockRecorder) GetCountLocations(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCountLocations", reflect.TypeOf((*MockStore)(nil).GetCountLocations), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetImagesByLocation mocks base method.
|
||||
func (m *MockStore) GetImagesByLocation(arg0 context.Context, arg1 db.GetImagesByLocationParams) ([]db.GetImagesByLocationRow, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
0
db/queries/follow.sql
Normal file → Executable file
0
db/queries/follow.sql
Normal file → Executable file
0
db/queries/images.sql
Normal file → Executable file
0
db/queries/images.sql
Normal file → Executable file
0
db/queries/locations.sql
Normal file → Executable file
0
db/queries/locations.sql
Normal file → Executable file
0
db/queries/news_events.sql
Normal file → Executable file
0
db/queries/news_events.sql
Normal file → Executable file
0
db/queries/provinces.sql
Normal file → Executable file
0
db/queries/provinces.sql
Normal file → Executable file
0
db/queries/regencies.sql
Normal file → Executable file
0
db/queries/regencies.sql
Normal file → Executable file
0
db/queries/regions.sql
Normal file → Executable file
0
db/queries/regions.sql
Normal file → Executable file
0
db/queries/reviews.sql
Normal file → Executable file
0
db/queries/reviews.sql
Normal file → Executable file
0
db/queries/sessions.sql
Normal file → Executable file
0
db/queries/sessions.sql
Normal file → Executable file
0
db/queries/users.sql
Normal file → Executable file
0
db/queries/users.sql
Normal file → Executable file
2
db/sqlc/db.go
Normal file → Executable file
2
db/sqlc/db.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
|
||||
package db
|
||||
|
||||
|
0
db/sqlc/error.go
Normal file → Executable file
0
db/sqlc/error.go
Normal file → Executable file
2
db/sqlc/follow.sql.go
Normal file → Executable file
2
db/sqlc/follow.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: follow.sql
|
||||
|
||||
package db
|
||||
|
25
db/sqlc/helper.go
Normal file
25
db/sqlc/helper.go
Normal file
@ -0,0 +1,25 @@
|
||||
package db
|
||||
|
||||
import "strings"
|
||||
|
||||
func IsLocationTypeValid(l string) bool {
|
||||
var validLocationTypes = []LocationType{
|
||||
LocationTypeAmusementpark,
|
||||
LocationTypeBeach,
|
||||
LocationTypeCulinary,
|
||||
LocationTypeHikingCamping,
|
||||
LocationTypeOther,
|
||||
}
|
||||
|
||||
lTypes := strings.Split(l, ",")
|
||||
|
||||
for _, v := range validLocationTypes {
|
||||
for _, k := range lTypes {
|
||||
if v != LocationType(k) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
0
db/sqlc/images.go
Normal file → Executable file
0
db/sqlc/images.go
Normal file → Executable file
2
db/sqlc/images.sql.go
Normal file → Executable file
2
db/sqlc/images.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: images.sql
|
||||
|
||||
package db
|
||||
|
40
db/sqlc/locations.go
Normal file → Executable file
40
db/sqlc/locations.go
Normal file → Executable file
@ -111,6 +111,40 @@ func (q *Queries) GetTopListLocations(ctx context.Context, arg GetTopListLocatio
|
||||
return items, nil
|
||||
}
|
||||
|
||||
type GetCountLocationsParams struct {
|
||||
LocationTypes string `json:"location_type"`
|
||||
Regency string `json:"regency"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetCountLocations(ctx context.Context, arg GetCountLocationsParams) (int32, error) {
|
||||
var count int32
|
||||
sqlBuilder := pgq.Select("COUNT(id)").From("locations l")
|
||||
|
||||
if arg.Regency != "" {
|
||||
regencies := strings.Split(arg.Regency, ",")
|
||||
sqlBuilder = sqlBuilder.Where(pgq.Eq{"regency_id": regencies})
|
||||
}
|
||||
|
||||
if arg.LocationTypes != "" {
|
||||
locType := strings.Split(arg.LocationTypes, ",")
|
||||
sqlBuilder = sqlBuilder.Where(pgq.Eq{"l.location_type": locType})
|
||||
}
|
||||
|
||||
query, argx, err := sqlBuilder.SQL()
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
err = q.db.QueryRow(ctx, query, argx...).Scan(&count)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, err
|
||||
|
||||
}
|
||||
|
||||
type GetListRecentLocationsWithRatingsRow struct {
|
||||
ID int32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@ -125,9 +159,10 @@ type GetListRecentLocationsWithRatingsRow struct {
|
||||
}
|
||||
|
||||
type GetListRecentLocationsParams struct {
|
||||
Limit int32 `json:"limit" default:"12"`
|
||||
Limit uint64 `json:"limit" default:"15"`
|
||||
Regions string `json:"regions" default:""`
|
||||
LocationTypes string `json:"location_type" default:""`
|
||||
Offset uint64 `json:"offset" default:"0"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetListRecentLocationsWithRatings(ctx context.Context, arg GetListRecentLocationsParams) ([]GetListRecentLocationsWithRatingsRow, error) {
|
||||
@ -146,7 +181,8 @@ func (q *Queries) GetListRecentLocationsWithRatings(ctx context.Context, arg Get
|
||||
From("locations l").
|
||||
Join("regencies re on re.id = l.regency_id").
|
||||
Join("provinces pr on re.province_id = pr.id").
|
||||
Limit(uint64(arg.Limit))
|
||||
Limit(arg.Limit).
|
||||
Offset(arg.Offset)
|
||||
|
||||
if arg.Regions != "" {
|
||||
region := strings.Split(arg.Regions, ",")
|
||||
|
2
db/sqlc/locations.sql.go
Normal file → Executable file
2
db/sqlc/locations.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: locations.sql
|
||||
|
||||
package db
|
||||
|
2
db/sqlc/models.go
Normal file → Executable file
2
db/sqlc/models.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
|
||||
package db
|
||||
|
||||
|
0
db/sqlc/news_events.go
Normal file → Executable file
0
db/sqlc/news_events.go
Normal file → Executable file
2
db/sqlc/news_events.sql.go
Normal file → Executable file
2
db/sqlc/news_events.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: news_events.sql
|
||||
|
||||
package db
|
||||
|
2
db/sqlc/provinces.sql.go
Normal file → Executable file
2
db/sqlc/provinces.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: provinces.sql
|
||||
|
||||
package db
|
||||
|
2
db/sqlc/querier.go
Normal file → Executable file
2
db/sqlc/querier.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
|
||||
package db
|
||||
|
||||
|
2
db/sqlc/regencies.sql.go
Normal file → Executable file
2
db/sqlc/regencies.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: regencies.sql
|
||||
|
||||
package db
|
||||
|
2
db/sqlc/regions.sql.go
Normal file → Executable file
2
db/sqlc/regions.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: regions.sql
|
||||
|
||||
package db
|
||||
|
0
db/sqlc/reviews.go
Normal file → Executable file
0
db/sqlc/reviews.go
Normal file → Executable file
2
db/sqlc/reviews.sql.go
Normal file → Executable file
2
db/sqlc/reviews.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: reviews.sql
|
||||
|
||||
package db
|
||||
|
2
db/sqlc/sessions.sql.go
Normal file → Executable file
2
db/sqlc/sessions.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: sessions.sql
|
||||
|
||||
package db
|
||||
|
1
db/sqlc/store.go
Normal file → Executable file
1
db/sqlc/store.go
Normal file → Executable file
@ -22,6 +22,7 @@ type Store interface {
|
||||
CreateLocationTx(ctx context.Context, arg CreateLocationTxParams) error
|
||||
GetNewsEventsList(ctx context.Context, arg GetNewsEventsListParams) ([]NewsEventRow, error)
|
||||
GetListRecentLocationsWithRatings(ctx context.Context, arg GetListRecentLocationsParams) ([]GetListRecentLocationsWithRatingsRow, error)
|
||||
GetCountLocations(ctx context.Context, arg GetCountLocationsParams) (int32, error)
|
||||
}
|
||||
|
||||
type SQLStore struct {
|
||||
|
0
db/sqlc/test/locations_test.go
Normal file → Executable file
0
db/sqlc/test/locations_test.go
Normal file → Executable file
0
db/sqlc/test/main_test.go
Normal file → Executable file
0
db/sqlc/test/main_test.go
Normal file → Executable file
0
db/sqlc/test/users_test.go
Normal file → Executable file
0
db/sqlc/test/users_test.go
Normal file → Executable file
0
db/sqlc/tx_location.go
Normal file → Executable file
0
db/sqlc/tx_location.go
Normal file → Executable file
0
db/sqlc/users.go
Normal file → Executable file
0
db/sqlc/users.go
Normal file → Executable file
2
db/sqlc/users.sql.go
Normal file → Executable file
2
db/sqlc/users.sql.go
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.25.0
|
||||
// sqlc v1.26.0
|
||||
// source: users.sql
|
||||
|
||||
package db
|
||||
|
0
dev.env.example
Normal file → Executable file
0
dev.env.example
Normal file → Executable file
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
cp ./db/csv_seeder/* /tmp/
|
||||
|
||||
# SEEDING MAIN DATAABSE
|
||||
sudo -u postgres psql \
|
||||
-c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
||||
-c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
||||
@ -10,6 +12,8 @@ sudo -u postgres psql \
|
||||
-c '\copy images(id,image_url,uploaded_by,image_type,image_of) FROM '"'/tmp/images.csv'"' DELIMITER '"'#'"' CSV HEADER;' \
|
||||
-c '\copy tags(id,name,submitted_by,target_id,tags_type) FROM '"'/tmp/tags.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
||||
-d hiling_dev &&
|
||||
|
||||
# SEEDING TEST DATABASE
|
||||
sudo -u postgres psql \
|
||||
-c '\copy users(id,username,password) FROM '"'/tmp/user.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
||||
-c '\copy regions(id, region_name) FROM '"'/tmp/regions.csv'"' DELIMITER '"','"' CSV HEADER;' \
|
||||
|
0
user_stories
Normal file → Executable file
0
user_stories
Normal file → Executable file
2
util/cloudfare/r2.go
Executable file
2
util/cloudfare/r2.go
Executable file
@ -0,0 +1,2 @@
|
||||
package cloudfare
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user