diff --git a/.drone.yml b/.drone.yml index 5f35800..bb9f7b5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -46,6 +46,7 @@ node: tag: aecde-docker-runner trigger: branch: + - main - develop event: - custom \ No newline at end of file diff --git a/go.mod b/go.mod index 3a66ea4..dc8063e 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,10 @@ require ( github.com/golang-jwt/jwt/v5 v5.3.0 github.com/labstack/echo/v4 v4.13.4 github.com/redis/go-redis/v9 v9.12.0 - github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.10.0 github.com/swaggo/echo-swagger v1.4.1 github.com/swaggo/swag v1.16.6 - go.mongodb.org/mongo-driver v1.17.4 + go.mongodb.org/mongo-driver/v2 v2.3.0 go.uber.org/zap v1.26.0 golang.org/x/crypto v0.40.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 @@ -41,24 +40,12 @@ require ( require ( github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect + github.com/golang/snappy v1.0.0 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/labstack/gommon v0.4.2 // indirect - github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/montanaflynn/stats v0.7.1 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/subosito/gotenv v1.6.0 // indirect + github.com/subosito/gotenv v1.6.0 github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect @@ -66,11 +53,9 @@ require ( github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.42.0 // indirect golang.org/x/sync v0.16.0 // indirect golang.org/x/sys v0.34.0 // indirect golang.org/x/text v0.27.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7840c21..7119583 100644 --- a/go.sum +++ b/go.sum @@ -8,16 +8,10 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= -github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic= @@ -30,12 +24,10 @@ github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZ github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= +github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= @@ -48,50 +40,20 @@ github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcX github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= -github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= -github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= -github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.12.0 h1:XlVPGlflh4nxfhsNXPA8Qp6EmEfTo0rp8oaBzPipXnU= github.com/redis/go-redis/v9 v9.12.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= -github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= -github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= -github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= -github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -115,8 +77,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= -go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= +go.mongodb.org/mongo-driver/v2 v2.3.0 h1:sh55yOXA2vUjW1QYw/2tRlHSQViwDyPnW61AwpZ4rtU= +go.mongodb.org/mongo-driver/v2 v2.3.0/go.mod h1:jHeEDJHJq7tm6ZF45Issun9dbogjfnPySb1vXA7EeAI= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= @@ -127,8 +89,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= @@ -168,12 +128,9 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/company/entity.go b/internal/company/entity.go index ba35457..fa633f4 100644 --- a/internal/company/entity.go +++ b/internal/company/entity.go @@ -3,7 +3,7 @@ package company import ( "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // CompanyStatus represents company account status @@ -66,7 +66,7 @@ type Company struct { // SetID sets the company ID (implements IDSetter interface) func (c *Company) SetID(id string) { - c.ID, _ = primitive.ObjectIDFromHex(id) + c.ID, _ = bson.ObjectIDFromHex(id) } // GetID returns the company ID (implements IDGetter interface) diff --git a/internal/company/repository.go b/internal/company/repository.go index 3bc4c15..f186aa8 100644 --- a/internal/company/repository.go +++ b/internal/company/repository.go @@ -8,7 +8,7 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines the interface for company data operations diff --git a/internal/company_category/entity.go b/internal/company_category/entity.go index 04ca39d..1037e1d 100644 --- a/internal/company_category/entity.go +++ b/internal/company_category/entity.go @@ -3,7 +3,7 @@ package company_category import ( "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type Category struct { @@ -17,7 +17,7 @@ type Category struct { // SetID sets the category ID (implements IDSetter interface) func (c *Category) SetID(id string) { - c.ID, _ = primitive.ObjectIDFromHex(id) + c.ID, _ = bson.ObjectIDFromHex(id) } // GetID returns the category ID (implements IDGetter interface) diff --git a/internal/company_category/repository.go b/internal/company_category/repository.go index b773292..cf34048 100644 --- a/internal/company_category/repository.go +++ b/internal/company_category/repository.go @@ -8,8 +8,7 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines the interface for category data operations @@ -99,9 +98,9 @@ func (r *categoryRepository) GetByID(ctx context.Context, id string) (*Category, // GetByIDs retrieves categories by IDs func (r *categoryRepository) GetByIDs(ctx context.Context, ids []string) ([]Category, error) { - objectIDs := make([]primitive.ObjectID, len(ids)) + objectIDs := make([]bson.ObjectID, len(ids)) for i, id := range ids { - objectID, err := primitive.ObjectIDFromHex(id) + objectID, err := bson.ObjectIDFromHex(id) if err != nil { return nil, err } diff --git a/internal/customer/entity.go b/internal/customer/entity.go index 3acf755..d865718 100644 --- a/internal/customer/entity.go +++ b/internal/customer/entity.go @@ -3,7 +3,7 @@ package customer import ( "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // CustomerStatus represents customer account status @@ -43,7 +43,7 @@ type Customer struct { // SetID sets the customer ID (implements IDSetter interface) func (c *Customer) SetID(id string) { - c.ID, _ = primitive.ObjectIDFromHex(id) + c.ID, _ = bson.ObjectIDFromHex(id) } // GetID returns the customer ID (implements IDGetter interface) diff --git a/internal/customer/repository.go b/internal/customer/repository.go index 6997cda..42dce33 100644 --- a/internal/customer/repository.go +++ b/internal/customer/repository.go @@ -8,7 +8,7 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines the interface for customer data operations diff --git a/internal/customer/service.go b/internal/customer/service.go index 4f2b5b1..c36294d 100644 --- a/internal/customer/service.go +++ b/internal/customer/service.go @@ -11,7 +11,7 @@ import ( "tm/pkg/authorization" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" "golang.org/x/crypto/bcrypt" ) @@ -562,7 +562,7 @@ func (s *customerService) RefreshToken(ctx context.Context, refreshToken string) } // Get customer information - customerID, err := primitive.ObjectIDFromHex(validationResult.Claims.UserID) + customerID, err := bson.ObjectIDFromHex(validationResult.Claims.UserID) if err != nil { s.logger.Error("Failed to parse customer ID from token", map[string]interface{}{ "error": err.Error(), diff --git a/internal/feedback/repository.go b/internal/feedback/repository.go index f3ea9bd..000781b 100644 --- a/internal/feedback/repository.go +++ b/internal/feedback/repository.go @@ -6,8 +6,8 @@ import ( "tm/pkg/logger" "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson" - driver "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + driver "go.mongodb.org/mongo-driver/v2/mongo" ) // FeedbackRepository interface defines feedback data access methods diff --git a/internal/inquiry/entity.go b/internal/inquiry/entity.go index e7ef0f8..55fcc1c 100644 --- a/internal/inquiry/entity.go +++ b/internal/inquiry/entity.go @@ -4,7 +4,7 @@ import ( "time" "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // Inquiry status constants @@ -35,7 +35,7 @@ type Inquiry struct { } func (i *Inquiry) SetID(id string) { - i.ID, _ = primitive.ObjectIDFromHex(id) + i.ID, _ = bson.ObjectIDFromHex(id) } func (i *Inquiry) GetID() string { diff --git a/internal/inquiry/repository.go b/internal/inquiry/repository.go index eef3873..629e9ab 100644 --- a/internal/inquiry/repository.go +++ b/internal/inquiry/repository.go @@ -8,7 +8,7 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines methods for inquiry data access diff --git a/internal/tender/repository.go b/internal/tender/repository.go index 801bc0f..5346207 100644 --- a/internal/tender/repository.go +++ b/internal/tender/repository.go @@ -7,8 +7,8 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) // TenderRepository interface defines tender data access methods diff --git a/internal/tender_approval/repository.go b/internal/tender_approval/repository.go index 8e091ce..3576f2a 100644 --- a/internal/tender_approval/repository.go +++ b/internal/tender_approval/repository.go @@ -7,8 +7,7 @@ import ( "tm/pkg/logger" "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines the interface for tender approval data operations @@ -214,7 +213,7 @@ func (r *tenderApprovalRepository) GetByIDs(ctx context.Context, ids []string) ( // Convert string IDs to ObjectIDs for MongoDB query objectIDs := make([]interface{}, len(ids)) for i, id := range ids { - objectID, err := primitive.ObjectIDFromHex(id) + objectID, err := bson.ObjectIDFromHex(id) if err != nil { r.logger.Warn("Invalid tender approval ID format", map[string]interface{}{ "id": id, diff --git a/internal/user/entity.go b/internal/user/entity.go index f3bb7bb..f13c1e4 100644 --- a/internal/user/entity.go +++ b/internal/user/entity.go @@ -3,7 +3,7 @@ package user import ( "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // UserRole represents user roles in the system @@ -44,7 +44,7 @@ type User struct { // SetID sets the user ID (implements IDSetter interface) func (u *User) SetID(id string) { - u.ID, _ = primitive.ObjectIDFromHex(id) + u.ID, _ = bson.ObjectIDFromHex(id) } // GetID returns the user ID (implements IDGetter interface) diff --git a/internal/user/middleware.go b/internal/user/middleware.go index 102e1b5..7cd19a3 100644 --- a/internal/user/middleware.go +++ b/internal/user/middleware.go @@ -6,7 +6,7 @@ import ( "tm/pkg/response" "github.com/labstack/echo/v4" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // AuthMiddleware validates JWT access tokens and extracts user information @@ -44,7 +44,7 @@ func (h *Handler) AuthMiddleware() echo.MiddlewareFunc { } // Extract user information from token - userID, err := primitive.ObjectIDFromHex(validationResult.Claims.UserID) + userID, err := bson.ObjectIDFromHex(validationResult.Claims.UserID) if err != nil { h.logger.Error("Failed to parse user ID from token", map[string]interface{}{ "error": err.Error(), diff --git a/internal/user/repository.go b/internal/user/repository.go index f19dab6..8444f41 100644 --- a/internal/user/repository.go +++ b/internal/user/repository.go @@ -8,7 +8,7 @@ import ( orm "tm/pkg/mongo" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // Repository defines methods for user data access diff --git a/internal/user/service.go b/internal/user/service.go index b349e59..ac3623e 100644 --- a/internal/user/service.go +++ b/internal/user/service.go @@ -9,7 +9,7 @@ import ( "tm/pkg/logger" "tm/pkg/response" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" "golang.org/x/crypto/bcrypt" ) @@ -368,7 +368,7 @@ func (s *userService) RefreshToken(ctx context.Context, refreshToken string) (*A } // Get user information - userID, err := primitive.ObjectIDFromHex(validationResult.Claims.UserID) + userID, err := bson.ObjectIDFromHex(validationResult.Claims.UserID) if err != nil { s.logger.Error("Failed to parse user ID from token", map[string]interface{}{ "error": err.Error(), diff --git a/pkg/mongo/connection.go b/pkg/mongo/connection.go index cf6668a..c1d9a11 100644 --- a/pkg/mongo/connection.go +++ b/pkg/mongo/connection.go @@ -5,10 +5,10 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) // ConnectionConfig holds MongoDB connection configuration @@ -62,7 +62,7 @@ func NewConnectionManager(config ConnectionConfig, logger Logger) (*ConnectionMa ctx, cancel := context.WithTimeout(context.Background(), config.ConnectTimeout) defer cancel() - client, err := mongo.Connect(ctx, clientOptions) + client, err := mongo.Connect(clientOptions) if err != nil { logger.Error("Failed to connect to MongoDB", map[string]interface{}{ "uri": config.URI, @@ -144,7 +144,7 @@ func (cm *ConnectionManager) DropIndexes(collectionName string, indexNames []str ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() - _, err := collection.Indexes().DropOne(ctx, indexName) + err := collection.Indexes().DropOne(ctx, indexName) if err != nil { cm.logger.Error("Failed to drop index", map[string]interface{}{ "collection": collectionName, diff --git a/pkg/mongo/interfaces.go b/pkg/mongo/interfaces.go index 36c9ea6..1f954b6 100644 --- a/pkg/mongo/interfaces.go +++ b/pkg/mongo/interfaces.go @@ -1,7 +1,7 @@ package mongo import ( - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // Logger defines the interface for logging operations @@ -32,7 +32,7 @@ type IDSetter interface { // Model provides a common base for MongoDB documents type Model struct { - ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + ID bson.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` CreatedAt int64 `bson:"created_at" json:"created_at"` UpdatedAt int64 `bson:"updated_at" json:"updated_at"` } @@ -44,7 +44,7 @@ func (b *Model) GetID() string { // SetID sets the document ID func (b *Model) SetID(id string) { - b.ID, _ = primitive.ObjectIDFromHex(id) + b.ID, _ = bson.ObjectIDFromHex(id) } // SetCreatedAt sets the creation timestamp diff --git a/pkg/mongo/repository.go b/pkg/mongo/repository.go index 9857e07..f9553b3 100644 --- a/pkg/mongo/repository.go +++ b/pkg/mongo/repository.go @@ -7,10 +7,9 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // Common errors @@ -83,7 +82,7 @@ func NewRepository[T any](collection *mongo.Collection, logger Logger) Repositor // FindByID retrieves a document by its ID func (r *repository[T]) FindByID(ctx context.Context, id string) (*T, error) { - objectID, err := primitive.ObjectIDFromHex(id) + objectID, err := bson.ObjectIDFromHex(id) if err != nil { r.logger.Error("Invalid ObjectID format", map[string]interface{}{ "id": id, @@ -228,7 +227,7 @@ func (r *repository[T]) Create(ctx context.Context, model *T) error { // Set the ID if the model implements IDSetter if idSetter, ok := any(model).(IDSetter); ok { - if oid, ok := result.InsertedID.(primitive.ObjectID); ok { + if oid, ok := result.InsertedID.(bson.ObjectID); ok { idSetter.SetID(oid.Hex()) } } @@ -253,7 +252,7 @@ func (r *repository[T]) Update(ctx context.Context, model *T) error { return err } - objectID, err := primitive.ObjectIDFromHex(id) + objectID, err := bson.ObjectIDFromHex(id) if err != nil { return fmt.Errorf("invalid id format: %w", err) } @@ -283,7 +282,7 @@ func (r *repository[T]) Update(ctx context.Context, model *T) error { // Delete removes a document by ID func (r *repository[T]) Delete(ctx context.Context, id string) error { - objectID, err := primitive.ObjectIDFromHex(id) + objectID, err := bson.ObjectIDFromHex(id) if err != nil { return fmt.Errorf("invalid id format: %w", err) } @@ -422,7 +421,7 @@ func (r *repository[T]) buildCursorFilter(cursor, sortField string, sortOrder in // Try to parse as ObjectID first if sortField == "_id" { - if objectID, err := primitive.ObjectIDFromHex(string(cursorBytes)); err == nil { + if objectID, err := bson.ObjectIDFromHex(string(cursorBytes)); err == nil { cursorValue = objectID } else { return nil, fmt.Errorf("%w: invalid ObjectID in cursor", ErrInvalidCursor) @@ -466,7 +465,7 @@ func (r *repository[T]) generateCursor(doc T, sortField string) (string, error) // Convert to string for encoding var cursorStr string switch v := sortValue.(type) { - case primitive.ObjectID: + case bson.ObjectID: cursorStr = v.Hex() case string: cursorStr = v @@ -500,7 +499,7 @@ func (r *repository[T]) getModelID(model *T) (string, error) { } if id, exists := docMap["_id"]; exists { - if oid, ok := id.(primitive.ObjectID); ok { + if oid, ok := id.(bson.ObjectID); ok { return oid.Hex(), nil } } diff --git a/pkg/mongo/utils.go b/pkg/mongo/utils.go index 1808b39..5189433 100644 --- a/pkg/mongo/utils.go +++ b/pkg/mongo/utils.go @@ -1,15 +1,15 @@ package mongo import ( - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // Index represents a MongoDB index type Index struct { Name string `json:"name"` Keys bson.D `json:"keys"` - Options *options.IndexOptions `json:"options"` + Options *options.IndexOptionsBuilder `json:"options"` } // NewIndex creates a new index with default options @@ -33,11 +33,6 @@ func (i *Index) WithSparse(sparse bool) *Index { return i } -// WithBackground sets the background option for the index -func (i *Index) WithBackground(background bool) *Index { - i.Options.SetBackground(background) - return i -} // WithExpireAfterSeconds sets the TTL for the index func (i *Index) WithExpireAfterSeconds(seconds int32) *Index { diff --git a/ted/scraper.go b/ted/scraper.go index 4348bd8..c067b0e 100644 --- a/ted/scraper.go +++ b/ted/scraper.go @@ -15,10 +15,9 @@ import ( "tm/pkg/logger" "tm/pkg/mongo" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - mongoDriver "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + mongoDriver "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // TEDScraper handles downloading and parsing TED XML files @@ -70,7 +69,7 @@ type ScrapingState struct { LastRunAt int64 `bson:"last_run_at" json:"last_run_at"` NextRunAt int64 `bson:"next_run_at" json:"next_run_at"` IsRunning bool `bson:"is_running" json:"is_running"` - CurrentJobID primitive.ObjectID `bson:"current_job_id,omitempty" json:"current_job_id,omitempty"` + CurrentJobID bson.ObjectID `bson:"current_job_id,omitempty" json:"current_job_id,omitempty"` } // ScraperConfig holds configuration for the TED scraper @@ -758,7 +757,7 @@ func (s *TEDScraper) completeJob(ctx context.Context, job *ScrapingJob, state *S // Update state state.IsRunning = false - state.CurrentJobID = primitive.NilObjectID + state.CurrentJobID = bson.NilObjectID state.LastRunAt = completedAt state.NextRunAt = endTime.Add(s.config.ScrapingInterval).Unix() state.UpdatedAt = completedAt