diff --git a/go.mod b/go.mod index c24ea38..c8e6d8f 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,21 @@ module wallet-api + // +heroku goVersion go1.15 go 1.15 require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/gin-gonic/gin v1.7.1 - github.com/go-pg/migrations/v8 v8.1.0 - github.com/go-pg/pg/v10 v10.9.1 - github.com/go-playground/validator/v10 v10.5.0 // indirect + github.com/gin-gonic/gin v1.7.7 + github.com/go-pg/pg/v10 v10.10.6 + github.com/go-playground/validator/v10 v10.10.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/uuid v1.2.0 - github.com/joho/godotenv v1.3.0 - github.com/json-iterator/go v1.1.11 // indirect - github.com/leodido/go-urn v1.2.1 // indirect + github.com/google/uuid v1.3.0 + github.com/joho/godotenv v1.4.0 + github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/ugorji/go v1.2.5 // indirect - golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf - golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect - golang.org/x/text v0.3.6 // indirect + github.com/ugorji/go v1.2.6 // indirect + golang.org/x/crypto v0.0.0-20220214200702-86341886e292 + golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect + golang.org/x/text v0.3.7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index be6e788..6831591 100644 --- a/go.sum +++ b/go.sum @@ -2,44 +2,41 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v1.0.2 h1:KPldsxuKGsS2FPWsNeg9ZO18aCrGKujPoWXn2yo+KQM= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.1 h1:qC89GU3p8TvKWMAVhEpmpB2CIb1hnqt2UdKZaP93mS8= -github.com/gin-gonic/gin v1.7.1/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= -github.com/go-pg/migrations/v8 v8.1.0 h1:bc1wQwFoWRKvLdluXCRFRkeaw9xDU4qJ63uCAagh66w= -github.com/go-pg/migrations/v8 v8.1.0/go.mod h1:o+CN1u572XHphEHZyK6tqyg2GDkRvL2bIoLNyGIewus= -github.com/go-pg/pg v8.0.7+incompatible h1:ty/sXL1OZLo+47KK9N8llRcmbA9tZasqbQ/OO4ld53g= -github.com/go-pg/pg/v10 v10.4.0/go.mod h1:BfgPoQnD2wXNd986RYEHzikqv9iE875PrFaZ9vXvtNM= -github.com/go-pg/pg/v10 v10.9.1 h1:kU4t84zWGGaU0Qsu49FbNtToUVrlSTkNOngW8aQmwvk= -github.com/go-pg/pg/v10 v10.9.1/go.mod h1:rgmTPgHgl5EN2CNKKoMwC7QT62t8BqsdpEkUQuiZMQs= +github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= +github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= +github.com/go-pg/pg/v10 v10.10.6 h1:1vNtPZ4Z9dWUw/TjJwOfFUbF5nEq1IkR6yG8Mq/Iwso= +github.com/go-pg/pg/v10 v10.10.6/go.mod h1:GLmFXufrElQHf5uzM3BQlcfwV3nsgnHue5uzjQ6Nqxg= github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU= github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-playground/validator/v10 v10.5.0 h1:X9rflw/KmpACwT8zdrm1upefpvdy6ur8d1kWyq6sg3E= -github.com/go-playground/validator/v10 v10.5.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= +github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0= +github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -56,93 +53,86 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.5 h1:NozRHfUeEta89taVkyfsDVSy2f7v89Frft4pjnWuGuc= -github.com/ugorji/go v1.2.5/go.mod h1:gat2tIT8KJG8TVI8yv77nEO/KYT6dV7JE1gfUa8Xuls= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E= +github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.5 h1:8WobZKAk18Msm2CothY2jnztY56YVY8kF1oQrj21iis= -github.com/ugorji/go/codec v1.2.5/go.mod h1:QPxoTbPKSEAlAHPYt02++xp/en9B/wUdwFCz+hj5caA= +github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= +github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94= github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ= -github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1/go.mod h1:xlngVLeyQ/Qi05oQxhQ+oTuqa03RjMwMfk/7/TCs+QI= -github.com/vmihailenco/msgpack/v5 v5.3.0 h1:8G3at/kelmBKeHY6d6cKnGsYO3BLn+uubitdOtOhyNI= -github.com/vmihailenco/msgpack/v5 v5.3.0/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= +github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel v0.19.0 h1:Lenfy7QHRXPZVsw/12CWpxX6d/JkrX8wrx2vO8G80Ng= -go.opentelemetry.io/otel v0.19.0/go.mod h1:j9bF567N9EfomkSidSfmMwIwIBuP37AMAIzVW85OxSg= -go.opentelemetry.io/otel/metric v0.19.0 h1:dtZ1Ju44gkJkYvo+3qGqVXmf88tc+a42edOywypengg= -go.opentelemetry.io/otel/metric v0.19.0/go.mod h1:8f9fglJPRnXuskQmKpnad31lcLJ2VmNNqIsx/uIwBSc= -go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA= -go.opentelemetry.io/otel/trace v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc= -go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg= golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf h1:B2n+Zi5QeYRDAEodEu72OS36gmTWjgpXr2+cWcBW90o= -golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -153,13 +143,11 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -171,34 +159,33 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 h1:dXfMednGJh/SUUFjTLsWJz3P+TQt9qnR11GgeI3vWKs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= @@ -220,16 +207,21 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= diff --git a/pkg/controllers/auth.go b/pkg/controllers/auth.go index f4fcae6..a2f5661 100644 --- a/pkg/controllers/auth.go +++ b/pkg/controllers/auth.go @@ -51,6 +51,7 @@ func (rc *AuthController) PostLogin(c *gin.Context) { if exceptionReturn.Message != "" { c.JSON(exceptionReturn.StatusCode, exceptionReturn) + return } else { c.JSON(200, returnedUser) } @@ -74,6 +75,7 @@ func (rc *AuthController) PostRegister(c *gin.Context) { if exceptionReturn.Message != "" { c.JSON(exceptionReturn.StatusCode, exceptionReturn) + return } else { c.JSON(200, returnedUser.Payload()) } @@ -94,6 +96,7 @@ func (rc *AuthController) Delete(c *gin.Context) { if er.Message != "" { c.JSON(er.StatusCode, er) + return } else { c.JSON(200, mr) } @@ -114,6 +117,7 @@ func (rc *AuthController) CheckToken(c *gin.Context) { if err != nil { re.Valid = false c.AbortWithStatusJSON(400, re) + return } re.Valid = true diff --git a/pkg/controllers/subscriptionTypes.go b/pkg/controllers/subscriptionTypes.go index 738d464..7e8b7d4 100644 --- a/pkg/controllers/subscriptionTypes.go +++ b/pkg/controllers/subscriptionTypes.go @@ -45,7 +45,11 @@ func (wc *SubscriptionTypeController) New(c *gin.Context) { return } - wm := wc.SubscriptionTypeService.New(c, body) + wm, exception := wc.SubscriptionTypeService.New(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -58,7 +62,10 @@ GetAll func (wc *SubscriptionTypeController) GetAll(c *gin.Context) { embed, _ := c.GetQuery("embed") - wm := wc.SubscriptionTypeService.GetAll(c, embed) - + wm, exception := wc.SubscriptionTypeService.GetAll(c, embed) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } diff --git a/pkg/controllers/subscriptions.go b/pkg/controllers/subscriptions.go index b66624e..0ddaaba 100644 --- a/pkg/controllers/subscriptions.go +++ b/pkg/controllers/subscriptions.go @@ -52,7 +52,13 @@ func (wc *SubscriptionController) New(c *gin.Context) { return } - wm := wc.SubscriptionService.New(c, body) + wm, exception := wc.SubscriptionService.New(c, body) + + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } + c.JSON(200, wm) } @@ -71,7 +77,11 @@ func (wc *SubscriptionController) Edit(c *gin.Context) { id := c.Param("id") - wm := wc.SubscriptionService.Edit(c, body, id) + wm, exception := wc.SubscriptionService.Edit(c, body, id) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -93,7 +103,11 @@ func (wc *SubscriptionController) Get(c *gin.Context) { embed, _ := c.GetQuery("embed") params.Embed = embed - fr := wc.SubscriptionService.Get(c, body, id, params) + fr, exception := wc.SubscriptionService.Get(c, body, id, params) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } @@ -113,7 +127,11 @@ func (wc *SubscriptionController) End(c *gin.Context) { id := c.Param("id") - fr := wc.SubscriptionService.End(c, id) + fr, exception := wc.SubscriptionService.End(c, id) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } @@ -132,7 +150,11 @@ func (wc *SubscriptionController) GetAll(c *gin.Context) { fr := FilteredResponse(c) wallet, _ := c.GetQuery("walletId") - wc.SubscriptionService.GetAll(c, body, wallet, fr) + exception := wc.SubscriptionService.GetAll(c, body, wallet, fr) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } diff --git a/pkg/controllers/transactionStatus.go b/pkg/controllers/transactionStatus.go index db26c2a..cadb96e 100644 --- a/pkg/controllers/transactionStatus.go +++ b/pkg/controllers/transactionStatus.go @@ -45,7 +45,11 @@ func (wc *TransactionStatusController) New(c *gin.Context) { return } - wm := wc.TransactionStatusService.New(c, body) + wm, exception := wc.TransactionStatusService.New(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -58,7 +62,11 @@ GetAll func (wc *TransactionStatusController) GetAll(c *gin.Context) { embed, _ := c.GetQuery("embed") - wm := wc.TransactionStatusService.GetAll(c, embed) + wm, exception := wc.TransactionStatusService.GetAll(c, embed) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } diff --git a/pkg/controllers/transactionTypes.go b/pkg/controllers/transactionTypes.go index a41faec..1874bb6 100644 --- a/pkg/controllers/transactionTypes.go +++ b/pkg/controllers/transactionTypes.go @@ -45,7 +45,11 @@ func (wc *TransactionTypeController) New(c *gin.Context) { return } - wm := wc.TransactionTypeService.New(c, body) + wm, exception := wc.TransactionTypeService.New(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -58,7 +62,11 @@ GetAll func (wc *TransactionTypeController) GetAll(c *gin.Context) { embed, _ := c.GetQuery("embed") - wm := wc.TransactionTypeService.GetAll(c, embed) + wm, exception := wc.TransactionTypeService.GetAll(c, embed) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } diff --git a/pkg/controllers/transactions.go b/pkg/controllers/transactions.go index 4416ec8..7448b7c 100644 --- a/pkg/controllers/transactions.go +++ b/pkg/controllers/transactions.go @@ -30,8 +30,16 @@ func NewTransactionController(as *services.TransactionService, s *gin.RouterGrou s.GET("", wc.GetAll) s.PUT("/:id", wc.Edit) s.GET("/:id", wc.Get) - s.GET("check", wc.Check) - s.PUT("/bulk", wc.BulkEdit) + + bulkGroup := s.Group("bulk") + { + bulkGroup.PUT("", wc.BulkEdit) + } + + checkGroup := s.Group("check") + { + checkGroup.GET("check", wc.Check) + } return wc } @@ -49,7 +57,11 @@ func (wc *TransactionController) New(c *gin.Context) { return } - wm := wc.TransactionService.New(c, body) + wm, exception := wc.TransactionService.New(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -70,7 +82,11 @@ func (wc *TransactionController) GetAll(c *gin.Context) { noPendingQry, _ := c.GetQuery("noPending") noPending := noPendingQry != "" - wc.TransactionService.GetAll(c, body, wallet, fr, noPending) + exception := wc.TransactionService.GetAll(c, body, wallet, fr, noPending) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } @@ -89,7 +105,11 @@ func (wc *TransactionController) Check(c *gin.Context) { fr := FilteredResponse(c) wallet, _ := c.GetQuery("walletId") - wc.TransactionService.Check(c, body, wallet, fr) + exception := wc.TransactionService.Check(c, body, wallet, fr) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } @@ -109,7 +129,11 @@ func (wc *TransactionController) Edit(c *gin.Context) { id := c.Param("id") - wm := wc.TransactionService.Edit(c, body, id) + wm, exception := wc.TransactionService.Edit(c, body, id) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -126,7 +150,11 @@ func (wc *TransactionController) BulkEdit(c *gin.Context) { return } - wm := wc.TransactionService.BulkEdit(c, body) + wm, exception := wc.TransactionService.BulkEdit(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -148,7 +176,11 @@ func (wc *TransactionController) Get(c *gin.Context) { embed, _ := c.GetQuery("embed") params.Embed = embed - fr := wc.TransactionService.Get(c, body, id, params) + fr, exception := wc.TransactionService.Get(c, body, id, params) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } diff --git a/pkg/controllers/wallets-header.go b/pkg/controllers/wallets-header.go index 888ba9f..da4be0d 100644 --- a/pkg/controllers/wallets-header.go +++ b/pkg/controllers/wallets-header.go @@ -44,7 +44,11 @@ func (wc *WalletsHeaderController) Get(c *gin.Context) { auth := c.MustGet("auth") body.Id = auth.(*models.Auth).Id - wm := wc.WalletService.GetHeader(c, body, walletId) + wm, exception := wc.WalletService.GetHeader(c, body, walletId) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } diff --git a/pkg/controllers/wallets.go b/pkg/controllers/wallets.go index 377e054..ba00ed0 100644 --- a/pkg/controllers/wallets.go +++ b/pkg/controllers/wallets.go @@ -51,7 +51,11 @@ func (wc *WalletsController) New(c *gin.Context) { get := c.MustGet("auth") body.UserID = get.(*models.Auth).Id - wm := wc.WalletService.New(c, body) + wm, exception := wc.WalletService.New(c, body) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -68,7 +72,11 @@ func (wc *WalletsController) GetAll(c *gin.Context) { fr := FilteredResponse(c) - wc.WalletService.GetAll(c, body, fr) + exception := wc.WalletService.GetAll(c, body, fr) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } @@ -88,7 +96,11 @@ func (wc *WalletsController) Edit(c *gin.Context) { id := c.Param("id") - wm := wc.WalletService.Edit(c, body, id) + wm, exception := wc.WalletService.Edit(c, body, id) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, wm) } @@ -106,7 +118,11 @@ func (wc *WalletsController) Get(c *gin.Context) { embed, _ := c.GetQuery("embed") params.Embed = embed - fr := wc.WalletService.Get(c, id, params) + fr, exception := wc.WalletService.Get(c, id, params) + if exception != nil { + c.JSON(exception.StatusCode, exception) + return + } c.JSON(200, fr) } diff --git a/pkg/middleware/cors.go b/pkg/middleware/cors.go index 10a86dc..a9d3782 100644 --- a/pkg/middleware/cors.go +++ b/pkg/middleware/cors.go @@ -23,4 +23,4 @@ func CORSMiddleware() gin.HandlerFunc { c.Next() } -} \ No newline at end of file +} diff --git a/pkg/services/services.go b/pkg/services/services.go index 5c26047..c87a50f 100644 --- a/pkg/services/services.go +++ b/pkg/services/services.go @@ -16,7 +16,7 @@ Adds filters to query and executes it. interface{}: model to be mapped from query execution. *models.FilteredResponse: filter options. */ -func FilteredResponse(qry *pg.Query, mdl interface{}, filtered *models.FilteredResponse) { +func FilteredResponse(qry *pg.Query, mdl interface{}, filtered *models.FilteredResponse) error { if filtered.Page == 0 { filtered.Page = 1 } @@ -33,4 +33,6 @@ func FilteredResponse(qry *pg.Query, mdl interface{}, filtered *models.FilteredR filtered.TotalRecords = count filtered.Items = mdl + + return err } diff --git a/pkg/services/subscriptionTypes.go b/pkg/services/subscriptionTypes.go index 1594558..eb637d7 100644 --- a/pkg/services/subscriptionTypes.go +++ b/pkg/services/subscriptionTypes.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "wallet-api/pkg/models" "wallet-api/pkg/utl/common" @@ -21,19 +22,27 @@ Inserts new row to subscription type table. *models.NewSubscriptionTypeBody: Values to create new row Returns: *models.SubscriptionType: Created row from database. + *models.Exception: Exception payload. */ -func (as *SubscriptionTypeService) New(ctx context.Context, body *models.NewSubscriptionTypeBody) *models.SubscriptionType { +func (as *SubscriptionTypeService) New(ctx context.Context, body *models.NewSubscriptionTypeBody) (*models.SubscriptionType, *models.Exception) { db := as.Db.WithContext(ctx) tm := new(models.SubscriptionType) + exceptionReturn := new(models.Exception) tm.Init() tm.Name = body.Name tm.Type = body.Type - db.Model(tm).Insert() + _, err := db.Model(tm).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400114" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"subscriptionTypes\" table: %s", err) + return nil, exceptionReturn + } - return tm + return tm, nil } /* @@ -45,14 +54,22 @@ Gets all rows from subscription type table. string: Relations to embed Returns: *[]models.SubscriptionType: List of subscription type objects. + *models.Exception: Exception payload. */ -func (as *SubscriptionTypeService) GetAll(ctx context.Context, embed string) *[]models.SubscriptionType { +func (as *SubscriptionTypeService) GetAll(ctx context.Context, embed string) (*[]models.SubscriptionType, *models.Exception) { db := as.Db.WithContext(ctx) wm := new([]models.SubscriptionType) + exceptionReturn := new(models.Exception) query := db.Model(wm) - common.GenerateEmbed(query, embed).Select() + err := common.GenerateEmbed(query, embed).Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400135" + exceptionReturn.Message = fmt.Sprintf("Error selecting rows in \"subscriptionTypes\" table: %s", err) + return nil, exceptionReturn + } - return wm + return wm, nil } diff --git a/pkg/services/subscriptions.go b/pkg/services/subscriptions.go index aca02b1..a1ce86f 100644 --- a/pkg/services/subscriptions.go +++ b/pkg/services/subscriptions.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "math" "time" "wallet-api/pkg/models" @@ -23,11 +24,13 @@ Inserts new row to subscription table. *models.NewSubscriptionBody: Request body Returns: *models.Subscription: Created Subscription row object from database. + *models.Exception: Exception payload. */ -func (as *SubscriptionService) New(ctx context.Context, body *models.NewSubscriptionBody) *models.Subscription { +func (as *SubscriptionService) New(ctx context.Context, body *models.NewSubscriptionBody) (*models.Subscription, *models.Exception) { db := as.Db.WithContext(ctx) tm := new(models.Subscription) + exceptionReturn := new(models.Exception) amount, _ := body.Amount.Float64() customRange, _ := body.CustomRange.Int64() @@ -50,10 +53,16 @@ func (as *SubscriptionService) New(ctx context.Context, body *models.NewSubscrip tx, _ := db.Begin() defer tx.Rollback() - tx.Model(tm).Insert() + _, err := tx.Model(tm).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400109" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"subscription\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -67,10 +76,12 @@ Gets row from subscription table by id. params: *models.Params Returns: *models.Subscription: Subscription row object from database. + *models.Exception: Exception payload. */ -func (as *SubscriptionService) Get(ctx context.Context, am *models.Auth, id string, params *models.Params) *models.Subscription { +func (as *SubscriptionService) Get(ctx context.Context, am *models.Auth, id string, params *models.Params) (*models.Subscription, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) wm := new(models.Subscription) wm.Id = id @@ -78,11 +89,17 @@ func (as *SubscriptionService) Get(ctx context.Context, am *models.Auth, id stri defer tx.Rollback() qry := tx.Model(wm) - common.GenerateEmbed(qry, params.Embed).WherePK().Select() + err := common.GenerateEmbed(qry, params.Embed).WherePK().Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400129" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"subscription\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return wm + return wm, nil } /* @@ -94,11 +111,14 @@ Gets filtered rows from subscription table. *models.Auth: Authentication object string: Wallet id to search *models.FilteredResponse: filter options + Returns: + *models.Exception: Exception payload. */ -func (as *SubscriptionService) GetAll(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse) { +func (as *SubscriptionService) GetAll(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse) *models.Exception { db := as.Db.WithContext(ctx) wm := new([]models.Subscription) + exceptionReturn := new(models.Exception) tx, _ := db.Begin() defer tx.Rollback() @@ -108,8 +128,16 @@ func (as *SubscriptionService) GetAll(ctx context.Context, am *models.Auth, wall query = query.Where("? = ?", pg.Ident("wallet_id"), walletId) } - FilteredResponse(query, wm, filtered) + err := FilteredResponse(query, wm, filtered) + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400110" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"subscription\" table: %s", err) + return exceptionReturn + } tx.Commit() + + return nil } /* @@ -122,11 +150,13 @@ Updates row from subscription table by id. string: id to search Returns: *models.Subscription: Edited Subscription row object from database. + *models.Exception: Exception payload. */ -func (as *SubscriptionService) Edit(ctx context.Context, body *models.SubscriptionEdit, id string) *models.Subscription { +func (as *SubscriptionService) Edit(ctx context.Context, body *models.SubscriptionEdit, id string) (*models.Subscription, *models.Exception) { db := as.Db.WithContext(ctx) amount, _ := body.Amount.Float64() + exceptionReturn := new(models.Exception) tm := new(models.Subscription) tm.Id = id @@ -139,11 +169,17 @@ func (as *SubscriptionService) Edit(ctx context.Context, body *models.Subscripti tx, _ := db.Begin() defer tx.Rollback() - tx.Model(tm).WherePK().UpdateNotZero() + _, err := tx.Model(tm).WherePK().UpdateNotZero() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400111" + exceptionReturn.Message = fmt.Sprintf("Error updating row in \"subscription\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -157,9 +193,11 @@ Ends subscription with current date. string: id to search Returns: *models.Subscription: Created Subscription row object from database. + *models.Exception: Exception payload. */ -func (as *SubscriptionService) End(ctx context.Context, id string) *models.Subscription { +func (as *SubscriptionService) End(ctx context.Context, id string) (*models.Subscription, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) tm := new(models.Subscription) tm.Id = id @@ -169,11 +207,17 @@ func (as *SubscriptionService) End(ctx context.Context, id string) *models.Subsc tx, _ := db.Begin() defer tx.Rollback() - tx.Model(tm).WherePK().UpdateNotZero() + _, err := tx.Model(tm).WherePK().UpdateNotZero() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400112" + exceptionReturn.Message = fmt.Sprintf("Error updating row in \"subscription\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -183,8 +227,11 @@ Generates and Inserts new Transaction rows from the subscription model. Args: *models.Subscription: Subscription model to generate new transactions from *pg.Tx: Postgres query context + Returns: + *models.Exception: Exception payload. */ -func (as *SubscriptionService) SubToTrans(subModel *models.Subscription, tx *pg.Tx) { +func (as *SubscriptionService) SubToTrans(subModel *models.Subscription, tx *pg.Tx) *models.Exception { + exceptionReturn := new(models.Exception) now := time.Now() @@ -228,12 +275,20 @@ func (as *SubscriptionService) SubToTrans(subModel *models.Subscription, tx *pg. } } + var err error if len(*transactions) > 0 { for _, trans := range *transactions { - _, err := tx.Model(&trans).Where("? = ?", pg.Ident("transaction_date"), trans.TransactionDate).Where("? = ?", pg.Ident("subscription_id"), trans.SubscriptionID).OnConflict("DO NOTHING").SelectOrInsert() + _, err = tx.Model(&trans).Where("? = ?", pg.Ident("transaction_date"), trans.TransactionDate).Where("? = ?", pg.Ident("subscription_id"), trans.SubscriptionID).OnConflict("DO NOTHING").SelectOrInsert() if err != nil { - tx.Model(subModel).Set("? = ?", pg.Ident("last_transaction_date"), trans.TransactionDate).WherePK().Update() + _, err = tx.Model(subModel).Set("? = ?", pg.Ident("last_transaction_date"), trans.TransactionDate).WherePK().Update() } } } + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400113" + exceptionReturn.Message = fmt.Sprintf("Error updating row in \"subscription\" table: %s", err) + return exceptionReturn + } + return nil } diff --git a/pkg/services/transactionStatus.go b/pkg/services/transactionStatus.go index 4d20423..08ea176 100644 --- a/pkg/services/transactionStatus.go +++ b/pkg/services/transactionStatus.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "wallet-api/pkg/models" "wallet-api/pkg/utl/common" @@ -21,19 +22,27 @@ Inserts new row to transaction status table. *models.NewTransactionStatusBody: object to create Returns: *models.TransactionType: Transaction Type object from database. + *models.Exception: Exception payload. */ -func (as *TransactionStatusService) New(ctx context.Context, body *models.NewTransactionStatusBody) *models.TransactionStatus { +func (as *TransactionStatusService) New(ctx context.Context, body *models.NewTransactionStatusBody) (*models.TransactionStatus, *models.Exception) { db := as.Db.WithContext(ctx) tm := new(models.TransactionStatus) + exceptionReturn := new(models.Exception) tm.Init() tm.Name = body.Name tm.Status = body.Status - db.Model(tm).Insert() + _, err := db.Model(tm).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400123" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"transactionStatus\" table: %s", err) + return nil, exceptionReturn + } - return tm + return tm, nil } /* @@ -45,14 +54,22 @@ Gets all rows from transaction status table. string: Relations to embed Returns: *[]models.TransactionStatus: List of Transaction status objects from database. + *models.Exception: Exception payload. */ -func (as *TransactionStatusService) GetAll(ctx context.Context, embed string) *[]models.TransactionStatus { +func (as *TransactionStatusService) GetAll(ctx context.Context, embed string) (*[]models.TransactionStatus, *models.Exception) { db := as.Db.WithContext(ctx) wm := new([]models.TransactionStatus) + exceptionReturn := new(models.Exception) query := db.Model(wm) - common.GenerateEmbed(query, embed).Select() + err := common.GenerateEmbed(query, embed).Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400124" + exceptionReturn.Message = fmt.Sprintf("Error selecting rows in \"transactionStatus\" table: %s", err) + return nil, exceptionReturn + } - return wm + return wm, nil } diff --git a/pkg/services/transactionTypes.go b/pkg/services/transactionTypes.go index 8f2cf9f..aa67324 100644 --- a/pkg/services/transactionTypes.go +++ b/pkg/services/transactionTypes.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "wallet-api/pkg/models" "wallet-api/pkg/utl/common" @@ -21,19 +22,27 @@ Inserts new row to transaction type table. *models.NewTransactionTypeBody: object to create Returns: *models.TransactionType: Transaction Type object from database. + *models.Exception: Exception payload. */ -func (as *TransactionTypeService) New(ctx context.Context, body *models.NewTransactionTypeBody) *models.TransactionType { +func (as *TransactionTypeService) New(ctx context.Context, body *models.NewTransactionTypeBody) (*models.TransactionType, *models.Exception) { db := as.Db.WithContext(ctx) tm := new(models.TransactionType) + exceptionReturn := new(models.Exception) tm.Init() tm.Name = body.Name tm.Type = body.Type - db.Model(tm).Insert() + _, err := db.Model(tm).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400125" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"transactionTypes\" table: %s", err) + return nil, exceptionReturn + } - return tm + return tm, nil } /* @@ -45,14 +54,22 @@ Gets all rows from transaction type table. string: Relations to embed Returns: *[]models.TransactionType: List of Transaction type objects from database. + *models.Exception: Exception payload. */ -func (as *TransactionTypeService) GetAll(ctx context.Context, embed string) *[]models.TransactionType { +func (as *TransactionTypeService) GetAll(ctx context.Context, embed string) (*[]models.TransactionType, *models.Exception) { db := as.Db.WithContext(ctx) wm := new([]models.TransactionType) + exceptionReturn := new(models.Exception) query := db.Model(wm) - common.GenerateEmbed(query, embed).Select() + err := common.GenerateEmbed(query, embed).Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400133" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactionTypes\" table: %s", err) + return nil, exceptionReturn + } - return wm + return wm, nil } diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go index 74080d1..4185a32 100644 --- a/pkg/services/transactions.go +++ b/pkg/services/transactions.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "math" "time" "wallet-api/pkg/models" @@ -24,9 +25,11 @@ Inserts *models.NewTransactionBody: Transaction body object Returns: *models.Transaction: Transaction object + *models.Exception: Exception payload. */ -func (as *TransactionService) New(ctx context.Context, body *models.NewTransactionBody) *models.Transaction { +func (as *TransactionService) New(ctx context.Context, body *models.NewTransactionBody) (*models.Transaction, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) tm := new(models.Transaction) transactionStatus := new(models.TransactionStatus) @@ -34,7 +37,13 @@ func (as *TransactionService) New(ctx context.Context, body *models.NewTransacti tx, _ := db.Begin() defer tx.Rollback() - tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + err := tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400115" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactionsStatus\" table: %s", err) + return nil, exceptionReturn + } amount, _ := body.Amount.Float64() @@ -50,10 +59,16 @@ func (as *TransactionService) New(ctx context.Context, body *models.NewTransacti tm.TransactionDate = time.Now() } - tx.Model(tm).Insert() + _, err = tx.Model(tm).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400116" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"transaction\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -64,19 +79,26 @@ Gets all rows from subscription type table. context.Context: Application context string: Relations to embed Returns: - *[]models.SubscriptionType: List of subscription type objects. + *models.Exception: Exception payload. */ // Gets filtered rows from transaction table. -func (as *TransactionService) GetAll(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse, noPending bool) { +func (as *TransactionService) GetAll(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse, noPending bool) *models.Exception { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) wm := new([]models.Transaction) transactionStatus := new(models.TransactionStatus) tx, _ := db.Begin() defer tx.Rollback() - tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + err := tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400117" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactionStatus\" table: %s", err) + return exceptionReturn + } query := tx.Model(wm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id) if walletId != "" { @@ -86,9 +108,16 @@ func (as *TransactionService) GetAll(ctx context.Context, am *models.Auth, walle query = query.Where("? = ?", pg.Ident("transaction_status_id"), transactionStatus.Id) } - FilteredResponse(query, wm, filtered) + err = FilteredResponse(query, wm, filtered) + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400118" + exceptionReturn.Message = fmt.Sprintf("Error selecting row(s) in \"transaction\" table: %s", err) + return exceptionReturn + } tx.Commit() + return nil } /* @@ -99,20 +128,27 @@ Checks subscriptions and create transacitons. context.Context: Application context string: Relations to embed Returns: - *[]models.SubscriptionType: List of subscription type objects. + *models.Exception: Exception payload. */ // Gets filtered rows from transaction table. -func (as *TransactionService) Check(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse) { +func (as *TransactionService) Check(ctx context.Context, am *models.Auth, walletId string, filtered *models.FilteredResponse) *models.Exception { db := as.Db.WithContext(ctx) wm := new([]models.Transaction) sm := new([]models.Subscription) transactionStatus := new(models.TransactionStatus) + exceptionReturn := new(models.Exception) tx, _ := db.Begin() defer tx.Rollback() - tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "pending").Select() + err := tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "pending").Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400119" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactionStatus\" table: %s", err) + return exceptionReturn + } query2 := tx.Model(sm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id) if walletId != "" { query2 = query2.Where("? = ?", pg.Ident("wallet_id"), walletId) @@ -131,9 +167,16 @@ func (as *TransactionService) Check(ctx context.Context, am *models.Auth, wallet } query = query.Where("? = ?", pg.Ident("transaction_status_id"), transactionStatus.Id) - FilteredResponse(query, wm, filtered) + err = FilteredResponse(query, wm, filtered) + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400120" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transaction\" table: %s", err) + return exceptionReturn + } tx.Commit() + return nil } /* @@ -146,12 +189,15 @@ Updates row in transaction table by id. string: id to search Returns: *models.Transaction: Transaction object from database. + *models.Exception: Exception payload. */ -func (as *TransactionService) Edit(ctx context.Context, body *models.TransactionEdit, id string) *models.Transaction { +func (as *TransactionService) Edit(ctx context.Context, body *models.TransactionEdit, id string) (*models.Transaction, *models.Exception) { db := as.Db.WithContext(ctx) amount, _ := body.Amount.Float64() + exceptionReturn := new(models.Exception) + tm := new(models.Transaction) tm.Id = id tm.Description = body.Description @@ -164,11 +210,26 @@ func (as *TransactionService) Edit(ctx context.Context, body *models.Transaction tx, _ := db.Begin() defer tx.Rollback() - tx.Model(tm).WherePK().UpdateNotZero() + _, err := tx.Model(tm).WherePK().UpdateNotZero() + + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400107" + exceptionReturn.Message = fmt.Sprintf("Error updating row in \"transaction\" table: %s", err) + return nil, exceptionReturn + } + + err = tx.Model(tm).WherePK().Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400108" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transaction\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -181,13 +242,15 @@ Updates row in transaction table by id. string: id to search Returns: *models.Transaction: Transaction object from database. + *models.Exception: Exception payload. */ -func (as *TransactionService) BulkEdit(ctx context.Context, body *[]models.TransactionEdit) *[]models.Transaction { +func (as *TransactionService) BulkEdit(ctx context.Context, body *[]models.TransactionEdit) (*[]models.Transaction, *models.Exception) { db := as.Db.WithContext(ctx) tx, _ := db.Begin() defer tx.Rollback() transactions := new([]models.Transaction) + exceptionReturn := new(models.Exception) for _, transaction := range *body { @@ -201,13 +264,20 @@ func (as *TransactionService) BulkEdit(ctx context.Context, body *[]models.Trans tm.TransactionDate = transaction.TransactionDate tm.Amount = float32(math.Round(amount*100) / 100) - tx.Model(tm).WherePK().UpdateNotZero() *transactions = append(*transactions, *tm) } + _, err := tx.Model(transactions).WherePK().UpdateNotZero() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400121" + exceptionReturn.Message = fmt.Sprintf("Error updating rows in \"transactions\" table: %s", err) + return nil, exceptionReturn + } + tx.Commit() - return transactions + return transactions, nil } /* @@ -221,10 +291,12 @@ Gets row from transaction table by id. *model.Params: url query parameters Returns: *models.Transaction: Transaction object from database. + *models.Exception: Exception payload. */ -func (as *TransactionService) Get(ctx context.Context, am *models.Auth, id string, params *models.Params) *models.Transaction { +func (as *TransactionService) Get(ctx context.Context, am *models.Auth, id string, params *models.Params) (*models.Transaction, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) wm := new(models.Transaction) wm.Id = id @@ -232,9 +304,15 @@ func (as *TransactionService) Get(ctx context.Context, am *models.Auth, id strin defer tx.Rollback() qry := tx.Model(wm) - common.GenerateEmbed(qry, params.Embed).WherePK().Select() + err := common.GenerateEmbed(qry, params.Embed).WherePK().Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400122" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactions\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return wm + return wm, nil } diff --git a/pkg/services/wallets.go b/pkg/services/wallets.go index 8c0c043..fb99554 100644 --- a/pkg/services/wallets.go +++ b/pkg/services/wallets.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "time" "wallet-api/pkg/models" "wallet-api/pkg/utl/common" @@ -23,16 +24,24 @@ Inserts row to wallets table. *models.NewWalletBody: Object to be inserted Returns: *models.Wallet: Wallet object from database. + *models.Exception: Exception payload. */ -func (as *WalletService) New(ctx context.Context, am *models.NewWalletBody) *models.Wallet { +func (as *WalletService) New(ctx context.Context, am *models.NewWalletBody) (*models.Wallet, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) walletModel := new(models.Wallet) walletModel.Init() walletModel.UserID = am.UserID walletModel.Name = am.Name - db.Model(walletModel).Insert() - return walletModel + _, err := db.Model(walletModel).Insert() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400126" + exceptionReturn.Message = fmt.Sprintf("Error inserting row in \"wallets\" table: %s", err) + return nil, exceptionReturn + } + return walletModel, nil } /* @@ -45,10 +54,12 @@ Updates row in wallets table by id. string: id to search Returns: *models.Wallet: Wallet object from database. + *models.Exception: Exception payload. */ -func (as *WalletService) Edit(ctx context.Context, body *models.WalletEdit, id string) *models.Wallet { +func (as *WalletService) Edit(ctx context.Context, body *models.WalletEdit, id string) (*models.Wallet, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) tm := new(models.Wallet) tm.Id = id tm.Name = body.Name @@ -56,11 +67,17 @@ func (as *WalletService) Edit(ctx context.Context, body *models.WalletEdit, id s tx, _ := db.Begin() defer tx.Rollback() - tx.Model(tm).WherePK().UpdateNotZero() + _, err := tx.Model(tm).WherePK().UpdateNotZero() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400127" + exceptionReturn.Message = fmt.Sprintf("Error updating row in \"wallets\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return tm + return tm, nil } /* @@ -73,9 +90,11 @@ Gets row in wallets table by id. *models.Params: url query parameters Returns: *models.Wallet: Wallet object from database + *models.Exception: Exception payload. */ -func (as *WalletService) Get(ctx context.Context, id string, params *models.Params) *models.Wallet { +func (as *WalletService) Get(ctx context.Context, id string, params *models.Params) (*models.Wallet, *models.Exception) { db := as.Db.WithContext(ctx) + exceptionReturn := new(models.Exception) wm := new(models.Wallet) wm.Id = id @@ -84,11 +103,17 @@ func (as *WalletService) Get(ctx context.Context, id string, params *models.Para defer tx.Rollback() qry := tx.Model(wm) - common.GenerateEmbed(qry, params.Embed).WherePK().Select() + err := common.GenerateEmbed(qry, params.Embed).WherePK().Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400128" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"wallets\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() - return wm + return wm, nil } /* @@ -99,13 +124,23 @@ Gets filtered rows from wallets table. context.Context: Application context *models.Auth: Authentication object *models.FilteredResponse: filter options + Returns: + *models.Exception: Exception payload. */ -func (as *WalletService) GetAll(ctx context.Context, am *models.Auth, filtered *models.FilteredResponse) { +func (as *WalletService) GetAll(ctx context.Context, am *models.Auth, filtered *models.FilteredResponse) *models.Exception { + exceptionReturn := new(models.Exception) db := as.Db.WithContext(ctx) wm := new([]models.Wallet) query := db.Model(wm).Where("? = ?", pg.Ident("user_id"), am.Id) - FilteredResponse(query, wm, filtered) + err := FilteredResponse(query, wm, filtered) + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400134" + exceptionReturn.Message = fmt.Sprintf("Error selecting rows in \"wallets\" table: %s", err) + return exceptionReturn + } + return nil } /* @@ -120,8 +155,9 @@ Calculates previous month, current and next month totals. string: wallet id to search Returns: *models.WalletHeader: generated wallet header object + *models.Exception: Exception payload. */ -func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletId string) *models.WalletHeader { +func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletId string) (*models.WalletHeader, *models.Exception) { db := as.Db.WithContext(ctx) wm := new(models.WalletHeader) @@ -129,16 +165,29 @@ func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletI transactions := new([]models.Transaction) subscriptions := new([]models.Subscription) transactionStatus := new(models.TransactionStatus) + exceptionReturn := new(models.Exception) tx, _ := db.Begin() defer tx.Rollback() - tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + err := tx.Model(transactionStatus).Where("? = ?", pg.Ident("status"), "completed").Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400130" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactionStatuses\" table: %s", err) + return nil, exceptionReturn + } query2 := tx.Model(subscriptions).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id).Relation("TransactionType").Relation("SubscriptionType") if walletId != "" { query2.Where("? = ?", pg.Ident("wallet_id"), walletId) } query2.Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400131" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"subscriptions\" table: %s", err) + return nil, exceptionReturn + } now := time.Now() @@ -155,6 +204,12 @@ func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletI } query = query.Where("? = ?", pg.Ident("transaction_status_id"), transactionStatus.Id) query.Select() + if err != nil { + exceptionReturn.StatusCode = 400 + exceptionReturn.ErrorCode = "400132" + exceptionReturn.Message = fmt.Sprintf("Error selecting row in \"transactions\" table: %s", err) + return nil, exceptionReturn + } tx.Commit() for _, sub := range *subscriptions { @@ -222,7 +277,7 @@ func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletI wm.Currency = "USD" wm.WalletId = walletId - return wm + return wm, nil } /* @@ -235,6 +290,8 @@ If missing, it creates the item list. *[]models.WalletTransactions: list to append to string: wallet id to check models.Transaction: Transaction to append + Returns: + *models.Exception: Exception payload. */ func addWhere(s *[]models.WalletTransactions, walletId string, e models.Transaction) { var exists bool