Dmitriy Gnatenko hai 2 meses
pai
achega
97b1d67a1c
Modificáronse 100 ficheiros con 2065 adicións e 7834 borrados
  1. 18 181
      go.mod
  2. 16 0
      init/systemd/homethings.service
  3. 5 2
      internal/api/v1/auth/check_auth.go
  4. 7 6
      internal/api/v1/auth/check_auth_test.go
  5. 6 0
      internal/api/v1/auth/login.go
  6. 6 8
      internal/api/v1/auth/login_test.go
  7. 43 43
      internal/api/v1/auth/mocks/auth_service_minimock.go
  8. 1 1
      internal/api/v1/auth/mocks/user_repository_minimock.go
  9. 0 8
      internal/api/v1/common.go
  10. 44 48
      internal/api/v1/image/add_image.go
  11. 51 133
      internal/api/v1/image/add_image_test.go
  12. 19 12
      internal/api/v1/image/delete_place_image.go
  13. 46 34
      internal/api/v1/image/delete_place_image_test.go
  14. 19 12
      internal/api/v1/image/delete_thing_image.go
  15. 45 33
      internal/api/v1/image/delete_thing_image_test.go
  16. 8 6
      internal/api/v1/image/get_place_images.go
  17. 18 17
      internal/api/v1/image/get_place_images_test.go
  18. 6 5
      internal/api/v1/image/get_thing_images.go
  19. 14 13
      internal/api/v1/image/get_thing_images_test.go
  20. 1 1
      internal/api/v1/image/mocks/file_repository_minimock.go
  21. 42 730
      internal/api/v1/image/mocks/place_image_repository_minimock.go
  22. 42 730
      internal/api/v1/image/mocks/thing_image_repository_minimock.go
  23. 393 0
      internal/api/v1/image/mocks/transaction_manager_minimock.go
  24. 14 8
      internal/api/v1/notification/add_thing_notification.go
  25. 12 15
      internal/api/v1/notification/add_thing_notification_test.go
  26. 7 2
      internal/api/v1/notification/delete_thing_notification.go
  27. 13 15
      internal/api/v1/notification/delete_thing_notification_test.go
  28. 6 3
      internal/api/v1/notification/get_expired_thing_notifications.go
  29. 9 8
      internal/api/v1/notification/get_expired_thing_notifications_test.go
  30. 7 3
      internal/api/v1/notification/get_thing_notification.go
  31. 12 11
      internal/api/v1/notification/get_thing_notification_test.go
  32. 75 160
      internal/api/v1/notification/mocks/thing_notification_repository_minimock.go
  33. 17 7
      internal/api/v1/notification/update_thing_notification.go
  34. 19 21
      internal/api/v1/notification/update_thing_notification_test.go
  35. 26 20
      internal/api/v1/place/add_place.go
  36. 0 177
      internal/api/v1/place/add_place_test.go
  37. 71 65
      internal/api/v1/place/delete_place.go
  38. 0 1443
      internal/api/v1/place/delete_place_test.go
  39. 7 3
      internal/api/v1/place/get_place.go
  40. 6 3
      internal/api/v1/place/get_place_nested.go
  41. 11 10
      internal/api/v1/place/get_place_nested_test.go
  42. 0 138
      internal/api/v1/place/get_place_test.go
  43. 6 3
      internal/api/v1/place/get_place_tree.go
  44. 10 9
      internal/api/v1/place/get_place_tree_test.go
  45. 6 3
      internal/api/v1/place/get_places.go
  46. 10 9
      internal/api/v1/place/get_places_test.go
  47. 1 1
      internal/api/v1/place/mocks/file_repository_minimock.go
  48. 47 76
      internal/api/v1/place/mocks/place_image_repository_minimock.go
  49. 43 727
      internal/api/v1/place/mocks/place_repository_minimock.go
  50. 24 53
      internal/api/v1/place/mocks/place_thing_repository_minimock.go
  51. 47 76
      internal/api/v1/place/mocks/thing_image_repository_minimock.go
  52. 24 53
      internal/api/v1/place/mocks/thing_notification_repository_minimock.go
  53. 47 76
      internal/api/v1/place/mocks/thing_repository_minimock.go
  54. 24 53
      internal/api/v1/place/mocks/thing_tag_repository_minimock.go
  55. 10 4
      internal/api/v1/place/update_place.go
  56. 18 20
      internal/api/v1/place/update_place_test.go
  57. 9 12
      internal/api/v1/tag/add_tag.go
  58. 43 727
      internal/api/v1/tag/mocks/tag_repository_minimock.go
  59. 24 24
      internal/api/v1/tag/mocks/thing_repository_minimock.go
  60. 52 137
      internal/api/v1/tag/mocks/thing_tag_repository_minimock.go
  61. 15 18
      internal/api/v1/thing/add_thing.go
  62. 1 1
      internal/api/v1/thing/mocks/file_repository_minimock.go
  63. 75 160
      internal/api/v1/thing/mocks/place_thing_repository_minimock.go
  64. 47 76
      internal/api/v1/thing/mocks/thing_image_repository_minimock.go
  65. 24 53
      internal/api/v1/thing/mocks/thing_notification_repository_minimock.go
  66. 45 729
      internal/api/v1/thing/mocks/thing_repository_minimock.go
  67. 47 76
      internal/api/v1/thing/mocks/thing_tag_repository_minimock.go
  68. 6 1
      internal/api/v1/user/add_user.go
  69. 0 161
      internal/api/v1/user/add_user_test.go
  70. 1 1
      internal/api/v1/user/mocks/auth_service_minimock.go
  71. 11 11
      internal/api/v1/user/mocks/user_repository_minimock.go
  72. 6 0
      internal/api/v1/user/update_user.go
  73. 0 234
      internal/api/v1/user/update_user_test.go
  74. 5 5
      internal/dto/image.go
  75. 4 4
      internal/dto/notification.go
  76. 9 9
      internal/dto/place.go
  77. 1 1
      internal/dto/tag.go
  78. 4 4
      internal/dto/thing.go
  79. 1 1
      internal/factory/error.go
  80. 106 47
      internal/fiber/fiber.go
  81. 1 1
      internal/helpers/location/location.go
  82. 1 1
      internal/helpers/random/random.go
  83. 2 7
      internal/helpers/test/convert.go
  84. 8 0
      internal/helpers/test/marshal.go
  85. 3 0
      internal/helpers/test/test.go
  86. 3 3
      internal/mappers/image.go
  87. 5 5
      internal/mappers/place.go
  88. 1 1
      internal/mappers/place_image.go
  89. 3 3
      internal/mappers/tag.go
  90. 4 4
      internal/mappers/thing.go
  91. 1 1
      internal/mappers/thing_image.go
  92. 1 1
      internal/mappers/thing_notification.go
  93. 1 1
      internal/mappers/user.go
  94. 1 1
      internal/models/image.go
  95. 2 2
      internal/models/place.go
  96. 1 1
      internal/models/place_image.go
  97. 2 2
      internal/models/place_thing.go
  98. 2 2
      internal/models/tag.go
  99. 7 7
      internal/models/thing.go
  100. 1 1
      internal/models/thing_image.go

+ 18 - 181
go.mod

@@ -3,11 +3,12 @@ module git.dmitriygnatenko.ru/dima/homethings
 go 1.22.2
 
 require (
+	git.dmitriygnatenko.ru/dima/go-common v1.6.2
 	github.com/Masterminds/squirrel v1.5.3
-	github.com/brianvoe/gofakeit/v6 v6.19.0
+	github.com/brianvoe/gofakeit/v6 v6.28.0
 	github.com/disintegration/imaging v1.6.2
-	github.com/go-playground/validator/v10 v10.11.1
-	github.com/gofiber/fiber/v2 v2.42.0
+	github.com/go-playground/validator/v10 v10.22.0
+	github.com/gofiber/fiber/v2 v2.52.5
 	github.com/gofiber/jwt/v3 v3.3.6
 	github.com/gofiber/swagger v0.1.7
 	github.com/gojuno/minimock/v3 v3.3.13
@@ -16,225 +17,61 @@ require (
 	github.com/spf13/viper v1.19.0
 	github.com/stretchr/testify v1.9.0
 	github.com/swaggo/swag v1.16.3
-	golang.org/x/crypto v0.25.0
+	golang.org/x/crypto v0.26.0
 )
 
 require (
-	4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
-	4d63.com/gochecknoglobals v0.2.1 // indirect
-	github.com/4meepo/tagalign v1.3.4 // indirect
-	github.com/Abirdcfly/dupword v0.0.14 // indirect
-	github.com/Antonboom/errname v0.1.13 // indirect
-	github.com/Antonboom/nilnil v0.1.9 // indirect
-	github.com/Antonboom/testifylint v1.4.3 // indirect
-	github.com/BurntSushi/toml v1.4.0 // indirect
-	github.com/Crocmagnon/fatcontext v0.4.0 // indirect
-	github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
-	github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect
 	github.com/KyleBanks/depth v1.2.1 // indirect
-	github.com/Masterminds/semver/v3 v3.2.1 // indirect
-	github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect
-	github.com/alecthomas/go-check-sumtype v0.1.4 // indirect
-	github.com/alexkohler/nakedret/v2 v2.0.4 // indirect
-	github.com/alexkohler/prealloc v1.0.0 // indirect
-	github.com/alingse/asasalint v0.0.11 // indirect
-	github.com/andybalholm/brotli v1.0.4 // indirect
-	github.com/ashanbrown/forbidigo v1.6.0 // indirect
-	github.com/ashanbrown/makezero v1.1.1 // indirect
-	github.com/beorn7/perks v1.0.1 // indirect
-	github.com/bkielbasa/cyclop v1.2.1 // indirect
-	github.com/blizzy78/varnamelen v0.8.0 // indirect
-	github.com/bombsimon/wsl/v4 v4.4.1 // indirect
-	github.com/breml/bidichk v0.2.7 // indirect
-	github.com/breml/errchkjson v0.3.6 // indirect
-	github.com/butuzov/ireturn v0.3.0 // indirect
-	github.com/butuzov/mirror v1.2.0 // indirect
-	github.com/catenacyber/perfsprint v0.7.1 // indirect
-	github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
-	github.com/cespare/xxhash/v2 v2.3.0 // indirect
-	github.com/charithe/durationcheck v0.0.10 // indirect
-	github.com/chavacava/garif v0.1.0 // indirect
-	github.com/ckaznocha/intrange v0.1.2 // indirect
-	github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
-	github.com/curioswitch/go-reassign v0.2.0 // indirect
-	github.com/daixiang0/gci v0.13.4 // indirect
+	github.com/andybalholm/brotli v1.1.0 // indirect
 	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
-	github.com/denis-tingaikin/go-header v0.5.0 // indirect
-	github.com/ettle/strcase v0.2.0 // indirect
-	github.com/fatih/color v1.17.0 // indirect
-	github.com/fatih/structtag v1.2.0 // indirect
-	github.com/firefart/nonamedreturns v1.0.5 // indirect
 	github.com/fsnotify/fsnotify v1.7.0 // indirect
-	github.com/fzipp/gocyclo v0.6.0 // indirect
-	github.com/ghostiam/protogetter v0.3.6 // indirect
-	github.com/go-critic/go-critic v0.11.4 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.3 // indirect
 	github.com/go-openapi/jsonpointer v0.21.0 // indirect
 	github.com/go-openapi/jsonreference v0.21.0 // indirect
 	github.com/go-openapi/spec v0.21.0 // indirect
 	github.com/go-openapi/swag v0.23.0 // indirect
-	github.com/go-playground/locales v0.14.0 // indirect
-	github.com/go-playground/universal-translator v0.18.0 // indirect
-	github.com/go-toolsmith/astcast v1.1.0 // indirect
-	github.com/go-toolsmith/astcopy v1.1.0 // indirect
-	github.com/go-toolsmith/astequal v1.2.0 // indirect
-	github.com/go-toolsmith/astfmt v1.1.0 // indirect
-	github.com/go-toolsmith/astp v1.1.0 // indirect
-	github.com/go-toolsmith/strparse v1.1.0 // indirect
-	github.com/go-toolsmith/typep v1.1.0 // indirect
-	github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
-	github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
-	github.com/gobwas/glob v0.2.3 // indirect
-	github.com/gofrs/flock v0.12.1 // indirect
-	github.com/golang/protobuf v1.5.4 // indirect
-	github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
-	github.com/golangci/gofmt v0.0.0-20240724082148-399ed8a42d42 // indirect
-	github.com/golangci/golangci-lint v1.59.1 // indirect
-	github.com/golangci/misspell v0.6.0 // indirect
-	github.com/golangci/modinfo v0.3.4 // indirect
-	github.com/golangci/plugin-module-register v0.1.1 // indirect
-	github.com/golangci/revgrep v0.5.3 // indirect
-	github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
-	github.com/google/go-cmp v0.6.0 // indirect
+	github.com/go-playground/locales v0.14.1 // indirect
+	github.com/go-playground/universal-translator v0.18.1 // indirect
 	github.com/google/uuid v1.6.0 // indirect
-	github.com/gordonklaus/ineffassign v0.1.0 // indirect
-	github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
-	github.com/gostaticanalysis/comment v1.4.2 // indirect
-	github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
-	github.com/gostaticanalysis/nilerr v0.1.1 // indirect
-	github.com/hashicorp/go-version v1.7.0 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
-	github.com/hexdigest/gowrap v1.3.10 // indirect
-	github.com/hexops/gotextdiff v1.0.3 // indirect
-	github.com/inconshreveable/mousetrap v1.1.0 // indirect
-	github.com/jgautheron/goconst v1.7.1 // indirect
-	github.com/jingyugao/rowserrcheck v1.1.1 // indirect
-	github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
-	github.com/jjti/go-spancheck v0.6.2 // indirect
+	github.com/jmoiron/sqlx v1.4.0 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
-	github.com/julz/importas v0.1.0 // indirect
-	github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
-	github.com/kisielk/errcheck v1.7.0 // indirect
-	github.com/kkHAIKE/contextcheck v1.1.5 // indirect
 	github.com/klauspost/compress v1.17.9 // indirect
-	github.com/kulti/thelper v0.6.3 // indirect
-	github.com/kunwardeep/paralleltest v1.0.10 // indirect
-	github.com/kyoh86/exportloopref v0.1.11 // indirect
 	github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
 	github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
-	github.com/lasiar/canonicalheader v1.1.1 // indirect
-	github.com/ldez/gomoddirectives v0.2.4 // indirect
-	github.com/ldez/tagliatelle v0.5.0 // indirect
-	github.com/leodido/go-urn v1.2.1 // indirect
-	github.com/leonklingele/grouper v1.1.2 // indirect
-	github.com/lufeee/execinquery v1.2.1 // indirect
-	github.com/macabu/inamedparam v0.1.3 // indirect
+	github.com/leodido/go-urn v1.4.0 // indirect
 	github.com/magiconair/properties v1.8.7 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
-	github.com/maratori/testableexamples v1.0.0 // indirect
-	github.com/maratori/testpackage v1.1.1 // indirect
-	github.com/matoous/godox v0.0.0-20240105082147-c5b5e0e7c0c0 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
 	github.com/mattn/go-isatty v0.0.20 // indirect
 	github.com/mattn/go-runewidth v0.0.16 // indirect
-	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
-	github.com/mgechev/revive v1.3.9 // indirect
-	github.com/mitchellh/go-homedir v1.1.0 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
-	github.com/moricho/tparallel v0.3.2 // indirect
-	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
-	github.com/nakabonne/nestif v0.3.1 // indirect
-	github.com/nishanths/exhaustive v0.12.0 // indirect
-	github.com/nishanths/predeclared v0.2.2 // indirect
-	github.com/nunnatsa/ginkgolinter v0.16.2 // indirect
-	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
-	github.com/philhofer/fwd v1.1.1 // indirect
-	github.com/pkg/errors v0.9.1 // indirect
+	github.com/philhofer/fwd v1.1.2 // indirect
 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
-	github.com/polyfloyd/go-errorlint v1.5.2 // indirect
-	github.com/prometheus/client_golang v1.19.1 // indirect
-	github.com/prometheus/client_model v0.6.1 // indirect
-	github.com/prometheus/common v0.55.0 // indirect
-	github.com/prometheus/procfs v0.15.1 // indirect
-	github.com/quasilyte/go-ruleguard v0.4.2 // indirect
-	github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
-	github.com/quasilyte/gogrep v0.5.0 // indirect
-	github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
-	github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
 	github.com/rivo/uniseg v0.4.7 // indirect
 	github.com/rogpeppe/go-internal v1.12.0 // indirect
-	github.com/russross/blackfriday/v2 v2.1.0 // indirect
-	github.com/ryancurrah/gomodguard v1.3.3 // indirect
-	github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
 	github.com/sagikazarmark/locafero v0.6.0 // indirect
 	github.com/sagikazarmark/slog-shim v0.1.0 // indirect
-	github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect
-	github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
-	github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
-	github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect
 	github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
 	github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect
-	github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9 // indirect
-	github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
-	github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
-	github.com/sirupsen/logrus v1.9.3 // indirect
-	github.com/sivchari/containedctx v1.0.3 // indirect
-	github.com/sivchari/tenv v1.10.0 // indirect
-	github.com/sonatard/noctx v0.0.2 // indirect
 	github.com/sourcegraph/conc v0.3.0 // indirect
-	github.com/sourcegraph/go-diff v0.7.0 // indirect
 	github.com/spf13/afero v1.11.0 // indirect
 	github.com/spf13/cast v1.6.0 // indirect
-	github.com/spf13/cobra v1.8.1 // indirect
-	github.com/spf13/jwalterweatherman v1.1.0 // indirect
 	github.com/spf13/pflag v1.0.5 // indirect
-	github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
-	github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
-	github.com/stretchr/objx v0.5.2 // indirect
 	github.com/subosito/gotenv v1.6.0 // indirect
 	github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a // indirect
-	github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
-	github.com/tdakkota/asciicheck v0.2.0 // indirect
-	github.com/tetafro/godot v1.4.16 // indirect
-	github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a // indirect
-	github.com/timonwong/loggercheck v0.9.4 // indirect
-	github.com/tinylib/msgp v1.1.6 // indirect
-	github.com/tomarrell/wrapcheck/v2 v2.8.3 // indirect
-	github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
-	github.com/ultraware/funlen v0.1.0 // indirect
-	github.com/ultraware/whitespace v0.1.1 // indirect
-	github.com/urfave/cli/v2 v2.27.3 // indirect
-	github.com/uudashr/gocognit v1.1.3 // indirect
+	github.com/tinylib/msgp v1.1.8 // indirect
 	github.com/valyala/bytebufferpool v1.0.0 // indirect
-	github.com/valyala/fasthttp v1.44.0 // indirect
+	github.com/valyala/fasthttp v1.55.0 // indirect
 	github.com/valyala/tcplisten v1.0.0 // indirect
-	github.com/xen0n/gosmopolitan v1.2.2 // indirect
-	github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
-	github.com/yagipy/maintidx v1.0.0 // indirect
-	github.com/yeya24/promlinter v0.3.0 // indirect
-	github.com/ykadowak/zerologlint v0.1.5 // indirect
-	gitlab.com/bosi/decorder v0.4.2 // indirect
-	go-simpler.org/musttag v0.12.2 // indirect
-	go-simpler.org/sloglint v0.7.2 // indirect
-	go.uber.org/atomic v1.11.0 // indirect
-	go.uber.org/automaxprocs v1.5.3 // indirect
 	go.uber.org/multierr v1.11.0 // indirect
-	go.uber.org/zap v1.27.0 // indirect
 	golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
-	golang.org/x/exp/typeparams v0.0.0-20240719175910-8a7402abbf56 // indirect
 	golang.org/x/image v0.11.0 // indirect
-	golang.org/x/mod v0.19.0 // indirect
-	golang.org/x/net v0.27.0 // indirect
-	golang.org/x/sync v0.7.0 // indirect
-	golang.org/x/sys v0.22.0 // indirect
-	golang.org/x/text v0.16.0 // indirect
-	golang.org/x/tools v0.23.0 // indirect
-	google.golang.org/protobuf v1.34.2 // indirect
+	golang.org/x/net v0.28.0 // indirect
+	golang.org/x/sys v0.24.0 // indirect
+	golang.org/x/text v0.17.0 // indirect
+	golang.org/x/tools v0.24.0 // indirect
 	gopkg.in/ini.v1 v1.67.0 // indirect
-	gopkg.in/yaml.v2 v2.4.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
-	honnef.co/go/tools v0.4.7 // indirect
-	mvdan.cc/gofumpt v0.6.0 // indirect
-	mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
-	sigs.k8s.io/yaml v1.4.0 // indirect
 )

+ 16 - 0
init/systemd/homethings.service

@@ -0,0 +1,16 @@
+[Unit]
+Description=Homethings service
+After=network.target
+After=nginx.service
+After=postgresql.service
+
+[Service]
+Type=simple
+User=dima
+Group=dima
+ExecStart=/var/www/homethings.ru/build/app/app -config="/var/www/homethings.ru/.env"
+WorkingDirectory=/var/www/homethings.ru/build/app
+Restart=always
+
+[Install]
+WantedBy=multi-user.target

+ 5 - 2
internal/api/v1/auth/check_auth.go

@@ -9,6 +9,7 @@ import (
 	"database/sql"
 	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 	"github.com/golang-jwt/jwt/v4"
 
@@ -18,9 +19,9 @@ import (
 
 type (
 	AuthService interface {
-		GetClaims(fctx *fiber.Ctx) jwt.MapClaims
+		GetClaims(*fiber.Ctx) jwt.MapClaims
 		IsCorrectPassword(password string, hash string) bool
-		GenerateToken(user models.User) (string, error)
+		GenerateToken(models.User) (string, error)
 	}
 
 	UserRepository interface {
@@ -47,9 +48,11 @@ func CheckAuthHandler(
 		user, err := userRepository.Get(ctx, claims["name"].(string))
 		if err != nil {
 			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusForbidden, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 7 - 6
internal/api/v1/auth/check_auth_test.go

@@ -3,7 +3,6 @@ package auth
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"testing"
 
@@ -13,10 +12,9 @@ import (
 	"github.com/golang-jwt/jwt/v4"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/auth/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -31,7 +29,7 @@ func TestCheckAuthHandler(t *testing.T) {
 
 	var (
 		username  = gofakeit.Username()
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 
 		correctReq = req{
 			method:      fiber.MethodGet,
@@ -126,10 +124,13 @@ func TestCheckAuthHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/auth/check", CheckAuthHandler(tt.authServiceMock(mc), tt.userRepoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 6 - 0
internal/api/v1/auth/login.go

@@ -4,6 +4,7 @@ import (
 	"database/sql"
 	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 
@@ -30,20 +31,24 @@ func LoginHandler(
 		ctx := fctx.Context()
 		req := dto.LoginRequest{}
 		if err := fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err := validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
 		user, err := userRepository.Get(ctx, req.Username)
 		if err != nil {
 			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusForbidden, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
@@ -53,6 +58,7 @@ func LoginHandler(
 
 		token, err := authService.GenerateToken(*user)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 6 - 8
internal/api/v1/auth/login_test.go

@@ -3,7 +3,6 @@ package auth
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"testing"
 
@@ -12,10 +11,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/auth/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -30,12 +28,12 @@ func TestLoginHandler(t *testing.T) {
 	}
 
 	var (
-		id           = gofakeit.Number(1, 1000)
+		id           = gofakeit.Uint64()
 		username     = gofakeit.Username()
 		password     = gofakeit.Word()
 		passwordHash = gofakeit.Word()
 		token        = gofakeit.Word()
-		testError    = errors.New(gofakeit.Phrase())
+		testError    = gofakeit.Error()
 
 		correctReq = req{
 			method: fiber.MethodPost,
@@ -203,13 +201,13 @@ func TestLoginHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Post("/v1/auth/login", LoginHandler(tt.authServiceMock(mc), tt.userRepoMock(mc)))
 
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
+			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, test.ConvertDataToIOReader(tt.req.body))
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 43 - 43
internal/api/v1/auth/mocks/auth_service_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -20,14 +20,14 @@ type AuthServiceMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcGenerateToken          func(user models.User) (s1 string, err error)
-	inspectFuncGenerateToken   func(user models.User)
+	funcGenerateToken          func(u1 models.User) (s1 string, err error)
+	inspectFuncGenerateToken   func(u1 models.User)
 	afterGenerateTokenCounter  uint64
 	beforeGenerateTokenCounter uint64
 	GenerateTokenMock          mAuthServiceMockGenerateToken
 
-	funcGetClaims          func(fctx *fiber.Ctx) (m1 jwt.MapClaims)
-	inspectFuncGetClaims   func(fctx *fiber.Ctx)
+	funcGetClaims          func(cp1 *fiber.Ctx) (m1 jwt.MapClaims)
+	inspectFuncGetClaims   func(cp1 *fiber.Ctx)
 	afterGetClaimsCounter  uint64
 	beforeGetClaimsCounter uint64
 	GetClaimsMock          mAuthServiceMockGetClaims
@@ -84,12 +84,12 @@ type AuthServiceMockGenerateTokenExpectation struct {
 
 // AuthServiceMockGenerateTokenParams contains parameters of the AuthService.GenerateToken
 type AuthServiceMockGenerateTokenParams struct {
-	user models.User
+	u1 models.User
 }
 
 // AuthServiceMockGenerateTokenParamPtrs contains pointers to parameters of the AuthService.GenerateToken
 type AuthServiceMockGenerateTokenParamPtrs struct {
-	user *models.User
+	u1 *models.User
 }
 
 // AuthServiceMockGenerateTokenResults contains results of the AuthService.GenerateToken
@@ -109,7 +109,7 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) Optional() *mAuthServiceMo
 }
 
 // Expect sets up expected params for AuthService.GenerateToken
-func (mmGenerateToken *mAuthServiceMockGenerateToken) Expect(user models.User) *mAuthServiceMockGenerateToken {
+func (mmGenerateToken *mAuthServiceMockGenerateToken) Expect(u1 models.User) *mAuthServiceMockGenerateToken {
 	if mmGenerateToken.mock.funcGenerateToken != nil {
 		mmGenerateToken.mock.t.Fatalf("AuthServiceMock.GenerateToken mock is already set by Set")
 	}
@@ -122,7 +122,7 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) Expect(user models.User) *
 		mmGenerateToken.mock.t.Fatalf("AuthServiceMock.GenerateToken mock is already set by ExpectParams functions")
 	}
 
-	mmGenerateToken.defaultExpectation.params = &AuthServiceMockGenerateTokenParams{user}
+	mmGenerateToken.defaultExpectation.params = &AuthServiceMockGenerateTokenParams{u1}
 	for _, e := range mmGenerateToken.expectations {
 		if minimock.Equal(e.params, mmGenerateToken.defaultExpectation.params) {
 			mmGenerateToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGenerateToken.defaultExpectation.params)
@@ -132,8 +132,8 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) Expect(user models.User) *
 	return mmGenerateToken
 }
 
-// ExpectUserParam1 sets up expected param user for AuthService.GenerateToken
-func (mmGenerateToken *mAuthServiceMockGenerateToken) ExpectUserParam1(user models.User) *mAuthServiceMockGenerateToken {
+// ExpectU1Param1 sets up expected param u1 for AuthService.GenerateToken
+func (mmGenerateToken *mAuthServiceMockGenerateToken) ExpectU1Param1(u1 models.User) *mAuthServiceMockGenerateToken {
 	if mmGenerateToken.mock.funcGenerateToken != nil {
 		mmGenerateToken.mock.t.Fatalf("AuthServiceMock.GenerateToken mock is already set by Set")
 	}
@@ -149,13 +149,13 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) ExpectUserParam1(user mode
 	if mmGenerateToken.defaultExpectation.paramPtrs == nil {
 		mmGenerateToken.defaultExpectation.paramPtrs = &AuthServiceMockGenerateTokenParamPtrs{}
 	}
-	mmGenerateToken.defaultExpectation.paramPtrs.user = &user
+	mmGenerateToken.defaultExpectation.paramPtrs.u1 = &u1
 
 	return mmGenerateToken
 }
 
 // Inspect accepts an inspector function that has same arguments as the AuthService.GenerateToken
-func (mmGenerateToken *mAuthServiceMockGenerateToken) Inspect(f func(user models.User)) *mAuthServiceMockGenerateToken {
+func (mmGenerateToken *mAuthServiceMockGenerateToken) Inspect(f func(u1 models.User)) *mAuthServiceMockGenerateToken {
 	if mmGenerateToken.mock.inspectFuncGenerateToken != nil {
 		mmGenerateToken.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.GenerateToken")
 	}
@@ -179,7 +179,7 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) Return(s1 string, err erro
 }
 
 // Set uses given function f to mock the AuthService.GenerateToken method
-func (mmGenerateToken *mAuthServiceMockGenerateToken) Set(f func(user models.User) (s1 string, err error)) *AuthServiceMock {
+func (mmGenerateToken *mAuthServiceMockGenerateToken) Set(f func(u1 models.User) (s1 string, err error)) *AuthServiceMock {
 	if mmGenerateToken.defaultExpectation != nil {
 		mmGenerateToken.mock.t.Fatalf("Default expectation is already set for the AuthService.GenerateToken method")
 	}
@@ -194,14 +194,14 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) Set(f func(user models.Use
 
 // When sets expectation for the AuthService.GenerateToken which will trigger the result defined by the following
 // Then helper
-func (mmGenerateToken *mAuthServiceMockGenerateToken) When(user models.User) *AuthServiceMockGenerateTokenExpectation {
+func (mmGenerateToken *mAuthServiceMockGenerateToken) When(u1 models.User) *AuthServiceMockGenerateTokenExpectation {
 	if mmGenerateToken.mock.funcGenerateToken != nil {
 		mmGenerateToken.mock.t.Fatalf("AuthServiceMock.GenerateToken mock is already set by Set")
 	}
 
 	expectation := &AuthServiceMockGenerateTokenExpectation{
 		mock:   mmGenerateToken.mock,
-		params: &AuthServiceMockGenerateTokenParams{user},
+		params: &AuthServiceMockGenerateTokenParams{u1},
 	}
 	mmGenerateToken.expectations = append(mmGenerateToken.expectations, expectation)
 	return expectation
@@ -234,15 +234,15 @@ func (mmGenerateToken *mAuthServiceMockGenerateToken) invocationsDone() bool {
 }
 
 // GenerateToken implements auth.AuthService
-func (mmGenerateToken *AuthServiceMock) GenerateToken(user models.User) (s1 string, err error) {
+func (mmGenerateToken *AuthServiceMock) GenerateToken(u1 models.User) (s1 string, err error) {
 	mm_atomic.AddUint64(&mmGenerateToken.beforeGenerateTokenCounter, 1)
 	defer mm_atomic.AddUint64(&mmGenerateToken.afterGenerateTokenCounter, 1)
 
 	if mmGenerateToken.inspectFuncGenerateToken != nil {
-		mmGenerateToken.inspectFuncGenerateToken(user)
+		mmGenerateToken.inspectFuncGenerateToken(u1)
 	}
 
-	mm_params := AuthServiceMockGenerateTokenParams{user}
+	mm_params := AuthServiceMockGenerateTokenParams{u1}
 
 	// Record call args
 	mmGenerateToken.GenerateTokenMock.mutex.Lock()
@@ -261,12 +261,12 @@ func (mmGenerateToken *AuthServiceMock) GenerateToken(user models.User) (s1 stri
 		mm_want := mmGenerateToken.GenerateTokenMock.defaultExpectation.params
 		mm_want_ptrs := mmGenerateToken.GenerateTokenMock.defaultExpectation.paramPtrs
 
-		mm_got := AuthServiceMockGenerateTokenParams{user}
+		mm_got := AuthServiceMockGenerateTokenParams{u1}
 
 		if mm_want_ptrs != nil {
 
-			if mm_want_ptrs.user != nil && !minimock.Equal(*mm_want_ptrs.user, mm_got.user) {
-				mmGenerateToken.t.Errorf("AuthServiceMock.GenerateToken got unexpected parameter user, want: %#v, got: %#v%s\n", *mm_want_ptrs.user, mm_got.user, minimock.Diff(*mm_want_ptrs.user, mm_got.user))
+			if mm_want_ptrs.u1 != nil && !minimock.Equal(*mm_want_ptrs.u1, mm_got.u1) {
+				mmGenerateToken.t.Errorf("AuthServiceMock.GenerateToken got unexpected parameter u1, want: %#v, got: %#v%s\n", *mm_want_ptrs.u1, mm_got.u1, minimock.Diff(*mm_want_ptrs.u1, mm_got.u1))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -280,9 +280,9 @@ func (mmGenerateToken *AuthServiceMock) GenerateToken(user models.User) (s1 stri
 		return (*mm_results).s1, (*mm_results).err
 	}
 	if mmGenerateToken.funcGenerateToken != nil {
-		return mmGenerateToken.funcGenerateToken(user)
+		return mmGenerateToken.funcGenerateToken(u1)
 	}
-	mmGenerateToken.t.Fatalf("Unexpected call to AuthServiceMock.GenerateToken. %v", user)
+	mmGenerateToken.t.Fatalf("Unexpected call to AuthServiceMock.GenerateToken. %v", u1)
 	return
 }
 
@@ -377,12 +377,12 @@ type AuthServiceMockGetClaimsExpectation struct {
 
 // AuthServiceMockGetClaimsParams contains parameters of the AuthService.GetClaims
 type AuthServiceMockGetClaimsParams struct {
-	fctx *fiber.Ctx
+	cp1 *fiber.Ctx
 }
 
 // AuthServiceMockGetClaimsParamPtrs contains pointers to parameters of the AuthService.GetClaims
 type AuthServiceMockGetClaimsParamPtrs struct {
-	fctx **fiber.Ctx
+	cp1 **fiber.Ctx
 }
 
 // AuthServiceMockGetClaimsResults contains results of the AuthService.GetClaims
@@ -401,7 +401,7 @@ func (mmGetClaims *mAuthServiceMockGetClaims) Optional() *mAuthServiceMockGetCla
 }
 
 // Expect sets up expected params for AuthService.GetClaims
-func (mmGetClaims *mAuthServiceMockGetClaims) Expect(fctx *fiber.Ctx) *mAuthServiceMockGetClaims {
+func (mmGetClaims *mAuthServiceMockGetClaims) Expect(cp1 *fiber.Ctx) *mAuthServiceMockGetClaims {
 	if mmGetClaims.mock.funcGetClaims != nil {
 		mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
 	}
@@ -414,7 +414,7 @@ func (mmGetClaims *mAuthServiceMockGetClaims) Expect(fctx *fiber.Ctx) *mAuthServ
 		mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by ExpectParams functions")
 	}
 
-	mmGetClaims.defaultExpectation.params = &AuthServiceMockGetClaimsParams{fctx}
+	mmGetClaims.defaultExpectation.params = &AuthServiceMockGetClaimsParams{cp1}
 	for _, e := range mmGetClaims.expectations {
 		if minimock.Equal(e.params, mmGetClaims.defaultExpectation.params) {
 			mmGetClaims.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetClaims.defaultExpectation.params)
@@ -424,8 +424,8 @@ func (mmGetClaims *mAuthServiceMockGetClaims) Expect(fctx *fiber.Ctx) *mAuthServ
 	return mmGetClaims
 }
 
-// ExpectFctxParam1 sets up expected param fctx for AuthService.GetClaims
-func (mmGetClaims *mAuthServiceMockGetClaims) ExpectFctxParam1(fctx *fiber.Ctx) *mAuthServiceMockGetClaims {
+// ExpectCp1Param1 sets up expected param cp1 for AuthService.GetClaims
+func (mmGetClaims *mAuthServiceMockGetClaims) ExpectCp1Param1(cp1 *fiber.Ctx) *mAuthServiceMockGetClaims {
 	if mmGetClaims.mock.funcGetClaims != nil {
 		mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
 	}
@@ -441,13 +441,13 @@ func (mmGetClaims *mAuthServiceMockGetClaims) ExpectFctxParam1(fctx *fiber.Ctx)
 	if mmGetClaims.defaultExpectation.paramPtrs == nil {
 		mmGetClaims.defaultExpectation.paramPtrs = &AuthServiceMockGetClaimsParamPtrs{}
 	}
-	mmGetClaims.defaultExpectation.paramPtrs.fctx = &fctx
+	mmGetClaims.defaultExpectation.paramPtrs.cp1 = &cp1
 
 	return mmGetClaims
 }
 
 // Inspect accepts an inspector function that has same arguments as the AuthService.GetClaims
-func (mmGetClaims *mAuthServiceMockGetClaims) Inspect(f func(fctx *fiber.Ctx)) *mAuthServiceMockGetClaims {
+func (mmGetClaims *mAuthServiceMockGetClaims) Inspect(f func(cp1 *fiber.Ctx)) *mAuthServiceMockGetClaims {
 	if mmGetClaims.mock.inspectFuncGetClaims != nil {
 		mmGetClaims.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.GetClaims")
 	}
@@ -471,7 +471,7 @@ func (mmGetClaims *mAuthServiceMockGetClaims) Return(m1 jwt.MapClaims) *AuthServ
 }
 
 // Set uses given function f to mock the AuthService.GetClaims method
-func (mmGetClaims *mAuthServiceMockGetClaims) Set(f func(fctx *fiber.Ctx) (m1 jwt.MapClaims)) *AuthServiceMock {
+func (mmGetClaims *mAuthServiceMockGetClaims) Set(f func(cp1 *fiber.Ctx) (m1 jwt.MapClaims)) *AuthServiceMock {
 	if mmGetClaims.defaultExpectation != nil {
 		mmGetClaims.mock.t.Fatalf("Default expectation is already set for the AuthService.GetClaims method")
 	}
@@ -486,14 +486,14 @@ func (mmGetClaims *mAuthServiceMockGetClaims) Set(f func(fctx *fiber.Ctx) (m1 jw
 
 // When sets expectation for the AuthService.GetClaims which will trigger the result defined by the following
 // Then helper
-func (mmGetClaims *mAuthServiceMockGetClaims) When(fctx *fiber.Ctx) *AuthServiceMockGetClaimsExpectation {
+func (mmGetClaims *mAuthServiceMockGetClaims) When(cp1 *fiber.Ctx) *AuthServiceMockGetClaimsExpectation {
 	if mmGetClaims.mock.funcGetClaims != nil {
 		mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
 	}
 
 	expectation := &AuthServiceMockGetClaimsExpectation{
 		mock:   mmGetClaims.mock,
-		params: &AuthServiceMockGetClaimsParams{fctx},
+		params: &AuthServiceMockGetClaimsParams{cp1},
 	}
 	mmGetClaims.expectations = append(mmGetClaims.expectations, expectation)
 	return expectation
@@ -526,15 +526,15 @@ func (mmGetClaims *mAuthServiceMockGetClaims) invocationsDone() bool {
 }
 
 // GetClaims implements auth.AuthService
-func (mmGetClaims *AuthServiceMock) GetClaims(fctx *fiber.Ctx) (m1 jwt.MapClaims) {
+func (mmGetClaims *AuthServiceMock) GetClaims(cp1 *fiber.Ctx) (m1 jwt.MapClaims) {
 	mm_atomic.AddUint64(&mmGetClaims.beforeGetClaimsCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetClaims.afterGetClaimsCounter, 1)
 
 	if mmGetClaims.inspectFuncGetClaims != nil {
-		mmGetClaims.inspectFuncGetClaims(fctx)
+		mmGetClaims.inspectFuncGetClaims(cp1)
 	}
 
-	mm_params := AuthServiceMockGetClaimsParams{fctx}
+	mm_params := AuthServiceMockGetClaimsParams{cp1}
 
 	// Record call args
 	mmGetClaims.GetClaimsMock.mutex.Lock()
@@ -553,12 +553,12 @@ func (mmGetClaims *AuthServiceMock) GetClaims(fctx *fiber.Ctx) (m1 jwt.MapClaims
 		mm_want := mmGetClaims.GetClaimsMock.defaultExpectation.params
 		mm_want_ptrs := mmGetClaims.GetClaimsMock.defaultExpectation.paramPtrs
 
-		mm_got := AuthServiceMockGetClaimsParams{fctx}
+		mm_got := AuthServiceMockGetClaimsParams{cp1}
 
 		if mm_want_ptrs != nil {
 
-			if mm_want_ptrs.fctx != nil && !minimock.Equal(*mm_want_ptrs.fctx, mm_got.fctx) {
-				mmGetClaims.t.Errorf("AuthServiceMock.GetClaims got unexpected parameter fctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.fctx, mm_got.fctx, minimock.Diff(*mm_want_ptrs.fctx, mm_got.fctx))
+			if mm_want_ptrs.cp1 != nil && !minimock.Equal(*mm_want_ptrs.cp1, mm_got.cp1) {
+				mmGetClaims.t.Errorf("AuthServiceMock.GetClaims got unexpected parameter cp1, want: %#v, got: %#v%s\n", *mm_want_ptrs.cp1, mm_got.cp1, minimock.Diff(*mm_want_ptrs.cp1, mm_got.cp1))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -572,9 +572,9 @@ func (mmGetClaims *AuthServiceMock) GetClaims(fctx *fiber.Ctx) (m1 jwt.MapClaims
 		return (*mm_results).m1
 	}
 	if mmGetClaims.funcGetClaims != nil {
-		return mmGetClaims.funcGetClaims(fctx)
+		return mmGetClaims.funcGetClaims(cp1)
 	}
-	mmGetClaims.t.Fatalf("Unexpected call to AuthServiceMock.GetClaims. %v", fctx)
+	mmGetClaims.t.Fatalf("Unexpected call to AuthServiceMock.GetClaims. %v", cp1)
 	return
 }
 

+ 1 - 1
internal/api/v1/auth/mocks/user_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 

+ 0 - 8
internal/api/v1/common.go

@@ -1,8 +0,0 @@
-package v1
-
-import "database/sql"
-
-const (
-	DefaultTxLevel     = sql.LevelReadCommitted
-	DefaultTestTimeOut = -1
-)

+ 44 - 48
internal/api/v1/image/add_image.go

@@ -2,21 +2,20 @@ package image
 
 //go:generate mkdir -p mocks
 //go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i FileRepository,ThingImageRepository,PlaceImageRepository -o ./mocks/ -s "_minimock.go"
+//go:generate minimock -i TransactionManager,FileRepository,ThingImageRepository,PlaceImageRepository -o ./mocks/ -s "_minimock.go"
 
 import (
 	"context"
-	"database/sql"
 	"mime/multipart"
 	"path/filepath"
 	"strconv"
 	"time"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/random"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
@@ -24,28 +23,28 @@ import (
 const fileDateLayout = "2006-01-02-15-04-05"
 
 type (
+	TransactionManager interface {
+		ReadCommitted(context.Context, func(ctx context.Context) error) error
+	}
+
 	FileRepository interface {
 		Save(fctx *fiber.Ctx, header *multipart.FileHeader, path string) error
 		Delete(path string) error
 	}
 
 	ThingImageRepository interface {
-		Add(ctx context.Context, req models.AddThingImageRequest, tx *sql.Tx) error
-		Get(ctx context.Context, imageID int) (*models.Image, error)
-		GetByThingID(ctx context.Context, thingID int) ([]models.Image, error)
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.Image, error)
-		Delete(ctx context.Context, imageID int, tx *sql.Tx) error
-		BeginTx(ctx context.Context, level sql.IsolationLevel) (*sql.Tx, error)
-		CommitTx(tx *sql.Tx) error
+		Add(ctx context.Context, req models.AddThingImageRequest) error
+		Get(ctx context.Context, id uint64) (*models.Image, error)
+		GetByThingID(ctx context.Context, id uint64) ([]models.Image, error)
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.Image, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	PlaceImageRepository interface {
-		Add(ctx context.Context, req models.AddPlaceImageRequest, tx *sql.Tx) error
-		Get(ctx context.Context, imageID int) (*models.Image, error)
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.Image, error)
-		Delete(ctx context.Context, imageID int, tx *sql.Tx) error
-		BeginTx(ctx context.Context, level sql.IsolationLevel) (*sql.Tx, error)
-		CommitTx(tx *sql.Tx) error
+		Add(ctx context.Context, req models.AddPlaceImageRequest) error
+		Get(ctx context.Context, id uint64) (*models.Image, error)
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.Image, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 )
 
@@ -62,41 +61,46 @@ type (
 // @Accept      mpfd
 // @Produce     json
 func AddImageHandler(
+	tm TransactionManager,
 	fileRepository FileRepository,
 	thingImageRepository ThingImageRepository,
 	placeImageRepository PlaceImageRepository,
 ) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		var form *multipart.Form
-		var placeID, thingID int
+		var placeID, thingID uint64
 		var files []string
 		var err error
 
 		ctx := fctx.Context()
 
 		if form, err = fctx.MultipartForm(); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		if formPlace := form.Value["place_id"]; len(formPlace) > 0 {
-			placeID, err = strconv.Atoi(formPlace[0])
+			placeID, err = strconv.ParseUint(formPlace[0], 0, 64)
 			if err != nil {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, err.Error())
 			}
 		}
 
 		if formThing := form.Value["thing_id"]; len(formThing) > 0 {
-			thingID, err = strconv.Atoi(formThing[0])
+			thingID, err = strconv.ParseUint(formThing[0], 0, 64)
 			if err != nil {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, err.Error())
 			}
 		}
 
 		date := time.Now().Format(fileDateLayout)
 		for _, file := range form.File["files"] {
-			filename := "/files/" + date + "_" + helpers.GenerateRandomString(10) + filepath.Ext(file.Filename)
+			filename := "/files/" + date + "_" + random.GenerateRandomString(10) + filepath.Ext(file.Filename)
 
 			if err = fileRepository.Save(fctx, file, filename); err != nil {
+				logger.Error(ctx, err.Error())
 				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 			}
 
@@ -107,37 +111,29 @@ func AddImageHandler(
 			return fiber.NewError(fiber.StatusBadRequest, "")
 		}
 
-		var tx *sql.Tx
-		if thingID > 0 {
-			tx, err = thingImageRepository.BeginTx(ctx, API.DefaultTxLevel)
-			if err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
-
-			for _, file := range files {
-				if err = thingImageRepository.Add(ctx, mappers.ToAddThingImageRequest(thingID, file), tx); err != nil {
-					return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+		err = tm.ReadCommitted(ctx, func(ctx context.Context) error {
+			if thingID > 0 {
+				for _, file := range files {
+					txErr := thingImageRepository.Add(ctx, mappers.ToAddThingImageRequest(thingID, file))
+					if txErr != nil {
+						return txErr
+					}
 				}
-			}
-
-			if err = thingImageRepository.CommitTx(tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
-		} else {
-			tx, err = placeImageRepository.BeginTx(ctx, API.DefaultTxLevel)
-			if err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
-
-			for _, file := range files {
-				if err = placeImageRepository.Add(ctx, mappers.ToAddPlaceImageRequest(placeID, file), tx); err != nil {
-					return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+			} else {
+				for _, file := range files {
+					txErr := placeImageRepository.Add(ctx, mappers.ToAddPlaceImageRequest(placeID, file))
+					if txErr != nil {
+						return txErr
+					}
 				}
 			}
 
-			if err = placeImageRepository.CommitTx(tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
+			return nil
+		})
+
+		if err != nil {
+			logger.Error(ctx, err.Error())
+			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
 		return fctx.JSON(factory.CreateEmptyResponse())

+ 51 - 133
internal/api/v1/image/add_image_test.go

@@ -3,8 +3,6 @@ package image
 import (
 	"bytes"
 	"context"
-	"database/sql"
-	"errors"
 	"mime/multipart"
 	"net/http/httptest"
 	"strconv"
@@ -15,10 +13,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -34,15 +31,19 @@ func TestAddImageHandler(t *testing.T) {
 	}
 
 	var (
-		placeID   = gofakeit.Number(1, 1000)
-		thingID   = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
+		placeID   = gofakeit.Uint64()
+		thingID   = gofakeit.Uint64()
+		testError = gofakeit.Error()
+
+		txMockFunc = func(ctx context.Context, f func(ctx context.Context) error) error {
+			return f(ctx)
+		}
 	)
 
 	// Correct request for adding place image
 	addPlaceCorrectBody := &bytes.Buffer{}
 	addPlaceCorrectWriter := multipart.NewWriter(addPlaceCorrectBody)
-	addPlaceCorrectWriter.WriteField("place_id", strconv.Itoa(placeID))
+	addPlaceCorrectWriter.WriteField("place_id", strconv.FormatUint(placeID, 10))
 	addPlaceCorrectWriter.CreateFormFile("files", gofakeit.Word())
 	addPlaceCorrectContentType := addPlaceCorrectWriter.FormDataContentType()
 	addPlaceCorrectWriter.Close()
@@ -50,7 +51,7 @@ func TestAddImageHandler(t *testing.T) {
 	// Correct request for adding thing image
 	addThingCorrectBody := &bytes.Buffer{}
 	addThingCorrectWriter := multipart.NewWriter(addThingCorrectBody)
-	addThingCorrectWriter.WriteField("thing_id", strconv.Itoa(thingID))
+	addThingCorrectWriter.WriteField("thing_id", strconv.FormatUint(thingID, 10))
 	addThingCorrectWriter.CreateFormFile("files", gofakeit.Word())
 	addThingCorrectContentType := addThingCorrectWriter.FormDataContentType()
 	addThingCorrectWriter.Close()
@@ -80,6 +81,7 @@ func TestAddImageHandler(t *testing.T) {
 		req                req
 		resCode            int
 		resBody            interface{}
+		tmMock             func(mc *minimock.Controller) TransactionManager
 		fileRepoMock       func(mc *minimock.Controller) FileRepository
 		placeImageRepoMock func(mc *minimock.Controller) PlaceImageRepository
 		thingImageRepoMock func(mc *minimock.Controller) ThingImageRepository
@@ -91,6 +93,9 @@ func TestAddImageHandler(t *testing.T) {
 				route:  "/v1/images",
 			},
 			resCode: fiber.StatusBadRequest,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
@@ -110,6 +115,9 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: addPlaceIncorrectContentType,
 			},
 			resCode: fiber.StatusBadRequest,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
@@ -129,6 +137,9 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: addThingIncorrectContentType,
 			},
 			resCode: fiber.StatusBadRequest,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
@@ -148,6 +159,9 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: emptyContentType,
 			},
 			resCode: fiber.StatusBadRequest,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
@@ -159,30 +173,7 @@ func TestAddImageHandler(t *testing.T) {
 			},
 		},
 		{
-			name: "negative case - repository error (begin tx)",
-			req: req{
-				method:      fiber.MethodPost,
-				route:       "/v1/images",
-				body:        addPlaceCorrectBody.Bytes(),
-				contentType: addPlaceCorrectContentType,
-			},
-			resCode: fiber.StatusInternalServerError,
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-				mock.BeginTxMock.Return(nil, testError)
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-				mock.SaveMock.Return(nil)
-				return mock
-			},
-		},
-		{
-			name: "negative case - repository error (commit tx)",
+			name: "negative case - repository error (add image)",
 			req: req{
 				method:      fiber.MethodPost,
 				route:       "/v1/images",
@@ -190,43 +181,15 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: addPlaceCorrectContentType,
 			},
 			resCode: fiber.StatusInternalServerError,
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceImageRequest, tx *sql.Tx) {
-					assert.Equal(mc, placeID, req.PlaceID)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(testError)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-				mock.SaveMock.Return(nil)
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
 				return mock
 			},
-		},
-		{
-			name: "negative case - repository error (add image)",
-			req: req{
-				method:      fiber.MethodPost,
-				route:       "/v1/images",
-				body:        addPlaceCorrectBody.Bytes(),
-				contentType: addPlaceCorrectContentType,
-			},
-			resCode: fiber.StatusInternalServerError,
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceImageRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceImageRequest) {
 					assert.Equal(mc, placeID, req.PlaceID)
 				}).Return(testError)
 
@@ -251,17 +214,18 @@ func TestAddImageHandler(t *testing.T) {
 			},
 			resCode: fiber.StatusOK,
 			resBody: dto.EmptyResponse{},
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceImageRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceImageRequest) {
 					assert.Equal(mc, placeID, req.PlaceID)
 				}).Return(nil)
 
-				mock.CommitTxMock.Return(nil)
-
 				return mock
 			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
@@ -274,30 +238,7 @@ func TestAddImageHandler(t *testing.T) {
 			},
 		},
 		{
-			name: "negative case - repository error (begin tx)",
-			req: req{
-				method:      fiber.MethodPost,
-				route:       "/v1/images",
-				body:        addThingCorrectBody.Bytes(),
-				contentType: addThingCorrectContentType,
-			},
-			resCode: fiber.StatusInternalServerError,
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-				mock.BeginTxMock.Return(nil, testError)
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-				mock.SaveMock.Return(nil)
-				return mock
-			},
-		},
-		{
-			name: "negative case - repository error (commit tx)",
+			name: "negative case - repository error (add image)",
 			req: req{
 				method:      fiber.MethodPost,
 				route:       "/v1/images",
@@ -305,46 +246,18 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: addThingCorrectContentType,
 			},
 			resCode: fiber.StatusInternalServerError,
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingImageRequest, tx *sql.Tx) {
-					assert.Equal(mc, thingID, req.ThingID)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(testError)
-
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
 				return mock
 			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-				mock.SaveMock.Return(nil)
-				return mock
-			},
-		},
-		{
-			name: "negative case - repository error (add image)",
-			req: req{
-				method:      fiber.MethodPost,
-				route:       "/v1/images",
-				body:        addThingCorrectBody.Bytes(),
-				contentType: addThingCorrectContentType,
-			},
-			resCode: fiber.StatusInternalServerError,
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingImageRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingImageRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 				}).Return(testError)
 
@@ -366,20 +279,21 @@ func TestAddImageHandler(t *testing.T) {
 			},
 			resCode: fiber.StatusOK,
 			resBody: dto.EmptyResponse{},
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingImageRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingImageRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 				}).Return(nil)
 
-				mock.CommitTxMock.Return(nil)
-
 				return mock
 			},
 			fileRepoMock: func(mc *minimock.Controller) FileRepository {
@@ -397,6 +311,9 @@ func TestAddImageHandler(t *testing.T) {
 				contentType: addThingCorrectContentType,
 			},
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
@@ -419,6 +336,7 @@ func TestAddImageHandler(t *testing.T) {
 			fiberApp := fiber.New()
 
 			fiberApp.Post("/v1/images", AddImageHandler(
+				tt.tmMock(mc),
 				tt.fileRepoMock(mc),
 				tt.thingImageRepoMock(mc),
 				tt.placeImageRepoMock(mc),
@@ -426,11 +344,11 @@ func TestAddImageHandler(t *testing.T) {
 
 			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, bytes.NewReader(tt.req.body))
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 19 - 12
internal/api/v1/image/delete_place_image.go

@@ -1,9 +1,9 @@
 package image
 
 import (
-	"database/sql"
-	"errors"
+	"context"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
@@ -20,6 +20,7 @@ import (
 // @Accept      json
 // @Produce     json
 func DeletePlaceImageHandler(
+	tm TransactionManager,
 	fileRepository FileRepository,
 	placeImageRepository PlaceImageRepository,
 ) fiber.Handler {
@@ -27,23 +28,29 @@ func DeletePlaceImageHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("imageId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		image, err := placeImageRepository.Get(ctx, id)
-		if err != nil {
-			if errors.Is(err, sql.ErrNoRows) {
-				return fiber.NewError(fiber.StatusBadRequest, "")
+		err = tm.ReadCommitted(ctx, func(ctx context.Context) error {
+			image, txErr := placeImageRepository.Get(ctx, uint64(id))
+			if txErr != nil {
+				return txErr
 			}
 
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			if txErr = placeImageRepository.Delete(ctx, uint64(id)); txErr != nil {
+				return txErr
+			}
 
-		if err = placeImageRepository.Delete(ctx, id, nil); err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			if txErr = fileRepository.Delete(image.Image); txErr != nil {
+				return txErr
+			}
 
-		if err = fileRepository.Delete(image.Image); err != nil {
+			return nil
+		})
+
+		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 46 - 34
internal/api/v1/image/delete_place_image_test.go

@@ -2,8 +2,6 @@ package image
 
 import (
 	"context"
-	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -13,10 +11,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -29,13 +26,17 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 	}
 
 	var (
-		imageID   = gofakeit.Number(1, 1000)
+		imageID   = uint64(gofakeit.Number(1, 1000))
 		imageURL  = gofakeit.URL()
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
+
+		txMockFunc = func(ctx context.Context, f func(ctx context.Context) error) error {
+			return f(ctx)
+		}
 
 		correctReq = req{
 			method: fiber.MethodDelete,
-			route:  "/v1/images/place/" + strconv.Itoa(imageID),
+			route:  "/v1/images/place/" + strconv.FormatUint(imageID, 10),
 		}
 
 		repoRes = &models.Image{
@@ -48,6 +49,7 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 		req                req
 		resCode            int
 		resBody            interface{}
+		tmMock             func(mc *minimock.Controller) TransactionManager
 		placeImageRepoMock func(mc *minimock.Controller) PlaceImageRepository
 		fileRepoMock       func(mc *minimock.Controller) FileRepository
 	}{
@@ -58,25 +60,11 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 				route:  "/v1/images/place/" + gofakeit.Word(),
 			},
 			resCode: fiber.StatusBadRequest,
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
 			},
-		},
-		{
-			name:    "negative case - bad request (image not exists)",
-			req:     correctReq,
-			resCode: fiber.StatusBadRequest,
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, imageID, id)
-				}).Return(nil, sql.ErrNoRows)
-
-				return mock
+				return mocks.NewPlaceImageRepositoryMock(mc)
 			},
 			fileRepoMock: func(mc *minimock.Controller) FileRepository {
 				return mocks.NewFileRepositoryMock(mc)
@@ -86,10 +74,15 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 			name:    "negative case - repository error (get)",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil, testError)
 
@@ -100,17 +93,22 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 			},
 		},
 		{
-			name:    "negative case - repository error (update)",
+			name:    "negative case - repository error (delete)",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(testError)
 
@@ -124,14 +122,19 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 			name:    "negative case - file delete error",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil)
 
@@ -148,14 +151,19 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 			req:     correctReq,
 			resCode: fiber.StatusOK,
 			resBody: dto.EmptyResponse{},
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil)
 
@@ -177,15 +185,19 @@ func TestDeletePlaceImageHandler(t *testing.T) {
 			fiberApp := fiber.New()
 
 			fiberApp.Delete("/v1/images/place/:imageId", DeletePlaceImageHandler(
+				tt.tmMock(mc),
 				tt.fileRepoMock(mc),
 				tt.placeImageRepoMock(mc),
 			))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 19 - 12
internal/api/v1/image/delete_thing_image.go

@@ -1,9 +1,9 @@
 package image
 
 import (
-	"database/sql"
-	"errors"
+	"context"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
@@ -20,6 +20,7 @@ import (
 // @Accept      json
 // @Produce     json
 func DeleteThingImageHandler(
+	tm TransactionManager,
 	fileRepository FileRepository,
 	thingImageRepository ThingImageRepository,
 ) fiber.Handler {
@@ -27,23 +28,29 @@ func DeleteThingImageHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("imageId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		image, err := thingImageRepository.Get(ctx, id)
-		if err != nil {
-			if errors.Is(err, sql.ErrNoRows) {
-				return fiber.NewError(fiber.StatusBadRequest, "")
+		err = tm.ReadCommitted(ctx, func(ctx context.Context) error {
+			image, txErr := thingImageRepository.Get(ctx, uint64(id))
+			if txErr != nil {
+				return txErr
 			}
 
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			if txErr = thingImageRepository.Delete(ctx, uint64(id)); txErr != nil {
+				return txErr
+			}
 
-		if err = thingImageRepository.Delete(ctx, id, nil); err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			if txErr = fileRepository.Delete(image.Image); txErr != nil {
+				return txErr
+			}
 
-		if err = fileRepository.Delete(image.Image); err != nil {
+			return nil
+		})
+
+		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 45 - 33
internal/api/v1/image/delete_thing_image_test.go

@@ -2,8 +2,6 @@ package image
 
 import (
 	"context"
-	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -13,10 +11,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -29,13 +26,17 @@ func TestDeleteThingImageHandler(t *testing.T) {
 	}
 
 	var (
-		imageID   = gofakeit.Number(1, 1000)
+		imageID   = uint64(gofakeit.Number(1, 1000))
 		imageURL  = gofakeit.URL()
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
+
+		txMockFunc = func(ctx context.Context, f func(ctx context.Context) error) error {
+			return f(ctx)
+		}
 
 		correctReq = req{
 			method: fiber.MethodDelete,
-			route:  "/v1/images/thing/" + strconv.Itoa(imageID),
+			route:  "/v1/images/thing/" + strconv.FormatUint(imageID, 10),
 		}
 
 		repoRes = &models.Image{
@@ -48,6 +49,7 @@ func TestDeleteThingImageHandler(t *testing.T) {
 		req                req
 		resCode            int
 		resBody            interface{}
+		tmMock             func(mc *minimock.Controller) TransactionManager
 		thingImageRepoMock func(mc *minimock.Controller) ThingImageRepository
 		fileRepoMock       func(mc *minimock.Controller) FileRepository
 	}{
@@ -58,25 +60,11 @@ func TestDeleteThingImageHandler(t *testing.T) {
 				route:  "/v1/images/thing/" + gofakeit.Word(),
 			},
 			resCode: fiber.StatusBadRequest,
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				return mocks.NewTransactionManagerMock(mc)
 			},
-		},
-		{
-			name:    "negative case - bad request (image not exists)",
-			req:     correctReq,
-			resCode: fiber.StatusBadRequest,
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, imageID, id)
-				}).Return(nil, sql.ErrNoRows)
-
-				return mock
+				return mocks.NewThingImageRepositoryMock(mc)
 			},
 			fileRepoMock: func(mc *minimock.Controller) FileRepository {
 				return mocks.NewFileRepositoryMock(mc)
@@ -86,10 +74,15 @@ func TestDeleteThingImageHandler(t *testing.T) {
 			name:    "negative case - repository error (get)",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil, testError)
 
@@ -103,14 +96,19 @@ func TestDeleteThingImageHandler(t *testing.T) {
 			name:    "negative case - repository error (delete)",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(testError)
 
@@ -124,14 +122,19 @@ func TestDeleteThingImageHandler(t *testing.T) {
 			name:    "negative case - file delete error",
 			req:     correctReq,
 			resCode: fiber.StatusInternalServerError,
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil)
 
@@ -148,14 +151,19 @@ func TestDeleteThingImageHandler(t *testing.T) {
 			req:     correctReq,
 			resCode: fiber.StatusOK,
 			resBody: dto.EmptyResponse{},
+			tmMock: func(mc *minimock.Controller) TransactionManager {
+				mock := mocks.NewTransactionManagerMock(mc)
+				mock.ReadCommittedMock.Set(txMockFunc)
+				return mock
+			},
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, imageID, id)
 				}).Return(nil)
 
@@ -177,15 +185,19 @@ func TestDeleteThingImageHandler(t *testing.T) {
 			fiberApp := fiber.New()
 
 			fiberApp.Delete("/v1/images/thing/:imageId", DeleteThingImageHandler(
+				tt.tmMock(mc),
 				tt.fileRepoMock(mc),
 				tt.thingImageRepoMock(mc),
 			))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 8 - 6
internal/api/v1/image/get_place_images.go

@@ -3,9 +3,10 @@ package image
 import (
 	"sort"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
@@ -29,17 +30,20 @@ func GetPlaceImagesHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("placeId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		placesRes, err := placeImageRepository.GetByPlaceID(ctx, id)
+		placesRes, err := placeImageRepository.GetByPlaceID(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 		res = append(res, placesRes...)
 
-		thingsRes, err := thingImageRepository.GetByPlaceID(ctx, id)
+		thingsRes, err := thingImageRepository.GetByPlaceID(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 		res = append(res, thingsRes...)
@@ -48,8 +52,6 @@ func GetPlaceImagesHandler(
 			return res[i].CreatedAt.After(res[j].CreatedAt)
 		})
 
-		res = helpers.ApplyLocation(fctx, res)
-
-		return fctx.JSON(mappers.ToImagesResponse(res))
+		return fctx.JSON(mappers.ToImagesResponse(location.ApplyLocation(fctx, res)))
 	}
 }

+ 18 - 17
internal/api/v1/image/get_place_images_test.go

@@ -3,7 +3,6 @@ package image
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -14,10 +13,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -30,28 +28,28 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 	}
 
 	var (
-		placeID   = gofakeit.Number(1, 1000)
-		thingID   = gofakeit.Number(1, 1000)
+		placeID   = uint64(gofakeit.Number(1, 1000))
+		thingID   = uint64(gofakeit.Number(1, 1000))
 		date1     = gofakeit.Date()
 		date2     = date1.Add(time.Hour)
 		date3     = date2.Add(time.Hour)
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodGet,
-			route:  "/v1/images/place/" + strconv.Itoa(placeID),
+			route:  "/v1/images/place/" + strconv.FormatUint(placeID, 10),
 		}
 
 		placeImageRepoRes = []models.Image{
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				PlaceID:   sql.NullInt64{Valid: true, Int64: int64(placeID)},
 				CreatedAt: date1,
 			},
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				PlaceID:   sql.NullInt64{Valid: true, Int64: int64(placeID)},
 				CreatedAt: date2,
@@ -60,7 +58,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 
 		thingImageRepoRes = []models.Image{
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				ThingID:   sql.NullInt64{Valid: true, Int64: int64(thingID)},
 				CreatedAt: date3,
@@ -120,7 +118,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(nil, testError)
 
@@ -137,7 +135,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(nil, nil)
 
@@ -146,7 +144,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(nil, testError)
 
@@ -161,7 +159,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
 				mock := mocks.NewPlaceImageRepositoryMock(mc)
 
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(placeImageRepoRes, nil)
 
@@ -170,7 +168,7 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(thingImageRepoRes, nil)
 
@@ -191,11 +189,14 @@ func TestGetPlaceImagesHandler(t *testing.T) {
 				tt.placeImageRepoMock(mc),
 			))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 6 - 5
internal/api/v1/image/get_thing_images.go

@@ -1,9 +1,10 @@
 package image
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -24,16 +25,16 @@ func GetThingImagesHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("thingId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		res, err := thingImageRepository.GetByThingID(ctx, id)
+		res, err := thingImageRepository.GetByThingID(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
-
-		return fctx.JSON(mappers.ToImagesResponse(res))
+		return fctx.JSON(mappers.ToImagesResponse(location.ApplyLocation(fctx, res)))
 	}
 }

+ 14 - 13
internal/api/v1/image/get_thing_images_test.go

@@ -3,7 +3,6 @@ package image
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -13,10 +12,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -29,30 +27,30 @@ func TestGetThingImagesHandler(t *testing.T) {
 	}
 
 	var (
-		thingID   = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
+		thingID   = uint64(gofakeit.Number(1, 1000))
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodGet,
-			route:  "/v1/images/thing/" + strconv.Itoa(thingID),
+			route:  "/v1/images/thing/" + strconv.FormatUint(thingID, 10),
 		}
 
 		imageRepoRes = []models.Image{
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				CreatedAt: gofakeit.Date(),
 				ThingID:   sql.NullInt64{Valid: true, Int64: int64(thingID)},
 			},
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				CreatedAt: gofakeit.Date(),
 				ThingID:   sql.NullInt64{Valid: true, Int64: int64(thingID)},
 			},
 			{
-				ID:        gofakeit.Number(1, 1000),
+				ID:        gofakeit.Uint64(),
 				Image:     gofakeit.URL(),
 				CreatedAt: gofakeit.Date(),
 				ThingID:   sql.NullInt64{Valid: true, Int64: int64(thingID)},
@@ -108,7 +106,7 @@ func TestGetThingImagesHandler(t *testing.T) {
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, testError)
 
@@ -123,7 +121,7 @@ func TestGetThingImagesHandler(t *testing.T) {
 			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
 				mock := mocks.NewThingImageRepositoryMock(mc)
 
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(imageRepoRes, nil)
 
@@ -141,11 +139,14 @@ func TestGetThingImagesHandler(t *testing.T) {
 
 			fiberApp.Get("/v1/images/thing/:thingId", GetThingImagesHandler(tt.thingImageRepoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 1 - 1
internal/api/v1/image/mocks/file_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 42 - 730
internal/api/v1/image/mocks/place_image_repository_minimock.go


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 42 - 730
internal/api/v1/image/mocks/thing_image_repository_minimock.go


+ 393 - 0
internal/api/v1/image/mocks/transaction_manager_minimock.go

@@ -0,0 +1,393 @@
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
+
+package mocks
+
+//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image.TransactionManager -o transaction_manager_minimock.go -n TransactionManagerMock -p mocks
+
+import (
+	"context"
+	"sync"
+	mm_atomic "sync/atomic"
+	mm_time "time"
+
+	"github.com/gojuno/minimock/v3"
+)
+
+// TransactionManagerMock implements image.TransactionManager
+type TransactionManagerMock struct {
+	t          minimock.Tester
+	finishOnce sync.Once
+
+	funcReadCommitted          func(ctx context.Context, f1 func(ctx context.Context) error) (err error)
+	inspectFuncReadCommitted   func(ctx context.Context, f1 func(ctx context.Context) error)
+	afterReadCommittedCounter  uint64
+	beforeReadCommittedCounter uint64
+	ReadCommittedMock          mTransactionManagerMockReadCommitted
+}
+
+// NewTransactionManagerMock returns a mock for image.TransactionManager
+func NewTransactionManagerMock(t minimock.Tester) *TransactionManagerMock {
+	m := &TransactionManagerMock{t: t}
+
+	if controller, ok := t.(minimock.MockController); ok {
+		controller.RegisterMocker(m)
+	}
+
+	m.ReadCommittedMock = mTransactionManagerMockReadCommitted{mock: m}
+	m.ReadCommittedMock.callArgs = []*TransactionManagerMockReadCommittedParams{}
+
+	t.Cleanup(m.MinimockFinish)
+
+	return m
+}
+
+type mTransactionManagerMockReadCommitted struct {
+	optional           bool
+	mock               *TransactionManagerMock
+	defaultExpectation *TransactionManagerMockReadCommittedExpectation
+	expectations       []*TransactionManagerMockReadCommittedExpectation
+
+	callArgs []*TransactionManagerMockReadCommittedParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// TransactionManagerMockReadCommittedExpectation specifies expectation struct of the TransactionManager.ReadCommitted
+type TransactionManagerMockReadCommittedExpectation struct {
+	mock      *TransactionManagerMock
+	params    *TransactionManagerMockReadCommittedParams
+	paramPtrs *TransactionManagerMockReadCommittedParamPtrs
+	results   *TransactionManagerMockReadCommittedResults
+	Counter   uint64
+}
+
+// TransactionManagerMockReadCommittedParams contains parameters of the TransactionManager.ReadCommitted
+type TransactionManagerMockReadCommittedParams struct {
+	ctx context.Context
+	f1  func(ctx context.Context) error
+}
+
+// TransactionManagerMockReadCommittedParamPtrs contains pointers to parameters of the TransactionManager.ReadCommitted
+type TransactionManagerMockReadCommittedParamPtrs struct {
+	ctx *context.Context
+	f1  *func(ctx context.Context) error
+}
+
+// TransactionManagerMockReadCommittedResults contains results of the TransactionManager.ReadCommitted
+type TransactionManagerMockReadCommittedResults struct {
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Optional() *mTransactionManagerMockReadCommitted {
+	mmReadCommitted.optional = true
+	return mmReadCommitted
+}
+
+// Expect sets up expected params for TransactionManager.ReadCommitted
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Expect(ctx context.Context, f1 func(ctx context.Context) error) *mTransactionManagerMockReadCommitted {
+	if mmReadCommitted.mock.funcReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Set")
+	}
+
+	if mmReadCommitted.defaultExpectation == nil {
+		mmReadCommitted.defaultExpectation = &TransactionManagerMockReadCommittedExpectation{}
+	}
+
+	if mmReadCommitted.defaultExpectation.paramPtrs != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by ExpectParams functions")
+	}
+
+	mmReadCommitted.defaultExpectation.params = &TransactionManagerMockReadCommittedParams{ctx, f1}
+	for _, e := range mmReadCommitted.expectations {
+		if minimock.Equal(e.params, mmReadCommitted.defaultExpectation.params) {
+			mmReadCommitted.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmReadCommitted.defaultExpectation.params)
+		}
+	}
+
+	return mmReadCommitted
+}
+
+// ExpectCtxParam1 sets up expected param ctx for TransactionManager.ReadCommitted
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) ExpectCtxParam1(ctx context.Context) *mTransactionManagerMockReadCommitted {
+	if mmReadCommitted.mock.funcReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Set")
+	}
+
+	if mmReadCommitted.defaultExpectation == nil {
+		mmReadCommitted.defaultExpectation = &TransactionManagerMockReadCommittedExpectation{}
+	}
+
+	if mmReadCommitted.defaultExpectation.params != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Expect")
+	}
+
+	if mmReadCommitted.defaultExpectation.paramPtrs == nil {
+		mmReadCommitted.defaultExpectation.paramPtrs = &TransactionManagerMockReadCommittedParamPtrs{}
+	}
+	mmReadCommitted.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmReadCommitted
+}
+
+// ExpectF1Param2 sets up expected param f1 for TransactionManager.ReadCommitted
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) ExpectF1Param2(f1 func(ctx context.Context) error) *mTransactionManagerMockReadCommitted {
+	if mmReadCommitted.mock.funcReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Set")
+	}
+
+	if mmReadCommitted.defaultExpectation == nil {
+		mmReadCommitted.defaultExpectation = &TransactionManagerMockReadCommittedExpectation{}
+	}
+
+	if mmReadCommitted.defaultExpectation.params != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Expect")
+	}
+
+	if mmReadCommitted.defaultExpectation.paramPtrs == nil {
+		mmReadCommitted.defaultExpectation.paramPtrs = &TransactionManagerMockReadCommittedParamPtrs{}
+	}
+	mmReadCommitted.defaultExpectation.paramPtrs.f1 = &f1
+
+	return mmReadCommitted
+}
+
+// Inspect accepts an inspector function that has same arguments as the TransactionManager.ReadCommitted
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Inspect(f func(ctx context.Context, f1 func(ctx context.Context) error)) *mTransactionManagerMockReadCommitted {
+	if mmReadCommitted.mock.inspectFuncReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("Inspect function is already set for TransactionManagerMock.ReadCommitted")
+	}
+
+	mmReadCommitted.mock.inspectFuncReadCommitted = f
+
+	return mmReadCommitted
+}
+
+// Return sets up results that will be returned by TransactionManager.ReadCommitted
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Return(err error) *TransactionManagerMock {
+	if mmReadCommitted.mock.funcReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Set")
+	}
+
+	if mmReadCommitted.defaultExpectation == nil {
+		mmReadCommitted.defaultExpectation = &TransactionManagerMockReadCommittedExpectation{mock: mmReadCommitted.mock}
+	}
+	mmReadCommitted.defaultExpectation.results = &TransactionManagerMockReadCommittedResults{err}
+	return mmReadCommitted.mock
+}
+
+// Set uses given function f to mock the TransactionManager.ReadCommitted method
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Set(f func(ctx context.Context, f1 func(ctx context.Context) error) (err error)) *TransactionManagerMock {
+	if mmReadCommitted.defaultExpectation != nil {
+		mmReadCommitted.mock.t.Fatalf("Default expectation is already set for the TransactionManager.ReadCommitted method")
+	}
+
+	if len(mmReadCommitted.expectations) > 0 {
+		mmReadCommitted.mock.t.Fatalf("Some expectations are already set for the TransactionManager.ReadCommitted method")
+	}
+
+	mmReadCommitted.mock.funcReadCommitted = f
+	return mmReadCommitted.mock
+}
+
+// When sets expectation for the TransactionManager.ReadCommitted which will trigger the result defined by the following
+// Then helper
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) When(ctx context.Context, f1 func(ctx context.Context) error) *TransactionManagerMockReadCommittedExpectation {
+	if mmReadCommitted.mock.funcReadCommitted != nil {
+		mmReadCommitted.mock.t.Fatalf("TransactionManagerMock.ReadCommitted mock is already set by Set")
+	}
+
+	expectation := &TransactionManagerMockReadCommittedExpectation{
+		mock:   mmReadCommitted.mock,
+		params: &TransactionManagerMockReadCommittedParams{ctx, f1},
+	}
+	mmReadCommitted.expectations = append(mmReadCommitted.expectations, expectation)
+	return expectation
+}
+
+// Then sets up TransactionManager.ReadCommitted return parameters for the expectation previously defined by the When method
+func (e *TransactionManagerMockReadCommittedExpectation) Then(err error) *TransactionManagerMock {
+	e.results = &TransactionManagerMockReadCommittedResults{err}
+	return e.mock
+}
+
+// Times sets number of times TransactionManager.ReadCommitted should be invoked
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Times(n uint64) *mTransactionManagerMockReadCommitted {
+	if n == 0 {
+		mmReadCommitted.mock.t.Fatalf("Times of TransactionManagerMock.ReadCommitted mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmReadCommitted.expectedInvocations, n)
+	return mmReadCommitted
+}
+
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) invocationsDone() bool {
+	if len(mmReadCommitted.expectations) == 0 && mmReadCommitted.defaultExpectation == nil && mmReadCommitted.mock.funcReadCommitted == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmReadCommitted.mock.afterReadCommittedCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmReadCommitted.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// ReadCommitted implements image.TransactionManager
+func (mmReadCommitted *TransactionManagerMock) ReadCommitted(ctx context.Context, f1 func(ctx context.Context) error) (err error) {
+	mm_atomic.AddUint64(&mmReadCommitted.beforeReadCommittedCounter, 1)
+	defer mm_atomic.AddUint64(&mmReadCommitted.afterReadCommittedCounter, 1)
+
+	if mmReadCommitted.inspectFuncReadCommitted != nil {
+		mmReadCommitted.inspectFuncReadCommitted(ctx, f1)
+	}
+
+	mm_params := TransactionManagerMockReadCommittedParams{ctx, f1}
+
+	// Record call args
+	mmReadCommitted.ReadCommittedMock.mutex.Lock()
+	mmReadCommitted.ReadCommittedMock.callArgs = append(mmReadCommitted.ReadCommittedMock.callArgs, &mm_params)
+	mmReadCommitted.ReadCommittedMock.mutex.Unlock()
+
+	for _, e := range mmReadCommitted.ReadCommittedMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.err
+		}
+	}
+
+	if mmReadCommitted.ReadCommittedMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmReadCommitted.ReadCommittedMock.defaultExpectation.Counter, 1)
+		mm_want := mmReadCommitted.ReadCommittedMock.defaultExpectation.params
+		mm_want_ptrs := mmReadCommitted.ReadCommittedMock.defaultExpectation.paramPtrs
+
+		mm_got := TransactionManagerMockReadCommittedParams{ctx, f1}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmReadCommitted.t.Errorf("TransactionManagerMock.ReadCommitted got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+			if mm_want_ptrs.f1 != nil && !minimock.Equal(*mm_want_ptrs.f1, mm_got.f1) {
+				mmReadCommitted.t.Errorf("TransactionManagerMock.ReadCommitted got unexpected parameter f1, want: %#v, got: %#v%s\n", *mm_want_ptrs.f1, mm_got.f1, minimock.Diff(*mm_want_ptrs.f1, mm_got.f1))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmReadCommitted.t.Errorf("TransactionManagerMock.ReadCommitted got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmReadCommitted.ReadCommittedMock.defaultExpectation.results
+		if mm_results == nil {
+			mmReadCommitted.t.Fatal("No results are set for the TransactionManagerMock.ReadCommitted")
+		}
+		return (*mm_results).err
+	}
+	if mmReadCommitted.funcReadCommitted != nil {
+		return mmReadCommitted.funcReadCommitted(ctx, f1)
+	}
+	mmReadCommitted.t.Fatalf("Unexpected call to TransactionManagerMock.ReadCommitted. %v %v", ctx, f1)
+	return
+}
+
+// ReadCommittedAfterCounter returns a count of finished TransactionManagerMock.ReadCommitted invocations
+func (mmReadCommitted *TransactionManagerMock) ReadCommittedAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmReadCommitted.afterReadCommittedCounter)
+}
+
+// ReadCommittedBeforeCounter returns a count of TransactionManagerMock.ReadCommitted invocations
+func (mmReadCommitted *TransactionManagerMock) ReadCommittedBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmReadCommitted.beforeReadCommittedCounter)
+}
+
+// Calls returns a list of arguments used in each call to TransactionManagerMock.ReadCommitted.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmReadCommitted *mTransactionManagerMockReadCommitted) Calls() []*TransactionManagerMockReadCommittedParams {
+	mmReadCommitted.mutex.RLock()
+
+	argCopy := make([]*TransactionManagerMockReadCommittedParams, len(mmReadCommitted.callArgs))
+	copy(argCopy, mmReadCommitted.callArgs)
+
+	mmReadCommitted.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockReadCommittedDone returns true if the count of the ReadCommitted invocations corresponds
+// the number of defined expectations
+func (m *TransactionManagerMock) MinimockReadCommittedDone() bool {
+	if m.ReadCommittedMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.ReadCommittedMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.ReadCommittedMock.invocationsDone()
+}
+
+// MinimockReadCommittedInspect logs each unmet expectation
+func (m *TransactionManagerMock) MinimockReadCommittedInspect() {
+	for _, e := range m.ReadCommittedMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to TransactionManagerMock.ReadCommitted with params: %#v", *e.params)
+		}
+	}
+
+	afterReadCommittedCounter := mm_atomic.LoadUint64(&m.afterReadCommittedCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.ReadCommittedMock.defaultExpectation != nil && afterReadCommittedCounter < 1 {
+		if m.ReadCommittedMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to TransactionManagerMock.ReadCommitted")
+		} else {
+			m.t.Errorf("Expected call to TransactionManagerMock.ReadCommitted with params: %#v", *m.ReadCommittedMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcReadCommitted != nil && afterReadCommittedCounter < 1 {
+		m.t.Error("Expected call to TransactionManagerMock.ReadCommitted")
+	}
+
+	if !m.ReadCommittedMock.invocationsDone() && afterReadCommittedCounter > 0 {
+		m.t.Errorf("Expected %d calls to TransactionManagerMock.ReadCommitted but found %d calls",
+			mm_atomic.LoadUint64(&m.ReadCommittedMock.expectedInvocations), afterReadCommittedCounter)
+	}
+}
+
+// MinimockFinish checks that all mocked methods have been called the expected number of times
+func (m *TransactionManagerMock) MinimockFinish() {
+	m.finishOnce.Do(func() {
+		if !m.minimockDone() {
+			m.MinimockReadCommittedInspect()
+		}
+	})
+}
+
+// MinimockWait waits for all mocked methods to be called the expected number of times
+func (m *TransactionManagerMock) MinimockWait(timeout mm_time.Duration) {
+	timeoutCh := mm_time.After(timeout)
+	for {
+		if m.minimockDone() {
+			return
+		}
+		select {
+		case <-timeoutCh:
+			m.MinimockFinish()
+			return
+		case <-mm_time.After(10 * mm_time.Millisecond):
+		}
+	}
+}
+
+func (m *TransactionManagerMock) minimockDone() bool {
+	done := true
+	return done &&
+		m.MinimockReadCommittedDone()
+}

+ 14 - 8
internal/api/v1/notification/add_thing_notification.go

@@ -6,14 +6,14 @@ package notification
 
 import (
 	"context"
-	"database/sql"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/repositories"
@@ -21,10 +21,10 @@ import (
 
 type (
 	ThingNotificationRepository interface {
-		Add(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) error
-		Update(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) error
-		Delete(ctx context.Context, thingID int, tx *sql.Tx) error
-		Get(ctx context.Context, thingID int) (*models.ThingNotification, error)
+		Add(ctx context.Context, req models.AddThingNotificationRequest) error
+		Update(ctx context.Context, req models.UpdateThingNotificationRequest) error
+		Delete(ctx context.Context, id uint64) error
+		Get(ctx context.Context, id uint64) (*models.ThingNotification, error)
 		GetExpired(ctx context.Context) ([]models.ExtThingNotification, error)
 	}
 )
@@ -47,33 +47,39 @@ func AddThingNotificationHandler(
 
 		req := dto.AddThingNotificationRequest{}
 		if err := fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err := validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
 		dbReq, err := mappers.ToAddThingNotificationRequest(req)
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		if err = thingNotificationRepository.Add(ctx, *dbReq, nil); err != nil {
+		if err = thingNotificationRepository.Add(ctx, *dbReq); err != nil {
 			if repositories.IsFKViolationError(err) || repositories.IsDuplicateKeyError(err) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
 		res, err := thingNotificationRepository.Get(ctx, req.ThingID)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToThingNotificationResponse(*res))
 	}

+ 12 - 15
internal/api/v1/notification/add_thing_notification_test.go

@@ -2,8 +2,6 @@ package notification
 
 import (
 	"context"
-	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"testing"
 	"time"
@@ -14,10 +12,9 @@ import (
 	"github.com/lib/pq"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/repositories"
 )
@@ -33,9 +30,9 @@ func TestAddThingNotificationHandler(t *testing.T) {
 	}
 
 	var (
-		thingID          = gofakeit.Number(1, 1000)
+		thingID          = uint64(gofakeit.Number(1, 1000))
 		notificationDate = gofakeit.Date().Truncate(time.Second)
-		testError        = errors.New(gofakeit.Phrase())
+		testError        = gofakeit.Error()
 		layout           = "2006-01-02 15:04:05"
 
 		correctReq = req{
@@ -78,12 +75,12 @@ func TestAddThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(nil)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(&repoRes, nil)
 
@@ -139,7 +136,7 @@ func TestAddThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(testError)
@@ -154,7 +151,7 @@ func TestAddThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(&pq.Error{Code: repositories.DuplicateKeyErrorCode})
@@ -169,12 +166,12 @@ func TestAddThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) {
+				mock.AddMock.Inspect(func(ctx context.Context, req models.AddThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(nil)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, testError)
 
@@ -191,13 +188,13 @@ func TestAddThingNotificationHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Post("/v1/things/notifications", AddThingNotificationHandler(tt.repoMock(mc)))
 
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
+			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, test.ConvertDataToIOReader(tt.req.body))
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 7 - 2
internal/api/v1/notification/delete_thing_notification.go

@@ -4,6 +4,7 @@ import (
 	"database/sql"
 	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
@@ -26,19 +27,23 @@ func DeleteThingNotificationHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("thingId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		_, err = thingNotificationRepository.Get(ctx, id)
+		_, err = thingNotificationRepository.Get(ctx, uint64(id))
 		if err != nil {
 			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		if err = thingNotificationRepository.Delete(ctx, id, nil); err != nil {
+		if err = thingNotificationRepository.Delete(ctx, uint64(id)); err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 13 - 15
internal/api/v1/notification/delete_thing_notification_test.go

@@ -3,7 +3,6 @@ package notification
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -14,9 +13,8 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -30,17 +28,17 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 	}
 
 	var (
-		thingID   = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
+		thingID   = uint64(gofakeit.Number(1, 1000))
+		testError = gofakeit.Error()
 
 		correctReq = req{
 			method:      fiber.MethodDelete,
-			route:       "/v1/things/notifications/" + strconv.Itoa(thingID),
+			route:       "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 			contentType: fiber.MIMEApplicationJSON,
 		}
 
 		repoRes = models.ThingNotification{
-			ThingID:          thingID,
+			ThingID:          uint64(thingID),
 			NotificationDate: gofakeit.Date().Truncate(time.Second),
 			CreatedAt:        gofakeit.Date(),
 			UpdatedAt:        gofakeit.Date(),
@@ -61,11 +59,11 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(&repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil)
 
@@ -91,7 +89,7 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, testError)
 
@@ -105,7 +103,7 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, sql.ErrNoRows)
 
@@ -119,11 +117,11 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(&repoRes, nil)
 
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
+				mock.DeleteMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(testError)
 
@@ -142,11 +140,11 @@ func Test_DeleteThingNotificationHandler(t *testing.T) {
 
 			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, nil)
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 6 - 3
internal/api/v1/notification/get_expired_thing_notifications.go

@@ -1,9 +1,10 @@
 package notification
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -20,12 +21,14 @@ func GetExpiredThingNotificationsHandler(
 	thingNotificationRepository ThingNotificationRepository,
 ) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
-		res, err := thingNotificationRepository.GetExpired(fctx.Context())
+		ctx := fctx.Context()
+		res, err := thingNotificationRepository.GetExpired(ctx)
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToThingNotificationsExtResponse(res))
 	}

+ 9 - 8
internal/api/v1/notification/get_expired_thing_notifications_test.go

@@ -1,7 +1,6 @@
 package notification
 
 import (
-	"errors"
 	"net/http/httptest"
 	"testing"
 	"time"
@@ -11,10 +10,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -27,7 +25,7 @@ func TestGetExpiredThingNotificationsHandler(t *testing.T) {
 	}
 
 	var (
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
@@ -37,8 +35,8 @@ func TestGetExpiredThingNotificationsHandler(t *testing.T) {
 
 		repoRes = []models.ExtThingNotification{
 			{
-				ThingID:          gofakeit.Number(1, 1000),
-				PlaceID:          gofakeit.Number(1, 1000),
+				ThingID:          uint64(gofakeit.Number(1, 1000)),
+				PlaceID:          uint64(gofakeit.Number(1, 1000)),
 				ThingTitle:       gofakeit.Phrase(),
 				PlaceTitle:       gofakeit.Phrase(),
 				NotificationDate: gofakeit.Date().Truncate(time.Second),
@@ -100,10 +98,13 @@ func TestGetExpiredThingNotificationsHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/things/notifications/expired", GetExpiredThingNotificationsHandler(tt.repoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 7 - 3
internal/api/v1/notification/get_thing_notification.go

@@ -4,9 +4,10 @@ import (
 	"database/sql"
 	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -28,19 +29,22 @@ func GetThingNotificationHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("thingId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		res, err := thingNotificationRepository.Get(ctx, id)
+		res, err := thingNotificationRepository.Get(ctx, uint64(id))
 		if err != nil {
 			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusNotFound, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToThingNotificationResponse(*res))
 	}

+ 12 - 11
internal/api/v1/notification/get_thing_notification_test.go

@@ -3,7 +3,6 @@ package notification
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -14,10 +13,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -30,13 +28,13 @@ func TestGetThingNotificationHandler(t *testing.T) {
 	}
 
 	var (
-		thingID   = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
+		thingID   = uint64(gofakeit.Number(1, 1000))
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodGet,
-			route:  "/v1/things/notifications/" + strconv.Itoa(thingID),
+			route:  "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 		}
 
 		repoRes = models.ThingNotification{
@@ -69,7 +67,7 @@ func TestGetThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(&repoRes, nil)
 
@@ -83,7 +81,7 @@ func TestGetThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, testError)
 
@@ -97,7 +95,7 @@ func TestGetThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, sql.ErrNoRows)
 
@@ -125,10 +123,13 @@ func TestGetThingNotificationHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/things/notifications/:thingId", GetThingNotificationHandler(tt.repoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 75 - 160
internal/api/v1/notification/mocks/thing_notification_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,20 +19,20 @@ type ThingNotificationRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcAdd          func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error)
-	inspectFuncAdd   func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx)
+	funcAdd          func(ctx context.Context, req models.AddThingNotificationRequest) (err error)
+	inspectFuncAdd   func(ctx context.Context, req models.AddThingNotificationRequest)
 	afterAddCounter  uint64
 	beforeAddCounter uint64
 	AddMock          mThingNotificationRepositoryMockAdd
 
-	funcDelete          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingNotificationRepositoryMockDelete
 
-	funcGet          func(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error)
-	inspectFuncGet   func(ctx context.Context, thingID int)
+	funcGet          func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)
+	inspectFuncGet   func(ctx context.Context, id uint64)
 	afterGetCounter  uint64
 	beforeGetCounter uint64
 	GetMock          mThingNotificationRepositoryMockGet
@@ -44,8 +43,8 @@ type ThingNotificationRepositoryMock struct {
 	beforeGetExpiredCounter uint64
 	GetExpiredMock          mThingNotificationRepositoryMockGetExpired
 
-	funcUpdate          func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) (err error)
-	inspectFuncUpdate   func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx)
+	funcUpdate          func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)
+	inspectFuncUpdate   func(ctx context.Context, req models.UpdateThingNotificationRequest)
 	afterUpdateCounter  uint64
 	beforeUpdateCounter uint64
 	UpdateMock          mThingNotificationRepositoryMockUpdate
@@ -104,14 +103,12 @@ type ThingNotificationRepositoryMockAddExpectation struct {
 type ThingNotificationRepositoryMockAddParams struct {
 	ctx context.Context
 	req models.AddThingNotificationRequest
-	tx  *sql.Tx
 }
 
 // ThingNotificationRepositoryMockAddParamPtrs contains pointers to parameters of the ThingNotificationRepository.Add
 type ThingNotificationRepositoryMockAddParamPtrs struct {
 	ctx *context.Context
 	req *models.AddThingNotificationRequest
-	tx  **sql.Tx
 }
 
 // ThingNotificationRepositoryMockAddResults contains results of the ThingNotificationRepository.Add
@@ -130,7 +127,7 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) Optional() *mThingNotification
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Add
-func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) *mThingNotificationRepositoryMockAdd {
+func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingNotificationRequest) *mThingNotificationRepositoryMockAdd {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
 	}
@@ -143,7 +140,7 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, re
 		mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by ExpectParams functions")
 	}
 
-	mmAdd.defaultExpectation.params = &ThingNotificationRepositoryMockAddParams{ctx, req, tx}
+	mmAdd.defaultExpectation.params = &ThingNotificationRepositoryMockAddParams{ctx, req}
 	for _, e := range mmAdd.expectations {
 		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
 			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
@@ -197,30 +194,8 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectReqParam2(req models.Add
 	return mmAdd
 }
 
-// ExpectTxParam3 sets up expected param tx for ThingNotificationRepository.Add
-func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mThingNotificationRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
-	}
-
-	if mmAdd.defaultExpectation.params != nil {
-		mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Expect")
-	}
-
-	if mmAdd.defaultExpectation.paramPtrs == nil {
-		mmAdd.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockAddParamPtrs{}
-	}
-	mmAdd.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmAdd
-}
-
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Add
-func (mmAdd *mThingNotificationRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx)) *mThingNotificationRepositoryMockAdd {
+func (mmAdd *mThingNotificationRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingNotificationRequest)) *mThingNotificationRepositoryMockAdd {
 	if mmAdd.mock.inspectFuncAdd != nil {
 		mmAdd.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Add")
 	}
@@ -244,7 +219,7 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) Return(err error) *ThingNotifi
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Add method
-func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
+func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
 	if mmAdd.defaultExpectation != nil {
 		mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Add method")
 	}
@@ -259,14 +234,14 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context
 
 // When sets expectation for the ThingNotificationRepository.Add which will trigger the result defined by the following
 // Then helper
-func (mmAdd *mThingNotificationRepositoryMockAdd) When(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) *ThingNotificationRepositoryMockAddExpectation {
+func (mmAdd *mThingNotificationRepositoryMockAdd) When(ctx context.Context, req models.AddThingNotificationRequest) *ThingNotificationRepositoryMockAddExpectation {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockAddExpectation{
 		mock:   mmAdd.mock,
-		params: &ThingNotificationRepositoryMockAddParams{ctx, req, tx},
+		params: &ThingNotificationRepositoryMockAddParams{ctx, req},
 	}
 	mmAdd.expectations = append(mmAdd.expectations, expectation)
 	return expectation
@@ -299,15 +274,15 @@ func (mmAdd *mThingNotificationRepositoryMockAdd) invocationsDone() bool {
 }
 
 // Add implements notification.ThingNotificationRepository
-func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req models.AddThingNotificationRequest, tx *sql.Tx) (err error) {
+func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req models.AddThingNotificationRequest) (err error) {
 	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
 	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
 
 	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, req, tx)
+		mmAdd.inspectFuncAdd(ctx, req)
 	}
 
-	mm_params := ThingNotificationRepositoryMockAddParams{ctx, req, tx}
+	mm_params := ThingNotificationRepositoryMockAddParams{ctx, req}
 
 	// Record call args
 	mmAdd.AddMock.mutex.Lock()
@@ -326,7 +301,7 @@ func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req model
 		mm_want := mmAdd.AddMock.defaultExpectation.params
 		mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockAddParams{ctx, req, tx}
+		mm_got := ThingNotificationRepositoryMockAddParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -338,10 +313,6 @@ func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req model
 				mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmAdd.t.Errorf("ThingNotificationRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -353,9 +324,9 @@ func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req model
 		return (*mm_results).err
 	}
 	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, req, tx)
+		return mmAdd.funcAdd(ctx, req)
 	}
-	mmAdd.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Add. %v %v %v", ctx, req, tx)
+	mmAdd.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Add. %v %v", ctx, req)
 	return
 }
 
@@ -450,16 +421,14 @@ type ThingNotificationRepositoryMockDeleteExpectation struct {
 
 // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
@@ -478,7 +447,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotifi
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -491,7 +460,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Conte
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -523,8 +492,8 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx cont
 	return mmDelete
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingNotificationRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
+func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -540,35 +509,13 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thin
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
 	}
@@ -592,7 +539,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *Thing
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Delete method
-func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
 	}
@@ -607,14 +554,14 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.C
 
 // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingNotificationRepositoryMockDeleteExpectation {
+func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx},
+		params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -647,15 +594,15 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements notification.ThingNotificationRepository
-func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, thingID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -674,7 +621,7 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -682,12 +629,8 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -701,9 +644,9 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, thingID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 
@@ -798,14 +741,14 @@ type ThingNotificationRepositoryMockGetExpectation struct {
 
 // ThingNotificationRepositoryMockGetParams contains parameters of the ThingNotificationRepository.Get
 type ThingNotificationRepositoryMockGetParams struct {
-	ctx     context.Context
-	thingID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingNotificationRepositoryMockGetParamPtrs contains pointers to parameters of the ThingNotificationRepository.Get
 type ThingNotificationRepositoryMockGetParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingNotificationRepositoryMockGetResults contains results of the ThingNotificationRepository.Get
@@ -825,7 +768,7 @@ func (mmGet *mThingNotificationRepositoryMockGet) Optional() *mThingNotification
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Get
-func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingNotificationRepositoryMockGet {
+func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockGet {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
 	}
@@ -838,7 +781,7 @@ func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, th
 		mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by ExpectParams functions")
 	}
 
-	mmGet.defaultExpectation.params = &ThingNotificationRepositoryMockGetParams{ctx, thingID}
+	mmGet.defaultExpectation.params = &ThingNotificationRepositoryMockGetParams{ctx, id}
 	for _, e := range mmGet.expectations {
 		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
 			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
@@ -870,8 +813,8 @@ func (mmGet *mThingNotificationRepositoryMockGet) ExpectCtxParam1(ctx context.Co
 	return mmGet
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingNotificationRepository.Get
-func (mmGet *mThingNotificationRepositoryMockGet) ExpectThingIDParam2(thingID int) *mThingNotificationRepositoryMockGet {
+// ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Get
+func (mmGet *mThingNotificationRepositoryMockGet) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockGet {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
 	}
@@ -887,13 +830,13 @@ func (mmGet *mThingNotificationRepositoryMockGet) ExpectThingIDParam2(thingID in
 	if mmGet.defaultExpectation.paramPtrs == nil {
 		mmGet.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetParamPtrs{}
 	}
-	mmGet.defaultExpectation.paramPtrs.thingID = &thingID
+	mmGet.defaultExpectation.paramPtrs.id = &id
 
 	return mmGet
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Get
-func (mmGet *mThingNotificationRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingNotificationRepositoryMockGet {
+func (mmGet *mThingNotificationRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockGet {
 	if mmGet.mock.inspectFuncGet != nil {
 		mmGet.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Get")
 	}
@@ -917,7 +860,7 @@ func (mmGet *mThingNotificationRepositoryMockGet) Return(tp1 *models.ThingNotifi
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Get method
-func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error)) *ThingNotificationRepositoryMock {
+func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)) *ThingNotificationRepositoryMock {
 	if mmGet.defaultExpectation != nil {
 		mmGet.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Get method")
 	}
@@ -932,14 +875,14 @@ func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context
 
 // When sets expectation for the ThingNotificationRepository.Get which will trigger the result defined by the following
 // Then helper
-func (mmGet *mThingNotificationRepositoryMockGet) When(ctx context.Context, thingID int) *ThingNotificationRepositoryMockGetExpectation {
+func (mmGet *mThingNotificationRepositoryMockGet) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockGetExpectation {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockGetExpectation{
 		mock:   mmGet.mock,
-		params: &ThingNotificationRepositoryMockGetParams{ctx, thingID},
+		params: &ThingNotificationRepositoryMockGetParams{ctx, id},
 	}
 	mmGet.expectations = append(mmGet.expectations, expectation)
 	return expectation
@@ -972,15 +915,15 @@ func (mmGet *mThingNotificationRepositoryMockGet) invocationsDone() bool {
 }
 
 // Get implements notification.ThingNotificationRepository
-func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.ThingNotification, err error) {
+func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error) {
 	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
 	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
 
 	if mmGet.inspectFuncGet != nil {
-		mmGet.inspectFuncGet(ctx, thingID)
+		mmGet.inspectFuncGet(ctx, id)
 	}
 
-	mm_params := ThingNotificationRepositoryMockGetParams{ctx, thingID}
+	mm_params := ThingNotificationRepositoryMockGetParams{ctx, id}
 
 	// Record call args
 	mmGet.GetMock.mutex.Lock()
@@ -999,7 +942,7 @@ func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, thingID i
 		mm_want := mmGet.GetMock.defaultExpectation.params
 		mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockGetParams{ctx, thingID}
+		mm_got := ThingNotificationRepositoryMockGetParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -1007,8 +950,8 @@ func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, thingID i
 				mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -1022,9 +965,9 @@ func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, thingID i
 		return (*mm_results).tp1, (*mm_results).err
 	}
 	if mmGet.funcGet != nil {
-		return mmGet.funcGet(ctx, thingID)
+		return mmGet.funcGet(ctx, id)
 	}
-	mmGet.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Get. %v %v", ctx, thingID)
+	mmGet.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Get. %v %v", ctx, id)
 	return
 }
 
@@ -1414,14 +1357,12 @@ type ThingNotificationRepositoryMockUpdateExpectation struct {
 type ThingNotificationRepositoryMockUpdateParams struct {
 	ctx context.Context
 	req models.UpdateThingNotificationRequest
-	tx  *sql.Tx
 }
 
 // ThingNotificationRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingNotificationRepository.Update
 type ThingNotificationRepositoryMockUpdateParamPtrs struct {
 	ctx *context.Context
 	req *models.UpdateThingNotificationRequest
-	tx  **sql.Tx
 }
 
 // ThingNotificationRepositoryMockUpdateResults contains results of the ThingNotificationRepository.Update
@@ -1440,7 +1381,7 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) Optional() *mThingNotifi
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Update
-func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) *mThingNotificationRepositoryMockUpdate {
+func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingNotificationRequest) *mThingNotificationRepositoryMockUpdate {
 	if mmUpdate.mock.funcUpdate != nil {
 		mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
 	}
@@ -1453,7 +1394,7 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Conte
 		mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by ExpectParams functions")
 	}
 
-	mmUpdate.defaultExpectation.params = &ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
+	mmUpdate.defaultExpectation.params = &ThingNotificationRepositoryMockUpdateParams{ctx, req}
 	for _, e := range mmUpdate.expectations {
 		if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
 			mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
@@ -1507,30 +1448,8 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectReqParam2(req mode
 	return mmUpdate
 }
 
-// ExpectTxParam3 sets up expected param tx for ThingNotificationRepository.Update
-func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectTxParam3(tx *sql.Tx) *mThingNotificationRepositoryMockUpdate {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
-	}
-
-	if mmUpdate.defaultExpectation == nil {
-		mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
-	}
-
-	if mmUpdate.defaultExpectation.params != nil {
-		mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Expect")
-	}
-
-	if mmUpdate.defaultExpectation.paramPtrs == nil {
-		mmUpdate.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockUpdateParamPtrs{}
-	}
-	mmUpdate.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmUpdate
-}
-
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Update
-func (mmUpdate *mThingNotificationRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx)) *mThingNotificationRepositoryMockUpdate {
+func (mmUpdate *mThingNotificationRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingNotificationRequest)) *mThingNotificationRepositoryMockUpdate {
 	if mmUpdate.mock.inspectFuncUpdate != nil {
 		mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Update")
 	}
@@ -1554,7 +1473,7 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) Return(err error) *Thing
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Update method
-func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
+func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
 	if mmUpdate.defaultExpectation != nil {
 		mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Update method")
 	}
@@ -1569,14 +1488,14 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.C
 
 // When sets expectation for the ThingNotificationRepository.Update which will trigger the result defined by the following
 // Then helper
-func (mmUpdate *mThingNotificationRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) *ThingNotificationRepositoryMockUpdateExpectation {
+func (mmUpdate *mThingNotificationRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingNotificationRequest) *ThingNotificationRepositoryMockUpdateExpectation {
 	if mmUpdate.mock.funcUpdate != nil {
 		mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockUpdateExpectation{
 		mock:   mmUpdate.mock,
-		params: &ThingNotificationRepositoryMockUpdateParams{ctx, req, tx},
+		params: &ThingNotificationRepositoryMockUpdateParams{ctx, req},
 	}
 	mmUpdate.expectations = append(mmUpdate.expectations, expectation)
 	return expectation
@@ -1609,15 +1528,15 @@ func (mmUpdate *mThingNotificationRepositoryMockUpdate) invocationsDone() bool {
 }
 
 // Update implements notification.ThingNotificationRepository
-func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) (err error) {
+func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req models.UpdateThingNotificationRequest) (err error) {
 	mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
 	defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
 
 	if mmUpdate.inspectFuncUpdate != nil {
-		mmUpdate.inspectFuncUpdate(ctx, req, tx)
+		mmUpdate.inspectFuncUpdate(ctx, req)
 	}
 
-	mm_params := ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
+	mm_params := ThingNotificationRepositoryMockUpdateParams{ctx, req}
 
 	// Record call args
 	mmUpdate.UpdateMock.mutex.Lock()
@@ -1636,7 +1555,7 @@ func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req
 		mm_want := mmUpdate.UpdateMock.defaultExpectation.params
 		mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockUpdateParams{ctx, req, tx}
+		mm_got := ThingNotificationRepositoryMockUpdateParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -1648,10 +1567,6 @@ func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req
 				mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -1663,9 +1578,9 @@ func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req
 		return (*mm_results).err
 	}
 	if mmUpdate.funcUpdate != nil {
-		return mmUpdate.funcUpdate(ctx, req, tx)
+		return mmUpdate.funcUpdate(ctx, req)
 	}
-	mmUpdate.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Update. %v %v %v", ctx, req, tx)
+	mmUpdate.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Update. %v %v", ctx, req)
 	return
 }
 

+ 17 - 7
internal/api/v1/notification/update_thing_notification.go

@@ -2,13 +2,15 @@ package notification
 
 import (
 	"database/sql"
+	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -30,43 +32,51 @@ func UpdateThingNotificationHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("thingId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		req := dto.UpdateThingNotificationRequest{}
 		if err = fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err = validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
-		_, err = thingNotificationRepository.Get(ctx, id)
+		_, err = thingNotificationRepository.Get(ctx, uint64(id))
 		if err != nil {
-			if err == sql.ErrNoRows {
+			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		dbReq, err := mappers.ToUpdateThingNotificationRequest(id, req)
+		dbReq, err := mappers.ToUpdateThingNotificationRequest(uint64(id), req)
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		if err = thingNotificationRepository.Update(ctx, *dbReq, nil); err != nil {
+		if err = thingNotificationRepository.Update(ctx, *dbReq); err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res, err := thingNotificationRepository.Get(ctx, id)
+		res, err := thingNotificationRepository.Get(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToThingNotificationResponse(*res))
 	}

+ 19 - 21
internal/api/v1/notification/update_thing_notification_test.go

@@ -3,7 +3,6 @@ package notification
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -14,10 +13,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -32,14 +30,14 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 	}
 
 	var (
-		thingID          = gofakeit.Number(1, 1000)
+		thingID          = uint64(gofakeit.Number(1, 1000))
 		notificationDate = gofakeit.Date().Truncate(time.Second)
-		testError        = errors.New(gofakeit.Phrase())
+		testError        = gofakeit.Error()
 		layout           = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodPut,
-			route:  "/v1/things/notifications/" + strconv.Itoa(thingID),
+			route:  "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 			body: &dto.UpdateThingNotificationRequest{
 				NotificationDate: notificationDate.Format(time.RFC3339),
 			},
@@ -76,12 +74,12 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(nil)
 
-				mock.GetMock.Set(func(ctx context.Context, id int) (*models.ThingNotification, error) {
+				mock.GetMock.Set(func(ctx context.Context, id uint64) (*models.ThingNotification, error) {
 					assert.Equal(mc, thingID, id)
 					if mock.GetAfterCounter() == 0 {
 						return nil, nil
@@ -107,7 +105,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			name: "negative case - body parse error",
 			req: req{
 				method: fiber.MethodPut,
-				route:  "/v1/things/notifications/" + strconv.Itoa(thingID),
+				route:  "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 			},
 			resCode: fiber.StatusBadRequest,
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
@@ -118,7 +116,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			name: "negative case - validate request error",
 			req: req{
 				method:      fiber.MethodPut,
-				route:       "/v1/things/notifications/" + strconv.Itoa(thingID),
+				route:       "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 				contentType: fiber.MIMEApplicationJSON,
 			},
 			resCode: fiber.StatusBadRequest,
@@ -133,7 +131,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, testError)
 
@@ -147,7 +145,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, sql.ErrNoRows)
 
@@ -158,7 +156,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			name: "negative case - bad request (notification not found)",
 			req: req{
 				method: fiber.MethodPut,
-				route:  "/v1/things/notifications/" + strconv.Itoa(thingID),
+				route:  "/v1/things/notifications/" + strconv.FormatUint(thingID, 10),
 				body: &dto.UpdateThingNotificationRequest{
 					NotificationDate: notificationDate.String(),
 				},
@@ -168,7 +166,7 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, nil)
 
@@ -182,11 +180,11 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, thingID, id)
 				}).Return(nil, nil)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(testError)
@@ -201,12 +199,12 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			repoMock: func(mc *minimock.Controller) ThingNotificationRepository {
 				mock := mocks.NewThingNotificationRepositoryMock(mc)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateThingNotificationRequest) {
 					assert.Equal(mc, thingID, req.ThingID)
 					assert.Equal(mc, notificationDate, req.NotificationDate)
 				}).Return(nil)
 
-				mock.GetMock.Set(func(ctx context.Context, id int) (*models.ThingNotification, error) {
+				mock.GetMock.Set(func(ctx context.Context, id uint64) (*models.ThingNotification, error) {
 					assert.Equal(mc, thingID, id)
 					if mock.GetAfterCounter() == 0 {
 						return nil, nil
@@ -227,13 +225,13 @@ func TestUpdateThingNotificationHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Put("/v1/things/notifications/:thingId", UpdateThingNotificationHandler(tt.repoMock(mc)))
 
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
+			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, test.ConvertDataToIOReader(tt.req.body))
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 26 - 20
internal/api/v1/place/add_place.go

@@ -6,55 +6,57 @@ package place
 
 import (
 	"context"
-	"database/sql"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
 type (
+	TransactionManager interface {
+		ReadCommitted(context.Context, func(ctx context.Context) error) error
+	}
+
 	PlaceRepository interface {
 		GetAll(ctx context.Context) ([]models.Place, error)
-		Get(ctx context.Context, placeID int) (*models.Place, error)
-		GetNestedPlaces(ctx context.Context, placeID int) ([]models.Place, error)
-		Add(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) (int, error)
-		Update(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) error
-		Delete(ctx context.Context, placeID int, tx *sql.Tx) error
-		BeginTx(ctx context.Context, level sql.IsolationLevel) (*sql.Tx, error)
-		CommitTx(tx *sql.Tx) error
+		Get(ctx context.Context, id uint64) (*models.Place, error)
+		GetNestedPlaces(ctx context.Context, id uint64) ([]models.Place, error)
+		Add(ctx context.Context, req models.AddPlaceRequest) (uint64, error)
+		Update(ctx context.Context, req models.UpdatePlaceRequest) error
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	ThingRepository interface {
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.Thing, error)
-		Delete(ctx context.Context, thingID int, tx *sql.Tx) error
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.Thing, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	PlaceImageRepository interface {
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.Image, error)
-		Delete(ctx context.Context, imageID int, tx *sql.Tx) error
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.Image, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	ThingImageRepository interface {
-		GetByThingID(ctx context.Context, thingID int) ([]models.Image, error)
-		Delete(ctx context.Context, imageID int, tx *sql.Tx) error
+		GetByThingID(ctx context.Context, id uint64) ([]models.Image, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	PlaceThingRepository interface {
-		DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) error
+		DeleteThing(ctx context.Context, id uint64) error
 	}
 
 	ThingTagRepository interface {
-		DeleteByThingID(ctx context.Context, thingID int, tx *sql.Tx) error
+		DeleteByThingID(ctx context.Context, id uint64) error
 	}
 
 	ThingNotificationRepository interface {
-		Delete(ctx context.Context, thingID int, tx *sql.Tx) error
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	FileRepository interface {
@@ -79,25 +81,29 @@ func AddPlaceHandler(
 		ctx := fctx.Context()
 		req := dto.AddPlaceRequest{}
 		if err := fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err := validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
-		id, err := placeRepository.Add(ctx, mappers.ToAddPlaceRequest(req), nil)
+		id, err := placeRepository.Add(ctx, mappers.ToAddPlaceRequest(req))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
 		res, err := placeRepository.Get(ctx, id)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlaceResponse(*res))
 	}

+ 0 - 177
internal/api/v1/place/add_place_test.go

@@ -1,177 +0,0 @@
-package place
-
-import (
-	"context"
-	"database/sql"
-	"errors"
-	"net/http/httptest"
-	"testing"
-
-	"github.com/brianvoe/gofakeit/v6"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/stretchr/testify/assert"
-
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
-)
-
-func TestAddPlaceHandler(t *testing.T) {
-	t.Parallel()
-
-	type req struct {
-		method      string
-		route       string
-		contentType string
-		body        *dto.AddPlaceRequest
-	}
-
-	var (
-		placeID   = gofakeit.Number(1, 1000)
-		parentID  = gofakeit.Number(1, 1000)
-		title     = gofakeit.Phrase()
-		testError = errors.New(gofakeit.Phrase())
-		layout    = "2006-01-02 15:04:05"
-
-		correctReq = req{
-			method: fiber.MethodPost,
-			route:  "/v1/places",
-			body: &dto.AddPlaceRequest{
-				Title:    title,
-				ParentID: &parentID,
-			},
-			contentType: fiber.MIMEApplicationJSON,
-		}
-
-		repoRes = models.Place{
-			ID:        placeID,
-			Title:     title,
-			ParentID:  sql.NullInt64{Int64: int64(parentID), Valid: true},
-			CreatedAt: gofakeit.Date(),
-			UpdatedAt: gofakeit.Date(),
-		}
-
-		expectedRes = dto.PlaceResponse{
-			ID:        placeID,
-			ParentID:  &parentID,
-			Title:     repoRes.Title,
-			CreatedAt: repoRes.CreatedAt.Format(layout),
-			UpdatedAt: repoRes.UpdatedAt.Format(layout),
-		}
-	)
-
-	tests := []struct {
-		name          string
-		req           req
-		resCode       int
-		resBody       interface{}
-		placeRepoMock func(mc *minimock.Controller) PlaceRepository
-	}{
-		{
-			name:    "positive case",
-			req:     correctReq,
-			resCode: fiber.StatusOK,
-			resBody: expectedRes,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) {
-					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, int64(parentID), req.ParentID.Int64)
-				}).Return(placeID, nil)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(&repoRes, nil)
-
-				return mock
-			},
-		},
-		{
-			name: "negative case - body parse error",
-			req: req{
-				method: fiber.MethodPost,
-				route:  "/v1/places",
-			},
-			resCode: fiber.StatusBadRequest,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				return mocks.NewPlaceRepositoryMock(mc)
-			},
-		},
-		{
-			name: "negative case - request without title",
-			req: req{
-				method:      fiber.MethodPost,
-				route:       "/v1/places",
-				contentType: fiber.MIMEApplicationJSON,
-				body:        &dto.AddPlaceRequest{},
-			},
-			resCode: fiber.StatusBadRequest,
-			resBody: []*dto.ValidateErrorResponse{
-				{
-					Field: "AddPlaceRequest.Title",
-					Tag:   "required",
-				},
-			},
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				return mocks.NewPlaceRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (add place)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) {
-					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, int64(parentID), req.ParentID.Int64)
-				}).Return(0, testError)
-
-				return mock
-			},
-		},
-		{
-			name:    "negative case - repository error (get place)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.AddMock.Inspect(func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) {
-					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, int64(parentID), req.ParentID.Int64)
-				}).Return(placeID, nil)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			t.Parallel()
-
-			mc := minimock.NewController(t)
-			fiberApp := fiber.New()
-			fiberApp.Post("/v1/places", AddPlaceHandler(tt.placeRepoMock(mc)))
-
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
-			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
-
-			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
-			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
-			}
-		})
-	}
-}

+ 71 - 65
internal/api/v1/place/delete_place.go

@@ -1,11 +1,13 @@
 package place
 
 import (
+	"context"
 	"database/sql"
+	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
@@ -21,6 +23,7 @@ import (
 // @Accept      json
 // @Produce     json
 func DeletePlaceHandler(
+	tm TransactionManager,
 	placeRepository PlaceRepository,
 	thingRepository ThingRepository,
 	placeImageRepository PlaceImageRepository,
@@ -34,20 +37,24 @@ func DeletePlaceHandler(
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("placeId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		_, err = placeRepository.Get(ctx, id)
+		_, err = placeRepository.Get(ctx, uint64(id))
 		if err != nil {
-			if err == sql.ErrNoRows {
+			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusBadRequest, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		nestedRes, err := placeRepository.GetNestedPlaces(ctx, id)
+		nestedRes, err := placeRepository.GetNestedPlaces(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
@@ -55,88 +62,87 @@ func DeletePlaceHandler(
 			return fiber.NewError(fiber.StatusBadRequest, "")
 		}
 
-		placeImages, err := placeImageRepository.GetByPlaceID(ctx, id)
-		if err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
-
-		things, err := thingRepository.GetByPlaceID(ctx, id)
-		if err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
-
-		var thingImages []models.Image
-		thingIDs := make([]int, 0, len(things))
-
-		for _, thing := range things {
-			thingIDs = append(thingIDs, thing.ID)
+		err = tm.ReadCommitted(ctx, func(ctx context.Context) error {
+			placeImages, txErr := placeImageRepository.GetByPlaceID(ctx, uint64(id))
+			if txErr != nil {
+				return txErr
+			}
 
-			thingImagesRes, thingImagesErr := thingImageRepository.GetByThingID(ctx, thing.ID)
-			if thingImagesErr != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, thingImagesErr.Error())
+			things, txErr := thingRepository.GetByPlaceID(ctx, uint64(id))
+			if txErr != nil {
+				return txErr
 			}
 
-			thingImages = append(thingImages, thingImagesRes...)
-		}
+			var thingImages []models.Image
+			thingIDs := make([]uint64, 0, len(things))
 
-		tx, err := placeRepository.BeginTx(ctx, API.DefaultTxLevel)
-		if err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			for _, thing := range things {
+				thingIDs = append(thingIDs, thing.ID)
 
-		placeImageURLs := make([]string, 0, len(placeImages))
-		for i := range placeImages {
-			placeImageURLs = append(placeImageURLs, placeImages[i].Image)
+				thingImagesRes, thingImagesErr := thingImageRepository.GetByThingID(ctx, thing.ID)
+				if thingImagesErr != nil {
+					return thingImagesErr
+				}
 
-			if err = placeImageRepository.Delete(ctx, placeImages[i].ID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+				thingImages = append(thingImages, thingImagesRes...)
 			}
-		}
 
-		for i := range thingImages {
-			if err = thingImageRepository.Delete(ctx, thingImages[i].ID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+			placeImageURLs := make([]string, 0, len(placeImages))
+			for i := range placeImages {
+				placeImageURLs = append(placeImageURLs, placeImages[i].Image)
+				if txErr = placeImageRepository.Delete(ctx, placeImages[i].ID); txErr != nil {
+					return txErr
+				}
 			}
-		}
 
-		for _, thingID := range thingIDs {
-			if err = placeThingRepository.DeleteThing(ctx, thingID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+			for i := range thingImages {
+				if txErr = thingImageRepository.Delete(ctx, thingImages[i].ID); txErr != nil {
+					return txErr
+				}
 			}
 
-			if err = thingTagRepository.DeleteByThingID(ctx, thingID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
+			for _, thingID := range thingIDs {
+				if txErr = placeThingRepository.DeleteThing(ctx, thingID); txErr != nil {
+					return txErr
+				}
 
-			if err = thingNotificationRepository.Delete(ctx, thingID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
+				if txErr = thingTagRepository.DeleteByThingID(ctx, thingID); txErr != nil {
+					return txErr
+				}
 
-			if err = thingRepository.Delete(ctx, thingID, tx); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-			}
-		}
+				if txErr = thingNotificationRepository.Delete(ctx, thingID); txErr != nil {
+					return txErr
+				}
 
-		if err = placeRepository.Delete(ctx, id, tx); err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+				if txErr = thingRepository.Delete(ctx, thingID); txErr != nil {
+					return txErr
+				}
+			}
 
-		if err = placeRepository.CommitTx(tx); err != nil {
-			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
-		}
+			if txErr = placeRepository.Delete(ctx, uint64(id)); txErr != nil {
+				return txErr
+			}
 
-		if len(placeImageURLs) > 0 {
-			for i := range placeImageURLs {
-				if err = fileRepository.Delete(placeImageURLs[i]); err != nil {
-					return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+			if len(placeImageURLs) > 0 {
+				for i := range placeImageURLs {
+					if txErr = fileRepository.Delete(placeImageURLs[i]); txErr != nil {
+						return txErr
+					}
 				}
 			}
-		}
 
-		for i := range thingImages {
-			if err = fileRepository.Delete(thingImages[i].Image); err != nil {
-				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+			for i := range thingImages {
+				if txErr = fileRepository.Delete(thingImages[i].Image); txErr != nil {
+					return txErr
+				}
 			}
+
+			return nil
+		})
+
+		if err != nil {
+			logger.Error(ctx, err.Error())
+			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
 		return fctx.JSON(factory.CreateEmptyResponse())

+ 0 - 1443
internal/api/v1/place/delete_place_test.go

@@ -1,1443 +0,0 @@
-package place
-
-import (
-	"context"
-	"database/sql"
-	"errors"
-	"net/http/httptest"
-	"strconv"
-	"testing"
-
-	"github.com/brianvoe/gofakeit/v6"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/stretchr/testify/assert"
-
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
-)
-
-func TestDeletePlaceHandler(t *testing.T) {
-	t.Parallel()
-
-	type req struct {
-		method string
-		route  string
-	}
-
-	var (
-		placeID = gofakeit.Number(1, 1000)
-		thingID = gofakeit.Number(1, 1000)
-
-		placeImageID  = gofakeit.Number(1, 1000)
-		placeImageURL = gofakeit.URL()
-		thingImageID  = gofakeit.Number(1, 1000)
-		thingImageURL = gofakeit.URL()
-		testError     = errors.New(gofakeit.Phrase())
-
-		correctReq = req{
-			method: fiber.MethodDelete,
-			route:  "/v1/places/" + strconv.Itoa(placeID),
-		}
-
-		thingRepoRes = []models.Thing{
-			{
-				ID:      thingID,
-				PlaceID: placeID,
-			},
-		}
-
-		placeImageRepoRes = []models.Image{
-			{
-				ID:    placeImageID,
-				Image: placeImageURL,
-			},
-		}
-
-		thingImageRepoRes = []models.Image{
-			{
-				ID:    thingImageID,
-				Image: thingImageURL,
-			},
-		}
-	)
-
-	tests := []struct {
-		name                      string
-		req                       req
-		resCode                   int
-		resBody                   interface{}
-		placeRepoMock             func(mc *minimock.Controller) PlaceRepository
-		thingRepoMock             func(mc *minimock.Controller) ThingRepository
-		placeThingRepoMock        func(mc *minimock.Controller) PlaceThingRepository
-		thingImageRepoMock        func(mc *minimock.Controller) ThingImageRepository
-		placeImageRepoMock        func(mc *minimock.Controller) PlaceImageRepository
-		thingTagRepoMock          func(mc *minimock.Controller) ThingTagRepository
-		thingNotificationRepoMock func(mc *minimock.Controller) ThingNotificationRepository
-		fileRepoMock              func(mc *minimock.Controller) FileRepository
-	}{
-		{
-			name: "negative case - bad request",
-			req: req{
-				method: fiber.MethodDelete,
-				route:  "/v1/places/" + gofakeit.Word(),
-			},
-			resCode: fiber.StatusBadRequest,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				return mocks.NewPlaceRepositoryMock(mc)
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - bad request (place not found)",
-			req:     correctReq,
-			resCode: fiber.StatusBadRequest,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, sql.ErrNoRows)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (get place)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (get nested places)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - bad request (nested places exists)",
-			req:     correctReq,
-			resCode: fiber.StatusBadRequest,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return([]models.Place{{}}, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				return mocks.NewPlaceImageRepositoryMock(mc)
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (get place images)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				return mocks.NewThingRepositoryMock(mc)
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (get things)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				return mocks.NewThingImageRepositoryMock(mc)
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (get things images)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (begin tx)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, testError)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete place image)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete thing image)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				return mocks.NewPlaceThingRepositoryMock(mc)
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete place thing)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				return mocks.NewThingTagRepositoryMock(mc)
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete thing tags)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				return mocks.NewThingNotificationRepositoryMock(mc)
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete thing notifications)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete thing)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (delete place)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeID, id)
-				}).Return(testError)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error (commit tx)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(testError)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				return mocks.NewFileRepositoryMock(mc)
-			},
-		},
-		{
-			name:    "negative case - delete place image error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-				mock.DeleteMock.When(placeImageURL).Then(testError)
-				return mock
-			},
-		},
-		{
-			name:    "negative case - delete thing image error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-
-				mock.DeleteMock.When(placeImageURL).Then(nil)
-				mock.DeleteMock.When(thingImageURL).Then(testError)
-
-				return mock
-			},
-		},
-		{
-			name:    "positive case",
-			req:     correctReq,
-			resCode: fiber.StatusOK,
-			resBody: &dto.EmptyResponse{},
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, nil)
-
-				mock.BeginTxMock.Return(nil, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil)
-
-				mock.CommitTxMock.Return(nil)
-
-				return mock
-			},
-			thingRepoMock: func(mc *minimock.Controller) ThingRepository {
-				mock := mocks.NewThingRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(thingRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeThingRepoMock: func(mc *minimock.Controller) PlaceThingRepository {
-				mock := mocks.NewPlaceThingRepositoryMock(mc)
-
-				mock.DeleteThingMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingImageRepoMock: func(mc *minimock.Controller) ThingImageRepository {
-				mock := mocks.NewThingImageRepositoryMock(mc)
-
-				mock.GetByThingIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, thingID, id)
-				}).Return(thingImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			placeImageRepoMock: func(mc *minimock.Controller) PlaceImageRepository {
-				mock := mocks.NewPlaceImageRepositoryMock(mc)
-
-				mock.GetByPlaceIDMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(placeImageRepoRes, nil)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, placeImageID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingTagRepoMock: func(mc *minimock.Controller) ThingTagRepository {
-				mock := mocks.NewThingTagRepositoryMock(mc)
-
-				mock.DeleteByThingIDMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			thingNotificationRepoMock: func(mc *minimock.Controller) ThingNotificationRepository {
-				mock := mocks.NewThingNotificationRepositoryMock(mc)
-
-				mock.DeleteMock.Inspect(func(ctx context.Context, id int, tx *sql.Tx) {
-					assert.Equal(mc, thingID, id)
-				}).Return(nil)
-
-				return mock
-			},
-			fileRepoMock: func(mc *minimock.Controller) FileRepository {
-				mock := mocks.NewFileRepositoryMock(mc)
-
-				mock.DeleteMock.When(placeImageURL).Then(nil)
-				mock.DeleteMock.When(thingImageURL).Then(nil)
-
-				return mock
-			},
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			t.Parallel()
-
-			mc := minimock.NewController(t)
-			fiberApp := fiber.New()
-
-			fiberApp.Delete("/v1/places/:placeId", DeletePlaceHandler(
-				tt.placeRepoMock(mc),
-				tt.thingRepoMock(mc),
-				tt.placeImageRepoMock(mc),
-				tt.thingImageRepoMock(mc),
-				tt.placeThingRepoMock(mc),
-				tt.thingTagRepoMock(mc),
-				tt.thingNotificationRepoMock(mc),
-				tt.fileRepoMock(mc),
-			))
-
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
-			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
-			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
-			}
-		})
-	}
-}

+ 7 - 3
internal/api/v1/place/get_place.go

@@ -4,9 +4,10 @@ import (
 	"database/sql"
 	"errors"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -26,19 +27,22 @@ func GetPlaceHandler(placeRepository PlaceRepository) fiber.Handler {
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("placeId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		res, err := placeRepository.Get(ctx, id)
+		res, err := placeRepository.Get(ctx, uint64(id))
 		if err != nil {
 			if errors.Is(err, sql.ErrNoRows) {
+				logger.Info(ctx, err.Error())
 				return fiber.NewError(fiber.StatusNotFound, "")
 			}
 
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlaceResponse(*res))
 	}

+ 6 - 3
internal/api/v1/place/get_place_nested.go

@@ -1,9 +1,10 @@
 package place
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -22,15 +23,17 @@ func GetNestedPlacesHandler(placeRepository PlaceRepository) fiber.Handler {
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("parentPlaceId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
-		res, err := placeRepository.GetNestedPlaces(ctx, id)
+		res, err := placeRepository.GetNestedPlaces(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlacesResponse(res))
 	}

+ 11 - 10
internal/api/v1/place/get_place_nested_test.go

@@ -3,7 +3,6 @@ package place
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -13,10 +12,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -29,13 +27,13 @@ func TestGetNestedPlacesHandler(t *testing.T) {
 	}
 
 	var (
-		placeID   = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
+		placeID   = uint64(gofakeit.Number(1, 1000))
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodGet,
-			route:  "/v1/places/" + strconv.Itoa(placeID) + "/nested",
+			route:  "/v1/places/" + strconv.FormatUint(placeID, 10) + "/nested",
 		}
 
 		repoRes = []models.Place{
@@ -76,7 +74,7 @@ func TestGetNestedPlacesHandler(t *testing.T) {
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
 				mock := mocks.NewPlaceRepositoryMock(mc)
 
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(repoRes, nil)
 
@@ -90,7 +88,7 @@ func TestGetNestedPlacesHandler(t *testing.T) {
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
 				mock := mocks.NewPlaceRepositoryMock(mc)
 
-				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetNestedPlacesMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(nil, testError)
 
@@ -119,10 +117,13 @@ func TestGetNestedPlacesHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/places/:parentPlaceId/nested", GetNestedPlacesHandler(tt.placeRepoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 0 - 138
internal/api/v1/place/get_place_test.go

@@ -1,138 +0,0 @@
-package place
-
-import (
-	"context"
-	"database/sql"
-	"errors"
-	"net/http/httptest"
-	"strconv"
-	"testing"
-
-	"github.com/brianvoe/gofakeit/v6"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/stretchr/testify/assert"
-
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
-)
-
-func TestGetPlaceHandler(t *testing.T) {
-	t.Parallel()
-
-	type req struct {
-		method string
-		route  string
-	}
-
-	var (
-		placeID   = gofakeit.Number(1, 1000)
-		parentID  = gofakeit.Number(1, 1000)
-		testError = errors.New(gofakeit.Phrase())
-		layout    = "2006-01-02 15:04:05"
-
-		correctReq = req{
-			method: fiber.MethodGet,
-			route:  "/v1/places/" + strconv.Itoa(placeID),
-		}
-
-		repoRes = models.Place{
-			ID:        placeID,
-			ParentID:  sql.NullInt64{Int64: int64(parentID), Valid: true},
-			Title:     gofakeit.Phrase(),
-			CreatedAt: gofakeit.Date(),
-			UpdatedAt: gofakeit.Date(),
-		}
-
-		expectedRes = dto.PlaceResponse{
-			ID:        placeID,
-			Title:     repoRes.Title,
-			ParentID:  &parentID,
-			CreatedAt: repoRes.CreatedAt.Format(layout),
-			UpdatedAt: repoRes.UpdatedAt.Format(layout),
-		}
-	)
-
-	tests := []struct {
-		name          string
-		req           req
-		resCode       int
-		resBody       interface{}
-		placeRepoMock func(mc *minimock.Controller) PlaceRepository
-	}{
-		{
-			name:    "positive case",
-			req:     correctReq,
-			resCode: fiber.StatusOK,
-			resBody: expectedRes,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(&repoRes, nil)
-
-				return mock
-			},
-		},
-		{
-			name:    "negative case - not found",
-			req:     correctReq,
-			resCode: fiber.StatusNotFound,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, sql.ErrNoRows)
-
-				return mock
-			},
-		},
-		{
-			name:    "negative case - repository error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				mock := mocks.NewPlaceRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
-					assert.Equal(mc, placeID, id)
-				}).Return(nil, testError)
-
-				return mock
-			},
-		},
-		{
-			name: "negative case - bad request",
-			req: req{
-				method: fiber.MethodGet,
-				route:  "/v1/places/" + gofakeit.Word(),
-			},
-			resCode: fiber.StatusBadRequest,
-			resBody: nil,
-			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
-				return mocks.NewPlaceRepositoryMock(mc)
-			},
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			t.Parallel()
-
-			mc := minimock.NewController(t)
-			fiberApp := fiber.New()
-			fiberApp.Get("/v1/places/:placeId", GetPlaceHandler(tt.placeRepoMock(mc)))
-
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
-			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
-			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
-			}
-		})
-	}
-}

+ 6 - 3
internal/api/v1/place/get_place_tree.go

@@ -1,9 +1,10 @@
 package place
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -17,12 +18,14 @@ import (
 // @Produce     json
 func GetPlaceTreeHandler(placeRepository PlaceRepository) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
-		res, err := placeRepository.GetAll(fctx.Context())
+		ctx := fctx.Context()
+		res, err := placeRepository.GetAll(ctx)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlaceTreeResponse(res))
 	}

+ 10 - 9
internal/api/v1/place/get_place_tree_test.go

@@ -2,7 +2,6 @@ package place
 
 import (
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"testing"
 
@@ -11,10 +10,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -27,12 +25,12 @@ func TestGetPlaceTreeHandler(t *testing.T) {
 	}
 
 	var (
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
-		id1 = gofakeit.Number(1, 1000)
-		id2 = gofakeit.Number(1, 1000)
-		id3 = gofakeit.Number(1, 1000)
+		id1 = uint64(gofakeit.Number(1, 1000))
+		id2 = uint64(gofakeit.Number(1, 1000))
+		id3 = uint64(gofakeit.Number(1, 1000))
 
 		correctReq = req{
 			method: fiber.MethodGet,
@@ -137,10 +135,13 @@ func TestGetPlaceTreeHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/places/tree", GetPlaceTreeHandler(tt.placeRepoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 6 - 3
internal/api/v1/place/get_places.go

@@ -1,9 +1,10 @@
 package place
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -17,12 +18,14 @@ import (
 // @Produce     json
 func GetPlacesHandler(placeRepository PlaceRepository) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
-		res, err := placeRepository.GetAll(fctx.Context())
+		ctx := fctx.Context()
+		res, err := placeRepository.GetAll(ctx)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlacesResponse(res))
 	}

+ 10 - 9
internal/api/v1/place/get_places_test.go

@@ -2,7 +2,6 @@ package place
 
 import (
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"testing"
 
@@ -11,10 +10,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -27,12 +25,12 @@ func TestGetPlacesHandler(t *testing.T) {
 	}
 
 	var (
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
-		id1 = gofakeit.Number(1, 1000)
-		id2 = gofakeit.Number(1, 1000)
-		id3 = gofakeit.Number(1, 1000)
+		id1 = uint64(gofakeit.Number(1, 1000))
+		id2 = uint64(gofakeit.Number(1, 1000))
+		id3 = uint64(gofakeit.Number(1, 1000))
 
 		correctReq = req{
 			method: fiber.MethodGet,
@@ -127,10 +125,13 @@ func TestGetPlacesHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Get("/v1/places", GetPlacesHandler(tt.placeRepoMock(mc)))
 
-			fiberRes, _ := fiberApp.Test(httptest.NewRequest(tt.req.method, tt.req.route, nil), API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(
+				httptest.NewRequest(tt.req.method, tt.req.route, nil),
+				test.TestTimeout,
+			)
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 1 - 1
internal/api/v1/place/mocks/file_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 

+ 47 - 76
internal/api/v1/place/mocks/place_image_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,14 +19,14 @@ type PlaceImageRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, imageID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, imageID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mPlaceImageRepositoryMockDelete
 
-	funcGetByPlaceID          func(ctx context.Context, placeID int) (ia1 []models.Image, err error)
-	inspectFuncGetByPlaceID   func(ctx context.Context, placeID int)
+	funcGetByPlaceID          func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
+	inspectFuncGetByPlaceID   func(ctx context.Context, id uint64)
 	afterGetByPlaceIDCounter  uint64
 	beforeGetByPlaceIDCounter uint64
 	GetByPlaceIDMock          mPlaceImageRepositoryMockGetByPlaceID
@@ -75,16 +74,14 @@ type PlaceImageRepositoryMockDeleteExpectation struct {
 
 // PlaceImageRepositoryMockDeleteParams contains parameters of the PlaceImageRepository.Delete
 type PlaceImageRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	imageID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // PlaceImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the PlaceImageRepository.Delete
 type PlaceImageRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	imageID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // PlaceImageRepositoryMockDeleteResults contains results of the PlaceImageRepository.Delete
@@ -103,7 +100,7 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) Optional() *mPlaceImageReposito
 }
 
 // Expect sets up expected params for PlaceImageRepository.Delete
-func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, imageID int, tx *sql.Tx) *mPlaceImageRepositoryMockDelete {
+func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -116,7 +113,7 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, ima
 		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mmDelete.defaultExpectation.params = &PlaceImageRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -148,8 +145,8 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Con
 	return mmDelete
 }
 
-// ExpectImageIDParam2 sets up expected param imageID for PlaceImageRepository.Delete
-func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectImageIDParam2(imageID int) *mPlaceImageRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for PlaceImageRepository.Delete
+func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -165,35 +162,13 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectImageIDParam2(imageID int
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.imageID = &imageID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for PlaceImageRepository.Delete
-func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mPlaceImageRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Delete
-func (mmDelete *mPlaceImageRepositoryMockDelete) Inspect(f func(ctx context.Context, imageID int, tx *sql.Tx)) *mPlaceImageRepositoryMockDelete {
+func (mmDelete *mPlaceImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Delete")
 	}
@@ -217,7 +192,7 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) Return(err error) *PlaceImageRe
 }
 
 // Set uses given function f to mock the PlaceImageRepository.Delete method
-func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context, imageID int, tx *sql.Tx) (err error)) *PlaceImageRepositoryMock {
+func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceImageRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Delete method")
 	}
@@ -232,14 +207,14 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context,
 
 // When sets expectation for the PlaceImageRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mPlaceImageRepositoryMockDelete) When(ctx context.Context, imageID int, tx *sql.Tx) *PlaceImageRepositoryMockDeleteExpectation {
+func (mmDelete *mPlaceImageRepositoryMockDelete) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &PlaceImageRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx},
+		params: &PlaceImageRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -272,15 +247,15 @@ func (mmDelete *mPlaceImageRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements place.PlaceImageRepository
-func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, imageID int, tx *sql.Tx) (err error) {
+func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, imageID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mm_params := PlaceImageRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -299,7 +274,7 @@ func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, imageID in
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx}
+		mm_got := PlaceImageRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -307,12 +282,8 @@ func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, imageID in
 				mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.imageID != nil && !minimock.Equal(*mm_want_ptrs.imageID, mm_got.imageID) {
-				mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter imageID, want: %#v, got: %#v%s\n", *mm_want_ptrs.imageID, mm_got.imageID, minimock.Diff(*mm_want_ptrs.imageID, mm_got.imageID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -326,9 +297,9 @@ func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, imageID in
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, imageID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Delete. %v %v %v", ctx, imageID, tx)
+	mmDelete.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 
@@ -423,14 +394,14 @@ type PlaceImageRepositoryMockGetByPlaceIDExpectation struct {
 
 // PlaceImageRepositoryMockGetByPlaceIDParams contains parameters of the PlaceImageRepository.GetByPlaceID
 type PlaceImageRepositoryMockGetByPlaceIDParams struct {
-	ctx     context.Context
-	placeID int
+	ctx context.Context
+	id  uint64
 }
 
 // PlaceImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the PlaceImageRepository.GetByPlaceID
 type PlaceImageRepositoryMockGetByPlaceIDParamPtrs struct {
-	ctx     *context.Context
-	placeID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // PlaceImageRepositoryMockGetByPlaceIDResults contains results of the PlaceImageRepository.GetByPlaceID
@@ -450,7 +421,7 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Optional() *mPlaceI
 }
 
 // Expect sets up expected params for PlaceImageRepository.GetByPlaceID
-func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mPlaceImageRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -463,7 +434,7 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.
 		mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByPlaceID.defaultExpectation.params = &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mmGetByPlaceID.defaultExpectation.params = &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
 	for _, e := range mmGetByPlaceID.expectations {
 		if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
 			mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
@@ -495,8 +466,8 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx
 	return mmGetByPlaceID
 }
 
-// ExpectPlaceIDParam2 sets up expected param placeID for PlaceImageRepository.GetByPlaceID
-func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mPlaceImageRepositoryMockGetByPlaceID {
+// ExpectIdParam2 sets up expected param id for PlaceImageRepository.GetByPlaceID
+func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -512,13 +483,13 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectPlaceIDParam2
 	if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
 		mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{}
 	}
-	mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
+	mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByPlaceID
 }
 
 // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.GetByPlaceID
-func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mPlaceImageRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.GetByPlaceID")
 	}
@@ -542,7 +513,7 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Return(ia1 []models
 }
 
 // Set uses given function f to mock the PlaceImageRepository.GetByPlaceID method
-func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ia1 []models.Image, err error)) *PlaceImageRepositoryMock {
+func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *PlaceImageRepositoryMock {
 	if mmGetByPlaceID.defaultExpectation != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.GetByPlaceID method")
 	}
@@ -557,14 +528,14 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx cont
 
 // When sets expectation for the PlaceImageRepository.GetByPlaceID which will trigger the result defined by the following
 // Then helper
-func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *PlaceImageRepositoryMockGetByPlaceIDExpectation {
+func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockGetByPlaceIDExpectation {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
 
 	expectation := &PlaceImageRepositoryMockGetByPlaceIDExpectation{
 		mock:   mmGetByPlaceID.mock,
-		params: &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID},
+		params: &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id},
 	}
 	mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
 	return expectation
@@ -597,15 +568,15 @@ func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) invocationsDone() b
 }
 
 // GetByPlaceID implements place.PlaceImageRepository
-func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ia1 []models.Image, err error) {
+func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
 	mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
 
 	if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
-		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
+		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
 	}
 
-	mm_params := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mm_params := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
 
 	// Record call args
 	mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
@@ -624,7 +595,7 @@ func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context
 		mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID}
+		mm_got := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -632,8 +603,8 @@ func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context
 				mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
-				mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -647,9 +618,9 @@ func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context
 		return (*mm_results).ia1, (*mm_results).err
 	}
 	if mmGetByPlaceID.funcGetByPlaceID != nil {
-		return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
+		return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
 	}
-	mmGetByPlaceID.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
+	mmGetByPlaceID.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.GetByPlaceID. %v %v", ctx, id)
 	return
 }
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 43 - 727
internal/api/v1/place/mocks/place_repository_minimock.go


+ 24 - 53
internal/api/v1/place/mocks/place_thing_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -19,8 +18,8 @@ type PlaceThingRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDeleteThing          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDeleteThing   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDeleteThing          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDeleteThing   func(ctx context.Context, id uint64)
 	afterDeleteThingCounter  uint64
 	beforeDeleteThingCounter uint64
 	DeleteThingMock          mPlaceThingRepositoryMockDeleteThing
@@ -65,16 +64,14 @@ type PlaceThingRepositoryMockDeleteThingExpectation struct {
 
 // PlaceThingRepositoryMockDeleteThingParams contains parameters of the PlaceThingRepository.DeleteThing
 type PlaceThingRepositoryMockDeleteThingParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // PlaceThingRepositoryMockDeleteThingParamPtrs contains pointers to parameters of the PlaceThingRepository.DeleteThing
 type PlaceThingRepositoryMockDeleteThingParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // PlaceThingRepositoryMockDeleteThingResults contains results of the PlaceThingRepository.DeleteThing
@@ -93,7 +90,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Optional() *mPlaceThi
 }
 
 // Expect sets up expected params for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, id uint64) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
@@ -106,7 +103,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Co
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by ExpectParams functions")
 	}
 
-	mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+	mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 	for _, e := range mmDeleteThing.expectations {
 		if minimock.Equal(e.params, mmDeleteThing.defaultExpectation.params) {
 			mmDeleteThing.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteThing.defaultExpectation.params)
@@ -138,8 +135,8 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectCtxParam1(ctx c
 	return mmDeleteThing
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectThingIDParam2(thingID int) *mPlaceThingRepositoryMockDeleteThing {
+// ExpectIdParam2 sets up expected param id for PlaceThingRepository.DeleteThing
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectIdParam2(id uint64) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
@@ -155,35 +152,13 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectThingIDParam2(t
 	if mmDeleteThing.defaultExpectation.paramPtrs == nil {
 		mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
 	}
-	mmDeleteThing.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDeleteThing
-}
-
-// ExpectTxParam3 sets up expected param tx for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
-	if mmDeleteThing.mock.funcDeleteThing != nil {
-		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
-	}
-
-	if mmDeleteThing.defaultExpectation == nil {
-		mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
-	}
-
-	if mmDeleteThing.defaultExpectation.params != nil {
-		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
-	}
-
-	if mmDeleteThing.defaultExpectation.paramPtrs == nil {
-		mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
-	}
-	mmDeleteThing.defaultExpectation.paramPtrs.tx = &tx
+	mmDeleteThing.defaultExpectation.paramPtrs.id = &id
 
 	return mmDeleteThing
 }
 
 // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mPlaceThingRepositoryMockDeleteThing {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, id uint64)) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.inspectFuncDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.DeleteThing")
 	}
@@ -207,7 +182,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Return(err error) *Pl
 }
 
 // Set uses given function f to mock the PlaceThingRepository.DeleteThing method
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceThingRepositoryMock {
 	if mmDeleteThing.defaultExpectation != nil {
 		mmDeleteThing.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.DeleteThing method")
 	}
@@ -222,14 +197,14 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx contex
 
 // When sets expectation for the PlaceThingRepository.DeleteThing which will trigger the result defined by the following
 // Then helper
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, thingID int, tx *sql.Tx) *PlaceThingRepositoryMockDeleteThingExpectation {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, id uint64) *PlaceThingRepositoryMockDeleteThingExpectation {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
 
 	expectation := &PlaceThingRepositoryMockDeleteThingExpectation{
 		mock:   mmDeleteThing.mock,
-		params: &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx},
+		params: &PlaceThingRepositoryMockDeleteThingParams{ctx, id},
 	}
 	mmDeleteThing.expectations = append(mmDeleteThing.expectations, expectation)
 	return expectation
@@ -262,15 +237,15 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) invocationsDone() boo
 }
 
 // DeleteThing implements place.PlaceThingRepository
-func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDeleteThing.beforeDeleteThingCounter, 1)
 	defer mm_atomic.AddUint64(&mmDeleteThing.afterDeleteThingCounter, 1)
 
 	if mmDeleteThing.inspectFuncDeleteThing != nil {
-		mmDeleteThing.inspectFuncDeleteThing(ctx, thingID, tx)
+		mmDeleteThing.inspectFuncDeleteThing(ctx, id)
 	}
 
-	mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+	mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 
 	// Record call args
 	mmDeleteThing.DeleteThingMock.mutex.Lock()
@@ -289,7 +264,7 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 		mm_want := mmDeleteThing.DeleteThingMock.defaultExpectation.params
 		mm_want_ptrs := mmDeleteThing.DeleteThingMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+		mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -297,12 +272,8 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -316,9 +287,9 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 		return (*mm_results).err
 	}
 	if mmDeleteThing.funcDeleteThing != nil {
-		return mmDeleteThing.funcDeleteThing(ctx, thingID, tx)
+		return mmDeleteThing.funcDeleteThing(ctx, id)
 	}
-	mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v %v", ctx, thingID, tx)
+	mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v", ctx, id)
 	return
 }
 

+ 47 - 76
internal/api/v1/place/mocks/thing_image_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,14 +19,14 @@ type ThingImageRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, imageID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, imageID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingImageRepositoryMockDelete
 
-	funcGetByThingID          func(ctx context.Context, thingID int) (ia1 []models.Image, err error)
-	inspectFuncGetByThingID   func(ctx context.Context, thingID int)
+	funcGetByThingID          func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
+	inspectFuncGetByThingID   func(ctx context.Context, id uint64)
 	afterGetByThingIDCounter  uint64
 	beforeGetByThingIDCounter uint64
 	GetByThingIDMock          mThingImageRepositoryMockGetByThingID
@@ -75,16 +74,14 @@ type ThingImageRepositoryMockDeleteExpectation struct {
 
 // ThingImageRepositoryMockDeleteParams contains parameters of the ThingImageRepository.Delete
 type ThingImageRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	imageID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingImageRepository.Delete
 type ThingImageRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	imageID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingImageRepositoryMockDeleteResults contains results of the ThingImageRepository.Delete
@@ -103,7 +100,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Optional() *mThingImageReposito
 }
 
 // Expect sets up expected params for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, imageID int, tx *sql.Tx) *mThingImageRepositoryMockDelete {
+func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -116,7 +113,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, ima
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -148,8 +145,8 @@ func (mmDelete *mThingImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Con
 	return mmDelete
 }
 
-// ExpectImageIDParam2 sets up expected param imageID for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) ExpectImageIDParam2(imageID int) *mThingImageRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingImageRepository.Delete
+func (mmDelete *mThingImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -165,35 +162,13 @@ func (mmDelete *mThingImageRepositoryMockDelete) ExpectImageIDParam2(imageID int
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.imageID = &imageID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingImageRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, imageID int, tx *sql.Tx)) *mThingImageRepositoryMockDelete {
+func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Delete")
 	}
@@ -217,7 +192,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Return(err error) *ThingImageRe
 }
 
 // Set uses given function f to mock the ThingImageRepository.Delete method
-func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, imageID int, tx *sql.Tx) (err error)) *ThingImageRepositoryMock {
+func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingImageRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Delete method")
 	}
@@ -232,14 +207,14 @@ func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context,
 
 // When sets expectation for the ThingImageRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, imageID int, tx *sql.Tx) *ThingImageRepositoryMockDeleteExpectation {
+func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingImageRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingImageRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingImageRepositoryMockDeleteParams{ctx, imageID, tx},
+		params: &ThingImageRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -272,15 +247,15 @@ func (mmDelete *mThingImageRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements place.ThingImageRepository
-func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, imageID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mm_params := ThingImageRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -299,7 +274,7 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+		mm_got := ThingImageRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -307,12 +282,8 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.imageID != nil && !minimock.Equal(*mm_want_ptrs.imageID, mm_got.imageID) {
-				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter imageID, want: %#v, got: %#v%s\n", *mm_want_ptrs.imageID, mm_got.imageID, minimock.Diff(*mm_want_ptrs.imageID, mm_got.imageID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -326,9 +297,9 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, imageID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v %v", ctx, imageID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 
@@ -423,14 +394,14 @@ type ThingImageRepositoryMockGetByThingIDExpectation struct {
 
 // ThingImageRepositoryMockGetByThingIDParams contains parameters of the ThingImageRepository.GetByThingID
 type ThingImageRepositoryMockGetByThingIDParams struct {
-	ctx     context.Context
-	thingID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingImageRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByThingID
 type ThingImageRepositoryMockGetByThingIDParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingImageRepositoryMockGetByThingIDResults contains results of the ThingImageRepository.GetByThingID
@@ -450,7 +421,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Optional() *mThingI
 }
 
 // Expect sets up expected params for ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mThingImageRepositoryMockGetByThingID {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -463,7 +434,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+	mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 	for _, e := range mmGetByThingID.expectations {
 		if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
 			mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
@@ -495,8 +466,8 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectCtxParam1(ctx
 	return mmGetByThingID
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectThingIDParam2(thingID int) *mThingImageRepositoryMockGetByThingID {
+// ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByThingID
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -512,13 +483,13 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectThingIDParam2
 	if mmGetByThingID.defaultExpectation.paramPtrs == nil {
 		mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
 	}
-	mmGetByThingID.defaultExpectation.paramPtrs.thingID = &thingID
+	mmGetByThingID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByThingID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mThingImageRepositoryMockGetByThingID {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByThingID")
 	}
@@ -542,7 +513,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Return(ia1 []models
 }
 
 // Set uses given function f to mock the ThingImageRepository.GetByThingID method
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
 	if mmGetByThingID.defaultExpectation != nil {
 		mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByThingID method")
 	}
@@ -557,14 +528,14 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx cont
 
 // When sets expectation for the ThingImageRepository.GetByThingID which will trigger the result defined by the following
 // Then helper
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *ThingImageRepositoryMockGetByThingIDExpectation {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByThingIDExpectation {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
 
 	expectation := &ThingImageRepositoryMockGetByThingIDExpectation{
 		mock:   mmGetByThingID.mock,
-		params: &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID},
+		params: &ThingImageRepositoryMockGetByThingIDParams{ctx, id},
 	}
 	mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
 	return expectation
@@ -597,15 +568,15 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) invocationsDone() b
 }
 
 // GetByThingID implements place.ThingImageRepository
-func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, thingID int) (ia1 []models.Image, err error) {
+func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
 	mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
 
 	if mmGetByThingID.inspectFuncGetByThingID != nil {
-		mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
+		mmGetByThingID.inspectFuncGetByThingID(ctx, id)
 	}
 
-	mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+	mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 
 	// Record call args
 	mmGetByThingID.GetByThingIDMock.mutex.Lock()
@@ -624,7 +595,7 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 		mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+		mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -632,8 +603,8 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -647,9 +618,9 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 		return (*mm_results).ia1, (*mm_results).err
 	}
 	if mmGetByThingID.funcGetByThingID != nil {
-		return mmGetByThingID.funcGetByThingID(ctx, thingID)
+		return mmGetByThingID.funcGetByThingID(ctx, id)
 	}
-	mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, thingID)
+	mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, id)
 	return
 }
 

+ 24 - 53
internal/api/v1/place/mocks/thing_notification_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -19,8 +18,8 @@ type ThingNotificationRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingNotificationRepositoryMockDelete
@@ -65,16 +64,14 @@ type ThingNotificationRepositoryMockDeleteExpectation struct {
 
 // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
@@ -93,7 +90,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotifi
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -106,7 +103,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Conte
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -138,8 +135,8 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx cont
 	return mmDelete
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingNotificationRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
+func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -155,35 +152,13 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thin
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
 	}
@@ -207,7 +182,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *Thing
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Delete method
-func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
 	}
@@ -222,14 +197,14 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.C
 
 // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingNotificationRepositoryMockDeleteExpectation {
+func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx},
+		params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -262,15 +237,15 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements place.ThingNotificationRepository
-func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, thingID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -289,7 +264,7 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -297,12 +272,8 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -316,9 +287,9 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, thingID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 

+ 47 - 76
internal/api/v1/place/mocks/thing_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,14 +19,14 @@ type ThingRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingRepositoryMockDelete
 
-	funcGetByPlaceID          func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
-	inspectFuncGetByPlaceID   func(ctx context.Context, placeID int)
+	funcGetByPlaceID          func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
+	inspectFuncGetByPlaceID   func(ctx context.Context, id uint64)
 	afterGetByPlaceIDCounter  uint64
 	beforeGetByPlaceIDCounter uint64
 	GetByPlaceIDMock          mThingRepositoryMockGetByPlaceID
@@ -75,16 +74,14 @@ type ThingRepositoryMockDeleteExpectation struct {
 
 // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
 type ThingRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
 type ThingRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
@@ -103,7 +100,7 @@ func (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDele
 }
 
 // Expect sets up expected params for ThingRepository.Delete
-func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingRepositoryMockDelete {
+func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
 	}
@@ -116,7 +113,7 @@ func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID
 		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
+	mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -148,8 +145,8 @@ func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context)
 	return mmDelete
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Delete
-func (mmDelete *mThingRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingRepository.Delete
+func (mmDelete *mThingRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
 	}
@@ -165,35 +162,13 @@ func (mmDelete *mThingRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mT
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingRepository.Delete
-func (mmDelete *mThingRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
-func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingRepositoryMockDelete {
+func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
 	}
@@ -217,7 +192,7 @@ func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMo
 }
 
 // Set uses given function f to mock the ThingRepository.Delete method
-func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingRepositoryMock {
+func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
 	}
@@ -232,14 +207,14 @@ func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thin
 
 // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingRepositoryMockDeleteExpectation {
+func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingRepositoryMockDeleteParams{ctx, thingID, tx},
+		params: &ThingRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -272,15 +247,15 @@ func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements place.ThingRepository
-func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, thingID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
+	mm_params := ThingRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -299,7 +274,7 @@ func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
+		mm_got := ThingRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -307,12 +282,8 @@ func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx
 				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -326,9 +297,9 @@ func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, thingID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 
@@ -423,14 +394,14 @@ type ThingRepositoryMockGetByPlaceIDExpectation struct {
 
 // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
 type ThingRepositoryMockGetByPlaceIDParams struct {
-	ctx     context.Context
-	placeID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
 type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
-	ctx     *context.Context
-	placeID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
@@ -450,7 +421,7 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingReposi
 }
 
 // Expect sets up expected params for ThingRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -463,7 +434,7 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Conte
 		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, id}
 	for _, e := range mmGetByPlaceID.expectations {
 		if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
 			mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
@@ -495,8 +466,8 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx cont
 	return mmGetByPlaceID
 }
 
-// ExpectPlaceIDParam2 sets up expected param placeID for ThingRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingRepositoryMockGetByPlaceID {
+// ExpectIdParam2 sets up expected param id for ThingRepository.GetByPlaceID
+func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -512,13 +483,13 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(plac
 	if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
 		mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
 	}
-	mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
+	mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByPlaceID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
 	}
@@ -542,7 +513,7 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thin
 }
 
 // Set uses given function f to mock the ThingRepository.GetByPlaceID method
-func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
+func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
 	if mmGetByPlaceID.defaultExpectation != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
 	}
@@ -557,14 +528,14 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.C
 
 // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
 // Then helper
-func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetByPlaceIDExpectation {
+func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetByPlaceIDExpectation {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
 
 	expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
 		mock:   mmGetByPlaceID.mock,
-		params: &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID},
+		params: &ThingRepositoryMockGetByPlaceIDParams{ctx, id},
 	}
 	mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
 	return expectation
@@ -597,15 +568,15 @@ func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
 }
 
 // GetByPlaceID implements place.ThingRepository
-func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
+func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
 	mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
 
 	if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
-		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
+		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
 	}
 
-	mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
 
 	// Record call args
 	mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
@@ -624,7 +595,7 @@ func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, pla
 		mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
+		mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -632,8 +603,8 @@ func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, pla
 				mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
-				mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -647,9 +618,9 @@ func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, pla
 		return (*mm_results).ta1, (*mm_results).err
 	}
 	if mmGetByPlaceID.funcGetByPlaceID != nil {
-		return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
+		return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
 	}
-	mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
+	mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, id)
 	return
 }
 

+ 24 - 53
internal/api/v1/place/mocks/thing_tag_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -19,8 +18,8 @@ type ThingTagRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDeleteByThingID          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDeleteByThingID   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDeleteByThingID          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDeleteByThingID   func(ctx context.Context, id uint64)
 	afterDeleteByThingIDCounter  uint64
 	beforeDeleteByThingIDCounter uint64
 	DeleteByThingIDMock          mThingTagRepositoryMockDeleteByThingID
@@ -65,16 +64,14 @@ type ThingTagRepositoryMockDeleteByThingIDExpectation struct {
 
 // ThingTagRepositoryMockDeleteByThingIDParams contains parameters of the ThingTagRepository.DeleteByThingID
 type ThingTagRepositoryMockDeleteByThingIDParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingTagRepositoryMockDeleteByThingIDParamPtrs contains pointers to parameters of the ThingTagRepository.DeleteByThingID
 type ThingTagRepositoryMockDeleteByThingIDParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingTagRepositoryMockDeleteByThingIDResults contains results of the ThingTagRepository.DeleteByThingID
@@ -93,7 +90,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Optional() *mTh
 }
 
 // Expect sets up expected params for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingTagRepositoryMockDeleteByThingID {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx context.Context, id uint64) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
@@ -106,7 +103,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx cont
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by ExpectParams functions")
 	}
 
-	mmDeleteByThingID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+	mmDeleteByThingID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 	for _, e := range mmDeleteByThingID.expectations {
 		if minimock.Equal(e.params, mmDeleteByThingID.defaultExpectation.params) {
 			mmDeleteByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteByThingID.defaultExpectation.params)
@@ -138,8 +135,8 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectCtxParam1
 	return mmDeleteByThingID
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectThingIDParam2(thingID int) *mThingTagRepositoryMockDeleteByThingID {
+// ExpectIdParam2 sets up expected param id for ThingTagRepository.DeleteByThingID
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectIdParam2(id uint64) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
@@ -155,35 +152,13 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectThingIDPa
 	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
 		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
 	}
-	mmDeleteByThingID.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDeleteByThingID
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectTxParam3(tx *sql.Tx) *mThingTagRepositoryMockDeleteByThingID {
-	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
-		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
-	}
-
-	if mmDeleteByThingID.defaultExpectation == nil {
-		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{}
-	}
-
-	if mmDeleteByThingID.defaultExpectation.params != nil {
-		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Expect")
-	}
-
-	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
-		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
-	}
-	mmDeleteByThingID.defaultExpectation.paramPtrs.tx = &tx
+	mmDeleteByThingID.defaultExpectation.paramPtrs.id = &id
 
 	return mmDeleteByThingID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingTagRepositoryMockDeleteByThingID {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.inspectFuncDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.DeleteByThingID")
 	}
@@ -207,7 +182,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Return(err erro
 }
 
 // Set uses given function f to mock the ThingTagRepository.DeleteByThingID method
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingTagRepositoryMock {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx context.Context, id uint64) (err error)) *ThingTagRepositoryMock {
 	if mmDeleteByThingID.defaultExpectation != nil {
 		mmDeleteByThingID.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.DeleteByThingID method")
 	}
@@ -222,14 +197,14 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx
 
 // When sets expectation for the ThingTagRepository.DeleteByThingID which will trigger the result defined by the following
 // Then helper
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingTagRepositoryMockDeleteByThingIDExpectation {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) When(ctx context.Context, id uint64) *ThingTagRepositoryMockDeleteByThingIDExpectation {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockDeleteByThingIDExpectation{
 		mock:   mmDeleteByThingID.mock,
-		params: &ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx},
+		params: &ThingTagRepositoryMockDeleteByThingIDParams{ctx, id},
 	}
 	mmDeleteByThingID.expectations = append(mmDeleteByThingID.expectations, expectation)
 	return expectation
@@ -262,15 +237,15 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) invocationsDone
 }
 
 // DeleteByThingID implements place.ThingTagRepository
-func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDeleteByThingID.beforeDeleteByThingIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmDeleteByThingID.afterDeleteByThingIDCounter, 1)
 
 	if mmDeleteByThingID.inspectFuncDeleteByThingID != nil {
-		mmDeleteByThingID.inspectFuncDeleteByThingID(ctx, thingID, tx)
+		mmDeleteByThingID.inspectFuncDeleteByThingID(ctx, id)
 	}
 
-	mm_params := ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+	mm_params := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 
 	// Record call args
 	mmDeleteByThingID.DeleteByThingIDMock.mutex.Lock()
@@ -289,7 +264,7 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 		mm_want := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.params
 		mm_want_ptrs := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+		mm_got := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -297,12 +272,8 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -316,9 +287,9 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 		return (*mm_results).err
 	}
 	if mmDeleteByThingID.funcDeleteByThingID != nil {
-		return mmDeleteByThingID.funcDeleteByThingID(ctx, thingID, tx)
+		return mmDeleteByThingID.funcDeleteByThingID(ctx, id)
 	}
-	mmDeleteByThingID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByThingID. %v %v %v", ctx, thingID, tx)
+	mmDeleteByThingID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByThingID. %v %v", ctx, id)
 	return
 }
 

+ 10 - 4
internal/api/v1/place/update_place.go

@@ -1,12 +1,13 @@
 package place
 
 import (
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/location"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
 )
 
@@ -26,30 +27,35 @@ func UpdatePlaceHandler(placeRepository PlaceRepository) fiber.Handler {
 		ctx := fctx.Context()
 		id, err := fctx.ParamsInt("placeId")
 		if err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		req := dto.UpdatePlaceRequest{}
 		if err = fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err = validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
-		err = placeRepository.Update(ctx, mappers.ToUpdatePlaceRequest(id, req), nil)
+		err = placeRepository.Update(ctx, mappers.ToUpdatePlaceRequest(uint64(id), req))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res, err := placeRepository.Get(ctx, id)
+		res, err := placeRepository.Get(ctx, uint64(id))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
-		res = helpers.ApplyLocation(fctx, res)
+		res = location.ApplyLocation(fctx, res)
 
 		return fctx.JSON(mappers.ToPlaceResponse(*res))
 	}

+ 18 - 20
internal/api/v1/place/update_place_test.go

@@ -3,7 +3,6 @@ package place
 import (
 	"context"
 	"database/sql"
-	"errors"
 	"net/http/httptest"
 	"strconv"
 	"testing"
@@ -13,10 +12,9 @@ import (
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
 
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place/mocks"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers/test"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
@@ -31,15 +29,15 @@ func TestUpdatePlaceHandler(t *testing.T) {
 	}
 
 	var (
-		placeID   = gofakeit.Number(1, 1000)
-		parentID  = gofakeit.Number(1, 1000)
+		placeID   = uint64(gofakeit.Number(1, 1000))
+		parentID  = uint64(gofakeit.Number(1, 1000))
 		title     = gofakeit.Phrase()
-		testError = errors.New(gofakeit.Phrase())
+		testError = gofakeit.Error()
 		layout    = "2006-01-02 15:04:05"
 
 		correctReq = req{
 			method: fiber.MethodPut,
-			route:  "/v1/places/" + strconv.Itoa(placeID),
+			route:  "/v1/places/" + strconv.FormatUint(placeID, 10),
 			body: &dto.UpdatePlaceRequest{
 				Title:    title,
 				ParentID: &parentID,
@@ -79,12 +77,12 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
 				mock := mocks.NewPlaceRepositoryMock(mc)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest) {
 					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, parentID, int(req.ParentID.Int64))
+					assert.Equal(mc, parentID, uint64(req.ParentID.Int64))
 				}).Return(nil)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(&repoRes, nil)
 
@@ -106,7 +104,7 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			name: "negative case - body parse error",
 			req: req{
 				method: fiber.MethodPut,
-				route:  "/v1/places/" + strconv.Itoa(placeID),
+				route:  "/v1/places/" + strconv.FormatUint(placeID, 10),
 			},
 			resCode: fiber.StatusBadRequest,
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
@@ -117,7 +115,7 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			name: "negative case - request without title",
 			req: req{
 				method:      fiber.MethodPut,
-				route:       "/v1/places/" + strconv.Itoa(placeID),
+				route:       "/v1/places/" + strconv.FormatUint(placeID, 10),
 				contentType: fiber.MIMEApplicationJSON,
 				body:        &dto.UpdatePlaceRequest{},
 			},
@@ -139,9 +137,9 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
 				mock := mocks.NewPlaceRepositoryMock(mc)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest) {
 					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, parentID, int(req.ParentID.Int64))
+					assert.Equal(mc, parentID, uint64(req.ParentID.Int64))
 				}).Return(testError)
 
 				return mock
@@ -154,12 +152,12 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			placeRepoMock: func(mc *minimock.Controller) PlaceRepository {
 				mock := mocks.NewPlaceRepositoryMock(mc)
 
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) {
+				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdatePlaceRequest) {
 					assert.Equal(mc, title, req.Title)
-					assert.Equal(mc, parentID, int(req.ParentID.Int64))
+					assert.Equal(mc, parentID, uint64(req.ParentID.Int64))
 				}).Return(nil)
 
-				mock.GetMock.Inspect(func(ctx context.Context, id int) {
+				mock.GetMock.Inspect(func(ctx context.Context, id uint64) {
 					assert.Equal(mc, placeID, id)
 				}).Return(nil, testError)
 
@@ -176,13 +174,13 @@ func TestUpdatePlaceHandler(t *testing.T) {
 			fiberApp := fiber.New()
 			fiberApp.Put("/v1/places/:placeId", UpdatePlaceHandler(tt.placeRepoMock(mc)))
 
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
+			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, test.ConvertDataToIOReader(tt.req.body))
 			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
+			fiberRes, _ := fiberApp.Test(fiberReq, test.TestTimeout)
 
 			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
 			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
+				assert.Equal(t, test.MarshalResponse(tt.resBody), test.ConvertBodyToString(fiberRes.Body))
 			}
 		})
 	}

+ 9 - 12
internal/api/v1/tag/add_tag.go

@@ -6,7 +6,6 @@ package tag
 
 import (
 	"context"
-	"database/sql"
 
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
@@ -21,23 +20,21 @@ import (
 type (
 	TagRepository interface {
 		GetAll(ctx context.Context) ([]models.Tag, error)
-		Get(ctx context.Context, tagID int) (*models.Tag, error)
-		GetByThingID(ctx context.Context, thingID int) ([]models.Tag, error)
-		Add(ctx context.Context, req models.AddTagRequest, tx *sql.Tx) (int, error)
-		Update(ctx context.Context, req models.UpdateTagRequest, tx *sql.Tx) error
-		Delete(ctx context.Context, tagID int, tx *sql.Tx) error
-		BeginTx(ctx context.Context, level sql.IsolationLevel) (*sql.Tx, error)
-		CommitTx(tx *sql.Tx) error
+		Get(ctx context.Context, id uint64) (*models.Tag, error)
+		GetByThingID(ctx context.Context, id uint64) ([]models.Tag, error)
+		Add(ctx context.Context, req models.AddTagRequest) (uint64, error)
+		Update(ctx context.Context, req models.UpdateTagRequest) error
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	ThingRepository interface {
-		Get(ctx context.Context, thingID int) (*models.Thing, error)
+		Get(ctx context.Context, id uint64) (*models.Thing, error)
 	}
 
 	ThingTagRepository interface {
-		Add(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) error
-		Delete(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) error
-		DeleteByTagID(ctx context.Context, tagID int, tx *sql.Tx) error
+		Add(ctx context.Context, req models.AddThingTagRequest) error
+		Delete(ctx context.Context, req models.DeleteThingTagRequest) error
+		DeleteByTagID(ctx context.Context, id uint64) error
 	}
 )
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 43 - 727
internal/api/v1/tag/mocks/tag_repository_minimock.go


+ 24 - 24
internal/api/v1/tag/mocks/thing_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -19,8 +19,8 @@ type ThingRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcGet          func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)
-	inspectFuncGet   func(ctx context.Context, thingID int)
+	funcGet          func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)
+	inspectFuncGet   func(ctx context.Context, id uint64)
 	afterGetCounter  uint64
 	beforeGetCounter uint64
 	GetMock          mThingRepositoryMockGet
@@ -65,14 +65,14 @@ type ThingRepositoryMockGetExpectation struct {
 
 // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
 type ThingRepositoryMockGetParams struct {
-	ctx     context.Context
-	thingID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingRepositoryMockGetParamPtrs contains pointers to parameters of the ThingRepository.Get
 type ThingRepositoryMockGetParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
@@ -92,7 +92,7 @@ func (mmGet *mThingRepositoryMockGet) Optional() *mThingRepositoryMockGet {
 }
 
 // Expect sets up expected params for ThingRepository.Get
-func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingRepositoryMockGet {
+func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGet {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
 	}
@@ -105,7 +105,7 @@ func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *
 		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by ExpectParams functions")
 	}
 
-	mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, thingID}
+	mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, id}
 	for _, e := range mmGet.expectations {
 		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
 			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
@@ -137,8 +137,8 @@ func (mmGet *mThingRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThi
 	return mmGet
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Get
-func (mmGet *mThingRepositoryMockGet) ExpectThingIDParam2(thingID int) *mThingRepositoryMockGet {
+// ExpectIdParam2 sets up expected param id for ThingRepository.Get
+func (mmGet *mThingRepositoryMockGet) ExpectIdParam2(id uint64) *mThingRepositoryMockGet {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
 	}
@@ -154,13 +154,13 @@ func (mmGet *mThingRepositoryMockGet) ExpectThingIDParam2(thingID int) *mThingRe
 	if mmGet.defaultExpectation.paramPtrs == nil {
 		mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
 	}
-	mmGet.defaultExpectation.paramPtrs.thingID = &thingID
+	mmGet.defaultExpectation.paramPtrs.id = &id
 
 	return mmGet
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
-func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingRepositoryMockGet {
+func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGet {
 	if mmGet.mock.inspectFuncGet != nil {
 		mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
 	}
@@ -184,7 +184,7 @@ func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *Thin
 }
 
 // Set uses given function f to mock the ThingRepository.Get method
-func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
+func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
 	if mmGet.defaultExpectation != nil {
 		mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
 	}
@@ -199,14 +199,14 @@ func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID in
 
 // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
 // Then helper
-func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, thingID int) *ThingRepositoryMockGetExpectation {
+func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, id uint64) *ThingRepositoryMockGetExpectation {
 	if mmGet.mock.funcGet != nil {
 		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
 	}
 
 	expectation := &ThingRepositoryMockGetExpectation{
 		mock:   mmGet.mock,
-		params: &ThingRepositoryMockGetParams{ctx, thingID},
+		params: &ThingRepositoryMockGetParams{ctx, id},
 	}
 	mmGet.expectations = append(mmGet.expectations, expectation)
 	return expectation
@@ -239,15 +239,15 @@ func (mmGet *mThingRepositoryMockGet) invocationsDone() bool {
 }
 
 // Get implements tag.ThingRepository
-func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.Thing, err error) {
+func (mmGet *ThingRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.Thing, err error) {
 	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
 	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
 
 	if mmGet.inspectFuncGet != nil {
-		mmGet.inspectFuncGet(ctx, thingID)
+		mmGet.inspectFuncGet(ctx, id)
 	}
 
-	mm_params := ThingRepositoryMockGetParams{ctx, thingID}
+	mm_params := ThingRepositoryMockGetParams{ctx, id}
 
 	// Record call args
 	mmGet.GetMock.mutex.Lock()
@@ -266,7 +266,7 @@ func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *mo
 		mm_want := mmGet.GetMock.defaultExpectation.params
 		mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingRepositoryMockGetParams{ctx, thingID}
+		mm_got := ThingRepositoryMockGetParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -274,8 +274,8 @@ func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *mo
 				mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -289,9 +289,9 @@ func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *mo
 		return (*mm_results).tp1, (*mm_results).err
 	}
 	if mmGet.funcGet != nil {
-		return mmGet.funcGet(ctx, thingID)
+		return mmGet.funcGet(ctx, id)
 	}
-	mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, thingID)
+	mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, id)
 	return
 }
 

+ 52 - 137
internal/api/v1/tag/mocks/thing_tag_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,20 +19,20 @@ type ThingTagRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcAdd          func(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) (err error)
-	inspectFuncAdd   func(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx)
+	funcAdd          func(ctx context.Context, req models.AddThingTagRequest) (err error)
+	inspectFuncAdd   func(ctx context.Context, req models.AddThingTagRequest)
 	afterAddCounter  uint64
 	beforeAddCounter uint64
 	AddMock          mThingTagRepositoryMockAdd
 
-	funcDelete          func(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, req models.DeleteThingTagRequest) (err error)
+	inspectFuncDelete   func(ctx context.Context, req models.DeleteThingTagRequest)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingTagRepositoryMockDelete
 
-	funcDeleteByTagID          func(ctx context.Context, tagID int, tx *sql.Tx) (err error)
-	inspectFuncDeleteByTagID   func(ctx context.Context, tagID int, tx *sql.Tx)
+	funcDeleteByTagID          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDeleteByTagID   func(ctx context.Context, id uint64)
 	afterDeleteByTagIDCounter  uint64
 	beforeDeleteByTagIDCounter uint64
 	DeleteByTagIDMock          mThingTagRepositoryMockDeleteByTagID
@@ -86,14 +85,12 @@ type ThingTagRepositoryMockAddExpectation struct {
 type ThingTagRepositoryMockAddParams struct {
 	ctx context.Context
 	req models.AddThingTagRequest
-	tx  *sql.Tx
 }
 
 // ThingTagRepositoryMockAddParamPtrs contains pointers to parameters of the ThingTagRepository.Add
 type ThingTagRepositoryMockAddParamPtrs struct {
 	ctx *context.Context
 	req *models.AddThingTagRequest
-	tx  **sql.Tx
 }
 
 // ThingTagRepositoryMockAddResults contains results of the ThingTagRepository.Add
@@ -112,7 +109,7 @@ func (mmAdd *mThingTagRepositoryMockAdd) Optional() *mThingTagRepositoryMockAdd
 }
 
 // Expect sets up expected params for ThingTagRepository.Add
-func (mmAdd *mThingTagRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) *mThingTagRepositoryMockAdd {
+func (mmAdd *mThingTagRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingTagRequest) *mThingTagRepositoryMockAdd {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("ThingTagRepositoryMock.Add mock is already set by Set")
 	}
@@ -125,7 +122,7 @@ func (mmAdd *mThingTagRepositoryMockAdd) Expect(ctx context.Context, req models.
 		mmAdd.mock.t.Fatalf("ThingTagRepositoryMock.Add mock is already set by ExpectParams functions")
 	}
 
-	mmAdd.defaultExpectation.params = &ThingTagRepositoryMockAddParams{ctx, req, tx}
+	mmAdd.defaultExpectation.params = &ThingTagRepositoryMockAddParams{ctx, req}
 	for _, e := range mmAdd.expectations {
 		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
 			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
@@ -179,30 +176,8 @@ func (mmAdd *mThingTagRepositoryMockAdd) ExpectReqParam2(req models.AddThingTagR
 	return mmAdd
 }
 
-// ExpectTxParam3 sets up expected param tx for ThingTagRepository.Add
-func (mmAdd *mThingTagRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mThingTagRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ThingTagRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ThingTagRepositoryMockAddExpectation{}
-	}
-
-	if mmAdd.defaultExpectation.params != nil {
-		mmAdd.mock.t.Fatalf("ThingTagRepositoryMock.Add mock is already set by Expect")
-	}
-
-	if mmAdd.defaultExpectation.paramPtrs == nil {
-		mmAdd.defaultExpectation.paramPtrs = &ThingTagRepositoryMockAddParamPtrs{}
-	}
-	mmAdd.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmAdd
-}
-
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.Add
-func (mmAdd *mThingTagRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx)) *mThingTagRepositoryMockAdd {
+func (mmAdd *mThingTagRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingTagRequest)) *mThingTagRepositoryMockAdd {
 	if mmAdd.mock.inspectFuncAdd != nil {
 		mmAdd.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.Add")
 	}
@@ -226,7 +201,7 @@ func (mmAdd *mThingTagRepositoryMockAdd) Return(err error) *ThingTagRepositoryMo
 }
 
 // Set uses given function f to mock the ThingTagRepository.Add method
-func (mmAdd *mThingTagRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) (err error)) *ThingTagRepositoryMock {
+func (mmAdd *mThingTagRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingTagRequest) (err error)) *ThingTagRepositoryMock {
 	if mmAdd.defaultExpectation != nil {
 		mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.Add method")
 	}
@@ -241,14 +216,14 @@ func (mmAdd *mThingTagRepositoryMockAdd) Set(f func(ctx context.Context, req mod
 
 // When sets expectation for the ThingTagRepository.Add which will trigger the result defined by the following
 // Then helper
-func (mmAdd *mThingTagRepositoryMockAdd) When(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) *ThingTagRepositoryMockAddExpectation {
+func (mmAdd *mThingTagRepositoryMockAdd) When(ctx context.Context, req models.AddThingTagRequest) *ThingTagRepositoryMockAddExpectation {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("ThingTagRepositoryMock.Add mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockAddExpectation{
 		mock:   mmAdd.mock,
-		params: &ThingTagRepositoryMockAddParams{ctx, req, tx},
+		params: &ThingTagRepositoryMockAddParams{ctx, req},
 	}
 	mmAdd.expectations = append(mmAdd.expectations, expectation)
 	return expectation
@@ -281,15 +256,15 @@ func (mmAdd *mThingTagRepositoryMockAdd) invocationsDone() bool {
 }
 
 // Add implements tag.ThingTagRepository
-func (mmAdd *ThingTagRepositoryMock) Add(ctx context.Context, req models.AddThingTagRequest, tx *sql.Tx) (err error) {
+func (mmAdd *ThingTagRepositoryMock) Add(ctx context.Context, req models.AddThingTagRequest) (err error) {
 	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
 	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
 
 	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, req, tx)
+		mmAdd.inspectFuncAdd(ctx, req)
 	}
 
-	mm_params := ThingTagRepositoryMockAddParams{ctx, req, tx}
+	mm_params := ThingTagRepositoryMockAddParams{ctx, req}
 
 	// Record call args
 	mmAdd.AddMock.mutex.Lock()
@@ -308,7 +283,7 @@ func (mmAdd *ThingTagRepositoryMock) Add(ctx context.Context, req models.AddThin
 		mm_want := mmAdd.AddMock.defaultExpectation.params
 		mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockAddParams{ctx, req, tx}
+		mm_got := ThingTagRepositoryMockAddParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -320,10 +295,6 @@ func (mmAdd *ThingTagRepositoryMock) Add(ctx context.Context, req models.AddThin
 				mmAdd.t.Errorf("ThingTagRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmAdd.t.Errorf("ThingTagRepositoryMock.Add got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmAdd.t.Errorf("ThingTagRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -335,9 +306,9 @@ func (mmAdd *ThingTagRepositoryMock) Add(ctx context.Context, req models.AddThin
 		return (*mm_results).err
 	}
 	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, req, tx)
+		return mmAdd.funcAdd(ctx, req)
 	}
-	mmAdd.t.Fatalf("Unexpected call to ThingTagRepositoryMock.Add. %v %v %v", ctx, req, tx)
+	mmAdd.t.Fatalf("Unexpected call to ThingTagRepositoryMock.Add. %v %v", ctx, req)
 	return
 }
 
@@ -434,14 +405,12 @@ type ThingTagRepositoryMockDeleteExpectation struct {
 type ThingTagRepositoryMockDeleteParams struct {
 	ctx context.Context
 	req models.DeleteThingTagRequest
-	tx  *sql.Tx
 }
 
 // ThingTagRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingTagRepository.Delete
 type ThingTagRepositoryMockDeleteParamPtrs struct {
 	ctx *context.Context
 	req *models.DeleteThingTagRequest
-	tx  **sql.Tx
 }
 
 // ThingTagRepositoryMockDeleteResults contains results of the ThingTagRepository.Delete
@@ -460,7 +429,7 @@ func (mmDelete *mThingTagRepositoryMockDelete) Optional() *mThingTagRepositoryMo
 }
 
 // Expect sets up expected params for ThingTagRepository.Delete
-func (mmDelete *mThingTagRepositoryMockDelete) Expect(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) *mThingTagRepositoryMockDelete {
+func (mmDelete *mThingTagRepositoryMockDelete) Expect(ctx context.Context, req models.DeleteThingTagRequest) *mThingTagRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingTagRepositoryMock.Delete mock is already set by Set")
 	}
@@ -473,7 +442,7 @@ func (mmDelete *mThingTagRepositoryMockDelete) Expect(ctx context.Context, req m
 		mmDelete.mock.t.Fatalf("ThingTagRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingTagRepositoryMockDeleteParams{ctx, req, tx}
+	mmDelete.defaultExpectation.params = &ThingTagRepositoryMockDeleteParams{ctx, req}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -527,30 +496,8 @@ func (mmDelete *mThingTagRepositoryMockDelete) ExpectReqParam2(req models.Delete
 	return mmDelete
 }
 
-// ExpectTxParam3 sets up expected param tx for ThingTagRepository.Delete
-func (mmDelete *mThingTagRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingTagRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingTagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingTagRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingTagRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmDelete
-}
-
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.Delete
-func (mmDelete *mThingTagRepositoryMockDelete) Inspect(f func(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx)) *mThingTagRepositoryMockDelete {
+func (mmDelete *mThingTagRepositoryMockDelete) Inspect(f func(ctx context.Context, req models.DeleteThingTagRequest)) *mThingTagRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.Delete")
 	}
@@ -574,7 +521,7 @@ func (mmDelete *mThingTagRepositoryMockDelete) Return(err error) *ThingTagReposi
 }
 
 // Set uses given function f to mock the ThingTagRepository.Delete method
-func (mmDelete *mThingTagRepositoryMockDelete) Set(f func(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) (err error)) *ThingTagRepositoryMock {
+func (mmDelete *mThingTagRepositoryMockDelete) Set(f func(ctx context.Context, req models.DeleteThingTagRequest) (err error)) *ThingTagRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.Delete method")
 	}
@@ -589,14 +536,14 @@ func (mmDelete *mThingTagRepositoryMockDelete) Set(f func(ctx context.Context, r
 
 // When sets expectation for the ThingTagRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingTagRepositoryMockDelete) When(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) *ThingTagRepositoryMockDeleteExpectation {
+func (mmDelete *mThingTagRepositoryMockDelete) When(ctx context.Context, req models.DeleteThingTagRequest) *ThingTagRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingTagRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingTagRepositoryMockDeleteParams{ctx, req, tx},
+		params: &ThingTagRepositoryMockDeleteParams{ctx, req},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -629,15 +576,15 @@ func (mmDelete *mThingTagRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements tag.ThingTagRepository
-func (mmDelete *ThingTagRepositoryMock) Delete(ctx context.Context, req models.DeleteThingTagRequest, tx *sql.Tx) (err error) {
+func (mmDelete *ThingTagRepositoryMock) Delete(ctx context.Context, req models.DeleteThingTagRequest) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, req, tx)
+		mmDelete.inspectFuncDelete(ctx, req)
 	}
 
-	mm_params := ThingTagRepositoryMockDeleteParams{ctx, req, tx}
+	mm_params := ThingTagRepositoryMockDeleteParams{ctx, req}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -656,7 +603,7 @@ func (mmDelete *ThingTagRepositoryMock) Delete(ctx context.Context, req models.D
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockDeleteParams{ctx, req, tx}
+		mm_got := ThingTagRepositoryMockDeleteParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -668,10 +615,6 @@ func (mmDelete *ThingTagRepositoryMock) Delete(ctx context.Context, req models.D
 				mmDelete.t.Errorf("ThingTagRepositoryMock.Delete got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingTagRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmDelete.t.Errorf("ThingTagRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -683,9 +626,9 @@ func (mmDelete *ThingTagRepositoryMock) Delete(ctx context.Context, req models.D
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, req, tx)
+		return mmDelete.funcDelete(ctx, req)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingTagRepositoryMock.Delete. %v %v %v", ctx, req, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingTagRepositoryMock.Delete. %v %v", ctx, req)
 	return
 }
 
@@ -780,16 +723,14 @@ type ThingTagRepositoryMockDeleteByTagIDExpectation struct {
 
 // ThingTagRepositoryMockDeleteByTagIDParams contains parameters of the ThingTagRepository.DeleteByTagID
 type ThingTagRepositoryMockDeleteByTagIDParams struct {
-	ctx   context.Context
-	tagID int
-	tx    *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingTagRepositoryMockDeleteByTagIDParamPtrs contains pointers to parameters of the ThingTagRepository.DeleteByTagID
 type ThingTagRepositoryMockDeleteByTagIDParamPtrs struct {
-	ctx   *context.Context
-	tagID *int
-	tx    **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingTagRepositoryMockDeleteByTagIDResults contains results of the ThingTagRepository.DeleteByTagID
@@ -808,7 +749,7 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Optional() *mThingT
 }
 
 // Expect sets up expected params for ThingTagRepository.DeleteByTagID
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Expect(ctx context.Context, tagID int, tx *sql.Tx) *mThingTagRepositoryMockDeleteByTagID {
+func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Expect(ctx context.Context, id uint64) *mThingTagRepositoryMockDeleteByTagID {
 	if mmDeleteByTagID.mock.funcDeleteByTagID != nil {
 		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by Set")
 	}
@@ -821,7 +762,7 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Expect(ctx context.
 		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by ExpectParams functions")
 	}
 
-	mmDeleteByTagID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByTagIDParams{ctx, tagID, tx}
+	mmDeleteByTagID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByTagIDParams{ctx, id}
 	for _, e := range mmDeleteByTagID.expectations {
 		if minimock.Equal(e.params, mmDeleteByTagID.defaultExpectation.params) {
 			mmDeleteByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteByTagID.defaultExpectation.params)
@@ -853,30 +794,8 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) ExpectCtxParam1(ctx
 	return mmDeleteByTagID
 }
 
-// ExpectTagIDParam2 sets up expected param tagID for ThingTagRepository.DeleteByTagID
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) ExpectTagIDParam2(tagID int) *mThingTagRepositoryMockDeleteByTagID {
-	if mmDeleteByTagID.mock.funcDeleteByTagID != nil {
-		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by Set")
-	}
-
-	if mmDeleteByTagID.defaultExpectation == nil {
-		mmDeleteByTagID.defaultExpectation = &ThingTagRepositoryMockDeleteByTagIDExpectation{}
-	}
-
-	if mmDeleteByTagID.defaultExpectation.params != nil {
-		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by Expect")
-	}
-
-	if mmDeleteByTagID.defaultExpectation.paramPtrs == nil {
-		mmDeleteByTagID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByTagIDParamPtrs{}
-	}
-	mmDeleteByTagID.defaultExpectation.paramPtrs.tagID = &tagID
-
-	return mmDeleteByTagID
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingTagRepository.DeleteByTagID
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) ExpectTxParam3(tx *sql.Tx) *mThingTagRepositoryMockDeleteByTagID {
+// ExpectIdParam2 sets up expected param id for ThingTagRepository.DeleteByTagID
+func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) ExpectIdParam2(id uint64) *mThingTagRepositoryMockDeleteByTagID {
 	if mmDeleteByTagID.mock.funcDeleteByTagID != nil {
 		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by Set")
 	}
@@ -892,13 +811,13 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) ExpectTxParam3(tx *
 	if mmDeleteByTagID.defaultExpectation.paramPtrs == nil {
 		mmDeleteByTagID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByTagIDParamPtrs{}
 	}
-	mmDeleteByTagID.defaultExpectation.paramPtrs.tx = &tx
+	mmDeleteByTagID.defaultExpectation.paramPtrs.id = &id
 
 	return mmDeleteByTagID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.DeleteByTagID
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Inspect(f func(ctx context.Context, tagID int, tx *sql.Tx)) *mThingTagRepositoryMockDeleteByTagID {
+func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Inspect(f func(ctx context.Context, id uint64)) *mThingTagRepositoryMockDeleteByTagID {
 	if mmDeleteByTagID.mock.inspectFuncDeleteByTagID != nil {
 		mmDeleteByTagID.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.DeleteByTagID")
 	}
@@ -922,7 +841,7 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Return(err error) *
 }
 
 // Set uses given function f to mock the ThingTagRepository.DeleteByTagID method
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Set(f func(ctx context.Context, tagID int, tx *sql.Tx) (err error)) *ThingTagRepositoryMock {
+func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Set(f func(ctx context.Context, id uint64) (err error)) *ThingTagRepositoryMock {
 	if mmDeleteByTagID.defaultExpectation != nil {
 		mmDeleteByTagID.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.DeleteByTagID method")
 	}
@@ -937,14 +856,14 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) Set(f func(ctx cont
 
 // When sets expectation for the ThingTagRepository.DeleteByTagID which will trigger the result defined by the following
 // Then helper
-func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) When(ctx context.Context, tagID int, tx *sql.Tx) *ThingTagRepositoryMockDeleteByTagIDExpectation {
+func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) When(ctx context.Context, id uint64) *ThingTagRepositoryMockDeleteByTagIDExpectation {
 	if mmDeleteByTagID.mock.funcDeleteByTagID != nil {
 		mmDeleteByTagID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByTagID mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockDeleteByTagIDExpectation{
 		mock:   mmDeleteByTagID.mock,
-		params: &ThingTagRepositoryMockDeleteByTagIDParams{ctx, tagID, tx},
+		params: &ThingTagRepositoryMockDeleteByTagIDParams{ctx, id},
 	}
 	mmDeleteByTagID.expectations = append(mmDeleteByTagID.expectations, expectation)
 	return expectation
@@ -977,15 +896,15 @@ func (mmDeleteByTagID *mThingTagRepositoryMockDeleteByTagID) invocationsDone() b
 }
 
 // DeleteByTagID implements tag.ThingTagRepository
-func (mmDeleteByTagID *ThingTagRepositoryMock) DeleteByTagID(ctx context.Context, tagID int, tx *sql.Tx) (err error) {
+func (mmDeleteByTagID *ThingTagRepositoryMock) DeleteByTagID(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDeleteByTagID.beforeDeleteByTagIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmDeleteByTagID.afterDeleteByTagIDCounter, 1)
 
 	if mmDeleteByTagID.inspectFuncDeleteByTagID != nil {
-		mmDeleteByTagID.inspectFuncDeleteByTagID(ctx, tagID, tx)
+		mmDeleteByTagID.inspectFuncDeleteByTagID(ctx, id)
 	}
 
-	mm_params := ThingTagRepositoryMockDeleteByTagIDParams{ctx, tagID, tx}
+	mm_params := ThingTagRepositoryMockDeleteByTagIDParams{ctx, id}
 
 	// Record call args
 	mmDeleteByTagID.DeleteByTagIDMock.mutex.Lock()
@@ -1004,7 +923,7 @@ func (mmDeleteByTagID *ThingTagRepositoryMock) DeleteByTagID(ctx context.Context
 		mm_want := mmDeleteByTagID.DeleteByTagIDMock.defaultExpectation.params
 		mm_want_ptrs := mmDeleteByTagID.DeleteByTagIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockDeleteByTagIDParams{ctx, tagID, tx}
+		mm_got := ThingTagRepositoryMockDeleteByTagIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -1012,12 +931,8 @@ func (mmDeleteByTagID *ThingTagRepositoryMock) DeleteByTagID(ctx context.Context
 				mmDeleteByTagID.t.Errorf("ThingTagRepositoryMock.DeleteByTagID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.tagID != nil && !minimock.Equal(*mm_want_ptrs.tagID, mm_got.tagID) {
-				mmDeleteByTagID.t.Errorf("ThingTagRepositoryMock.DeleteByTagID got unexpected parameter tagID, want: %#v, got: %#v%s\n", *mm_want_ptrs.tagID, mm_got.tagID, minimock.Diff(*mm_want_ptrs.tagID, mm_got.tagID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDeleteByTagID.t.Errorf("ThingTagRepositoryMock.DeleteByTagID got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDeleteByTagID.t.Errorf("ThingTagRepositoryMock.DeleteByTagID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -1031,9 +946,9 @@ func (mmDeleteByTagID *ThingTagRepositoryMock) DeleteByTagID(ctx context.Context
 		return (*mm_results).err
 	}
 	if mmDeleteByTagID.funcDeleteByTagID != nil {
-		return mmDeleteByTagID.funcDeleteByTagID(ctx, tagID, tx)
+		return mmDeleteByTagID.funcDeleteByTagID(ctx, id)
 	}
-	mmDeleteByTagID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByTagID. %v %v %v", ctx, tagID, tx)
+	mmDeleteByTagID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByTagID. %v %v", ctx, id)
 	return
 }
 

+ 15 - 18
internal/api/v1/thing/add_thing.go

@@ -6,7 +6,6 @@ package thing
 
 import (
 	"context"
-	"database/sql"
 
 	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
@@ -21,36 +20,34 @@ import (
 
 type (
 	ThingRepository interface {
-		Get(ctx context.Context, thingID int) (*models.Thing, error)
+		Get(ctx context.Context, id uint64) (*models.Thing, error)
 		Search(ctx context.Context, search string) ([]models.Thing, error)
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.Thing, error)
-		GetAllByPlaceID(ctx context.Context, placeID int) ([]models.Thing, error)
-		Add(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (int, error)
-		Update(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) error
-		Delete(ctx context.Context, thingID int, tx *sql.Tx) error
-		BeginTx(ctx context.Context, level sql.IsolationLevel) (*sql.Tx, error)
-		CommitTx(tx *sql.Tx) error
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.Thing, error)
+		GetAllByPlaceID(ctx context.Context, id uint64) ([]models.Thing, error)
+		Add(ctx context.Context, req models.AddThingRequest) (uint64, error)
+		Update(ctx context.Context, req models.UpdateThingRequest) error
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	PlaceThingRepository interface {
-		Add(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) error
-		GetByThingID(ctx context.Context, thingID int) (*models.PlaceThing, error)
-		UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) error
-		DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) error
+		Add(ctx context.Context, req models.AddPlaceThingRequest) error
+		GetByThingID(ctx context.Context, id uint64) (*models.PlaceThing, error)
+		UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest) error
+		DeleteThing(ctx context.Context, id uint64) error
 	}
 
 	ThingTagRepository interface {
-		GetByPlaceID(ctx context.Context, placeID int) ([]models.ThingTag, error)
-		DeleteByThingID(ctx context.Context, thingID int, tx *sql.Tx) error
+		GetByPlaceID(ctx context.Context, id uint64) ([]models.ThingTag, error)
+		DeleteByThingID(ctx context.Context, id uint64) error
 	}
 
 	ThingImageRepository interface {
-		GetByThingID(ctx context.Context, thingID int) ([]models.Image, error)
-		Delete(ctx context.Context, imageID int, tx *sql.Tx) error
+		GetByThingID(ctx context.Context, id uint64) ([]models.Image, error)
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	ThingNotificationRepository interface {
-		Delete(ctx context.Context, thingID int, tx *sql.Tx) error
+		Delete(ctx context.Context, id uint64) error
 	}
 
 	FileRepository interface {

+ 1 - 1
internal/api/v1/thing/mocks/file_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 

+ 75 - 160
internal/api/v1/thing/mocks/place_thing_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,26 +19,26 @@ type PlaceThingRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcAdd          func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)
-	inspectFuncAdd   func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)
+	funcAdd          func(ctx context.Context, req models.AddPlaceThingRequest) (err error)
+	inspectFuncAdd   func(ctx context.Context, req models.AddPlaceThingRequest)
 	afterAddCounter  uint64
 	beforeAddCounter uint64
 	AddMock          mPlaceThingRepositoryMockAdd
 
-	funcDeleteThing          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDeleteThing   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDeleteThing          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDeleteThing   func(ctx context.Context, id uint64)
 	afterDeleteThingCounter  uint64
 	beforeDeleteThingCounter uint64
 	DeleteThingMock          mPlaceThingRepositoryMockDeleteThing
 
-	funcGetByThingID          func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)
-	inspectFuncGetByThingID   func(ctx context.Context, thingID int)
+	funcGetByThingID          func(ctx context.Context, id uint64) (pp1 *models.PlaceThing, err error)
+	inspectFuncGetByThingID   func(ctx context.Context, id uint64)
 	afterGetByThingIDCounter  uint64
 	beforeGetByThingIDCounter uint64
 	GetByThingIDMock          mPlaceThingRepositoryMockGetByThingID
 
-	funcUpdatePlace          func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)
-	inspectFuncUpdatePlace   func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)
+	funcUpdatePlace          func(ctx context.Context, req models.UpdatePlaceThingRequest) (err error)
+	inspectFuncUpdatePlace   func(ctx context.Context, req models.UpdatePlaceThingRequest)
 	afterUpdatePlaceCounter  uint64
 	beforeUpdatePlaceCounter uint64
 	UpdatePlaceMock          mPlaceThingRepositoryMockUpdatePlace
@@ -95,14 +94,12 @@ type PlaceThingRepositoryMockAddExpectation struct {
 type PlaceThingRepositoryMockAddParams struct {
 	ctx context.Context
 	req models.AddPlaceThingRequest
-	tx  *sql.Tx
 }
 
 // PlaceThingRepositoryMockAddParamPtrs contains pointers to parameters of the PlaceThingRepository.Add
 type PlaceThingRepositoryMockAddParamPtrs struct {
 	ctx *context.Context
 	req *models.AddPlaceThingRequest
-	tx  **sql.Tx
 }
 
 // PlaceThingRepositoryMockAddResults contains results of the PlaceThingRepository.Add
@@ -121,7 +118,7 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) Optional() *mPlaceThingRepositoryMock
 }
 
 // Expect sets up expected params for PlaceThingRepository.Add
-func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockAdd {
+func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceThingRequest) *mPlaceThingRepositoryMockAdd {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
 	}
@@ -134,7 +131,7 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req model
 		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by ExpectParams functions")
 	}
 
-	mmAdd.defaultExpectation.params = &PlaceThingRepositoryMockAddParams{ctx, req, tx}
+	mmAdd.defaultExpectation.params = &PlaceThingRepositoryMockAddParams{ctx, req}
 	for _, e := range mmAdd.expectations {
 		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
 			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
@@ -188,30 +185,8 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectReqParam2(req models.AddPlaceTh
 	return mmAdd
 }
 
-// ExpectTxParam3 sets up expected param tx for PlaceThingRepository.Add
-func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
-	}
-
-	if mmAdd.defaultExpectation.params != nil {
-		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
-	}
-
-	if mmAdd.defaultExpectation.paramPtrs == nil {
-		mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
-	}
-	mmAdd.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmAdd
-}
-
 // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.Add
-func (mmAdd *mPlaceThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockAdd {
+func (mmAdd *mPlaceThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceThingRequest)) *mPlaceThingRepositoryMockAdd {
 	if mmAdd.mock.inspectFuncAdd != nil {
 		mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.Add")
 	}
@@ -235,7 +210,7 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) Return(err error) *PlaceThingReposito
 }
 
 // Set uses given function f to mock the PlaceThingRepository.Add method
-func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
+func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceThingRequest) (err error)) *PlaceThingRepositoryMock {
 	if mmAdd.defaultExpectation != nil {
 		mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.Add method")
 	}
@@ -250,14 +225,14 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req m
 
 // When sets expectation for the PlaceThingRepository.Add which will trigger the result defined by the following
 // Then helper
-func (mmAdd *mPlaceThingRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockAddExpectation {
+func (mmAdd *mPlaceThingRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceThingRequest) *PlaceThingRepositoryMockAddExpectation {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
 	}
 
 	expectation := &PlaceThingRepositoryMockAddExpectation{
 		mock:   mmAdd.mock,
-		params: &PlaceThingRepositoryMockAddParams{ctx, req, tx},
+		params: &PlaceThingRepositoryMockAddParams{ctx, req},
 	}
 	mmAdd.expectations = append(mmAdd.expectations, expectation)
 	return expectation
@@ -290,15 +265,15 @@ func (mmAdd *mPlaceThingRepositoryMockAdd) invocationsDone() bool {
 }
 
 // Add implements thing.PlaceThingRepository
-func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error) {
+func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPlaceThingRequest) (err error) {
 	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
 	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
 
 	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, req, tx)
+		mmAdd.inspectFuncAdd(ctx, req)
 	}
 
-	mm_params := PlaceThingRepositoryMockAddParams{ctx, req, tx}
+	mm_params := PlaceThingRepositoryMockAddParams{ctx, req}
 
 	// Record call args
 	mmAdd.AddMock.mutex.Lock()
@@ -317,7 +292,7 @@ func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPl
 		mm_want := mmAdd.AddMock.defaultExpectation.params
 		mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceThingRepositoryMockAddParams{ctx, req, tx}
+		mm_got := PlaceThingRepositoryMockAddParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -329,10 +304,6 @@ func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPl
 				mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -344,9 +315,9 @@ func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPl
 		return (*mm_results).err
 	}
 	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, req, tx)
+		return mmAdd.funcAdd(ctx, req)
 	}
-	mmAdd.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
+	mmAdd.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.Add. %v %v", ctx, req)
 	return
 }
 
@@ -441,16 +412,14 @@ type PlaceThingRepositoryMockDeleteThingExpectation struct {
 
 // PlaceThingRepositoryMockDeleteThingParams contains parameters of the PlaceThingRepository.DeleteThing
 type PlaceThingRepositoryMockDeleteThingParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // PlaceThingRepositoryMockDeleteThingParamPtrs contains pointers to parameters of the PlaceThingRepository.DeleteThing
 type PlaceThingRepositoryMockDeleteThingParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // PlaceThingRepositoryMockDeleteThingResults contains results of the PlaceThingRepository.DeleteThing
@@ -469,7 +438,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Optional() *mPlaceThi
 }
 
 // Expect sets up expected params for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, id uint64) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
@@ -482,7 +451,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Co
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by ExpectParams functions")
 	}
 
-	mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+	mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 	for _, e := range mmDeleteThing.expectations {
 		if minimock.Equal(e.params, mmDeleteThing.defaultExpectation.params) {
 			mmDeleteThing.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteThing.defaultExpectation.params)
@@ -514,8 +483,8 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectCtxParam1(ctx c
 	return mmDeleteThing
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectThingIDParam2(thingID int) *mPlaceThingRepositoryMockDeleteThing {
+// ExpectIdParam2 sets up expected param id for PlaceThingRepository.DeleteThing
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectIdParam2(id uint64) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
@@ -531,35 +500,13 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectThingIDParam2(t
 	if mmDeleteThing.defaultExpectation.paramPtrs == nil {
 		mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
 	}
-	mmDeleteThing.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDeleteThing
-}
-
-// ExpectTxParam3 sets up expected param tx for PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
-	if mmDeleteThing.mock.funcDeleteThing != nil {
-		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
-	}
-
-	if mmDeleteThing.defaultExpectation == nil {
-		mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
-	}
-
-	if mmDeleteThing.defaultExpectation.params != nil {
-		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
-	}
-
-	if mmDeleteThing.defaultExpectation.paramPtrs == nil {
-		mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
-	}
-	mmDeleteThing.defaultExpectation.paramPtrs.tx = &tx
+	mmDeleteThing.defaultExpectation.paramPtrs.id = &id
 
 	return mmDeleteThing
 }
 
 // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.DeleteThing
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mPlaceThingRepositoryMockDeleteThing {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, id uint64)) *mPlaceThingRepositoryMockDeleteThing {
 	if mmDeleteThing.mock.inspectFuncDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.DeleteThing")
 	}
@@ -583,7 +530,7 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Return(err error) *Pl
 }
 
 // Set uses given function f to mock the PlaceThingRepository.DeleteThing method
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceThingRepositoryMock {
 	if mmDeleteThing.defaultExpectation != nil {
 		mmDeleteThing.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.DeleteThing method")
 	}
@@ -598,14 +545,14 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx contex
 
 // When sets expectation for the PlaceThingRepository.DeleteThing which will trigger the result defined by the following
 // Then helper
-func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, thingID int, tx *sql.Tx) *PlaceThingRepositoryMockDeleteThingExpectation {
+func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, id uint64) *PlaceThingRepositoryMockDeleteThingExpectation {
 	if mmDeleteThing.mock.funcDeleteThing != nil {
 		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
 	}
 
 	expectation := &PlaceThingRepositoryMockDeleteThingExpectation{
 		mock:   mmDeleteThing.mock,
-		params: &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx},
+		params: &PlaceThingRepositoryMockDeleteThingParams{ctx, id},
 	}
 	mmDeleteThing.expectations = append(mmDeleteThing.expectations, expectation)
 	return expectation
@@ -638,15 +585,15 @@ func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) invocationsDone() boo
 }
 
 // DeleteThing implements thing.PlaceThingRepository
-func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDeleteThing.beforeDeleteThingCounter, 1)
 	defer mm_atomic.AddUint64(&mmDeleteThing.afterDeleteThingCounter, 1)
 
 	if mmDeleteThing.inspectFuncDeleteThing != nil {
-		mmDeleteThing.inspectFuncDeleteThing(ctx, thingID, tx)
+		mmDeleteThing.inspectFuncDeleteThing(ctx, id)
 	}
 
-	mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+	mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 
 	// Record call args
 	mmDeleteThing.DeleteThingMock.mutex.Lock()
@@ -665,7 +612,7 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 		mm_want := mmDeleteThing.DeleteThingMock.defaultExpectation.params
 		mm_want_ptrs := mmDeleteThing.DeleteThingMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
+		mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -673,12 +620,8 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -692,9 +635,9 @@ func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context,
 		return (*mm_results).err
 	}
 	if mmDeleteThing.funcDeleteThing != nil {
-		return mmDeleteThing.funcDeleteThing(ctx, thingID, tx)
+		return mmDeleteThing.funcDeleteThing(ctx, id)
 	}
-	mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v %v", ctx, thingID, tx)
+	mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v", ctx, id)
 	return
 }
 
@@ -789,14 +732,14 @@ type PlaceThingRepositoryMockGetByThingIDExpectation struct {
 
 // PlaceThingRepositoryMockGetByThingIDParams contains parameters of the PlaceThingRepository.GetByThingID
 type PlaceThingRepositoryMockGetByThingIDParams struct {
-	ctx     context.Context
-	thingID int
+	ctx context.Context
+	id  uint64
 }
 
 // PlaceThingRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the PlaceThingRepository.GetByThingID
 type PlaceThingRepositoryMockGetByThingIDParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // PlaceThingRepositoryMockGetByThingIDResults contains results of the PlaceThingRepository.GetByThingID
@@ -816,7 +759,7 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Optional() *mPlaceT
 }
 
 // Expect sets up expected params for PlaceThingRepository.GetByThingID
-func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mPlaceThingRepositoryMockGetByThingID {
+func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mPlaceThingRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -829,7 +772,7 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.
 		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByThingID.defaultExpectation.params = &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
+	mmGetByThingID.defaultExpectation.params = &PlaceThingRepositoryMockGetByThingIDParams{ctx, id}
 	for _, e := range mmGetByThingID.expectations {
 		if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
 			mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
@@ -861,8 +804,8 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectCtxParam1(ctx
 	return mmGetByThingID
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for PlaceThingRepository.GetByThingID
-func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectThingIDParam2(thingID int) *mPlaceThingRepositoryMockGetByThingID {
+// ExpectIdParam2 sets up expected param id for PlaceThingRepository.GetByThingID
+func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mPlaceThingRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -878,13 +821,13 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectThingIDParam2
 	if mmGetByThingID.defaultExpectation.paramPtrs == nil {
 		mmGetByThingID.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockGetByThingIDParamPtrs{}
 	}
-	mmGetByThingID.defaultExpectation.paramPtrs.thingID = &thingID
+	mmGetByThingID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByThingID
 }
 
 // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.GetByThingID
-func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mPlaceThingRepositoryMockGetByThingID {
+func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mPlaceThingRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.GetByThingID")
 	}
@@ -908,7 +851,7 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Return(pp1 *models.
 }
 
 // Set uses given function f to mock the PlaceThingRepository.GetByThingID method
-func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)) *PlaceThingRepositoryMock {
+func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (pp1 *models.PlaceThing, err error)) *PlaceThingRepositoryMock {
 	if mmGetByThingID.defaultExpectation != nil {
 		mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.GetByThingID method")
 	}
@@ -923,14 +866,14 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx cont
 
 // When sets expectation for the PlaceThingRepository.GetByThingID which will trigger the result defined by the following
 // Then helper
-func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *PlaceThingRepositoryMockGetByThingIDExpectation {
+func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *PlaceThingRepositoryMockGetByThingIDExpectation {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
 	}
 
 	expectation := &PlaceThingRepositoryMockGetByThingIDExpectation{
 		mock:   mmGetByThingID.mock,
-		params: &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID},
+		params: &PlaceThingRepositoryMockGetByThingIDParams{ctx, id},
 	}
 	mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
 	return expectation
@@ -963,15 +906,15 @@ func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) invocationsDone() b
 }
 
 // GetByThingID implements thing.PlaceThingRepository
-func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error) {
+func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context, id uint64) (pp1 *models.PlaceThing, err error) {
 	mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
 
 	if mmGetByThingID.inspectFuncGetByThingID != nil {
-		mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
+		mmGetByThingID.inspectFuncGetByThingID(ctx, id)
 	}
 
-	mm_params := PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
+	mm_params := PlaceThingRepositoryMockGetByThingIDParams{ctx, id}
 
 	// Record call args
 	mmGetByThingID.GetByThingIDMock.mutex.Lock()
@@ -990,7 +933,7 @@ func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context
 		mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
+		mm_got := PlaceThingRepositoryMockGetByThingIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -998,8 +941,8 @@ func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context
 				mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -1013,9 +956,9 @@ func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context
 		return (*mm_results).pp1, (*mm_results).err
 	}
 	if mmGetByThingID.funcGetByThingID != nil {
-		return mmGetByThingID.funcGetByThingID(ctx, thingID)
+		return mmGetByThingID.funcGetByThingID(ctx, id)
 	}
-	mmGetByThingID.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.GetByThingID. %v %v", ctx, thingID)
+	mmGetByThingID.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.GetByThingID. %v %v", ctx, id)
 	return
 }
 
@@ -1112,14 +1055,12 @@ type PlaceThingRepositoryMockUpdatePlaceExpectation struct {
 type PlaceThingRepositoryMockUpdatePlaceParams struct {
 	ctx context.Context
 	req models.UpdatePlaceThingRequest
-	tx  *sql.Tx
 }
 
 // PlaceThingRepositoryMockUpdatePlaceParamPtrs contains pointers to parameters of the PlaceThingRepository.UpdatePlace
 type PlaceThingRepositoryMockUpdatePlaceParamPtrs struct {
 	ctx *context.Context
 	req *models.UpdatePlaceThingRequest
-	tx  **sql.Tx
 }
 
 // PlaceThingRepositoryMockUpdatePlaceResults contains results of the PlaceThingRepository.UpdatePlace
@@ -1138,7 +1079,7 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Optional() *mPlaceThi
 }
 
 // Expect sets up expected params for PlaceThingRepository.UpdatePlace
-func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockUpdatePlace {
+func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Context, req models.UpdatePlaceThingRequest) *mPlaceThingRepositoryMockUpdatePlace {
 	if mmUpdatePlace.mock.funcUpdatePlace != nil {
 		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
 	}
@@ -1151,7 +1092,7 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Co
 		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by ExpectParams functions")
 	}
 
-	mmUpdatePlace.defaultExpectation.params = &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
+	mmUpdatePlace.defaultExpectation.params = &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
 	for _, e := range mmUpdatePlace.expectations {
 		if minimock.Equal(e.params, mmUpdatePlace.defaultExpectation.params) {
 			mmUpdatePlace.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdatePlace.defaultExpectation.params)
@@ -1205,30 +1146,8 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectReqParam2(req m
 	return mmUpdatePlace
 }
 
-// ExpectTxParam3 sets up expected param tx for PlaceThingRepository.UpdatePlace
-func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockUpdatePlace {
-	if mmUpdatePlace.mock.funcUpdatePlace != nil {
-		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
-	}
-
-	if mmUpdatePlace.defaultExpectation == nil {
-		mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
-	}
-
-	if mmUpdatePlace.defaultExpectation.params != nil {
-		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
-	}
-
-	if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
-		mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
-	}
-	mmUpdatePlace.defaultExpectation.paramPtrs.tx = &tx
-
-	return mmUpdatePlace
-}
-
 // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.UpdatePlace
-func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Inspect(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockUpdatePlace {
+func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Inspect(f func(ctx context.Context, req models.UpdatePlaceThingRequest)) *mPlaceThingRepositoryMockUpdatePlace {
 	if mmUpdatePlace.mock.inspectFuncUpdatePlace != nil {
 		mmUpdatePlace.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.UpdatePlace")
 	}
@@ -1252,7 +1171,7 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Return(err error) *Pl
 }
 
 // Set uses given function f to mock the PlaceThingRepository.UpdatePlace method
-func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
+func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx context.Context, req models.UpdatePlaceThingRequest) (err error)) *PlaceThingRepositoryMock {
 	if mmUpdatePlace.defaultExpectation != nil {
 		mmUpdatePlace.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.UpdatePlace method")
 	}
@@ -1267,14 +1186,14 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx contex
 
 // When sets expectation for the PlaceThingRepository.UpdatePlace which will trigger the result defined by the following
 // Then helper
-func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) When(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockUpdatePlaceExpectation {
+func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) When(ctx context.Context, req models.UpdatePlaceThingRequest) *PlaceThingRepositoryMockUpdatePlaceExpectation {
 	if mmUpdatePlace.mock.funcUpdatePlace != nil {
 		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
 	}
 
 	expectation := &PlaceThingRepositoryMockUpdatePlaceExpectation{
 		mock:   mmUpdatePlace.mock,
-		params: &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx},
+		params: &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req},
 	}
 	mmUpdatePlace.expectations = append(mmUpdatePlace.expectations, expectation)
 	return expectation
@@ -1307,15 +1226,15 @@ func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) invocationsDone() boo
 }
 
 // UpdatePlace implements thing.PlaceThingRepository
-func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error) {
+func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest) (err error) {
 	mm_atomic.AddUint64(&mmUpdatePlace.beforeUpdatePlaceCounter, 1)
 	defer mm_atomic.AddUint64(&mmUpdatePlace.afterUpdatePlaceCounter, 1)
 
 	if mmUpdatePlace.inspectFuncUpdatePlace != nil {
-		mmUpdatePlace.inspectFuncUpdatePlace(ctx, req, tx)
+		mmUpdatePlace.inspectFuncUpdatePlace(ctx, req)
 	}
 
-	mm_params := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
+	mm_params := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
 
 	// Record call args
 	mmUpdatePlace.UpdatePlaceMock.mutex.Lock()
@@ -1334,7 +1253,7 @@ func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context,
 		mm_want := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.params
 		mm_want_ptrs := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.paramPtrs
 
-		mm_got := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
+		mm_got := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
 
 		if mm_want_ptrs != nil {
 
@@ -1346,10 +1265,6 @@ func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context,
 				mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
 			}
 
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
-			}
-
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
 			mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
@@ -1361,9 +1276,9 @@ func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context,
 		return (*mm_results).err
 	}
 	if mmUpdatePlace.funcUpdatePlace != nil {
-		return mmUpdatePlace.funcUpdatePlace(ctx, req, tx)
+		return mmUpdatePlace.funcUpdatePlace(ctx, req)
 	}
-	mmUpdatePlace.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.UpdatePlace. %v %v %v", ctx, req, tx)
+	mmUpdatePlace.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.UpdatePlace. %v %v", ctx, req)
 	return
 }
 

+ 47 - 76
internal/api/v1/thing/mocks/thing_image_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,14 +19,14 @@ type ThingImageRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, imageID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, imageID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingImageRepositoryMockDelete
 
-	funcGetByThingID          func(ctx context.Context, thingID int) (ia1 []models.Image, err error)
-	inspectFuncGetByThingID   func(ctx context.Context, thingID int)
+	funcGetByThingID          func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
+	inspectFuncGetByThingID   func(ctx context.Context, id uint64)
 	afterGetByThingIDCounter  uint64
 	beforeGetByThingIDCounter uint64
 	GetByThingIDMock          mThingImageRepositoryMockGetByThingID
@@ -75,16 +74,14 @@ type ThingImageRepositoryMockDeleteExpectation struct {
 
 // ThingImageRepositoryMockDeleteParams contains parameters of the ThingImageRepository.Delete
 type ThingImageRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	imageID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingImageRepository.Delete
 type ThingImageRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	imageID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingImageRepositoryMockDeleteResults contains results of the ThingImageRepository.Delete
@@ -103,7 +100,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Optional() *mThingImageReposito
 }
 
 // Expect sets up expected params for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, imageID int, tx *sql.Tx) *mThingImageRepositoryMockDelete {
+func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -116,7 +113,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, ima
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -148,8 +145,8 @@ func (mmDelete *mThingImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Con
 	return mmDelete
 }
 
-// ExpectImageIDParam2 sets up expected param imageID for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) ExpectImageIDParam2(imageID int) *mThingImageRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingImageRepository.Delete
+func (mmDelete *mThingImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
@@ -165,35 +162,13 @@ func (mmDelete *mThingImageRepositoryMockDelete) ExpectImageIDParam2(imageID int
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.imageID = &imageID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingImageRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Delete
-func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, imageID int, tx *sql.Tx)) *mThingImageRepositoryMockDelete {
+func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Delete")
 	}
@@ -217,7 +192,7 @@ func (mmDelete *mThingImageRepositoryMockDelete) Return(err error) *ThingImageRe
 }
 
 // Set uses given function f to mock the ThingImageRepository.Delete method
-func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, imageID int, tx *sql.Tx) (err error)) *ThingImageRepositoryMock {
+func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingImageRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Delete method")
 	}
@@ -232,14 +207,14 @@ func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context,
 
 // When sets expectation for the ThingImageRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, imageID int, tx *sql.Tx) *ThingImageRepositoryMockDeleteExpectation {
+func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingImageRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingImageRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingImageRepositoryMockDeleteParams{ctx, imageID, tx},
+		params: &ThingImageRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -272,15 +247,15 @@ func (mmDelete *mThingImageRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements thing.ThingImageRepository
-func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, imageID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+	mm_params := ThingImageRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -299,7 +274,7 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingImageRepositoryMockDeleteParams{ctx, imageID, tx}
+		mm_got := ThingImageRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -307,12 +282,8 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.imageID != nil && !minimock.Equal(*mm_want_ptrs.imageID, mm_got.imageID) {
-				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter imageID, want: %#v, got: %#v%s\n", *mm_want_ptrs.imageID, mm_got.imageID, minimock.Diff(*mm_want_ptrs.imageID, mm_got.imageID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -326,9 +297,9 @@ func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, imageID in
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, imageID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v %v", ctx, imageID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 
@@ -423,14 +394,14 @@ type ThingImageRepositoryMockGetByThingIDExpectation struct {
 
 // ThingImageRepositoryMockGetByThingIDParams contains parameters of the ThingImageRepository.GetByThingID
 type ThingImageRepositoryMockGetByThingIDParams struct {
-	ctx     context.Context
-	thingID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingImageRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByThingID
 type ThingImageRepositoryMockGetByThingIDParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingImageRepositoryMockGetByThingIDResults contains results of the ThingImageRepository.GetByThingID
@@ -450,7 +421,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Optional() *mThingI
 }
 
 // Expect sets up expected params for ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mThingImageRepositoryMockGetByThingID {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -463,7 +434,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+	mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 	for _, e := range mmGetByThingID.expectations {
 		if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
 			mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
@@ -495,8 +466,8 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectCtxParam1(ctx
 	return mmGetByThingID
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectThingIDParam2(thingID int) *mThingImageRepositoryMockGetByThingID {
+// ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByThingID
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
@@ -512,13 +483,13 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectThingIDParam2
 	if mmGetByThingID.defaultExpectation.paramPtrs == nil {
 		mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
 	}
-	mmGetByThingID.defaultExpectation.paramPtrs.thingID = &thingID
+	mmGetByThingID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByThingID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByThingID
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mThingImageRepositoryMockGetByThingID {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByThingID {
 	if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByThingID")
 	}
@@ -542,7 +513,7 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Return(ia1 []models
 }
 
 // Set uses given function f to mock the ThingImageRepository.GetByThingID method
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
 	if mmGetByThingID.defaultExpectation != nil {
 		mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByThingID method")
 	}
@@ -557,14 +528,14 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx cont
 
 // When sets expectation for the ThingImageRepository.GetByThingID which will trigger the result defined by the following
 // Then helper
-func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *ThingImageRepositoryMockGetByThingIDExpectation {
+func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByThingIDExpectation {
 	if mmGetByThingID.mock.funcGetByThingID != nil {
 		mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
 	}
 
 	expectation := &ThingImageRepositoryMockGetByThingIDExpectation{
 		mock:   mmGetByThingID.mock,
-		params: &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID},
+		params: &ThingImageRepositoryMockGetByThingIDParams{ctx, id},
 	}
 	mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
 	return expectation
@@ -597,15 +568,15 @@ func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) invocationsDone() b
 }
 
 // GetByThingID implements thing.ThingImageRepository
-func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, thingID int) (ia1 []models.Image, err error) {
+func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
 	mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
 
 	if mmGetByThingID.inspectFuncGetByThingID != nil {
-		mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
+		mmGetByThingID.inspectFuncGetByThingID(ctx, id)
 	}
 
-	mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+	mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 
 	// Record call args
 	mmGetByThingID.GetByThingIDMock.mutex.Lock()
@@ -624,7 +595,7 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 		mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
+		mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -632,8 +603,8 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -647,9 +618,9 @@ func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context
 		return (*mm_results).ia1, (*mm_results).err
 	}
 	if mmGetByThingID.funcGetByThingID != nil {
-		return mmGetByThingID.funcGetByThingID(ctx, thingID)
+		return mmGetByThingID.funcGetByThingID(ctx, id)
 	}
-	mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, thingID)
+	mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, id)
 	return
 }
 

+ 24 - 53
internal/api/v1/thing/mocks/thing_notification_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -19,8 +18,8 @@ type ThingNotificationRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDelete          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDelete   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDelete          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDelete   func(ctx context.Context, id uint64)
 	afterDeleteCounter  uint64
 	beforeDeleteCounter uint64
 	DeleteMock          mThingNotificationRepositoryMockDelete
@@ -65,16 +64,14 @@ type ThingNotificationRepositoryMockDeleteExpectation struct {
 
 // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
 type ThingNotificationRepositoryMockDeleteParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
@@ -93,7 +90,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotifi
 }
 
 // Expect sets up expected params for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -106,7 +103,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Conte
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
 	}
 
-	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, id}
 	for _, e := range mmDelete.expectations {
 		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
 			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
@@ -138,8 +135,8 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx cont
 	return mmDelete
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingNotificationRepositoryMockDelete {
+// ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
+func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
@@ -155,35 +152,13 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectThingIDParam2(thin
 	if mmDelete.defaultExpectation.paramPtrs == nil {
 		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
 	}
-	mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDelete
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingNotificationRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
-	}
-
-	if mmDelete.defaultExpectation.params != nil {
-		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
-	}
-
-	if mmDelete.defaultExpectation.paramPtrs == nil {
-		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
-	}
-	mmDelete.defaultExpectation.paramPtrs.tx = &tx
+	mmDelete.defaultExpectation.paramPtrs.id = &id
 
 	return mmDelete
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
-func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingNotificationRepositoryMockDelete {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
 	if mmDelete.mock.inspectFuncDelete != nil {
 		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
 	}
@@ -207,7 +182,7 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *Thing
 }
 
 // Set uses given function f to mock the ThingNotificationRepository.Delete method
-func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingNotificationRepositoryMock {
+func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
 	if mmDelete.defaultExpectation != nil {
 		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
 	}
@@ -222,14 +197,14 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.C
 
 // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
 // Then helper
-func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingNotificationRepositoryMockDeleteExpectation {
+func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
 	if mmDelete.mock.funcDelete != nil {
 		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
 	}
 
 	expectation := &ThingNotificationRepositoryMockDeleteExpectation{
 		mock:   mmDelete.mock,
-		params: &ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx},
+		params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
 	}
 	mmDelete.expectations = append(mmDelete.expectations, expectation)
 	return expectation
@@ -262,15 +237,15 @@ func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
 }
 
 // Delete implements thing.ThingNotificationRepository
-func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
 	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
 
 	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, thingID, tx)
+		mmDelete.inspectFuncDelete(ctx, id)
 	}
 
-	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 	// Record call args
 	mmDelete.DeleteMock.mutex.Lock()
@@ -289,7 +264,7 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		mm_want := mmDelete.DeleteMock.defaultExpectation.params
 		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, thingID, tx}
+		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -297,12 +272,8 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -316,9 +287,9 @@ func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, thi
 		return (*mm_results).err
 	}
 	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, thingID, tx)
+		return mmDelete.funcDelete(ctx, id)
 	}
-	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
+	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
 	return
 }
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 45 - 729
internal/api/v1/thing/mocks/thing_repository_minimock.go


+ 47 - 76
internal/api/v1/thing/mocks/thing_tag_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -6,7 +6,6 @@ package mocks
 
 import (
 	"context"
-	"database/sql"
 	"sync"
 	mm_atomic "sync/atomic"
 	mm_time "time"
@@ -20,14 +19,14 @@ type ThingTagRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcDeleteByThingID          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
-	inspectFuncDeleteByThingID   func(ctx context.Context, thingID int, tx *sql.Tx)
+	funcDeleteByThingID          func(ctx context.Context, id uint64) (err error)
+	inspectFuncDeleteByThingID   func(ctx context.Context, id uint64)
 	afterDeleteByThingIDCounter  uint64
 	beforeDeleteByThingIDCounter uint64
 	DeleteByThingIDMock          mThingTagRepositoryMockDeleteByThingID
 
-	funcGetByPlaceID          func(ctx context.Context, placeID int) (ta1 []models.ThingTag, err error)
-	inspectFuncGetByPlaceID   func(ctx context.Context, placeID int)
+	funcGetByPlaceID          func(ctx context.Context, id uint64) (ta1 []models.ThingTag, err error)
+	inspectFuncGetByPlaceID   func(ctx context.Context, id uint64)
 	afterGetByPlaceIDCounter  uint64
 	beforeGetByPlaceIDCounter uint64
 	GetByPlaceIDMock          mThingTagRepositoryMockGetByPlaceID
@@ -75,16 +74,14 @@ type ThingTagRepositoryMockDeleteByThingIDExpectation struct {
 
 // ThingTagRepositoryMockDeleteByThingIDParams contains parameters of the ThingTagRepository.DeleteByThingID
 type ThingTagRepositoryMockDeleteByThingIDParams struct {
-	ctx     context.Context
-	thingID int
-	tx      *sql.Tx
+	ctx context.Context
+	id  uint64
 }
 
 // ThingTagRepositoryMockDeleteByThingIDParamPtrs contains pointers to parameters of the ThingTagRepository.DeleteByThingID
 type ThingTagRepositoryMockDeleteByThingIDParamPtrs struct {
-	ctx     *context.Context
-	thingID *int
-	tx      **sql.Tx
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingTagRepositoryMockDeleteByThingIDResults contains results of the ThingTagRepository.DeleteByThingID
@@ -103,7 +100,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Optional() *mTh
 }
 
 // Expect sets up expected params for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingTagRepositoryMockDeleteByThingID {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx context.Context, id uint64) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
@@ -116,7 +113,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx cont
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by ExpectParams functions")
 	}
 
-	mmDeleteByThingID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+	mmDeleteByThingID.defaultExpectation.params = &ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 	for _, e := range mmDeleteByThingID.expectations {
 		if minimock.Equal(e.params, mmDeleteByThingID.defaultExpectation.params) {
 			mmDeleteByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteByThingID.defaultExpectation.params)
@@ -148,8 +145,8 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectCtxParam1
 	return mmDeleteByThingID
 }
 
-// ExpectThingIDParam2 sets up expected param thingID for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectThingIDParam2(thingID int) *mThingTagRepositoryMockDeleteByThingID {
+// ExpectIdParam2 sets up expected param id for ThingTagRepository.DeleteByThingID
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectIdParam2(id uint64) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
@@ -165,35 +162,13 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectThingIDPa
 	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
 		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
 	}
-	mmDeleteByThingID.defaultExpectation.paramPtrs.thingID = &thingID
-
-	return mmDeleteByThingID
-}
-
-// ExpectTxParam3 sets up expected param tx for ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectTxParam3(tx *sql.Tx) *mThingTagRepositoryMockDeleteByThingID {
-	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
-		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
-	}
-
-	if mmDeleteByThingID.defaultExpectation == nil {
-		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{}
-	}
-
-	if mmDeleteByThingID.defaultExpectation.params != nil {
-		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Expect")
-	}
-
-	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
-		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
-	}
-	mmDeleteByThingID.defaultExpectation.paramPtrs.tx = &tx
+	mmDeleteByThingID.defaultExpectation.paramPtrs.id = &id
 
 	return mmDeleteByThingID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.DeleteByThingID
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingTagRepositoryMockDeleteByThingID {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingTagRepositoryMockDeleteByThingID {
 	if mmDeleteByThingID.mock.inspectFuncDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.DeleteByThingID")
 	}
@@ -217,7 +192,7 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Return(err erro
 }
 
 // Set uses given function f to mock the ThingTagRepository.DeleteByThingID method
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingTagRepositoryMock {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx context.Context, id uint64) (err error)) *ThingTagRepositoryMock {
 	if mmDeleteByThingID.defaultExpectation != nil {
 		mmDeleteByThingID.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.DeleteByThingID method")
 	}
@@ -232,14 +207,14 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx
 
 // When sets expectation for the ThingTagRepository.DeleteByThingID which will trigger the result defined by the following
 // Then helper
-func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingTagRepositoryMockDeleteByThingIDExpectation {
+func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) When(ctx context.Context, id uint64) *ThingTagRepositoryMockDeleteByThingIDExpectation {
 	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
 		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockDeleteByThingIDExpectation{
 		mock:   mmDeleteByThingID.mock,
-		params: &ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx},
+		params: &ThingTagRepositoryMockDeleteByThingIDParams{ctx, id},
 	}
 	mmDeleteByThingID.expectations = append(mmDeleteByThingID.expectations, expectation)
 	return expectation
@@ -272,15 +247,15 @@ func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) invocationsDone
 }
 
 // DeleteByThingID implements thing.ThingTagRepository
-func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
+func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Context, id uint64) (err error) {
 	mm_atomic.AddUint64(&mmDeleteByThingID.beforeDeleteByThingIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmDeleteByThingID.afterDeleteByThingIDCounter, 1)
 
 	if mmDeleteByThingID.inspectFuncDeleteByThingID != nil {
-		mmDeleteByThingID.inspectFuncDeleteByThingID(ctx, thingID, tx)
+		mmDeleteByThingID.inspectFuncDeleteByThingID(ctx, id)
 	}
 
-	mm_params := ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+	mm_params := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 
 	// Record call args
 	mmDeleteByThingID.DeleteByThingIDMock.mutex.Lock()
@@ -299,7 +274,7 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 		mm_want := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.params
 		mm_want_ptrs := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockDeleteByThingIDParams{ctx, thingID, tx}
+		mm_got := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -307,12 +282,8 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
-				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
-			}
-
-			if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
-				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -326,9 +297,9 @@ func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Con
 		return (*mm_results).err
 	}
 	if mmDeleteByThingID.funcDeleteByThingID != nil {
-		return mmDeleteByThingID.funcDeleteByThingID(ctx, thingID, tx)
+		return mmDeleteByThingID.funcDeleteByThingID(ctx, id)
 	}
-	mmDeleteByThingID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByThingID. %v %v %v", ctx, thingID, tx)
+	mmDeleteByThingID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByThingID. %v %v", ctx, id)
 	return
 }
 
@@ -423,14 +394,14 @@ type ThingTagRepositoryMockGetByPlaceIDExpectation struct {
 
 // ThingTagRepositoryMockGetByPlaceIDParams contains parameters of the ThingTagRepository.GetByPlaceID
 type ThingTagRepositoryMockGetByPlaceIDParams struct {
-	ctx     context.Context
-	placeID int
+	ctx context.Context
+	id  uint64
 }
 
 // ThingTagRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingTagRepository.GetByPlaceID
 type ThingTagRepositoryMockGetByPlaceIDParamPtrs struct {
-	ctx     *context.Context
-	placeID *int
+	ctx *context.Context
+	id  *uint64
 }
 
 // ThingTagRepositoryMockGetByPlaceIDResults contains results of the ThingTagRepository.GetByPlaceID
@@ -450,7 +421,7 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Optional() *mThingTag
 }
 
 // Expect sets up expected params for ThingTagRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingTagRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingTagRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingTagRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -463,7 +434,7 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Expect(ctx context.Co
 		mmGetByPlaceID.mock.t.Fatalf("ThingTagRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
 	}
 
-	mmGetByPlaceID.defaultExpectation.params = &ThingTagRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mmGetByPlaceID.defaultExpectation.params = &ThingTagRepositoryMockGetByPlaceIDParams{ctx, id}
 	for _, e := range mmGetByPlaceID.expectations {
 		if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
 			mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
@@ -495,8 +466,8 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx c
 	return mmGetByPlaceID
 }
 
-// ExpectPlaceIDParam2 sets up expected param placeID for ThingTagRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingTagRepositoryMockGetByPlaceID {
+// ExpectIdParam2 sets up expected param id for ThingTagRepository.GetByPlaceID
+func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingTagRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingTagRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
@@ -512,13 +483,13 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(p
 	if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
 		mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockGetByPlaceIDParamPtrs{}
 	}
-	mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
+	mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
 
 	return mmGetByPlaceID
 }
 
 // Inspect accepts an inspector function that has same arguments as the ThingTagRepository.GetByPlaceID
-func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingTagRepositoryMockGetByPlaceID {
+func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingTagRepositoryMockGetByPlaceID {
 	if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.GetByPlaceID")
 	}
@@ -542,7 +513,7 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Return(ta1 []models.T
 }
 
 // Set uses given function f to mock the ThingTagRepository.GetByPlaceID method
-func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.ThingTag, err error)) *ThingTagRepositoryMock {
+func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.ThingTag, err error)) *ThingTagRepositoryMock {
 	if mmGetByPlaceID.defaultExpectation != nil {
 		mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.GetByPlaceID method")
 	}
@@ -557,14 +528,14 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) Set(f func(ctx contex
 
 // When sets expectation for the ThingTagRepository.GetByPlaceID which will trigger the result defined by the following
 // Then helper
-func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingTagRepositoryMockGetByPlaceIDExpectation {
+func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingTagRepositoryMockGetByPlaceIDExpectation {
 	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
 		mmGetByPlaceID.mock.t.Fatalf("ThingTagRepositoryMock.GetByPlaceID mock is already set by Set")
 	}
 
 	expectation := &ThingTagRepositoryMockGetByPlaceIDExpectation{
 		mock:   mmGetByPlaceID.mock,
-		params: &ThingTagRepositoryMockGetByPlaceIDParams{ctx, placeID},
+		params: &ThingTagRepositoryMockGetByPlaceIDParams{ctx, id},
 	}
 	mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
 	return expectation
@@ -597,15 +568,15 @@ func (mmGetByPlaceID *mThingTagRepositoryMockGetByPlaceID) invocationsDone() boo
 }
 
 // GetByPlaceID implements thing.ThingTagRepository
-func (mmGetByPlaceID *ThingTagRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.ThingTag, err error) {
+func (mmGetByPlaceID *ThingTagRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.ThingTag, err error) {
 	mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
 	defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
 
 	if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
-		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
+		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
 	}
 
-	mm_params := ThingTagRepositoryMockGetByPlaceIDParams{ctx, placeID}
+	mm_params := ThingTagRepositoryMockGetByPlaceIDParams{ctx, id}
 
 	// Record call args
 	mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
@@ -624,7 +595,7 @@ func (mmGetByPlaceID *ThingTagRepositoryMock) GetByPlaceID(ctx context.Context,
 		mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
 		mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
 
-		mm_got := ThingTagRepositoryMockGetByPlaceIDParams{ctx, placeID}
+		mm_got := ThingTagRepositoryMockGetByPlaceIDParams{ctx, id}
 
 		if mm_want_ptrs != nil {
 
@@ -632,8 +603,8 @@ func (mmGetByPlaceID *ThingTagRepositoryMock) GetByPlaceID(ctx context.Context,
 				mmGetByPlaceID.t.Errorf("ThingTagRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
 			}
 
-			if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
-				mmGetByPlaceID.t.Errorf("ThingTagRepositoryMock.GetByPlaceID got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
+			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
+				mmGetByPlaceID.t.Errorf("ThingTagRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
 			}
 
 		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
@@ -647,9 +618,9 @@ func (mmGetByPlaceID *ThingTagRepositoryMock) GetByPlaceID(ctx context.Context,
 		return (*mm_results).ta1, (*mm_results).err
 	}
 	if mmGetByPlaceID.funcGetByPlaceID != nil {
-		return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
+		return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
 	}
-	mmGetByPlaceID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
+	mmGetByPlaceID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.GetByPlaceID. %v %v", ctx, id)
 	return
 }
 

+ 6 - 1
internal/api/v1/user/add_user.go

@@ -8,6 +8,7 @@ import (
 	"context"
 	"strings"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
 	"github.com/golang-jwt/jwt/v4"
@@ -25,7 +26,7 @@ type (
 
 	UserRepository interface {
 		Get(ctx context.Context, username string) (*models.User, error)
-		Add(ctx context.Context, username string, password string) (int, error)
+		Add(ctx context.Context, username string, password string) (uint64, error)
 		Update(ctx context.Context, req models.UpdateUserRequest) error
 	}
 )
@@ -48,21 +49,25 @@ func AddUserHandler(
 		ctx := fctx.Context()
 		req := dto.AddUserRequest{}
 		if err := fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
 		var validate = validator.New()
 		if err := validate.Struct(req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fctx.Status(fiber.StatusBadRequest).JSON(factory.CreateValidateErrorResponse(err))
 		}
 
 		hash, err := authService.GeneratePasswordHash(strings.TrimSpace(req.Password))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 
 		_, err = userRepository.Add(ctx, strings.TrimSpace(req.Username), hash)
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 0 - 161
internal/api/v1/user/add_user_test.go

@@ -1,161 +0,0 @@
-package user
-
-import (
-	"context"
-	"errors"
-	"net/http/httptest"
-	"testing"
-
-	"github.com/brianvoe/gofakeit/v6"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/stretchr/testify/assert"
-
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/user/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
-)
-
-func TestAddUserHandler(t *testing.T) {
-	t.Parallel()
-
-	type req struct {
-		method      string
-		route       string
-		contentType string
-		body        *dto.AddUserRequest
-	}
-
-	var (
-		id        = gofakeit.Number(1, 1000)
-		username  = gofakeit.Username()
-		password  = gofakeit.Word()
-		testError = errors.New(gofakeit.Phrase())
-
-		correctReq = req{
-			method: fiber.MethodPost,
-			route:  "/v1/users",
-			body: &dto.AddUserRequest{
-				Username: username,
-				Password: password,
-			},
-			contentType: fiber.MIMEApplicationJSON,
-		}
-	)
-
-	tests := []struct {
-		name            string
-		req             req
-		resCode         int
-		resBody         interface{}
-		userRepoMock    func(mc *minimock.Controller) UserRepository
-		authServiceMock func(mc *minimock.Controller) AuthService
-	}{
-		{
-			name:    "positive case",
-			req:     correctReq,
-			resCode: fiber.StatusOK,
-			resBody: dto.EmptyResponse{},
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.AddMock.Inspect(func(ctx context.Context, reqUsername string, reqPassword string) {
-					assert.Equal(mc, username, reqUsername)
-					assert.NotEmpty(mc, reqPassword)
-				}).Return(id, nil)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-				mock.GeneratePasswordHashMock.Return(password, nil)
-				return mock
-			},
-		},
-		{
-			name: "negative case - body parse error",
-			req: req{
-				method: fiber.MethodPost,
-				route:  "/v1/users",
-			},
-			resCode: fiber.StatusBadRequest,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				return mocks.NewAuthServiceMock(mc)
-			},
-		},
-		{
-			name: "negative case - bad request",
-			req: req{
-				method: fiber.MethodPost,
-				route:  "/v1/users",
-				body: &dto.AddUserRequest{
-					Password: password,
-				},
-				contentType: fiber.MIMEApplicationJSON,
-			},
-			resCode: fiber.StatusBadRequest,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				return mocks.NewAuthServiceMock(mc)
-			},
-		},
-		{
-			name:    "negative case - repository error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.AddMock.Inspect(func(ctx context.Context, reqUsername string, reqPassword string) {
-					assert.Equal(mc, username, reqUsername)
-					assert.NotEmpty(mc, reqPassword)
-				}).Return(0, testError)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-				mock.GeneratePasswordHashMock.Return(password, nil)
-				return mock
-			},
-		},
-		{
-			name:    "negative case - auth service error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-				mock.GeneratePasswordHashMock.Return("", testError)
-				return mock
-			},
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			t.Parallel()
-
-			mc := minimock.NewController(t)
-			fiberApp := fiber.New()
-			fiberApp.Post("/v1/users", AddUserHandler(tt.authServiceMock(mc), tt.userRepoMock(mc)))
-
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
-			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
-
-			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
-			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
-			}
-		})
-	}
-}

+ 1 - 1
internal/api/v1/user/mocks/auth_service_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 

+ 11 - 11
internal/api/v1/user/mocks/user_repository_minimock.go

@@ -1,4 +1,4 @@
-// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
 
 package mocks
 
@@ -19,7 +19,7 @@ type UserRepositoryMock struct {
 	t          minimock.Tester
 	finishOnce sync.Once
 
-	funcAdd          func(ctx context.Context, username string, password string) (i1 int, err error)
+	funcAdd          func(ctx context.Context, username string, password string) (u1 uint64, err error)
 	inspectFuncAdd   func(ctx context.Context, username string, password string)
 	afterAddCounter  uint64
 	beforeAddCounter uint64
@@ -97,7 +97,7 @@ type UserRepositoryMockAddParamPtrs struct {
 
 // UserRepositoryMockAddResults contains results of the UserRepository.Add
 type UserRepositoryMockAddResults struct {
-	i1  int
+	u1  uint64
 	err error
 }
 
@@ -213,7 +213,7 @@ func (mmAdd *mUserRepositoryMockAdd) Inspect(f func(ctx context.Context, usernam
 }
 
 // Return sets up results that will be returned by UserRepository.Add
-func (mmAdd *mUserRepositoryMockAdd) Return(i1 int, err error) *UserRepositoryMock {
+func (mmAdd *mUserRepositoryMockAdd) Return(u1 uint64, err error) *UserRepositoryMock {
 	if mmAdd.mock.funcAdd != nil {
 		mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
 	}
@@ -221,12 +221,12 @@ func (mmAdd *mUserRepositoryMockAdd) Return(i1 int, err error) *UserRepositoryMo
 	if mmAdd.defaultExpectation == nil {
 		mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{mock: mmAdd.mock}
 	}
-	mmAdd.defaultExpectation.results = &UserRepositoryMockAddResults{i1, err}
+	mmAdd.defaultExpectation.results = &UserRepositoryMockAddResults{u1, err}
 	return mmAdd.mock
 }
 
 // Set uses given function f to mock the UserRepository.Add method
-func (mmAdd *mUserRepositoryMockAdd) Set(f func(ctx context.Context, username string, password string) (i1 int, err error)) *UserRepositoryMock {
+func (mmAdd *mUserRepositoryMockAdd) Set(f func(ctx context.Context, username string, password string) (u1 uint64, err error)) *UserRepositoryMock {
 	if mmAdd.defaultExpectation != nil {
 		mmAdd.mock.t.Fatalf("Default expectation is already set for the UserRepository.Add method")
 	}
@@ -255,8 +255,8 @@ func (mmAdd *mUserRepositoryMockAdd) When(ctx context.Context, username string,
 }
 
 // Then sets up UserRepository.Add return parameters for the expectation previously defined by the When method
-func (e *UserRepositoryMockAddExpectation) Then(i1 int, err error) *UserRepositoryMock {
-	e.results = &UserRepositoryMockAddResults{i1, err}
+func (e *UserRepositoryMockAddExpectation) Then(u1 uint64, err error) *UserRepositoryMock {
+	e.results = &UserRepositoryMockAddResults{u1, err}
 	return e.mock
 }
 
@@ -281,7 +281,7 @@ func (mmAdd *mUserRepositoryMockAdd) invocationsDone() bool {
 }
 
 // Add implements user.UserRepository
-func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, password string) (i1 int, err error) {
+func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, password string) (u1 uint64, err error) {
 	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
 	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
 
@@ -299,7 +299,7 @@ func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, passw
 	for _, e := range mmAdd.AddMock.expectations {
 		if minimock.Equal(*e.params, mm_params) {
 			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.i1, e.results.err
+			return e.results.u1, e.results.err
 		}
 	}
 
@@ -332,7 +332,7 @@ func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, passw
 		if mm_results == nil {
 			mmAdd.t.Fatal("No results are set for the UserRepositoryMock.Add")
 		}
-		return (*mm_results).i1, (*mm_results).err
+		return (*mm_results).u1, (*mm_results).err
 	}
 	if mmAdd.funcAdd != nil {
 		return mmAdd.funcAdd(ctx, username, password)

+ 6 - 0
internal/api/v1/user/update_user.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"strings"
 
+	"git.dmitriygnatenko.ru/dima/go-common/logger"
 	"github.com/gofiber/fiber/v2"
 
 	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
@@ -34,6 +35,7 @@ func UpdateUserHandler(
 		ctx := fctx.Context()
 		req := dto.UpdateUserRequest{}
 		if err = fctx.BodyParser(&req); err != nil {
+			logger.Info(ctx, err.Error())
 			return fiber.NewError(fiber.StatusBadRequest, err.Error())
 		}
 
@@ -44,6 +46,7 @@ func UpdateUserHandler(
 		if req.Password != nil {
 			password, err = authService.GeneratePasswordHash(strings.TrimSpace(*req.Password))
 			if err != nil {
+				logger.Error(ctx, err.Error())
 				return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 			}
 		}
@@ -56,6 +59,8 @@ func UpdateUserHandler(
 
 		user, err := userRepository.Get(ctx, claims[auth.ClaimsKeyName].(string))
 		if err != nil {
+			logger.Error(ctx, err.Error())
+
 			if errors.Is(err, sql.ErrNoRows) {
 				return fiber.NewError(fiber.StatusBadRequest, "")
 			}
@@ -68,6 +73,7 @@ func UpdateUserHandler(
 
 		err = userRepository.Update(ctx, mappers.ToUpdateUserRequest(user.ID, req))
 		if err != nil {
+			logger.Error(ctx, err.Error())
 			return fiber.NewError(fiber.StatusInternalServerError, err.Error())
 		}
 

+ 0 - 234
internal/api/v1/user/update_user_test.go

@@ -1,234 +0,0 @@
-package user
-
-import (
-	"context"
-	"database/sql"
-	"errors"
-	"net/http/httptest"
-	"testing"
-
-	"github.com/brianvoe/gofakeit/v6"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/golang-jwt/jwt/v4"
-	"github.com/stretchr/testify/assert"
-
-	API "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/user/mocks"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/dto"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
-	"git.dmitriygnatenko.ru/dima/homethings/internal/services/auth"
-)
-
-func TestUpdateUserHandler(t *testing.T) {
-	t.Parallel()
-
-	type req struct {
-		method      string
-		route       string
-		contentType string
-		body        *dto.UpdateUserRequest
-	}
-
-	var (
-		id          = gofakeit.Number(1, 1000)
-		username    = gofakeit.Username()
-		password    = gofakeit.Word()
-		newUsername = gofakeit.Username()
-		newPassword = gofakeit.Word()
-		testError   = errors.New(gofakeit.Phrase())
-
-		correctReq = req{
-			method: fiber.MethodPut,
-			route:  "/v1/users",
-			body: &dto.UpdateUserRequest{
-				Username: &newUsername,
-				Password: &newPassword,
-			},
-			contentType: fiber.MIMEApplicationJSON,
-		}
-
-		claims = jwt.MapClaims{
-			auth.ClaimsKeyName: username,
-		}
-
-		user = models.User{
-			ID:       id,
-			Username: username,
-			Password: password,
-		}
-	)
-
-	tests := []struct {
-		name            string
-		req             req
-		resCode         int
-		resBody         interface{}
-		userRepoMock    func(mc *minimock.Controller) UserRepository
-		authServiceMock func(mc *minimock.Controller) AuthService
-	}{
-		{
-			name:    "positive case",
-			req:     correctReq,
-			resCode: fiber.StatusOK,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, reqUsername string) {
-					assert.Equal(mc, username, reqUsername)
-				}).Return(&user, nil)
-
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateUserRequest) {
-					assert.Equal(mc, id, req.ID)
-					assert.Equal(mc, newUsername, req.Username.String)
-					assert.Equal(mc, newPassword, req.Password.String)
-				}).Return(nil)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-
-				mock.GeneratePasswordHashMock.Expect(newPassword).Return(newPassword, nil)
-				mock.GetClaimsMock.Return(claims)
-
-				return mock
-			},
-		},
-		{
-			name: "negative case - body parse error",
-			req: req{
-				method: fiber.MethodPut,
-				route:  "/v1/users",
-			},
-			resCode: fiber.StatusBadRequest,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				return mocks.NewAuthServiceMock(mc)
-			},
-		},
-		{
-			name: "negative case - bad request",
-			req: req{
-				method:      fiber.MethodPut,
-				route:       "/v1/users",
-				body:        &dto.UpdateUserRequest{},
-				contentType: fiber.MIMEApplicationJSON,
-			},
-			resCode: fiber.StatusBadRequest,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				return mocks.NewAuthServiceMock(mc)
-			},
-		},
-		{
-			name:    "negative case - auth service error",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				return mocks.NewUserRepositoryMock(mc)
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-				mock.GeneratePasswordHashMock.Expect(newPassword).Return("", testError)
-				return mock
-			},
-		},
-		{
-			name:    "negative case - repository error (update)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, reqUsername string) {
-					assert.Equal(mc, username, reqUsername)
-				}).Return(&user, nil)
-
-				mock.UpdateMock.Inspect(func(ctx context.Context, req models.UpdateUserRequest) {
-					assert.Equal(mc, id, req.ID)
-					assert.Equal(mc, newUsername, req.Username.String)
-					assert.Equal(mc, newPassword, req.Password.String)
-				}).Return(testError)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-
-				mock.GeneratePasswordHashMock.Expect(newPassword).Return(newPassword, nil)
-				mock.GetClaimsMock.Return(claims)
-
-				return mock
-			},
-		},
-		{
-			name:    "negative case - repository error (get user)",
-			req:     correctReq,
-			resCode: fiber.StatusInternalServerError,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, reqUsername string) {
-					assert.Equal(mc, username, reqUsername)
-				}).Return(nil, testError)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-
-				mock.GeneratePasswordHashMock.Expect(newPassword).Return(newPassword, nil)
-				mock.GetClaimsMock.Return(claims)
-
-				return mock
-			},
-		},
-		{
-			name:    "negative case - repository error (user not found)",
-			req:     correctReq,
-			resCode: fiber.StatusBadRequest,
-			userRepoMock: func(mc *minimock.Controller) UserRepository {
-				mock := mocks.NewUserRepositoryMock(mc)
-
-				mock.GetMock.Inspect(func(ctx context.Context, reqUsername string) {
-					assert.Equal(mc, username, reqUsername)
-				}).Return(nil, sql.ErrNoRows)
-
-				return mock
-			},
-			authServiceMock: func(mc *minimock.Controller) AuthService {
-				mock := mocks.NewAuthServiceMock(mc)
-
-				mock.GeneratePasswordHashMock.Expect(newPassword).Return(newPassword, nil)
-				mock.GetClaimsMock.Return(claims)
-
-				return mock
-			},
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			t.Parallel()
-
-			mc := minimock.NewController(t)
-			fiberApp := fiber.New()
-			fiberApp.Put("/v1/users", UpdateUserHandler(tt.authServiceMock(mc), tt.userRepoMock(mc)))
-
-			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, helpers.ConvertDataToIOReader(tt.req.body))
-			fiberReq.Header.Add(fiber.HeaderContentType, tt.req.contentType)
-			fiberRes, _ := fiberApp.Test(fiberReq, API.DefaultTestTimeOut)
-
-			assert.Equal(t, tt.resCode, fiberRes.StatusCode)
-			if tt.resBody != nil {
-				assert.Equal(t, helpers.MarshalResponse(tt.resBody), helpers.ConvertBodyToString(fiberRes.Body))
-			}
-		})
-	}
-}

+ 5 - 5
internal/dto/image.go

@@ -1,11 +1,11 @@
 package dto
 
 type ImageResponse struct {
-	ID        int    `json:"id"`
-	Image     string `json:"image"`
-	PlaceID   *int   `json:"place_id"`
-	ThingID   *int   `json:"thing_id"`
-	CreatedAt string `json:"created_at"`
+	ID        uint64  `json:"id"`
+	Image     string  `json:"image"`
+	PlaceID   *uint64 `json:"place_id"`
+	ThingID   *uint64 `json:"thing_id"`
+	CreatedAt string  `json:"created_at"`
 }
 
 type ImagesResponse struct {

+ 4 - 4
internal/dto/notification.go

@@ -1,7 +1,7 @@
 package dto
 
 type AddThingNotificationRequest struct {
-	ThingID          int    `json:"thing_id" validate:"required"`
+	ThingID          uint64 `json:"thing_id" validate:"required"`
 	NotificationDate string `json:"notification_date" validate:"required" format:"date-time"`
 }
 
@@ -10,7 +10,7 @@ type UpdateThingNotificationRequest struct {
 }
 
 type ThingNotificationResponse struct {
-	ThingID          int    `json:"id"`
+	ThingID          uint64 `json:"id"`
 	NotificationDate string `json:"notification_date"`
 	CreatedAt        string `json:"created_at"`
 	UpdatedAt        string `json:"updated_at"`
@@ -21,8 +21,8 @@ type ThingNotificationsExtResponse struct {
 }
 
 type ThingNotificationExtResponse struct {
-	ThingID          int    `json:"thing_id"`
-	PlaceID          int    `json:"place_id"`
+	ThingID          uint64 `json:"thing_id"`
+	PlaceID          uint64 `json:"place_id"`
 	ThingTitle       string `json:"thing_title"`
 	PlaceTitle       string `json:"place_title"`
 	NotificationDate string `json:"notification_date"`

+ 9 - 9
internal/dto/place.go

@@ -1,21 +1,21 @@
 package dto
 
 type AddPlaceRequest struct {
-	ParentID *int   `json:"parent_id"`
-	Title    string `json:"title" validate:"required"`
+	ParentID *uint64 `json:"parent_id"`
+	Title    string  `json:"title" validate:"required"`
 }
 
 type UpdatePlaceRequest struct {
-	ParentID *int   `json:"parent_id"`
-	Title    string `json:"title" validate:"required"`
+	ParentID *uint64 `json:"parent_id"`
+	Title    string  `json:"title" validate:"required"`
 }
 
 type PlaceResponse struct {
-	ID        int    `json:"id"`
-	ParentID  *int   `json:"parent_id"`
-	Title     string `json:"title"`
-	CreatedAt string `json:"created_at"`
-	UpdatedAt string `json:"updated_at"`
+	ID        uint64  `json:"id"`
+	ParentID  *uint64 `json:"parent_id"`
+	Title     string  `json:"title"`
+	CreatedAt string  `json:"created_at"`
+	UpdatedAt string  `json:"updated_at"`
 }
 
 type PlacesResponse struct {

+ 1 - 1
internal/dto/tag.go

@@ -11,7 +11,7 @@ type UpdateTagRequest struct {
 }
 
 type TagResponse struct {
-	ID        int    `json:"id"`
+	ID        uint64 `json:"id"`
 	Title     string `json:"title"`
 	Style     string `json:"style"`
 	CreatedAt string `json:"created_at"`

+ 4 - 4
internal/dto/thing.go

@@ -1,20 +1,20 @@
 package dto
 
 type AddThingRequest struct {
-	PlaceID     int    `json:"place_id" validate:"required"`
+	PlaceID     uint64 `json:"place_id" validate:"required"`
 	Title       string `json:"title" validate:"required"`
 	Description string `json:"description"`
 }
 
 type UpdateThingRequest struct {
-	PlaceID     int    `json:"place_id" validate:"required"`
+	PlaceID     uint64 `json:"place_id" validate:"required"`
 	Title       string `json:"title" validate:"required"`
 	Description string `json:"description"`
 }
 
 type ThingResponse struct {
-	ID          int    `json:"id"`
-	PlaceID     int    `json:"place_id"`
+	ID          uint64 `json:"id"`
+	PlaceID     uint64 `json:"place_id"`
 	Title       string `json:"title"`
 	Description string `json:"description"`
 	CreatedAt   string `json:"created_at"`

+ 1 - 1
internal/factory/error.go

@@ -7,7 +7,7 @@ import (
 )
 
 func CreateValidateErrorResponse(errors error) []dto.ValidateErrorResponse {
-	var res []dto.ValidateErrorResponse //nolint
+	var res []dto.ValidateErrorResponse
 
 	for _, err := range errors.(validator.ValidationErrors) {
 		res = append(res, dto.ValidateErrorResponse{

+ 106 - 47
internal/fiber/fiber.go

@@ -2,8 +2,8 @@ package fiber
 
 import (
 	"errors"
-	"log"
 
+	"git.dmitriygnatenko.ru/dima/go-common/db"
 	"github.com/gofiber/fiber/v2"
 	"github.com/gofiber/fiber/v2/middleware/basicauth"
 	"github.com/gofiber/fiber/v2/middleware/cors"
@@ -12,7 +12,7 @@ import (
 	fiberJwt "github.com/gofiber/jwt/v3"
 	"github.com/gofiber/swagger"
 
-	_ "git.dmitriygnatenko.ru/dima/homethings/docs" //nolint
+	_ "git.dmitriygnatenko.ru/dima/homethings/docs" // nolint
 	authAPI "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/auth"
 	imageAPI "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image"
 	notificationAPI "git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/notification"
@@ -23,9 +23,8 @@ import (
 	"git.dmitriygnatenko.ru/dima/homethings/internal/factory"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/middleware/timezone"
 	"git.dmitriygnatenko.ru/dima/homethings/internal/repositories"
-	authService "git.dmitriygnatenko.ru/dima/homethings/internal/services/auth"
-	envService "git.dmitriygnatenko.ru/dima/homethings/internal/services/env"
-	mailerService "git.dmitriygnatenko.ru/dima/homethings/internal/services/mailer"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/services/auth"
+	"git.dmitriygnatenko.ru/dima/homethings/internal/services/config"
 )
 
 const (
@@ -36,9 +35,9 @@ const (
 
 type (
 	ServiceProvider interface {
-		EnvService() *envService.Service
-		MailerService() *mailerService.Service
-		AuthService() *authService.Service
+		ConfigService() *config.Service
+		AuthService() *auth.Service
+		TransactionManager() *db.TxManager
 		UserRepository() *repositories.UserRepository
 		PlaceRepository() *repositories.PlaceRepository
 		ThingRepository() *repositories.ThingRepository
@@ -53,7 +52,7 @@ type (
 )
 
 func Init(sp ServiceProvider) (*fiber.App, error) {
-	fiberApp := fiber.New(getFiberConfig(sp))
+	fiberApp := fiber.New(getFiberConfig())
 
 	// Configure web root
 	fiberApp.Static("/", staticPath)
@@ -73,7 +72,7 @@ func Init(sp ServiceProvider) (*fiber.App, error) {
 	// Configure Basic auth
 	basicAuth := basicauth.New(basicauth.Config{
 		Users: map[string]string{
-			sp.EnvService().BasicAuthUser(): sp.EnvService().BasicAuthPassword(),
+			sp.ConfigService().BasicAuthUser(): sp.ConfigService().BasicAuthPassword(),
 		},
 	})
 
@@ -90,15 +89,15 @@ func Init(sp ServiceProvider) (*fiber.App, error) {
 	return fiberApp, nil
 }
 
-func getFiberConfig(sp ServiceProvider) fiber.Config {
+func getFiberConfig() fiber.Config {
 	return fiber.Config{
 		AppName:               "Homethings",
 		DisableStartupMessage: true,
-		ErrorHandler:          getErrorHandler(sp),
+		ErrorHandler:          getErrorHandler(),
 	}
 }
 
-func getErrorHandler(sp ServiceProvider) fiber.ErrorHandler {
+func getErrorHandler() fiber.ErrorHandler {
 	return func(fctx *fiber.Ctx, err error) error {
 		errCode := fiber.StatusInternalServerError
 		var e *fiber.Error
@@ -107,18 +106,6 @@ func getErrorHandler(sp ServiceProvider) fiber.ErrorHandler {
 		}
 
 		if err.Error() != "" {
-			errorsEmail := sp.EnvService().ErrorsEmail()
-
-			if errCode == fiber.StatusInternalServerError && errorsEmail != "" {
-				log.Println(err)
-				// nolint
-				sp.MailerService().Send(
-					errorsEmail,
-					"AUTO - Homethings error",
-					err.Error(),
-				)
-			}
-
 			return fctx.Status(errCode).JSON(factory.CreateErrorResponse(err))
 		}
 
@@ -129,7 +116,7 @@ func getErrorHandler(sp ServiceProvider) fiber.ErrorHandler {
 // nolint
 func getJWTConfig(sp ServiceProvider) fiberJwt.Config {
 	return fiberJwt.Config{
-		SigningKey: []byte(sp.EnvService().JWTSecretKey()),
+		SigningKey: []byte(sp.ConfigService().JWTSecretKey()),
 		ErrorHandler: func(fctx *fiber.Ctx, err error) error {
 			return fiber.NewError(fiber.StatusForbidden, err.Error())
 		},
@@ -159,8 +146,8 @@ func getMetricsConfig() monitor.Config {
 
 func getCORSConfig(sp ServiceProvider) cors.Config {
 	return cors.Config{
-		AllowOrigins: sp.EnvService().CORSAllowOrigins(),
-		AllowMethods: sp.EnvService().CORSAllowMethods(),
+		AllowOrigins: sp.ConfigService().CORSAllowOrigins(),
+		AllowMethods: sp.ConfigService().CORSAllowMethods(),
 	}
 }
 
@@ -185,28 +172,46 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 
 	r.Get(
 		"/v1/places",
-		placeAPI.GetPlacesHandler(sp.PlaceRepository()),
+		placeAPI.GetPlacesHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/places/tree",
-		placeAPI.GetPlaceTreeHandler(sp.PlaceRepository()),
+		placeAPI.GetPlaceTreeHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/places/:placeId<int>",
-		placeAPI.GetPlaceHandler(sp.PlaceRepository()),
+		placeAPI.GetPlaceHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/places/:parentPlaceId<int>/nested",
-		placeAPI.GetNestedPlacesHandler(sp.PlaceRepository()),
+		placeAPI.GetNestedPlacesHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Post(
 		"/v1/places",
-		placeAPI.AddPlaceHandler(sp.PlaceRepository()),
+		placeAPI.AddPlaceHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Put(
 		"/v1/places/:placeId<int>",
-		placeAPI.UpdatePlaceHandler(sp.PlaceRepository()),
+		placeAPI.UpdatePlaceHandler(
+			sp.PlaceRepository(),
+		),
 	)
+
 	r.Delete(
 		"/v1/places/:placeId<int>",
 		placeAPI.DeletePlaceHandler(
@@ -225,10 +230,12 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 		"/v1/things/:thingId<int>",
 		thingAPI.GetThingHandler(sp.ThingRepository()),
 	)
+
 	r.Get(
 		"/v1/things/search/:search",
 		thingAPI.SearchThingHandler(sp.ThingRepository()),
 	)
+
 	r.Get(
 		"/v1/things/place/:placeId<int>",
 		thingAPI.GetPlaceThingsHandler(
@@ -236,6 +243,7 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.ThingTagRepository(),
 		),
 	)
+
 	r.Post(
 		"/v1/things",
 		thingAPI.AddThingHandler(
@@ -243,6 +251,7 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.PlaceThingRepository(),
 		),
 	)
+
 	r.Put(
 		"/v1/things/:thingId<int>",
 		thingAPI.UpdateThingHandler(
@@ -250,6 +259,7 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.PlaceThingRepository(),
 		),
 	)
+
 	r.Delete(
 		"/v1/things/:thingId<int>",
 		thingAPI.DeleteThingHandler(
@@ -269,27 +279,34 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.PlaceImageRepository(),
 		),
 	)
+
 	r.Get(
 		"/v1/images/thing/:thingId<int>",
 		imageAPI.GetThingImagesHandler(sp.ThingImageRepository()))
+
 	r.Post(
 		"/v1/images",
 		imageAPI.AddImageHandler(
+			sp.TransactionManager(),
 			sp.FileRepository(),
 			sp.ThingImageRepository(),
 			sp.PlaceImageRepository(),
 		),
 	)
+
 	r.Delete(
 		"/v1/images/place/:imageId<int>",
 		imageAPI.DeletePlaceImageHandler(
+			sp.TransactionManager(),
 			sp.FileRepository(),
 			sp.PlaceImageRepository(),
 		),
 	)
+
 	r.Delete(
 		"/v1/images/thing/:imageId<int>",
 		imageAPI.DeleteThingImageHandler(
+			sp.TransactionManager(),
 			sp.FileRepository(),
 			sp.ThingImageRepository(),
 		),
@@ -297,20 +314,32 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 
 	r.Get(
 		"/v1/tags",
-		tagAPI.GetTagsHandler(sp.TagRepository()),
+		tagAPI.GetTagsHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/tags/:tagId<int>",
-		tagAPI.GetTagHandler(sp.TagRepository()),
+		tagAPI.GetTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/tags/thing/:thingId<int>",
-		tagAPI.GetThingTagsHandler(sp.TagRepository()),
+		tagAPI.GetThingTagsHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Post(
 		"/v1/tags",
-		tagAPI.AddTagHandler(sp.TagRepository()),
+		tagAPI.AddTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Post(
 		"/v1/tags/:tagId<int>/thing/:thingId<int>",
 		tagAPI.AddThingTagHandler(
@@ -319,10 +348,14 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.ThingTagRepository(),
 		),
 	)
+
 	r.Put(
 		"/v1/tags/:tagId<int>",
-		tagAPI.UpdateTagHandler(sp.TagRepository()),
+		tagAPI.UpdateTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Delete(
 		"/v1/tags/:tagId<int>",
 		tagAPI.DeleteTagHandler(
@@ -330,6 +363,7 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.ThingTagRepository(),
 		),
 	)
+
 	r.Delete(
 		"/v1/tags/:tagId<int>/thing/:thingId<int>",
 		tagAPI.DeleteThingTagHandler(
@@ -338,18 +372,28 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.ThingTagRepository(),
 		),
 	)
+
 	r.Get(
 		"/v1/tags/:id<int>",
-		tagAPI.GetTagHandler(sp.TagRepository()),
+		tagAPI.UpdateTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Post(
 		"/v1/tags",
-		tagAPI.AddTagHandler(sp.TagRepository()),
+		tagAPI.UpdateTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Put(
 		"/v1/tags/:id<int>",
-		tagAPI.UpdateTagHandler(sp.TagRepository()),
+		tagAPI.UpdateTagHandler(
+			sp.TagRepository(),
+		),
 	)
+
 	r.Delete(
 		"/v1/tags/:id<int>",
 		tagAPI.DeleteTagHandler(
@@ -360,23 +404,37 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 
 	r.Get(
 		"/v1/things/notifications/:thingId<int>",
-		notificationAPI.GetThingNotificationHandler(sp.ThingNotificationRepository()),
+		notificationAPI.GetThingNotificationHandler(
+			sp.ThingNotificationRepository(),
+		),
 	)
+
 	r.Get(
 		"/v1/things/notifications/expired",
-		notificationAPI.GetExpiredThingNotificationsHandler(sp.ThingNotificationRepository()),
+		notificationAPI.GetExpiredThingNotificationsHandler(
+			sp.ThingNotificationRepository(),
+		),
 	)
+
 	r.Post(
 		"/v1/things/notifications",
-		notificationAPI.AddThingNotificationHandler(sp.ThingNotificationRepository()),
+		notificationAPI.AddThingNotificationHandler(
+			sp.ThingNotificationRepository(),
+		),
 	)
+
 	r.Put(
 		"/v1/things/notifications/:thingId<int>",
-		notificationAPI.UpdateThingNotificationHandler(sp.ThingNotificationRepository()),
+		notificationAPI.UpdateThingNotificationHandler(
+			sp.ThingNotificationRepository(),
+		),
 	)
+
 	r.Delete(
 		"/v1/things/notifications/:thingId<int>",
-		notificationAPI.DeleteThingNotificationHandler(sp.ThingNotificationRepository()),
+		notificationAPI.DeleteThingNotificationHandler(
+			sp.ThingNotificationRepository(),
+		),
 	)
 
 	r.Post(
@@ -386,6 +444,7 @@ func registerHandlers(r fiber.Router, sp ServiceProvider) {
 			sp.UserRepository(),
 		),
 	)
+
 	r.Put(
 		"/v1/users",
 		userAPI.UpdateUserHandler(

+ 1 - 1
internal/helpers/location.go → internal/helpers/location/location.go

@@ -1,4 +1,4 @@
-package helpers
+package location
 
 import (
 	"time"

+ 1 - 1
internal/helpers/random.go → internal/helpers/random/random.go

@@ -1,4 +1,4 @@
-package helpers
+package random
 
 import (
 	"math/rand"

+ 2 - 7
internal/helpers/test.go → internal/helpers/test/convert.go

@@ -1,4 +1,4 @@
-package helpers
+package test
 
 import (
 	"bytes"
@@ -8,7 +8,7 @@ import (
 
 func ConvertBodyToString(body io.ReadCloser) string {
 	buf := new(bytes.Buffer)
-	buf.ReadFrom(body) //nolint
+	buf.ReadFrom(body) // nolint
 	return buf.String()
 }
 
@@ -21,8 +21,3 @@ func ConvertDataToIOReader(data interface{}) io.Reader {
 
 	return res
 }
-
-func MarshalResponse(data interface{}) string {
-	res, _ := json.Marshal(data)
-	return string(res)
-}

+ 8 - 0
internal/helpers/test/marshal.go

@@ -0,0 +1,8 @@
+package test
+
+import "encoding/json"
+
+func MarshalResponse(data interface{}) string {
+	res, _ := json.Marshal(data)
+	return string(res)
+}

+ 3 - 0
internal/helpers/test/test.go

@@ -0,0 +1,3 @@
+package test
+
+const TestTimeout = -1

+ 3 - 3
internal/mappers/image.go

@@ -6,15 +6,15 @@ import (
 )
 
 func ToImageResponse(req models.Image) dto.ImageResponse {
-	var placeIDPtr, thingIDPtr *int
+	var placeIDPtr, thingIDPtr *uint64
 
 	if req.PlaceID.Valid {
-		placeID := int(req.PlaceID.Int64)
+		placeID := uint64(req.PlaceID.Int64)
 		placeIDPtr = &placeID
 	}
 
 	if req.ThingID.Valid {
-		thingID := int(req.ThingID.Int64)
+		thingID := uint64(req.ThingID.Int64)
 		thingIDPtr = &thingID
 	}
 

+ 5 - 5
internal/mappers/place.go

@@ -17,7 +17,7 @@ func ToPlaceResponse(req models.Place) dto.PlaceResponse {
 	}
 
 	if req.ParentID.Valid {
-		parentID := int(req.ParentID.Int64)
+		parentID := uint64(req.ParentID.Int64)
 		res.ParentID = &parentID
 	}
 
@@ -36,7 +36,7 @@ func ToAddPlaceRequest(req dto.AddPlaceRequest) models.AddPlaceRequest {
 	return res
 }
 
-func ToUpdatePlaceRequest(id int, req dto.UpdatePlaceRequest) models.UpdatePlaceRequest {
+func ToUpdatePlaceRequest(id uint64, req dto.UpdatePlaceRequest) models.UpdatePlaceRequest {
 	res := models.UpdatePlaceRequest{
 		ID:    id,
 		Title: req.Title,
@@ -67,7 +67,7 @@ func ToPlacesResponse(req []models.Place) dto.PlacesResponse {
 
 func ToPlaceTreeResponse(req []models.Place) dto.PlaceTreeResponse {
 	var res []dto.PlaceTree
-	parentMap := make(map[int][]models.Place, len(req))
+	parentMap := make(map[uint64][]models.Place, len(req))
 
 	for _, p := range req {
 		if !p.ParentID.Valid {
@@ -77,7 +77,7 @@ func ToPlaceTreeResponse(req []models.Place) dto.PlaceTreeResponse {
 			continue
 		}
 
-		parentID := int(p.ParentID.Int64)
+		parentID := uint64(p.ParentID.Int64)
 		parentMap[parentID] = append(parentMap[parentID], p)
 	}
 
@@ -94,7 +94,7 @@ func ToPlaceTreeResponse(req []models.Place) dto.PlaceTreeResponse {
 	}
 }
 
-func recursiveFillNested(item *dto.PlaceTree, parentMap map[int][]models.Place) {
+func recursiveFillNested(item *dto.PlaceTree, parentMap map[uint64][]models.Place) {
 	id := item.Place.ID
 
 	if _, ok := parentMap[id]; ok {

+ 1 - 1
internal/mappers/place_image.go

@@ -2,7 +2,7 @@ package mappers
 
 import "git.dmitriygnatenko.ru/dima/homethings/internal/models"
 
-func ToAddPlaceImageRequest(placeID int, image string) models.AddPlaceImageRequest {
+func ToAddPlaceImageRequest(placeID uint64, image string) models.AddPlaceImageRequest {
 	return models.AddPlaceImageRequest{
 		PlaceID: placeID,
 		Image:   image,

+ 3 - 3
internal/mappers/tag.go

@@ -14,7 +14,7 @@ func ToAddTagRequest(req dto.AddTagRequest) models.AddTagRequest {
 	}
 }
 
-func ToUpdateTagRequest(id int, req dto.UpdateTagRequest) models.UpdateTagRequest {
+func ToUpdateTagRequest(id uint64, req dto.UpdateTagRequest) models.UpdateTagRequest {
 	return models.UpdateTagRequest{
 		ID:    id,
 		Title: req.Title,
@@ -22,14 +22,14 @@ func ToUpdateTagRequest(id int, req dto.UpdateTagRequest) models.UpdateTagReques
 	}
 }
 
-func ToAddThingTagRequest(tagID int, thingID int) models.AddThingTagRequest {
+func ToAddThingTagRequest(tagID uint64, thingID uint64) models.AddThingTagRequest {
 	return models.AddThingTagRequest{
 		ThingID: thingID,
 		TagID:   tagID,
 	}
 }
 
-func ToDeleteThingTagRequest(tagID int, thingID int) models.DeleteThingTagRequest {
+func ToDeleteThingTagRequest(tagID uint64, thingID uint64) models.DeleteThingTagRequest {
 	return models.DeleteThingTagRequest{
 		ThingID: thingID,
 		TagID:   tagID,

+ 4 - 4
internal/mappers/thing.go

@@ -14,7 +14,7 @@ func ToAddThingRequest(req dto.AddThingRequest) models.AddThingRequest {
 	}
 }
 
-func ToUpdateThingRequest(id int, req dto.UpdateThingRequest) models.UpdateThingRequest {
+func ToUpdateThingRequest(id uint64, req dto.UpdateThingRequest) models.UpdateThingRequest {
 	return models.UpdateThingRequest{
 		ID:          id,
 		Title:       req.Title,
@@ -22,14 +22,14 @@ func ToUpdateThingRequest(id int, req dto.UpdateThingRequest) models.UpdateThing
 	}
 }
 
-func ToAddPlaceThingRequest(thingID int, placeID int) models.AddPlaceThingRequest {
+func ToAddPlaceThingRequest(thingID uint64, placeID uint64) models.AddPlaceThingRequest {
 	return models.AddPlaceThingRequest{
 		PlaceID: placeID,
 		ThingID: thingID,
 	}
 }
 
-func ToUpdatePlaceThingRequest(thingID int, placeID int) models.UpdatePlaceThingRequest {
+func ToUpdatePlaceThingRequest(thingID uint64, placeID uint64) models.UpdatePlaceThingRequest {
 	return models.UpdatePlaceThingRequest{
 		ThingID: thingID,
 		PlaceID: placeID,
@@ -60,7 +60,7 @@ func ToThingsResponse(things []models.Thing) dto.ThingsResponse {
 func ToThingsExtResponse(things []models.Thing, tags []models.ThingTag) dto.ThingsExtResponse {
 	res := make([]dto.ThingExtResponse, 0, len(things))
 
-	groupedTags := make(map[int][]dto.TagResponse)
+	groupedTags := make(map[uint64][]dto.TagResponse)
 	for _, tag := range tags {
 		if _, ok := groupedTags[tag.ThingID]; !ok {
 			groupedTags[tag.ThingID] = make([]dto.TagResponse, 0)

+ 1 - 1
internal/mappers/thing_image.go

@@ -2,7 +2,7 @@ package mappers
 
 import "git.dmitriygnatenko.ru/dima/homethings/internal/models"
 
-func ToAddThingImageRequest(thingID int, image string) models.AddThingImageRequest {
+func ToAddThingImageRequest(thingID uint64, image string) models.AddThingImageRequest {
 	return models.AddThingImageRequest{
 		ThingID: thingID,
 		Image:   image,

+ 1 - 1
internal/mappers/thing_notification.go

@@ -19,7 +19,7 @@ func ToAddThingNotificationRequest(req dto.AddThingNotificationRequest) (*models
 	}, nil
 }
 
-func ToUpdateThingNotificationRequest(thingID int, req dto.UpdateThingNotificationRequest) (*models.UpdateThingNotificationRequest, error) {
+func ToUpdateThingNotificationRequest(thingID uint64, req dto.UpdateThingNotificationRequest) (*models.UpdateThingNotificationRequest, error) {
 	date, err := time.Parse(time.RFC3339, req.NotificationDate)
 	if err != nil {
 		return nil, err

+ 1 - 1
internal/mappers/user.go

@@ -8,7 +8,7 @@ import (
 	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
 )
 
-func ToUpdateUserRequest(id int, req dto.UpdateUserRequest) models.UpdateUserRequest {
+func ToUpdateUserRequest(id uint64, req dto.UpdateUserRequest) models.UpdateUserRequest {
 	res := models.UpdateUserRequest{
 		ID: id,
 	}

+ 1 - 1
internal/models/image.go

@@ -6,7 +6,7 @@ import (
 )
 
 type Image struct {
-	ID        int
+	ID        uint64
 	ThingID   sql.NullInt64
 	PlaceID   sql.NullInt64
 	Image     string

+ 2 - 2
internal/models/place.go

@@ -6,7 +6,7 @@ import (
 )
 
 type Place struct {
-	ID        int
+	ID        uint64
 	Title     string
 	ParentID  sql.NullInt64
 	CreatedAt time.Time
@@ -19,7 +19,7 @@ type AddPlaceRequest struct {
 }
 
 type UpdatePlaceRequest struct {
-	ID       int
+	ID       uint64
 	Title    string
 	ParentID sql.NullInt64
 }

+ 1 - 1
internal/models/place_image.go

@@ -1,6 +1,6 @@
 package models
 
 type AddPlaceImageRequest struct {
-	PlaceID int
+	PlaceID uint64
 	Image   string
 }

+ 2 - 2
internal/models/place_thing.go

@@ -3,7 +3,7 @@ package models
 import "time"
 
 type PlaceThing struct {
-	PlaceID   int
-	ThingID   int
+	PlaceID   uint64
+	ThingID   uint64
 	CreatedAt time.Time
 }

+ 2 - 2
internal/models/tag.go

@@ -3,7 +3,7 @@ package models
 import "time"
 
 type Tag struct {
-	ID        int
+	ID        uint64
 	Title     string
 	Style     string
 	CreatedAt time.Time
@@ -16,7 +16,7 @@ type AddTagRequest struct {
 }
 
 type UpdateTagRequest struct {
-	ID    int
+	ID    uint64
 	Title string
 	Style string
 }

+ 7 - 7
internal/models/thing.go

@@ -3,8 +3,8 @@ package models
 import "time"
 
 type Thing struct {
-	ID          int
-	PlaceID     int
+	ID          uint64
+	PlaceID     uint64
 	Title       string
 	Description string
 	CreatedAt   time.Time
@@ -17,17 +17,17 @@ type AddThingRequest struct {
 }
 
 type UpdateThingRequest struct {
-	ID          int
+	ID          uint64
 	Title       string
 	Description string
 }
 
 type AddPlaceThingRequest struct {
-	PlaceID int
-	ThingID int
+	PlaceID uint64
+	ThingID uint64
 }
 
 type UpdatePlaceThingRequest struct {
-	ThingID int
-	PlaceID int
+	ThingID uint64
+	PlaceID uint64
 }

+ 1 - 1
internal/models/thing_image.go

@@ -1,6 +1,6 @@
 package models
 
 type AddThingImageRequest struct {
-	ThingID int
+	ThingID uint64
 	Image   string
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio