From 2dcbb7cf96b9b240ad3cf4a3a05edaed5f86a87d Mon Sep 17 00:00:00 2001 From: Keyur Shah <51239095+keyurboss@users.noreply.github.com> Date: Mon, 23 Dec 2024 03:50:43 +0530 Subject: [PATCH] feat(admin): Adding support APIs For Admin (#44) * feat: Get All Inactive User API Added * Two Tests Added * Some Test Written * Some Chnages --- coverage.out | 206 ++++++++++++++++++ .../get-in-active-trade-user.api.go | 21 ++ src/apis/data/trade-user/index.go | 1 + src/interfaces/admin-user.entity_test.go | 47 ++++ src/interfaces/base-entity.go | 2 +- src/interfaces/base-entity_test.go | 71 ++++++ src/mongodb/repos/bank-rate-calc.repo.go | 2 + src/mongodb/repos/trade-user.repo.go | 16 ++ src/services/trade-user.service.go | 7 +- 9 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 coverage.out create mode 100644 src/apis/data/trade-user/get-in-active-trade-user.api.go create mode 100644 src/interfaces/admin-user.entity_test.go create mode 100644 src/interfaces/base-entity_test.go diff --git a/coverage.out b/coverage.out new file mode 100644 index 0000000..0e5caba --- /dev/null +++ b/coverage.out @@ -0,0 +1,206 @@ +mode: set +github.com/rpsoftech/bullion-server/src/interfaces/admin-user.entity.go:12.67,14.2 1 1 +github.com/rpsoftech/bullion-server/src/interfaces/admin-user.entity.go:16.133,27.2 8 1 +github.com/rpsoftech/bullion-server/src/interfaces/bank-details.enitity.go:24.69,31.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/bank-rate.calc.entity.go:22.82,29.2 6 0 +github.com/rpsoftech/bullion-server/src/interfaces/bank-rate.calc.entity.go:31.74,35.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-entity.go:35.50,39.2 3 1 +github.com/rpsoftech/bullion-server/src/interfaces/base-entity.go:40.53,44.2 3 1 +github.com/rpsoftech/bullion-server/src/interfaces/base-entity.go:45.48,51.2 5 1 +github.com/rpsoftech/bullion-server/src/interfaces/base-entity.go:53.44,56.2 2 1 +github.com/rpsoftech/bullion-server/src/interfaces/base-enum-validator.interface.go:7.57,10.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:61.13,64.2 2 1 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:66.50,68.22 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:68.22,70.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:71.2,71.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:74.38,75.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:76.19,77.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:78.21,79.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:80.24,81.21 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:82.26,83.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:84.24,85.21 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:86.26,87.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:88.18,89.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:92.2,92.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:95.37,96.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:104.14,105.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:108.2,108.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:111.43,112.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:113.26,114.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:115.28,116.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:118.2,118.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:121.42,122.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:125.24,126.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:129.2,129.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:132.54,133.29 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:133.29,135.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/base-symbol.enum.go:135.8,137.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/bullion-site-info.interface.go:34.109,40.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/bullion-site-info.interface.go:42.100,68.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:35.13,38.2 2 1 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:45.47,46.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:47.24,48.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:49.24,50.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:51.28,52.19 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:54.2,54.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:57.46,58.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:62.24,63.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:66.2,66.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:69.49,70.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:71.34,72.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:73.35,74.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:75.35,76.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:78.2,78.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:81.48,82.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:86.31,87.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-on-price.enum.go:89.2,89.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:23.13,25.2 1 1 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:27.41,28.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:29.24,30.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:31.26,32.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:34.2,34.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:37.40,38.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:41.22,42.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/calculate-symbol.enum.go:45.2,45.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:11.37,12.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:13.27,14.19 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:15.23,16.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:17.27,18.19 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:20.2,20.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:23.36,24.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:28.23,29.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/device-types.enum.go:32.2,32.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/feeds.entity.go:24.50,25.25 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/feeds.entity.go:25.25,27.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/feeds.entity.go:28.2,29.10 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:23.13,25.2 1 1 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:26.48,27.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:28.43,29.22 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:30.42,31.21 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:32.41,33.20 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:35.2,35.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:38.47,39.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:43.37,44.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req-auth-status.enum.go:47.2,47.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-user-req.entity.go:10.122,19.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/general-users.entity.go:21.64,31.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/msg-variable.interface.go:24.41,28.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:66.71,67.60 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:67.60,74.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:75.2,76.27 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:76.27,77.41 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:77.41,79.4 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:80.8,82.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:84.2,84.28 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:84.28,91.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:93.2,101.24 4 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:101.24,103.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:105.2,105.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:108.193,118.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/order-entity.interface.go:120.111,129.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:57.13,61.2 3 1 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:62.38,63.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:64.19,65.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:66.19,67.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:68.19,69.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:70.20,71.24 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:72.21,73.25 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:74.27,75.31 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:76.22,77.26 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:78.29,79.33 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:81.2,81.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:84.37,85.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:94.25,95.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:98.2,98.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:101.36,102.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:103.14,104.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:105.13,106.17 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:108.2,108.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:111.35,112.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:115.9,116.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:118.2,118.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:121.34,122.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:123.11,124.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:125.12,126.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:128.2,128.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:131.33,132.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:135.8,136.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/order.enum.go:138.2,138.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/otp-req.entity.go:20.39,23.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/otp-req.entity.go:25.69,33.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:10.62,12.16 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:12.16,14.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:14.8,16.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:20.60,22.16 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:22.16,26.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/password.entity.go:27.2,29.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:37.13,39.2 1 1 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:41.39,42.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:43.26,44.20 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:45.25,46.19 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:47.26,48.20 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:49.25,50.19 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:51.27,52.21 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:53.26,54.20 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:55.17,56.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:57.17,58.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:59.18,60.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:61.19,62.17 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:64.2,64.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:67.38,68.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:79.15,80.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/price-key.enum.go:82.2,82.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/product-entity.interface.go:49.118,58.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/product-entity.interface.go:60.77,63.2 2 1 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:27.39,29.2 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:30.93,32.35 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:32.35,33.17 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:33.17,35.4 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:36.3,36.128 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:38.2,38.10 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:41.77,43.28 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:43.28,51.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:52.2,52.12 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:54.62,56.9 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:56.9,63.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:64.2,64.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:67.60,69.9 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:69.9,76.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/req-interfaces.go:77.2,77.16 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:43.66,47.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:49.72,53.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:55.67,56.41 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:56.41,58.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:58.8,58.45 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:58.45,60.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:60.8,60.86 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:60.86,62.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:63.2,63.72 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user-group.entity.go:66.99,72.2 5 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:46.59,49.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:51.60,55.2 3 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:56.64,59.2 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:61.116,63.34 2 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:63.34,65.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:65.8,65.43 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:65.43,67.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:69.2,69.55 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:69.55,77.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:79.2,79.34 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:79.34,81.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:81.8,81.43 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:81.43,83.3 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/trade-user.entity.go:84.2,84.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:29.13,31.2 1 1 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:33.46,35.2 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:37.36,38.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:39.23,40.22 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:41.24,42.23 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:43.18,44.17 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:45.25,46.24 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:47.23,48.22 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:49.16,50.15 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:53.2,53.18 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:56.35,57.11 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:64.12,65.14 1 0 +github.com/rpsoftech/bullion-server/src/interfaces/user-roles.enum.go:68.2,68.14 1 0 diff --git a/src/apis/data/trade-user/get-in-active-trade-user.api.go b/src/apis/data/trade-user/get-in-active-trade-user.api.go new file mode 100644 index 0000000..620a9ce --- /dev/null +++ b/src/apis/data/trade-user/get-in-active-trade-user.api.go @@ -0,0 +1,21 @@ +package tradeuser + +import ( + "github.com/gofiber/fiber/v2" + "github.com/rpsoftech/bullion-server/src/interfaces" + "github.com/rpsoftech/bullion-server/src/services" +) + +func apiGetInActiveTradeUsers(c *fiber.Ctx) error { + bullionId, err := interfaces.ExtractBullionIdFromCtx(c) + if err != nil { + return err + } + entity, err := services.TradeUserService.FindAndReturnAllInActiveTradeUsers(bullionId) + if err != nil { + return err + } else { + return c.JSON(entity) + } + +} diff --git a/src/apis/data/trade-user/index.go b/src/apis/data/trade-user/index.go index 238af0d..5bd9435 100644 --- a/src/apis/data/trade-user/index.go +++ b/src/apis/data/trade-user/index.go @@ -7,6 +7,7 @@ import ( func AddTradeUserAPIs(router fiber.Router) { adminGroup := router.Use(middleware.AllowOnlyBigAdmins.Validate) + adminGroup.Get("/getInActiveTradeUsers", apiGetInActiveTradeUsers) adminGroup.Get("/getTradeUser", apiGetTradeUserDetails) adminGroup.Patch("/updateTradeUserDetails", apiUpdateTradeUserDetails) adminGroup.Patch("/updateTradeUserStatus", apiChangeTradeUserStatus) diff --git a/src/interfaces/admin-user.entity_test.go b/src/interfaces/admin-user.entity_test.go new file mode 100644 index 0000000..5779616 --- /dev/null +++ b/src/interfaces/admin-user.entity_test.go @@ -0,0 +1,47 @@ +package interfaces + +import ( + "testing" +) + +func TestAdminUserEntity(t *testing.T) { + e := &AdminUserEntity{} + // // c.createNewId() + // Admin() + t.Run("Create New Admin Entity", func(t *testing.T) { + if e.BaseEntity != nil { + t.Fatalf("BaseEntity is not nil") + } + if e.UserRolesInterface != nil { + t.Fatalf("UserRolesInterface is not nil") + } + e.CreateNewEntity("admin", "password", "nickName", "bullionId") + if e.BaseEntity == nil { + t.Fatalf("BaseEntity is nil") + } + if e.UserName != "admin" { + t.Fatalf("UserName is not admin") + } + if e.Password != "password" { + t.Fatalf("Password is not password") + } + if e.NickName != "nickName" { + t.Fatalf("NickName is not nickName") + } + if e.BullionId != "bullionId" { + t.Fatalf("BullionId is not bullionId") + } + if e.UserRolesInterface == nil { + t.Fatalf("UserRolesInterface is nil") + } + if e.UserRolesInterface.Role != ROLE_ADMIN { + t.Fatalf("UserRolesInterface Role is not ROLE_ADMIN") + } + testBaseEntityCreateNewId(t, e.BaseEntity) + t.Run("password match", func(t *testing.T) { + if !e.MatchPassword("password") { + t.Fatalf("Password does not match") + } + }) + }) +} diff --git a/src/interfaces/base-entity.go b/src/interfaces/base-entity.go index 37da61e..7989e85 100644 --- a/src/interfaces/base-entity.go +++ b/src/interfaces/base-entity.go @@ -46,7 +46,7 @@ func (b *BaseEntity) createNewId() *BaseEntity { id := uuid.New().String() b.ID = id b.CreatedAt = time.Now() - b.ModifiedAt = time.Now() + b.ModifiedAt = b.CreatedAt return b } diff --git a/src/interfaces/base-entity_test.go b/src/interfaces/base-entity_test.go new file mode 100644 index 0000000..d6675f6 --- /dev/null +++ b/src/interfaces/base-entity_test.go @@ -0,0 +1,71 @@ +package interfaces + +import ( + "testing" + "time" +) + +func testBaseEntityCreateNewId(t *testing.T, c *BaseEntity) { + + if c.ID == "" { + t.Fatalf("Id is empty") + } + + if c.CreatedAt.IsZero() { + t.Fatalf("CreatedAt is empty") + } + if c.ModifiedAt.IsZero() { + t.Fatalf("ModifiedAt is empty") + } + if !c.CreatedAtExported.IsZero() { + t.Fatalf("CreatedAtExported is not empty %d", c.CreatedAtExported.Unix()) + } + if !c.ModifiedAtExported.IsZero() { + t.Fatalf("ModifiedAtExported is not empty") + } +} + +func TestBaseEntity(t *testing.T) { + c := &BaseEntity{} + c.createNewId() + t.Run("Create New ID", func(t *testing.T) { + id := c.ID + c.createNewId() + if c.ID == id { + t.Fatalf("Id Should Be Different") + } + testBaseEntityCreateNewId(t, c) + }) + t.Run("AddTimeStamps", func(t *testing.T) { + now := time.Now() + c.CreatedAt = now + c.ModifiedAt = now + c.AddTimeStamps() + if c.CreatedAtExported != now { + t.Fatalf("CreatedAt and CreatedAtExported Should be same") + } + if c.ModifiedAtExported != now { + t.Fatalf("ModifiedAt and ModifiedAtExported Should be same") + } + }) + t.Run("RestoreTimeStamp", func(t *testing.T) { + now := time.Now() + c.CreatedAtExported = now + c.ModifiedAtExported = now + c.RestoreTimeStamp() + if c.CreatedAt != now { + t.Fatalf("CreatedAt and CreatedAtExported Should be same") + } + if c.ModifiedAt != now { + t.Fatalf("ModifiedAt and ModifiedAtExported Should be same") + } + }) + t.Run("Updated", func(t *testing.T) { + now := time.Now() + c.ModifiedAt = now + c.Updated() + if c.ModifiedAt.Before(now) { + t.Fatalf("ModifiedAt Should be greater than now") + } + }) +} diff --git a/src/mongodb/repos/bank-rate-calc.repo.go b/src/mongodb/repos/bank-rate-calc.repo.go index fd53733..c2b5b2f 100644 --- a/src/mongodb/repos/bank-rate-calc.repo.go +++ b/src/mongodb/repos/bank-rate-calc.repo.go @@ -41,6 +41,7 @@ func init() { } func (repo *BankRateCalcRepoStruct) cacheDataToRedis(entity *interfaces.BankRateCalcEntity) { + entity.AddTimeStamps() if entityStringBytes, err := json.Marshal(entity); err == nil { entityString := string(entityStringBytes) repo.redis.SetStringDataWithExpiry(fmt.Sprintf("%s/%s", bankRateRedisCollection, entity.BullionId), entityString, time.Duration(24)*time.Hour) @@ -73,6 +74,7 @@ func (repo *BankRateCalcRepoStruct) FindOneByBullionId(id string) (*interfaces.B result := new(interfaces.BankRateCalcEntity) if redisData := repo.redis.GetStringData(fmt.Sprintf("%s/%s", bankRateRedisCollection, id)); redisData != "" { if err := json.Unmarshal([]byte(redisData), result); err == nil { + result.RestoreTimeStamp() return result, err } } diff --git a/src/mongodb/repos/trade-user.repo.go b/src/mongodb/repos/trade-user.repo.go index 82f4b81..f8bd3b9 100644 --- a/src/mongodb/repos/trade-user.repo.go +++ b/src/mongodb/repos/trade-user.repo.go @@ -133,10 +133,25 @@ func (repo *TradeUserRepoStruct) findByFilter(filter *mongoDbFilter) (*[]interfa return &result, err } +func (repo *TradeUserRepoStruct) FindAllInActiveUser(bullionId string) (*[]interfaces.TradeUserEntity, error) { + return repo.findByFilter(&mongoDbFilter{ + conditions: &bson.D{ + { + Key: "$and", + Value: bson.A{ + bson.D{{Key: "bullionId", Value: bullionId}}, + bson.D{{Key: "isActive", Value: false}}, + }, + }, + }, + }) +} + func (repo *TradeUserRepoStruct) FindOne(id string) (*interfaces.TradeUserEntity, error) { result := new(interfaces.TradeUserEntity) if redisData := repo.redis.GetStringData(fmt.Sprintf("tradeUser/%s", id)); redisData != "" { if err := json.Unmarshal([]byte(redisData), result); err == nil { + result.RestoreTimeStamp() return result, err } } @@ -167,6 +182,7 @@ func (repo *TradeUserRepoStruct) FindOne(id string) (*interfaces.TradeUserEntity } func (repo *TradeUserRepoStruct) cacheDataToRedis(entity *interfaces.TradeUserEntity) { + entity.AddTimeStamps() if entityStringBytes, err := json.Marshal(entity); err == nil { entityString := string(entityStringBytes) repo.redis.SetStringDataWithExpiry(fmt.Sprintf("tradeUser/%s", entity.ID), entityString, time.Duration(24)*time.Hour) diff --git a/src/services/trade-user.service.go b/src/services/trade-user.service.go index 316a1dd..180838d 100644 --- a/src/services/trade-user.service.go +++ b/src/services/trade-user.service.go @@ -300,7 +300,9 @@ func (service *tradeUserServiceStruct) UpdateTradeUser(entity *interfaces.TradeU user.TradeUserBase = entity.TradeUserBase user.TradeUserAdvanced.IsActive = entity.TradeUserAdvanced.IsActive user.TradeUserMargins = entity.TradeUserMargins - if _, err := service.tradeUserRepo.Save(entity); err != nil { + // TODO: Password Entity + // user.Password = entity.Password + if _, err := service.tradeUserRepo.Save(user); err != nil { return err } service.eventBus.Publish(events.CreateTradeUserUpdated(entity.BullionId, user, adminId)) @@ -327,6 +329,9 @@ func (service *tradeUserServiceStruct) generateTokensForTradeUserWithPasswordMat return service.generateTokensForTradeUser(tradeUser) } +func (service *tradeUserServiceStruct) FindAndReturnAllInActiveTradeUsers(bullionId string) (*[]interfaces.TradeUserEntity, error) { + return service.tradeUserRepo.FindAllInActiveUser(bullionId) +} func (service *tradeUserServiceStruct) FindOneUserById(id string) (*interfaces.TradeUserEntity, error) { return service.tradeUserRepo.FindOne(id) }