Compare commits
734 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3762e6c46 | |||
| 157eb140eb | |||
| 83a0c27259 | |||
| 5c4a8e37c4 | |||
| e4faf64ea3 | |||
| a4849fa4f0 | |||
| 32155ca63d | |||
| 9ea3327517 | |||
| 946a7810a7 | |||
| ea8021b359 | |||
| caa27841ef | |||
| d1cd13723a | |||
| 0e946a4b3b | |||
| 051c319890 | |||
| f2baa4ae65 | |||
| 05a93667eb | |||
| c137156c97 | |||
| 8f8a94cd66 | |||
| 4cdb599bf3 | |||
| 77a5ccd796 | |||
| 99ae18d06d | |||
| 90318d5690 | |||
| f133692002 | |||
| 0b17251f94 | |||
| 24724bb19f | |||
| b23d630daa | |||
| fcb954ff40 | |||
| 889225301c | |||
| 816d0e7ceb | |||
| f2c0ffab99 | |||
| f1f61a9038 | |||
| 77439f675b | |||
| c57f17233a | |||
| c91a56547f | |||
| 10dc2d1713 | |||
| d3c8a520ca | |||
| 681f888529 | |||
| bce8c23b05 | |||
| 788bfa7d4b | |||
| 6d331c873b | |||
| a03df7ed36 | |||
| b0b330903c | |||
| 4e16f963a8 | |||
| 8ef4b5537c | |||
| 8273e06e43 | |||
| b91305c490 | |||
| de086aa29e | |||
| 4c69243bef | |||
| 57d8edea0a | |||
| a098c100d7 | |||
| 8fb209440d | |||
| d05736d0eb | |||
| c92a9e61b0 | |||
| 2e04affb00 | |||
| 731b6e8bad | |||
| 2b63e50837 | |||
| e22f512f22 | |||
| 9a83393290 | |||
| 30ebe49875 | |||
| e15a850cfe | |||
| 34ebc06a8d | |||
| a86428cc4d | |||
| efce4cc04e | |||
| a8484cfcaf | |||
| cc55b98e80 | |||
| 0620194c78 | |||
| a00a67f3d1 | |||
| 6b9ad1a1c8 | |||
| 3d0b993c45 | |||
| dc74ac0d0b | |||
| 7ed923b347 | |||
| 1f63aa8cdf | |||
| 84f7eab95d | |||
| 7d6c7f49e5 | |||
| 021e523d63 | |||
| 266dafa4a9 | |||
| 579c903398 | |||
| 5d2e880bc5 | |||
| 8085f7cf11 | |||
| aea4cf7e8b | |||
| 3d56bfa114 | |||
| a7280bf7ed | |||
| 085f9817fc | |||
| fcca77bca5 | |||
| 4bf2e94a9d | |||
| 95c2494545 | |||
| 7662e0eb02 | |||
| 9f438dd648 | |||
| 08a1f3a5f7 | |||
| 26d77de67a | |||
| 4f9ab9db75 | |||
| 0b83518921 | |||
| 0f8de8d699 | |||
| aae23c285e | |||
| daf73dc964 | |||
| bc0893b518 | |||
| a87bda09f7 | |||
| aa7652279e | |||
| d86dea4081 | |||
| 15d476fd40 | |||
| 453a9ff61c | |||
| 26e9a0ef2a | |||
| 7849b2f05c | |||
| 2cbcc40ca9 | |||
| 184dad8185 | |||
| 46a7cd441f | |||
| 55249e07a3 | |||
| d4850b4a18 | |||
| 93819d5894 | |||
| 4a4cec3d69 | |||
| 432993121c | |||
| 1ce0c62c30 | |||
| b1343ba92a | |||
| 84a96d80b7 | |||
| 4b249a0ebb | |||
| 58de308f30 | |||
| f151eb6197 | |||
| 9eaac329b9 | |||
| a33123022f | |||
| 3eac9af403 | |||
| a371058096 | |||
| ee003160e5 | |||
| 847349dcbd | |||
| a2d6aff28b | |||
| cc3e1f2978 | |||
| dc9bf1a1d8 | |||
| 32af32d02e | |||
| d91c99c177 | |||
| d0e8419b2e | |||
| dad3f1041e | |||
| 7b70b2db29 | |||
| e5a04596e1 | |||
| 297f8b9987 | |||
| 9eddab3dd8 | |||
| ec97d2df91 | |||
| 3dd39defc1 | |||
| c0cc9b5247 | |||
| dc13afc071 | |||
| 628bd48f73 | |||
| c827675e14 | |||
| 09fb474921 | |||
| 7e1338e081 | |||
| 7a5d7337cd | |||
| b80041433c | |||
| dd32ab83cb | |||
| c8db448dfc | |||
| 51edca66d1 | |||
| bb5529098f | |||
| d5a54dd1fb | |||
| 329119fc3b | |||
| e43cf26bb5 | |||
| 93bc3bf94b | |||
| 675b5f039a | |||
| b3e4e39b49 | |||
| 4dc072f56d | |||
| b5d72c89f2 | |||
| d2b3900ed4 | |||
| 4e44553c07 | |||
| ec6b5fb155 | |||
| 16e53feaf4 | |||
| 182bdb34cd | |||
| 59d03b54d7 | |||
| 445969c449 | |||
| 29214a3bf3 | |||
| d979dc3535 | |||
| 399413a270 | |||
| d9c8142c51 | |||
| c951285049 | |||
| 0e372969b3 | |||
| 2d51f7b2be | |||
| 02a5dcf9ba | |||
| 9a70cfe24c | |||
| 023d875a00 | |||
| 640f74c612 | |||
| 768b005200 | |||
| fb315127f9 | |||
| 756e6cac5a | |||
| daae5b68cd | |||
| 0e391bee50 | |||
| 9627e65d6d | |||
| 830974500b | |||
| 0438964e17 | |||
| 226d44651f | |||
| db71ac5279 | |||
| 7e2a0b1483 | |||
| a219444953 | |||
| 5fec41055e | |||
| 5107e451d8 | |||
| 3b34cdbda2 | |||
| 35fcd32a96 | |||
| cf325b4267 | |||
| 860ef610b7 | |||
| 5c5e6a60a7 | |||
| 435c38fb27 | |||
| d640b7a5f5 | |||
| ae25b4eb4e | |||
| 315a686fed | |||
| 4dd79b07d9 | |||
| e88d803232 | |||
| 1489854444 | |||
| c5f9e276b4 | |||
| b2a8b359d1 | |||
| 72f6a9e9a3 | |||
| 809172bf34 | |||
| c34887240e | |||
| f041e7cb7d | |||
| 5eca777891 | |||
| a9e3b79eb1 | |||
| 0a376217c6 | |||
| 687d062bfc | |||
| e123498895 | |||
| a917d16c26 | |||
| 0884af038d | |||
| 72619f3dad | |||
| cf120dbcbf | |||
| 9906f1b1a7 | |||
| ea32bfa5fc | |||
| 14f6de8af1 | |||
| 176d5a15c5 | |||
| cfc7a5bd49 | |||
| 4b68ccf678 | |||
| cb57b216d0 | |||
| 222951139c | |||
| 821c7bfbd3 | |||
| 722c1d7917 | |||
| 4d065bc724 | |||
| 2a2cb3acc9 | |||
| 4a16b82700 | |||
| ea97f8cf7a | |||
| 28f113d992 | |||
| 46caf46ef7 | |||
| 185758b638 | |||
| 1e047aed80 | |||
| 8ef7676b4f | |||
| b2fc24d5ae | |||
| 065cd9dff8 | |||
| 532c762553 | |||
| 4857055eaf | |||
| 604379bf85 | |||
| 3d0f793cf6 | |||
| 9f8634ac11 | |||
| 6ab70b97b4 | |||
| 8c164ec833 | |||
| 09d47459b6 | |||
| 2916106f27 | |||
| 6b4292596a | |||
| 78aebb7d6c | |||
| 771bb35e9f | |||
| 453ed4227d | |||
| 88a284a21b | |||
| 9488b85705 | |||
| 8be3fd7ed4 | |||
| 8fdc0019ea | |||
| b21dd73ff2 | |||
| 24432701dd | |||
| 802cdabd75 | |||
| 8c83af1543 | |||
| deb465377e | |||
| bed2aef7f8 | |||
| 57b2b2492f | |||
| 87cdaee547 | |||
| a8b0ef2483 | |||
| 63e976e5cb | |||
| f73830d37b | |||
| 6511c4e810 | |||
| 008c58f52b | |||
| fa4a17f47b | |||
| 3fc2a763b4 | |||
| 1b2726a55c | |||
| 229fa27b73 | |||
| 072f44245d | |||
| dc837c430f | |||
| 429e270a9e | |||
| 985cefc297 | |||
| 285fc0ced3 | |||
| 777e14b6d4 | |||
| d18e8211ca | |||
| 2984980a54 | |||
| 2302f31f18 | |||
| f673677c2a | |||
| acc9bf77fb | |||
| 678769da0e | |||
| 2389208c95 | |||
| 28a1080ccc | |||
| 432d3fd3c3 | |||
| 8fc73b866b | |||
| dbc62aac93 | |||
| 79802a46fd | |||
| 3d8ecb42c1 | |||
| bcaf554ae4 | |||
| 3ac4a921e0 | |||
| 128f86b643 | |||
| 828fc690b6 | |||
| 55d06640b5 | |||
| 3874a8da21 | |||
| 6a3ecd5b09 | |||
| afcd4f7262 | |||
| b0ae731fa6 | |||
| 0b678fe69a | |||
| 4cecc78a74 | |||
| 92273d2fc6 | |||
| 04ec749c3c | |||
| 165377816c | |||
| 729904e1c3 | |||
| 6bc4fa0a82 | |||
| f12403672b | |||
| 97daff8d4f | |||
| a32451fd7f | |||
| ca14770971 | |||
| 35ac0695c7 | |||
| 589b614a53 | |||
| 64ea3e05d8 | |||
| 5d0e115438 | |||
| 9f35c1eded | |||
| ff07346fe9 | |||
| 22fffc2f8c | |||
| 205363dd42 | |||
| d2297b882f | |||
| 48bf8dbc5b | |||
| 9585c760d5 | |||
| 8c2cd0aa4d | |||
| 2e680b04c9 | |||
| e2b81f7b57 | |||
| c38b277887 | |||
| a1f6304b22 | |||
| 09d7f56efc | |||
| 9221f3fc96 | |||
| 6b30a0aebc | |||
| 158563f387 | |||
| b0fc5752e2 | |||
| 28903615ed | |||
| caa83c0432 | |||
| 045f4a42db | |||
| 3275bc9cae | |||
| 6d14eaefe1 | |||
| 03274725be | |||
| 0951006063 | |||
| 616bfc6a2a | |||
| c0bfe429ee | |||
| c1d90485a1 | |||
| 6c30527684 | |||
| 4ac751f492 | |||
| de7b137257 | |||
| 0bf689fa8d | |||
| f31ef1649f | |||
| c66bc62c41 | |||
| 9ee59215c8 | |||
| a991adecaf | |||
| 601b1d5c89 | |||
| 8b593883a7 | |||
| bb549c9a89 | |||
| 9f2005622a | |||
| 4238bde13a | |||
| 2d4ce1aac0 | |||
| 37269abde2 | |||
| 54038eabd4 | |||
| 57922e3071 | |||
| ad36dfd448 | |||
| 6e334d2efb | |||
| d3dc1401fd | |||
| 0f59c9911d | |||
| 0ebfd2bc76 | |||
| 734625c1e3 | |||
| eaaea8a64f | |||
| c026ab1777 | |||
| 2c7193efea | |||
| 21f5ef469b | |||
| e7f9eb6e06 | |||
| 9db9c382ab | |||
| b2ba626cde | |||
| 85d93c4f4b | |||
| 09f6dd8d82 | |||
| 2aa6df48c6 | |||
| 2a16260b05 | |||
| c28158b041 | |||
| 661199850c | |||
| 67b69a45cc | |||
| 579322578b | |||
| 0de65042b0 | |||
| f9643f8651 | |||
| fc9ac4c40e | |||
| 84843066f2 | |||
| af3d5c4654 | |||
| 676f3daf50 | |||
| 54970015cb | |||
| 2b49430530 | |||
| feea5f3518 | |||
| 04e580b40f | |||
| f07a3ba97d | |||
| f44e3a81ab | |||
| 77d3bd019e | |||
| 72725d5ab4 | |||
| aa717ed1fe | |||
| 292b49ba79 | |||
| c600eb5d5a | |||
| 6d2f788fa2 | |||
| b8acff3e7c | |||
| b8bdb03fc0 | |||
| 7257abefb4 | |||
| 3095613a76 | |||
| db12b64b3a | |||
| a081edde25 | |||
| 5496c4a10a | |||
| c968ded99a | |||
| 4224a833b4 | |||
| df470f1a5e | |||
| ed0100a82c | |||
| 0ad72e8334 | |||
| 50ee5d1f49 | |||
| 94283a8da2 | |||
| 86e9a3e838 | |||
| d77b9ef7c9 | |||
| e29afa3155 | |||
| 7376fbe7a1 | |||
| 04e98e1c39 | |||
| ddca6e7ec9 | |||
| 1ac12ac668 | |||
| 399936e3ab | |||
| 3d086992dc | |||
| 62ded1290c | |||
| 33cbdfbd13 | |||
| f5ce6ed4bc | |||
| eb9a2ac2e0 | |||
| 8bed529d05 | |||
| 41a8b8007a | |||
| 141dc843f3 | |||
| 902825404e | |||
| 749eaaab30 | |||
| 8f5767b992 | |||
| 715f0c5853 | |||
| a960fd3d56 | |||
| 17b8ac6d0b | |||
| 4ac78fe4d1 | |||
| 957bcf790f | |||
| 66f0b38008 | |||
| f6a2246aab | |||
| fa3e941069 | |||
| 9bb049f746 | |||
| c41f2a4d65 | |||
| 06ff9f2499 | |||
| f91f9fcc94 | |||
| 9a626b0d4f | |||
| ac2adaf4ba | |||
| 3ab198615b | |||
| 7c2831098c | |||
| 2454e22ea2 | |||
| b1fb40ca61 | |||
| e403e938c3 | |||
| 952ba1f1ea | |||
| a25690c2d3 | |||
| 6b6b9c61d7 | |||
| fcc5e522a7 | |||
| c33c0487cf | |||
| 1753a6c247 | |||
| 195f513416 | |||
| c6d38bb3d7 | |||
| 9b2fba9600 | |||
| c88f6501fa | |||
| c511346160 | |||
| 0b02daac1d | |||
| 2390c085e4 | |||
| 698d94feed | |||
| a9a6d39127 | |||
| 395bd31898 | |||
| 7e24492ce8 | |||
| 19d3d80013 | |||
| 8c7875d7ea | |||
| 110ce0d4c6 | |||
| ff8c57fdab | |||
| 54ccdc57bf | |||
| 2463f06ba1 | |||
| 88d5b1f98f | |||
| 43522e9c81 | |||
| 6e798f739f | |||
| 5b5f1280af | |||
| 2188e8dd78 | |||
| 8659e9ea37 | |||
| 4cff481d61 | |||
| 6da910d8fb | |||
| cc08ad46e3 | |||
| 5b52c1adbb | |||
| a20958a89b | |||
| dea36d4b80 | |||
| 6cb7e4caf7 | |||
| 6e41668b25 | |||
| d3e1acddc5 | |||
| a9c511eb2e | |||
| ffef33a9fc | |||
| 982917ddbb | |||
| 07406a50bb | |||
| 78f325e127 | |||
| e1bb97a1db | |||
| 831952806d | |||
| 4c57b7a009 | |||
| 683188f67a | |||
| 848e5271ab | |||
| 7ca5614c44 | |||
| 70fc781a03 | |||
| aafdbab781 | |||
| 5dd0f7ea10 | |||
| 9393d9105c | |||
| 2c3856be3c | |||
| dc746a51a5 | |||
| 0f2c9354f0 | |||
| af00032ee9 | |||
| 5d7e685dc4 | |||
| bfcb79c02b | |||
| ebee6273b0 | |||
| b45900e5bc | |||
| 9f0657683a | |||
| 35b8d8ca25 | |||
| 8f7095ce19 | |||
| d9c8dd20e9 | |||
| 8dcc462a30 | |||
| b561948030 | |||
| 2cbd8684cf | |||
| 107c9fce94 | |||
| 4c18b3e059 | |||
| 9960ec4d58 | |||
| 2a09e048e4 | |||
| 9711f3ba72 | |||
| 0622d2b81b | |||
| a372d1fb60 | |||
| 99e55e730e | |||
| 57d1e915e6 | |||
| 96ad6228bd | |||
| 678f9fbe87 | |||
| 714933df56 | |||
| f0ef9ad51e | |||
| 0255213934 | |||
| 0ad92a999c | |||
| b06456d573 | |||
| 6f1fc2c9b4 | |||
| 44a1982d87 | |||
| 6b0cf5aa96 | |||
| 2cfac7a772 | |||
| 99aaf35e0b | |||
| 942ed1fb55 | |||
| 25f83a98e3 | |||
| ed4040f2ec | |||
| 41034de676 | |||
| 2db0f1a6c8 | |||
| 6b06cc7ef5 | |||
| 2bf26212af | |||
| 9d273c172d | |||
| 6ae3bc82bb | |||
| c782002274 | |||
| cd0906d041 | |||
| f936ecca33 | |||
| 8794e3bc53 | |||
| 4503e2a222 | |||
| 015725f88c | |||
| 39451f0e37 | |||
| 2bb0b7faa5 | |||
| 8db7c3769a | |||
| d4e32de882 | |||
| db75dea9ee | |||
| 489bba9c4b | |||
| 4accc49d60 | |||
| 5a47cd5216 | |||
| 439608cf27 | |||
| f9df7a1b5a | |||
| 78c801994a | |||
| 882fd68cf9 | |||
| 3433b73edf | |||
| a235d6a8cd | |||
| d76e88af21 | |||
| 3f6c6c443a | |||
| 13c6d406cf | |||
| 19fea4e761 | |||
| c84c96dcd1 | |||
| cdd8ccc2d4 | |||
| 09210d5d40 | |||
| 8f44a26037 | |||
| 5e986b2d04 | |||
| 298c0922cb | |||
| dc127ea6a3 | |||
| 522ed94c32 | |||
| 6edf66a599 | |||
| 475ec24528 | |||
| b555af0df7 | |||
| f90430e544 | |||
| 4ccb75818c | |||
| c5c9ed24c3 | |||
| 386aa0adc1 | |||
| 0b26b75699 | |||
| d013f67c70 | |||
| dc7c0e61fd | |||
| 89bd041d29 | |||
| ac730d6086 | |||
| 427eaed544 | |||
| 00f783c0b6 | |||
| 8e1e53d55e | |||
| 5c9a5c13b8 | |||
| c1f03a8e75 | |||
| 1affa83620 | |||
| 2aa8180113 | |||
| e6001d83a4 | |||
| 8550c8fde9 | |||
| 48d9a09307 | |||
| 9d0b874488 | |||
| 062a13b2c2 | |||
| 937f8723ed | |||
| 0c5cabbd79 | |||
| 95d8f710d8 | |||
| bb9b8b34e5 | |||
| 54c1164bd7 | |||
| 89c1158d95 | |||
| 9cae189941 | |||
| 53a31cd4c4 | |||
| d72a615481 | |||
| 8dcffa80a8 | |||
| 7cf53acd18 | |||
| 748cf68055 | |||
| 9cd22bdc06 | |||
| 5830d4b91c | |||
| b42f7f566b | |||
| db8223ca98 | |||
| 9403afc392 | |||
| 2b2d3b9517 | |||
| 3eebdfcdb3 | |||
| f7766bc3d4 | |||
| f2614abbdd | |||
| 58824ea879 | |||
| 9ef7a18847 | |||
| 58c0167696 | |||
| 9adfd286f9 | |||
| 4e8f530fbb | |||
| 3e694b0772 | |||
| 2fd5b04d4d | |||
| 4688b9a9c9 | |||
| 153e0035ba | |||
| 88b6ecc557 | |||
| 9df55874a6 | |||
| 87d4ab827a | |||
| 318166f23a | |||
| cc3f712659 | |||
| ee399d8a08 | |||
| 96c233d5c5 | |||
| 652b3e1954 | |||
| a8b76d5537 | |||
| e041b70cdd | |||
| 63bf912b3e | |||
| 0cbe7b1655 | |||
| 7bbec29c5b | |||
| 7cec7dbac8 | |||
| 09a19b5f42 | |||
| 8fe765c097 | |||
| b11e8e07c4 | |||
| f72763306d | |||
| e3d1a476e2 | |||
| f0bc86d42f | |||
| a62e806175 | |||
| 5bcf5bf93e | |||
| 4f35ba0931 | |||
| 2bcdfe778a | |||
| c89da1d0f7 | |||
| 46a1eda029 | |||
| 1c39819112 | |||
| 0efe617c03 | |||
| 10df947efe | |||
| fb7790ba4a | |||
| a9338ed822 | |||
| eaab8cdd93 | |||
| edfcd0dc6e | |||
| 838b56089b | |||
| 178810f908 | |||
| 69f5aca853 | |||
| 8e6aece9ae | |||
| 59b883ff7f | |||
| 548d34fbf4 | |||
| bb6345ccfa | |||
| d59a10f718 | |||
| aab1c5419a | |||
| 9b83785b95 | |||
| 099b710eb1 | |||
| a5424afc38 | |||
| 626325066d | |||
| 37195f6008 | |||
| fcbc68cefe | |||
| 9241953e31 | |||
| 651a912498 | |||
| a05f6fb6b5 | |||
| d6440d31f2 | |||
| 88d5dc2f17 | |||
| a17ad85858 | |||
| 4b49c1f30f | |||
| a9e36b9a59 | |||
| 80429bbfb8 | |||
| f39e20d7a7 | |||
| a03bac5d74 | |||
| 1aff09598a | |||
| 4036a71ee1 | |||
| a966be2f46 | |||
| a0b3bc1cab | |||
| eb2e2b0a26 | |||
| 55ad7b2e81 | |||
| dbcd2897a4 | |||
| 68a6d1c166 | |||
| fe82ec6fc2 | |||
| 5f2819a961 | |||
| 812bfc7cf5 | |||
| d164cafd33 | |||
| 3ada4183d9 | |||
| fa68621b41 | |||
| 4f2b9d39da | |||
| fd01c9269f | |||
| 82d150e53a | |||
| 251f3fe2da | |||
| 4f0e1e6b3d | |||
| a5dbf5d4b7 | |||
| 38baf77c30 | |||
| bfb8b03fc9 | |||
| 2dd38d9b03 | |||
| 307c64bc1e | |||
| 782e3a85f9 | |||
| 3bae6e749a | |||
| 530ef6b83e | |||
| 5b334eb2d5 | |||
| 28dc2e425a | |||
| 83b72e7403 | |||
| 01e1f65ffe | |||
| 9b15f888e6 | |||
| 171b8afa8e | |||
| 27f2f9f13a | |||
| 2c3983cead | |||
| bebd043d58 | |||
| a1c828fe62 | |||
| dfb885f38d | |||
| 702c095544 | |||
| b3e886d444 | |||
| 46d85e92cd | |||
| 0d84f2857f | |||
| ac6c80db90 |
@@ -23,28 +23,34 @@ jobs:
|
|||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=raw,value=latest
|
type=raw,value=latest
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Set up the environment
|
- name: Set up the environment
|
||||||
run: |
|
run: |
|
||||||
|
sed -r -i 's#FROM( --.*)? (.*:.*)?#FROM\1 ${{ secrets.DOCKER_REPO }}/mirrors/\2#g' Dockerfile
|
||||||
cat >> docker/custom-backend-pre-setup.sh <<EOF
|
cat >> docker/custom-backend-pre-setup.sh <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
${{ secrets.CUSTOM_BACKEND_PRE_SETUP }}
|
${{ vars.CUSTOM_BACKEND_PRE_SETUP }}
|
||||||
EOF
|
EOF
|
||||||
cat >> docker/custom-frontend-pre-setup.sh <<EOF
|
cat >> docker/custom-frontend-pre-setup.sh <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
${{ secrets.CUSTOM_FRONTEND_PRE_SETUP }}
|
${{ vars.CUSTOM_FRONTEND_PRE_SETUP }}
|
||||||
EOF
|
EOF
|
||||||
chmod +x docker/custom-backend-pre-setup.sh
|
chmod +x docker/custom-backend-pre-setup.sh
|
||||||
chmod +x docker/custom-frontend-pre-setup.sh
|
chmod +x docker/custom-frontend-pre-setup.sh
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
env:
|
|
||||||
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
|
||||||
with:
|
with:
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
context: .
|
context: .
|
||||||
|
platforms: ${{ vars.BUILD_RELEASE_PLATFORMS }}
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
RELEASE_BUILD=1
|
RELEASE_BUILD=1
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|||||||
@@ -23,27 +23,32 @@ jobs:
|
|||||||
type=raw,value=latest-snapshot
|
type=raw,value=latest-snapshot
|
||||||
type=sha,format=short,prefix=SNAPSHOT-
|
type=sha,format=short,prefix=SNAPSHOT-
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Set up the environment
|
- name: Set up the environment
|
||||||
run: |
|
run: |
|
||||||
sed -i 's#FROM #FROM ${{ secrets.DOCKER_REPO }}/mirrors/#g' Dockerfile
|
sed -r -i 's#FROM( --.*)? (.*:.*)?#FROM\1 ${{ secrets.DOCKER_REPO }}/mirrors/\2#g' Dockerfile
|
||||||
cat >> docker/custom-backend-pre-setup.sh <<EOF
|
cat >> docker/custom-backend-pre-setup.sh <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
${{ secrets.CUSTOM_BACKEND_PRE_SETUP }}
|
${{ vars.CUSTOM_BACKEND_PRE_SETUP }}
|
||||||
EOF
|
EOF
|
||||||
cat >> docker/custom-frontend-pre-setup.sh <<EOF
|
cat >> docker/custom-frontend-pre-setup.sh <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
${{ secrets.CUSTOM_FRONTEND_PRE_SETUP }}
|
${{ vars.CUSTOM_FRONTEND_PRE_SETUP }}
|
||||||
EOF
|
EOF
|
||||||
chmod +x docker/custom-backend-pre-setup.sh
|
chmod +x docker/custom-backend-pre-setup.sh
|
||||||
chmod +x docker/custom-frontend-pre-setup.sh
|
chmod +x docker/custom-frontend-pre-setup.sh
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
env:
|
|
||||||
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
|
||||||
with:
|
with:
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
context: .
|
context: .
|
||||||
|
platforms: ${{ vars.BUILD_SNAPSHOT_PLATFORMS }}
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|||||||
+6
-4
@@ -1,5 +1,5 @@
|
|||||||
# Build backend binary file
|
# Build backend binary file
|
||||||
FROM golang:1.20.4-alpine3.17 AS be-builder
|
FROM golang:1.21.12-alpine3.20 AS be-builder
|
||||||
ARG RELEASE_BUILD
|
ARG RELEASE_BUILD
|
||||||
ENV RELEASE_BUILD=$RELEASE_BUILD
|
ENV RELEASE_BUILD=$RELEASE_BUILD
|
||||||
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
||||||
@@ -9,7 +9,7 @@ RUN apk add git gcc g++ libc-dev
|
|||||||
RUN ./build.sh backend
|
RUN ./build.sh backend
|
||||||
|
|
||||||
# Build frontend files
|
# Build frontend files
|
||||||
FROM node:18.16.0-alpine3.17 AS fe-builder
|
FROM --platform=$BUILDPLATFORM node:18.20.3-alpine3.20 AS fe-builder
|
||||||
ARG RELEASE_BUILD
|
ARG RELEASE_BUILD
|
||||||
ENV RELEASE_BUILD=$RELEASE_BUILD
|
ENV RELEASE_BUILD=$RELEASE_BUILD
|
||||||
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
||||||
@@ -19,7 +19,7 @@ RUN apk add git
|
|||||||
RUN ./build.sh frontend
|
RUN ./build.sh frontend
|
||||||
|
|
||||||
# Package docker image
|
# Package docker image
|
||||||
FROM alpine:3.17.3
|
FROM alpine:3.20.1
|
||||||
LABEL maintainer="MaysWind <i@mayswind.net>"
|
LABEL maintainer="MaysWind <i@mayswind.net>"
|
||||||
RUN addgroup -S -g 1000 ezbookkeeping && adduser -S -G ezbookkeeping -u 1000 ezbookkeeping
|
RUN addgroup -S -g 1000 ezbookkeeping && adduser -S -G ezbookkeeping -u 1000 ezbookkeeping
|
||||||
RUN apk --no-cache add tzdata
|
RUN apk --no-cache add tzdata
|
||||||
@@ -27,11 +27,13 @@ COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
|
|||||||
RUN chmod +x /docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
RUN mkdir -p /ezbookkeeping && chown 1000:1000 /ezbookkeeping \
|
RUN mkdir -p /ezbookkeeping && chown 1000:1000 /ezbookkeeping \
|
||||||
&& mkdir -p /ezbookkeeping/data && chown 1000:1000 /ezbookkeeping/data \
|
&& mkdir -p /ezbookkeeping/data && chown 1000:1000 /ezbookkeeping/data \
|
||||||
&& mkdir -p /ezbookkeeping/log && chown 1000:1000 /ezbookkeeping/log
|
&& mkdir -p /ezbookkeeping/log && chown 1000:1000 /ezbookkeeping/log \
|
||||||
|
&& mkdir -p /ezbookkeeping/storage && chown 1000:1000 /ezbookkeeping/storage
|
||||||
WORKDIR /ezbookkeeping
|
WORKDIR /ezbookkeeping
|
||||||
COPY --from=be-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/ezbookkeeping /ezbookkeeping/ezbookkeeping
|
COPY --from=be-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/ezbookkeeping /ezbookkeeping/ezbookkeeping
|
||||||
COPY --from=fe-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/dist /ezbookkeeping/public
|
COPY --from=fe-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/dist /ezbookkeeping/public
|
||||||
COPY --chown=1000:1000 conf /ezbookkeeping/conf
|
COPY --chown=1000:1000 conf /ezbookkeeping/conf
|
||||||
|
COPY --chown=1000:1000 templates /ezbookkeeping/templates
|
||||||
COPY --chown=1000:1000 LICENSE /ezbookkeeping/LICENSE
|
COPY --chown=1000:1000 LICENSE /ezbookkeeping/LICENSE
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2023 MaysWind (i@mayswind.net)
|
Copyright (c) 2020-2024 MaysWind (i@mayswind.net)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -8,17 +8,21 @@
|
|||||||
## Introduction
|
## Introduction
|
||||||
ezBookkeeping is a lightweight personal bookkeeping app hosted by yourself. It can be deployed on almost all platforms, including Windows, macOS and Linux on x86, amd64 and ARM architectures. You can even deploy it on an raspberry device. It also supports many different databases, including sqlite and mysql. With docker, you can just deploy it via one command without complicated configuration.
|
ezBookkeeping is a lightweight personal bookkeeping app hosted by yourself. It can be deployed on almost all platforms, including Windows, macOS and Linux on x86, amd64 and ARM architectures. You can even deploy it on an raspberry device. It also supports many different databases, including sqlite and mysql. With docker, you can just deploy it via one command without complicated configuration.
|
||||||
|
|
||||||
|
Online Demo: [https://ezbookkeeping-demo.mayswind.net](https://ezbookkeeping-demo.mayswind.net)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
1. Open source & Self-hosted
|
1. Open source & Self-hosted
|
||||||
2. Lightweight & Fast
|
2. Lightweight & Fast
|
||||||
3. Easy to install
|
3. Easy to install
|
||||||
* Docker support
|
* Docker support
|
||||||
* Multiple database support (sqlite, mysql, etc.)
|
* Multiple database support (SQLite, MySQL, PostgreSQL, etc.)
|
||||||
* Multiple os & architecture support (Windows, macOS, Linux & x86, amd64, ARM)
|
* Multiple operation system & hardware support (Windows, macOS, Linux & x86, amd64, ARM)
|
||||||
4. User-friendly interface
|
4. User-friendly interface
|
||||||
|
* Both desktop and mobile UI
|
||||||
* Close to native app experience (for mobile device)
|
* Close to native app experience (for mobile device)
|
||||||
* Two-level account & two-level category support
|
* Two-level account & two-level category support
|
||||||
* Plentiful preset categories
|
* Plentiful preset categories
|
||||||
|
* Geographic location and map support
|
||||||
* Searching & filtering history records
|
* Searching & filtering history records
|
||||||
* Data statistics
|
* Data statistics
|
||||||
* Dark theme
|
* Dark theme
|
||||||
@@ -26,12 +30,15 @@ ezBookkeeping is a lightweight personal bookkeeping app hosted by yourself. It c
|
|||||||
6. Multiple timezone support
|
6. Multiple timezone support
|
||||||
7. Multi-language support
|
7. Multi-language support
|
||||||
8. Two-factor authentication
|
8. Two-factor authentication
|
||||||
9. Application lock (WebAuthn support)
|
9. Application lock (PIN code / WebAuthn)
|
||||||
10. Data export
|
10. Data export
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
### Mobile Device
|
### Desktop Version
|
||||||
[](https://raw.githubusercontent.com/wiki/mayswind/ezbookkeeping/img/en.png)
|
[](https://raw.githubusercontent.com/wiki/mayswind/ezbookkeeping/img/desktop/en.png)
|
||||||
|
|
||||||
|
### Mobile Version
|
||||||
|
[](https://raw.githubusercontent.com/wiki/mayswind/ezbookkeeping/img/mobile/en.png)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
### Ship with docker
|
### Ship with docker
|
||||||
@@ -48,19 +55,35 @@ Latest Daily Build:
|
|||||||
### Install from binary
|
### Install from binary
|
||||||
Latest release: [https://github.com/mayswind/ezbookkeeping/releases](https://github.com/mayswind/ezbookkeeping/releases)
|
Latest release: [https://github.com/mayswind/ezbookkeeping/releases](https://github.com/mayswind/ezbookkeeping/releases)
|
||||||
|
|
||||||
|
**Linux / macOS**
|
||||||
|
|
||||||
$ ./ezbookkeeping server run
|
$ ./ezbookkeeping server run
|
||||||
|
|
||||||
ezBookkeeping will listen at port 8080 as default. Then you can visit http://{YOUR_HOST_ADDRESS}:8080/ .
|
**Windows**
|
||||||
|
|
||||||
|
> .\ezbookkeeping.exe server run
|
||||||
|
|
||||||
|
ezBookkeeping will listen at port 8080 as default. Then you can visit `http://{YOUR_HOST_ADDRESS}:8080/` .
|
||||||
|
|
||||||
### Build from source
|
### Build from source
|
||||||
Make sure you have [Golang](https://golang.org/), [GCC](http://gcc.gnu.org/), [Node.js](https://nodejs.org/) and [NPM](https://www.npmjs.com/) installed. Then download the source code, and follow these steps:
|
Make sure you have [Golang](https://golang.org/), [GCC](http://gcc.gnu.org/), [Node.js](https://nodejs.org/) and [NPM](https://www.npmjs.com/) installed. Then download the source code, and follow these steps:
|
||||||
|
|
||||||
|
**Linux / macOS**
|
||||||
|
|
||||||
$ ./build.sh package -o ezbookkeeping.tar.gz
|
$ ./build.sh package -o ezbookkeeping.tar.gz
|
||||||
|
|
||||||
All the files will be packaged in `ezbookkeeping.tar.gz`.
|
All the files will be packaged in `ezbookkeeping.tar.gz`.
|
||||||
|
|
||||||
|
**Windows**
|
||||||
|
|
||||||
|
> .\build.bat package -o ezbookkeeping.zip
|
||||||
|
|
||||||
|
All the files will be packaged in `ezbookkeeping.zip`.
|
||||||
|
|
||||||
You can also build docker image, make sure you have [docker](https://www.docker.com/) installed, then follow these steps:
|
You can also build docker image, make sure you have [docker](https://www.docker.com/) installed, then follow these steps:
|
||||||
|
|
||||||
|
**Linux**
|
||||||
|
|
||||||
$ ./build.sh docker
|
$ ./build.sh docker
|
||||||
|
|
||||||
## Documents
|
## Documents
|
||||||
|
|||||||
@@ -0,0 +1,264 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
set "TYPE="
|
||||||
|
set "NO_LINT=0"
|
||||||
|
set "NO_TEST=0"
|
||||||
|
set "RELEASE=%RELEASE_BUILD%"
|
||||||
|
set "RELEASE_TYPE=unknown"
|
||||||
|
set "VERSION="
|
||||||
|
set "COMMIT_HASH="
|
||||||
|
set "BUILD_UNIXTIME="
|
||||||
|
set "BUILD_DATE="
|
||||||
|
set "PACKAGE_FILENAME="
|
||||||
|
for /f %%a in ('"prompt $E$S & echo on & for %%b in (1) do rem"') do set "ESC=%%a"
|
||||||
|
|
||||||
|
if "%~1"=="" call :show_help & goto :end
|
||||||
|
goto :pre_parse_args
|
||||||
|
|
||||||
|
:echo_red
|
||||||
|
echo %ESC%[91m%~1%ESC%[0m
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:set_unixtime
|
||||||
|
setlocal enableextensions
|
||||||
|
for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x
|
||||||
|
set /a z=(14-100%Month%%%100)/12, y=10000%Year%%%10000-z
|
||||||
|
set /a ut=y*365+y/4-y/100+y/400+(153*(100%Month%%%100+12*z-3)+2)/5+Day-719469
|
||||||
|
set /a ut=ut*86400+100%Hour%%%100*3600+100%Minute%%%100*60+100%Second%%%100
|
||||||
|
endlocal & set "%1=%ut%" & goto :eof
|
||||||
|
|
||||||
|
:set_date
|
||||||
|
setlocal enableextensions
|
||||||
|
for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do set %%x
|
||||||
|
if %Month% lss 10 set "Month=0%Month%"
|
||||||
|
if %Day% lss 10 set "Day=0%Day%"
|
||||||
|
endlocal & set "%1=%Year%%Month%%Day%" & goto :eof
|
||||||
|
|
||||||
|
:check_dependency
|
||||||
|
if "%~1"=="" goto :eof
|
||||||
|
where /q %~1 || call :echo_red "Error: "%~1" is required." && goto :end
|
||||||
|
|
||||||
|
shift
|
||||||
|
goto :check_dependency
|
||||||
|
|
||||||
|
:show_help
|
||||||
|
echo ezBookkeeping build script for Windows
|
||||||
|
echo.
|
||||||
|
echo Usage:
|
||||||
|
echo build.cmd type [options]
|
||||||
|
echo.
|
||||||
|
echo Types:
|
||||||
|
echo backend Build backend binary file
|
||||||
|
echo frontend Build frontend files
|
||||||
|
echo package Build package archive
|
||||||
|
echo.
|
||||||
|
echo Options:
|
||||||
|
echo /r, --release Build release (The script will use environment variable "RELEASE_BUILD" to detect whether this is release building by default)
|
||||||
|
echo /o, --output ^<filename^> Package file name (For "package" type only)
|
||||||
|
echo --no-lint Do not execute lint check before building
|
||||||
|
echo --no-test Do not execute unit testing before building
|
||||||
|
echo /h, --help Show help
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:pre_parse_args
|
||||||
|
if "%~1"=="" goto :post_parse_args
|
||||||
|
|
||||||
|
if /i "%~1"=="backend" set "TYPE=%~1" & shift
|
||||||
|
if /i "%~1"=="frontend" set "TYPE=%~1" & shift
|
||||||
|
if /i "%~1"=="package" set "TYPE=%~1" & shift
|
||||||
|
|
||||||
|
:parse_args
|
||||||
|
if "%~1"=="" goto :post_parse_args
|
||||||
|
|
||||||
|
if /i "%~1"=="/r" set "RELEASE=1" & shift & goto :parse_args
|
||||||
|
if /i "%~1"=="-r" set "RELEASE=1" & shift & goto :parse_args
|
||||||
|
if /i "%~1"=="--release" set "RELEASE=1" & shift & goto :parse_args
|
||||||
|
|
||||||
|
if /i "%~1"=="/o" set "PACKAGE_FILENAME=%~2" & shift & shift & goto :parse_args
|
||||||
|
if /i "%~1"=="-o" set "PACKAGE_FILENAME=%~2" & shift & shift & goto :parse_args
|
||||||
|
if /i "%~1"=="--output" set "PACKAGE_FILENAME=%~2" & shift & shift & goto :parse_args
|
||||||
|
|
||||||
|
if /i "%~1"=="--no-lint" set "NO_LINT=1" & shift & goto :parse_args
|
||||||
|
if /i "%~1"=="--no-test" set "NO_TEST=1" & shift & goto :parse_args
|
||||||
|
|
||||||
|
if /i "%~1"=="/h" call :show_help & goto :end
|
||||||
|
if /i "%~1"=="-h" call :show_help & goto :end
|
||||||
|
if /i "%~1"=="--help" call :show_help & goto :end
|
||||||
|
|
||||||
|
call :echo_red "Invalid argument: %~1" & call :show_help & goto :end
|
||||||
|
|
||||||
|
:post_parse_args
|
||||||
|
if "%RELEASE%"=="" set "RELEASE=0"
|
||||||
|
|
||||||
|
if "%RELEASE%"=="0" (
|
||||||
|
set "RELEASE_TYPE=snapshot"
|
||||||
|
) else (
|
||||||
|
set "RELEASE_TYPE=release"
|
||||||
|
)
|
||||||
|
|
||||||
|
:check_type_dependencies
|
||||||
|
if not defined TYPE call :echo_red "Error: No specified type" & call :show_help & goto :end
|
||||||
|
|
||||||
|
call :check_dependency "git"
|
||||||
|
if "%TYPE%"=="backend" call :check_dependency "go" "gcc"
|
||||||
|
if "%TYPE%"=="frontend" call :check_dependency "node" "npm"
|
||||||
|
if "%TYPE%"=="package" call :check_dependency "go" "gcc" "node" "npm" "7z"
|
||||||
|
|
||||||
|
if not "%errorlevel%"=="0" goto :end
|
||||||
|
|
||||||
|
:set_build_parameters
|
||||||
|
for /f "tokens=2 delims=:" %%x in ('findstr "\"version\": \"*\"," package.json') do set "VERSION=%%x"
|
||||||
|
set VERSION=%VERSION: =%
|
||||||
|
set VERSION=%VERSION:,=%
|
||||||
|
set VERSION=%VERSION:"=%
|
||||||
|
for /f %%x in ('git rev-parse --short HEAD') do set "COMMIT_HASH=%%x"
|
||||||
|
call :set_unixtime BUILD_UNIXTIME
|
||||||
|
call :set_date BUILD_DATE
|
||||||
|
|
||||||
|
:main
|
||||||
|
if "%TYPE%"=="backend" call :build_backend & goto :end
|
||||||
|
if "%TYPE%"=="frontend" call :build_frontend & goto :end
|
||||||
|
if "%TYPE%"=="package" call :build_package & goto :end
|
||||||
|
goto :end
|
||||||
|
|
||||||
|
:build_backend
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
echo Pulling backend dependencies...
|
||||||
|
call go get .
|
||||||
|
|
||||||
|
if "%NO_LINT%"=="0" (
|
||||||
|
echo Executing backend lint checking...
|
||||||
|
call go vet -v .\...
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
call :echo_red "Error: Failed to pass lint checking"
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%NO_TEST%"=="0" (
|
||||||
|
echo Executing backend unit testing...
|
||||||
|
call go clean -cache
|
||||||
|
call go test .\... -v
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
call :echo_red "Error: Failed to pass unit testing"
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
set "CGO_ENABLED=1"
|
||||||
|
|
||||||
|
setlocal
|
||||||
|
set "backend_build_extra_arguments=-X main.Version=%VERSION%"
|
||||||
|
set "backend_build_extra_arguments=%backend_build_extra_arguments% -X main.CommitHash=%COMMIT_HASH%"
|
||||||
|
|
||||||
|
if "%RELEASE%"=="0" (
|
||||||
|
set "backend_build_extra_arguments=%backend_build_extra_arguments% -X main.BuildUnixTime=%BUILD_UNIXTIME%"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Building backend binary file (%RELEASE_TYPE%)...
|
||||||
|
|
||||||
|
call go build -a -v -trimpath -tags timetzdata -ldflags "-w -s -linkmode external -extldflags '-static' %backend_build_extra_arguments%" -o ezbookkeeping.exe ezbookkeeping.go
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
set "CGO_ENABLED="
|
||||||
|
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:build_frontend
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
echo Pulling frontend dependencies...
|
||||||
|
call npm install
|
||||||
|
|
||||||
|
if "%NO_LINT%"=="0" (
|
||||||
|
echo Executing frontend lint checking...
|
||||||
|
|
||||||
|
call npm run lint
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
call :echo_red "Error: Failed to pass lint checking"
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
echo Building frontend files(%RELEASE_TYPE%)...
|
||||||
|
|
||||||
|
if "%RELEASE%"=="0" (
|
||||||
|
set "buildUnixTime=%BUILD_UNIXTIME%"
|
||||||
|
call npm run build
|
||||||
|
set "buildUnixTime="
|
||||||
|
) else (
|
||||||
|
call npm run build
|
||||||
|
)
|
||||||
|
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:build_package
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
set "package_file_name=%VERSION%"
|
||||||
|
|
||||||
|
if "%RELEASE%"=="0" (
|
||||||
|
set "build_date="
|
||||||
|
set "package_file_name=%package_file_name%-%build_date%"
|
||||||
|
)
|
||||||
|
|
||||||
|
set "package_file_name=ezbookkeeping-%package_file_name%-windows.zip"
|
||||||
|
|
||||||
|
if defined PACKAGE_FILENAME set "package_file_name=%PACKAGE_FILENAME%"
|
||||||
|
|
||||||
|
echo Building package archive "%package_file_name%" (%RELEASE_TYPE%)...
|
||||||
|
|
||||||
|
call :build_backend
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
|
||||||
|
call :build_frontend
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
|
||||||
|
rmdir package /s /q
|
||||||
|
mkdir package
|
||||||
|
mkdir package\data
|
||||||
|
mkdir package\storage
|
||||||
|
mkdir package\log
|
||||||
|
xcopy ezbookkeeping.exe package\
|
||||||
|
xcopy dist package\public /e /i
|
||||||
|
xcopy conf package\conf /e /i
|
||||||
|
xcopy templates package\templates /e /i
|
||||||
|
xcopy LICENSE package\
|
||||||
|
|
||||||
|
cd package
|
||||||
|
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
call :echo_red "Error: Build Failed"
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
|
||||||
|
call 7z a -r -tzip -mx9 ..\%package_file_name% package *
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:end
|
||||||
|
set "TYPE="
|
||||||
|
set "NO_LINT="
|
||||||
|
set "NO_TEST="
|
||||||
|
set "RELEASE="
|
||||||
|
set "RELEASE_TYPE="
|
||||||
|
set "VERSION="
|
||||||
|
set "COMMIT_HASH="
|
||||||
|
set "BUILD_UNIXTIME="
|
||||||
|
set "BUILD_DATE="
|
||||||
|
set "PACKAGE_FILENAME="
|
||||||
|
exit /B
|
||||||
@@ -121,6 +121,9 @@ set_build_parameters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build_backend() {
|
build_backend() {
|
||||||
|
echo "Pulling backend dependencies..."
|
||||||
|
go get .
|
||||||
|
|
||||||
if [ "$NO_LINT" = "0" ]; then
|
if [ "$NO_LINT" = "0" ]; then
|
||||||
echo "Executing backend lint checking..."
|
echo "Executing backend lint checking..."
|
||||||
go vet -v ./...
|
go vet -v ./...
|
||||||
@@ -199,10 +202,12 @@ build_package() {
|
|||||||
rm -rf package
|
rm -rf package
|
||||||
mkdir package
|
mkdir package
|
||||||
mkdir package/data
|
mkdir package/data
|
||||||
|
mkdir package/storage
|
||||||
mkdir package/log
|
mkdir package/log
|
||||||
cp ezbookkeeping package/
|
cp ezbookkeeping package/
|
||||||
cp -R dist package/public
|
cp -R dist package/public
|
||||||
cp -R conf package/conf
|
cp -R conf package/conf
|
||||||
|
cp -R templates package/templates
|
||||||
cp LICENSE package/
|
cp LICENSE package/
|
||||||
|
|
||||||
cd package || { echo_red "Error: Build Failed"; exit 1; }
|
cd package || { echo_red "Error: Build Failed"; exit 1; }
|
||||||
|
|||||||
+10
-2
@@ -58,7 +58,7 @@ func updateAllDatabaseTablesStructure() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[database.updateAllDatabaseTablesStructure] two factor table maintained successfully")
|
log.BootInfof("[database.updateAllDatabaseTablesStructure] two-factor table maintained successfully")
|
||||||
|
|
||||||
err = datastore.Container.UserStore.SyncStructs(new(models.TwoFactorRecoveryCode))
|
err = datastore.Container.UserStore.SyncStructs(new(models.TwoFactorRecoveryCode))
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ func updateAllDatabaseTablesStructure() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[database.updateAllDatabaseTablesStructure] two factor recovery code table maintained successfully")
|
log.BootInfof("[database.updateAllDatabaseTablesStructure] two-factor recovery code table maintained successfully")
|
||||||
|
|
||||||
err = datastore.Container.TokenStore.SyncStructs(new(models.TokenRecord))
|
err = datastore.Container.TokenStore.SyncStructs(new(models.TokenRecord))
|
||||||
|
|
||||||
@@ -116,5 +116,13 @@ func updateAllDatabaseTablesStructure() error {
|
|||||||
|
|
||||||
log.BootInfof("[database.updateAllDatabaseTablesStructure] transaction tag index table maintained successfully")
|
log.BootInfof("[database.updateAllDatabaseTablesStructure] transaction tag index table maintained successfully")
|
||||||
|
|
||||||
|
err = datastore.Container.UserDataStore.SyncStructs(new(models.TransactionTemplate))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[database.updateAllDatabaseTablesStructure] transaction template table maintained successfully")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-11
@@ -7,9 +7,12 @@ import (
|
|||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/datastore"
|
"github.com/mayswind/ezbookkeeping/pkg/datastore"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/duplicatechecker"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/exchangerates"
|
"github.com/mayswind/ezbookkeeping/pkg/exchangerates"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/mail"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/storage"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/uuid"
|
"github.com/mayswind/ezbookkeeping/pkg/uuid"
|
||||||
)
|
)
|
||||||
@@ -17,64 +20,117 @@ import (
|
|||||||
func initializeSystem(c *cli.Context) (*settings.Config, error) {
|
func initializeSystem(c *cli.Context) (*settings.Config, error) {
|
||||||
var err error
|
var err error
|
||||||
configFilePath := c.String("conf-path")
|
configFilePath := c.String("conf-path")
|
||||||
|
isDisableBootLog := c.Bool("no-boot-log")
|
||||||
|
|
||||||
if configFilePath != "" {
|
if configFilePath != "" {
|
||||||
if _, err = os.Stat(configFilePath); err != nil {
|
if _, err = os.Stat(configFilePath); err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] cannot load configuration from custom config path %s, because file not exists", configFilePath)
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] cannot load configuration from custom config path %s, because file not exists", configFilePath)
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[initializer.initializeSystem] will loading configuration from custom config path %s", configFilePath)
|
if !isDisableBootLog {
|
||||||
|
log.BootInfof("[initializer.initializeSystem] will loading configuration from custom config path %s", configFilePath)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
configFilePath, err = settings.GetDefaultConfigFilePath()
|
configFilePath, err = settings.GetDefaultConfigFilePath()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] cannot get default configuration path, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] cannot get default configuration path, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[initializer.initializeSystem] will load configuration from default config path %s", configFilePath)
|
if !isDisableBootLog {
|
||||||
|
log.BootInfof("[initializer.initializeSystem] will load configuration from default config path %s", configFilePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := settings.LoadConfiguration(configFilePath)
|
config, err := settings.LoadConfiguration(configFilePath)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] cannot load configuration, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] cannot load configuration, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.SecretKeyNoSet {
|
||||||
|
log.BootWarnf("[initializer.initializeSystem] \"secret_key\" in config file is not set, please change it to keep your user data safe")
|
||||||
|
}
|
||||||
|
|
||||||
settings.SetCurrentConfig(config)
|
settings.SetCurrentConfig(config)
|
||||||
|
|
||||||
err = datastore.InitializeDataStore(config)
|
err = datastore.InitializeDataStore(config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] initializes data store failed, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes data store failed, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = log.SetLoggerConfiguration(config)
|
err = log.SetLoggerConfiguration(config, isDisableBootLog)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] sets logger configuration failed, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] sets logger configuration failed, because %s", err.Error())
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = storage.InitializeStorageContainer(config)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes object storage failed, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = uuid.InitializeUuidGenerator(config)
|
err = uuid.InitializeUuidGenerator(config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] initializes uuid generator failed, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes uuid generator failed, because %s", err.Error())
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = duplicatechecker.InitializeDuplicateChecker(config)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes duplicate checker failed, because %s", err.Error())
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = mail.InitializeMailer(config)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes mailer failed, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = exchangerates.InitializeExchangeRatesDataSource(config)
|
err = exchangerates.InitializeExchangeRatesDataSource(config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[initializer.initializeSystem] initializes exchange rates data source failed, because %s", err.Error())
|
if !isDisableBootLog {
|
||||||
|
log.BootErrorf("[initializer.initializeSystem] initializes exchange rates data source failed, because %s", err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgJson, _ := json.Marshal(getConfigWithoutSensitiveData(config))
|
cfgJson, _ := json.Marshal(getConfigWithoutSensitiveData(config))
|
||||||
log.BootInfof("[initializer.initializeSystem] has loaded configuration %s", cfgJson)
|
|
||||||
|
if !isDisableBootLog {
|
||||||
|
log.BootInfof("[initializer.initializeSystem] has loaded configuration %s", cfgJson)
|
||||||
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
@@ -88,7 +144,10 @@ func getConfigWithoutSensitiveData(config *settings.Config) *settings.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clonedConfig.DatabaseConfig.DatabasePassword = "****"
|
clonedConfig.DatabaseConfig.DatabasePassword = "****"
|
||||||
|
clonedConfig.SMTPConfig.SMTPPasswd = "****"
|
||||||
|
clonedConfig.MinIOConfig.SecretAccessKey = "****"
|
||||||
clonedConfig.SecretKey = "****"
|
clonedConfig.SecretKey = "****"
|
||||||
|
clonedConfig.AmapApplicationSecret = "****"
|
||||||
|
|
||||||
return clonedConfig
|
return clonedConfig
|
||||||
}
|
}
|
||||||
|
|||||||
+260
-6
@@ -2,13 +2,14 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
clis "github.com/mayswind/ezbookkeeping/pkg/cli"
|
clis "github.com/mayswind/ezbookkeeping/pkg/cli"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -86,6 +87,71 @@ var UserData = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "user-enable",
|
||||||
|
Usage: "Enable specified user",
|
||||||
|
Action: enableUser,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user-disable",
|
||||||
|
Usage: "Disable specified user",
|
||||||
|
Action: disableUser,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user-resend-verify-email",
|
||||||
|
Usage: "Resend user verify email",
|
||||||
|
Action: resendUserVerifyEmail,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user-set-email-verified",
|
||||||
|
Usage: "Set user email address verified",
|
||||||
|
Action: setUserEmailVerified,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user-set-email-unverified",
|
||||||
|
Usage: "Set user email address unverified",
|
||||||
|
Action: setUserEmailUnverified,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "user-delete",
|
Name: "user-delete",
|
||||||
Usage: "Delete specified user",
|
Usage: "Delete specified user",
|
||||||
@@ -138,6 +204,19 @@ var UserData = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "send-password-reset-mail",
|
||||||
|
Usage: "Send password reset mail",
|
||||||
|
Action: sendPasswordResetMail,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "transaction-check",
|
Name: "transaction-check",
|
||||||
Usage: "Check whether user all transactions and accounts are correct",
|
Usage: "Check whether user all transactions and accounts are correct",
|
||||||
@@ -151,9 +230,22 @@ var UserData = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "transaction-tag-index-fix-transaction-time",
|
||||||
|
Usage: "Fix the transaction tag index data which does not have transaction time",
|
||||||
|
Action: fixTransactionTagIndexNotHaveTransactionTime,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Specific user name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "transaction-export",
|
Name: "transaction-export",
|
||||||
Usage: "Export user all transactions to csv file",
|
Usage: "Export user all transactions to file",
|
||||||
Action: exportUserTransaction,
|
Action: exportUserTransaction,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
@@ -168,6 +260,12 @@ var UserData = &cli.Command{
|
|||||||
Required: true,
|
Required: true,
|
||||||
Usage: "Specific exported file path (e.g. transaction.csv)",
|
Usage: "Specific exported file path (e.g. transaction.csv)",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "type",
|
||||||
|
Aliases: []string{"t"},
|
||||||
|
Required: false,
|
||||||
|
Usage: "Export file type, support csv or tsv, default is csv",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -239,6 +337,126 @@ func modifyUserPassword(c *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendPasswordResetMail(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.SendPasswordResetMail(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.sendPasswordResetMail] error occurs when sending password reset email")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.sendPasswordResetMail] a password reset email for user \"%s\" has been sent", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func enableUser(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.EnableUser(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.enableUser] error occurs when setting user enabled")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.enableUser] user \"%s\" has been set enabled", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func disableUser(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.DisableUser(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.disableUser] error occurs when setting user disabled")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.disableUser] user \"%s\" has been set disabled", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resendUserVerifyEmail(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.ResendVerifyEmail(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.resendUserVerifyEmail] error occurs when resending user verify email")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.resendUserVerifyEmail] verify email for user \"%s\" has been resent", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setUserEmailVerified(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.SetUserEmailVerified(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.setUserEmailVerified] error occurs when setting user email address verified")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.setUserEmailVerified] user \"%s\" email address has been set verified", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setUserEmailUnverified(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
err = clis.UserData.SetUserEmailUnverified(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.setUserEmailUnverified] error occurs when setting user email address unverified")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.setUserEmailUnverified] user \"%s\" email address has been set unverified", username)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func deleteUser(c *cli.Context) error {
|
func deleteUser(c *cli.Context) error {
|
||||||
_, err := initializeSystem(c)
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
@@ -270,11 +488,11 @@ func disableUser2FA(c *cli.Context) error {
|
|||||||
err = clis.UserData.DisableUserTwoFactorAuthorization(c, username)
|
err = clis.UserData.DisableUserTwoFactorAuthorization(c, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.disableUser2FA] error occurs when disabling user two factor authorization")
|
log.BootErrorf("[user_data.disableUser2FA] error occurs when disabling user two-factor authorization")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[user_data.disableUser2FA] two factor authorization of user \"%s\" has been disabled", username)
|
log.BootInfof("[user_data.disableUser2FA] two-factor authorization of user \"%s\" has been disabled", username)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -348,6 +566,29 @@ func checkUserTransactionAndAccount(c *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fixTransactionTagIndexNotHaveTransactionTime(c *cli.Context) error {
|
||||||
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
username := c.String("username")
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.fixTransactionTagIndexNotHaveTransactionTime] starting fixing user \"%s\" transaction tag index data", username)
|
||||||
|
|
||||||
|
_, err = clis.UserData.FixTransactionTagIndexWithTransactionTime(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.fixTransactionTagIndexNotHaveTransactionTime] error occurs when fixing user data")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.BootInfof("[user_data.fixTransactionTagIndexNotHaveTransactionTime] user transaction tag index data has been fixed successfully")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func exportUserTransaction(c *cli.Context) error {
|
func exportUserTransaction(c *cli.Context) error {
|
||||||
_, err := initializeSystem(c)
|
_, err := initializeSystem(c)
|
||||||
|
|
||||||
@@ -357,9 +598,15 @@ func exportUserTransaction(c *cli.Context) error {
|
|||||||
|
|
||||||
username := c.String("username")
|
username := c.String("username")
|
||||||
filePath := c.String("file")
|
filePath := c.String("file")
|
||||||
|
fileType := c.String("type")
|
||||||
|
|
||||||
|
if fileType != "" && fileType != "csv" && fileType != "tsv" {
|
||||||
|
log.BootErrorf("[user_data.exportUserTransaction] export file type is not supported")
|
||||||
|
return errs.ErrNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
if filePath == "" {
|
if filePath == "" {
|
||||||
log.BootErrorf("[user_data.exportUserTransaction] export file path is not specified")
|
log.BootErrorf("[user_data.exportUserTransaction] export file path is unspecified")
|
||||||
return os.ErrNotExist
|
return os.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +619,7 @@ func exportUserTransaction(c *cli.Context) error {
|
|||||||
|
|
||||||
log.BootInfof("[user_data.exportUserTransaction] starting exporting user \"%s\" data", username)
|
log.BootInfof("[user_data.exportUserTransaction] starting exporting user \"%s\" data", username)
|
||||||
|
|
||||||
content, err := clis.UserData.ExportTransaction(c, username)
|
content, err := clis.UserData.ExportTransaction(c, username, fileType)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.exportUserTransaction] error occurs when exporting user data")
|
log.BootErrorf("[user_data.exportUserTransaction] error occurs when exporting user data")
|
||||||
@@ -407,6 +654,12 @@ func printUserInfo(user *models.User) {
|
|||||||
fmt.Printf("[ShortDateFormat] %s (%d)\n", user.ShortDateFormat, user.ShortDateFormat)
|
fmt.Printf("[ShortDateFormat] %s (%d)\n", user.ShortDateFormat, user.ShortDateFormat)
|
||||||
fmt.Printf("[LongTimeFormat] %s (%d)\n", user.LongTimeFormat, user.LongTimeFormat)
|
fmt.Printf("[LongTimeFormat] %s (%d)\n", user.LongTimeFormat, user.LongTimeFormat)
|
||||||
fmt.Printf("[ShortTimeFormat] %s (%d)\n", user.ShortTimeFormat, user.ShortTimeFormat)
|
fmt.Printf("[ShortTimeFormat] %s (%d)\n", user.ShortTimeFormat, user.ShortTimeFormat)
|
||||||
|
fmt.Printf("[DecimalSeparator] %s (%d)\n", user.DecimalSeparator, user.DecimalSeparator)
|
||||||
|
fmt.Printf("[DigitGroupingSymbol] %s (%d)\n", user.DigitGroupingSymbol, user.DigitGroupingSymbol)
|
||||||
|
fmt.Printf("[DigitGrouping] %s (%d)\n", user.DigitGrouping, user.DigitGrouping)
|
||||||
|
fmt.Printf("[CurrencyDisplayType] %s (%d)\n", user.CurrencyDisplayType, user.CurrencyDisplayType)
|
||||||
|
fmt.Printf("[ExpenseAmountColor] %s (%d)\n", user.ExpenseAmountColor, user.ExpenseAmountColor)
|
||||||
|
fmt.Printf("[IncomeAmountColor] %s (%d)\n", user.IncomeAmountColor, user.IncomeAmountColor)
|
||||||
fmt.Printf("[Deleted] %t\n", user.Deleted)
|
fmt.Printf("[Deleted] %t\n", user.Deleted)
|
||||||
fmt.Printf("[EmailVerified] %t\n", user.EmailVerified)
|
fmt.Printf("[EmailVerified] %t\n", user.EmailVerified)
|
||||||
fmt.Printf("[CreatedAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(user.CreatedUnixTime), user.CreatedUnixTime)
|
fmt.Printf("[CreatedAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(user.CreatedUnixTime), user.CreatedUnixTime)
|
||||||
@@ -427,5 +680,6 @@ func printUserInfo(user *models.User) {
|
|||||||
func printTokenInfo(token *models.TokenRecord) {
|
func printTokenInfo(token *models.TokenRecord) {
|
||||||
fmt.Printf("[CreatedAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(token.CreatedUnixTime), token.CreatedUnixTime)
|
fmt.Printf("[CreatedAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(token.CreatedUnixTime), token.CreatedUnixTime)
|
||||||
fmt.Printf("[ExpiredAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(token.ExpiredUnixTime), token.ExpiredUnixTime)
|
fmt.Printf("[ExpiredAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(token.ExpiredUnixTime), token.ExpiredUnixTime)
|
||||||
|
fmt.Printf("[LastSeen] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(token.LastSeenUnixTime), token.LastSeenUnixTime)
|
||||||
fmt.Printf("[UserAgent] %s\n", token.UserAgent)
|
fmt.Printf("[UserAgent] %s\n", token.UserAgent)
|
||||||
}
|
}
|
||||||
|
|||||||
+129
@@ -0,0 +1,129 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/mail"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/requestid"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Utilities represents the utilities command
|
||||||
|
var Utilities = &cli.Command{
|
||||||
|
Name: "utility",
|
||||||
|
Usage: "ezBookkeeping utilities",
|
||||||
|
Subcommands: []*cli.Command{
|
||||||
|
{
|
||||||
|
Name: "parse-default-request-id",
|
||||||
|
Usage: "Parse a request id which is generated by default request generator and show the details",
|
||||||
|
Action: parseRequestId,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "id",
|
||||||
|
Required: true,
|
||||||
|
Usage: "Request ID",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "send-test-mail",
|
||||||
|
Usage: "Send an email to specified e-mail address",
|
||||||
|
Action: sendTestMail,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "to",
|
||||||
|
Required: true,
|
||||||
|
Usage: "To e-mail address",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseRequestId(c *cli.Context) error {
|
||||||
|
config, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = requestid.InitializeRequestIdGenerator(config)
|
||||||
|
defaultGenerator, err := requestid.NewDefaultRequestIdGenerator(config)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
requestId := c.String("id")
|
||||||
|
requestIdInfo, err := defaultGenerator.ParseRequestIdInfo(requestId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
newRequestId := defaultGenerator.GenerateRequestId(net.IPv4zero.String(), 0)
|
||||||
|
newRequestIdInfo, err := defaultGenerator.ParseRequestIdInfo(newRequestId)
|
||||||
|
printRequestIdInfo(requestId, requestIdInfo, newRequestIdInfo)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendTestMail(c *cli.Context) error {
|
||||||
|
config, err := initializeSystem(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !config.EnableSMTP || mail.Container.Current == nil {
|
||||||
|
return errs.ErrSMTPServerNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
toAddress := c.String("to")
|
||||||
|
|
||||||
|
err = mail.Container.Current.SendMail(&mail.MailMessage{
|
||||||
|
To: toAddress,
|
||||||
|
Subject: "ezBookkeeping test e-mail",
|
||||||
|
Body: "This is a test e-mail",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Test e-mail has been sent")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func printRequestIdInfo(requestId string, requestIdInfo *requestid.RequestIdInfo, newRequestIdInfo *requestid.RequestIdInfo) {
|
||||||
|
fmt.Printf("[RequestId] %s\n", requestId)
|
||||||
|
fmt.Printf("[ServerUniqId] %d (Current Server %d)\n", requestIdInfo.ServerUniqId, newRequestIdInfo.ServerUniqId)
|
||||||
|
fmt.Printf("[InstanceUniqId] %d (Current Server %d)\n", requestIdInfo.InstanceUniqId, newRequestIdInfo.InstanceUniqId)
|
||||||
|
|
||||||
|
displayTime, err := utils.ParseFromElapsedSeconds(int(requestIdInfo.SecondsElapsedToday))
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
fmt.Printf("[SecondsElapsedToday] %d (%s)\n", requestIdInfo.SecondsElapsedToday, displayTime)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("[SecondsElapsedToday] %d\n", requestIdInfo.SecondsElapsedToday)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("[RequestSeqId] %d\n", requestIdInfo.RequestSeqId)
|
||||||
|
fmt.Printf("[IsClientIpv6] %t\n", requestIdInfo.IsClientIpv6)
|
||||||
|
|
||||||
|
if requestIdInfo.IsClientIpv6 {
|
||||||
|
fmt.Printf("[ClientIpv6Hash] %d\n", requestIdInfo.ClientIp)
|
||||||
|
} else {
|
||||||
|
ip := make(net.IP, 4)
|
||||||
|
binary.BigEndian.PutUint32(ip, requestIdInfo.ClientIp)
|
||||||
|
fmt.Printf("[ClientIpv4] %s\n", ip.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("[ClientPort] %d\n", requestIdInfo.ClientPort)
|
||||||
|
}
|
||||||
+163
-22
@@ -3,7 +3,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/cache"
|
||||||
|
"github.com/gin-contrib/cache/persistence"
|
||||||
"github.com/gin-contrib/gzip"
|
"github.com/gin-contrib/gzip"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
@@ -41,13 +44,13 @@ func startWebServer(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[server.startWebServer] static root path is %s", config.StaticRootPath)
|
log.BootInfof("[webserver.startWebServer] static root path is %s", config.StaticRootPath)
|
||||||
|
|
||||||
if config.AutoUpdateDatabase {
|
if config.AutoUpdateDatabase {
|
||||||
err = updateAllDatabaseTablesStructure()
|
err = updateAllDatabaseTablesStructure()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[server.startWebServer] update database table structure failed, because %s", err.Error())
|
log.BootErrorf("[webserver.startWebServer] update database table structure failed, because %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +58,7 @@ func startWebServer(c *cli.Context) error {
|
|||||||
err = requestid.InitializeRequestIdGenerator(config)
|
err = requestid.InitializeRequestIdGenerator(config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[server.startWebServer] initializes requestid generator failed, because %s", err.Error())
|
log.BootErrorf("[webserver.startWebServer] initializes requestid generator failed, because %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,12 +68,14 @@ func startWebServer(c *cli.Context) error {
|
|||||||
uuidServerInfo = fmt.Sprintf(", current uuid server id is %d", config.UuidServerId)
|
uuidServerInfo = fmt.Sprintf(", current uuid server id is %d", config.UuidServerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.BootInfof("[server.startWebServer] %s%s", serverInfo, uuidServerInfo)
|
log.BootInfof("[webserver.startWebServer] %s%s", serverInfo, uuidServerInfo)
|
||||||
|
|
||||||
if config.Mode == settings.MODE_PRODUCTION {
|
if config.Mode == settings.MODE_PRODUCTION {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workboxFileNames := utils.ListFileNamesWithPrefixAndSuffix(config.StaticRootPath, "workbox-", ".js")
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
router.Use(bindMiddleware(middlewares.Recovery))
|
router.Use(bindMiddleware(middlewares.Recovery))
|
||||||
|
|
||||||
@@ -84,6 +89,7 @@ func startWebServer(c *cli.Context) error {
|
|||||||
_ = v.RegisterValidation("validEmail", validators.ValidEmail)
|
_ = v.RegisterValidation("validEmail", validators.ValidEmail)
|
||||||
_ = v.RegisterValidation("validCurrency", validators.ValidCurrency)
|
_ = v.RegisterValidation("validCurrency", validators.ValidCurrency)
|
||||||
_ = v.RegisterValidation("validHexRGBColor", validators.ValidHexRGBColor)
|
_ = v.RegisterValidation("validHexRGBColor", validators.ValidHexRGBColor)
|
||||||
|
_ = v.RegisterValidation("validAmountFilter", validators.ValidAmountFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
router.NoRoute(bindApi(api.Default.ApiNotFound))
|
router.NoRoute(bindApi(api.Default.ApiNotFound))
|
||||||
@@ -116,7 +122,6 @@ func startWebServer(c *cli.Context) error {
|
|||||||
router.StaticFile("/mobile/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json"))
|
router.StaticFile("/mobile/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json"))
|
||||||
router.StaticFile("/mobile/sw.js", filepath.Join(config.StaticRootPath, "sw.js"))
|
router.StaticFile("/mobile/sw.js", filepath.Join(config.StaticRootPath, "sw.js"))
|
||||||
|
|
||||||
workboxFileNames := utils.ListFileNamesWithPrefixAndSuffix(config.StaticRootPath, "workbox-", ".js")
|
|
||||||
for i := 0; i < len(workboxFileNames); i++ {
|
for i := 0; i < len(workboxFileNames); i++ {
|
||||||
router.StaticFile("/mobile/"+workboxFileNames[i], filepath.Join(config.StaticRootPath, workboxFileNames[i]))
|
router.StaticFile("/mobile/"+workboxFileNames[i], filepath.Join(config.StaticRootPath, workboxFileNames[i]))
|
||||||
}
|
}
|
||||||
@@ -134,6 +139,19 @@ func startWebServer(c *cli.Context) error {
|
|||||||
router.StaticFile("/desktop/favicon.png", filepath.Join(config.StaticRootPath, "favicon.png"))
|
router.StaticFile("/desktop/favicon.png", filepath.Join(config.StaticRootPath, "favicon.png"))
|
||||||
router.StaticFile("/desktop/touchicon.png", filepath.Join(config.StaticRootPath, "touchicon.png"))
|
router.StaticFile("/desktop/touchicon.png", filepath.Join(config.StaticRootPath, "touchicon.png"))
|
||||||
router.StaticFile("/desktop/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json"))
|
router.StaticFile("/desktop/manifest.json", filepath.Join(config.StaticRootPath, "manifest.json"))
|
||||||
|
router.StaticFile("/desktop/sw.js", filepath.Join(config.StaticRootPath, "sw.js"))
|
||||||
|
|
||||||
|
for i := 0; i < len(workboxFileNames); i++ {
|
||||||
|
router.StaticFile("/desktop/"+workboxFileNames[i], filepath.Join(config.StaticRootPath, workboxFileNames[i]))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.AvatarProvider == settings.InternalAvatarProvider {
|
||||||
|
avatarRoute := router.Group("/avatar")
|
||||||
|
avatarRoute.Use(bindMiddleware(middlewares.JWTAuthorizationByQueryString))
|
||||||
|
{
|
||||||
|
avatarRoute.GET("/:fileName", bindImage(api.Users.UserGetAvatarHandler))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
router.GET("/healthz.json", bindApi(api.Healths.HealthStatusHandler))
|
router.GET("/healthz.json", bindApi(api.Healths.HealthStatusHandler))
|
||||||
|
|
||||||
@@ -146,33 +164,81 @@ func startWebServer(c *cli.Context) error {
|
|||||||
proxyRoute.Use(bindMiddleware(middlewares.JWTAuthorizationByQueryString))
|
proxyRoute.Use(bindMiddleware(middlewares.JWTAuthorizationByQueryString))
|
||||||
{
|
{
|
||||||
if config.EnableMapDataFetchProxy {
|
if config.EnableMapDataFetchProxy {
|
||||||
if config.MapProvider == settings.OpenStreetMapProvider {
|
if config.MapProvider == settings.OpenStreetMapProvider ||
|
||||||
proxyRoute.GET("/openstreetmap/tile/:zoomLevel/:coordinateX/:fileName", bindProxy(api.MapImages.OpenStreetMapTileImageProxyHandler))
|
config.MapProvider == settings.OpenStreetMapHumanitarianStyleProvider ||
|
||||||
|
config.MapProvider == settings.OpenTopoMapProvider ||
|
||||||
|
config.MapProvider == settings.OPNVKarteMapProvider ||
|
||||||
|
config.MapProvider == settings.CyclOSMMapProvider ||
|
||||||
|
config.MapProvider == settings.CartoDBMapProvider ||
|
||||||
|
config.MapProvider == settings.TomTomMapProvider ||
|
||||||
|
config.MapProvider == settings.TianDiTuProvider ||
|
||||||
|
config.MapProvider == settings.CustomProvider {
|
||||||
|
proxyRoute.GET("/map/tile/:zoomLevel/:coordinateX/:fileName", bindProxy(api.MapImages.MapTileImageProxyHandler))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.TianDiTuProvider ||
|
||||||
|
(config.MapProvider == settings.CustomProvider && config.CustomMapTileServerAnnotationLayerUrl != "") {
|
||||||
|
proxyRoute.GET("/map/annotation/:zoomLevel/:coordinateX/:fileName", bindProxy(api.MapImages.MapAnnotationImageProxyHandler))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.AmapProvider && config.AmapSecurityVerificationMethod == settings.AmapSecurityVerificationInternalProxyMethod {
|
||||||
|
amapApiProxyRoute := router.Group("/_AMapService")
|
||||||
|
amapApiProxyRoute.Use(bindMiddleware(middlewares.JWTAuthorizationByCookie))
|
||||||
|
{
|
||||||
|
amapApiProxyRoute.GET("/*action", bindProxy(api.AmapApis.AmapApiProxyHandler))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qrCodeRoute := router.Group("/qrcode")
|
||||||
|
qrCodeRoute.Use(bindMiddleware(middlewares.RequestId(config)))
|
||||||
|
{
|
||||||
|
qrCodeCacheStore := persistence.NewInMemoryStore(time.Minute)
|
||||||
|
qrCodeRoute.GET("/mobile_url.png", bindCachedImage(api.QrCodes.MobileUrlQrCodeHandler, qrCodeCacheStore))
|
||||||
|
}
|
||||||
|
|
||||||
apiRoute := router.Group("/api")
|
apiRoute := router.Group("/api")
|
||||||
|
|
||||||
apiRoute.Use(bindMiddleware(middlewares.RequestId(config)))
|
apiRoute.Use(bindMiddleware(middlewares.RequestId(config)))
|
||||||
apiRoute.Use(bindMiddleware(middlewares.RequestLog))
|
apiRoute.Use(bindMiddleware(middlewares.RequestLog))
|
||||||
{
|
{
|
||||||
apiRoute.POST("/authorize.json", bindApi(api.Authorizations.AuthorizeHandler))
|
apiRoute.POST("/authorize.json", bindApiWithTokenUpdate(api.Authorizations.AuthorizeHandler, config))
|
||||||
|
|
||||||
if config.EnableTwoFactor {
|
if config.EnableTwoFactor {
|
||||||
twoFactorRoute := apiRoute.Group("/2fa")
|
twoFactorRoute := apiRoute.Group("/2fa")
|
||||||
twoFactorRoute.Use(bindMiddleware(middlewares.JWTTwoFactorAuthorization))
|
twoFactorRoute.Use(bindMiddleware(middlewares.JWTTwoFactorAuthorization))
|
||||||
{
|
{
|
||||||
twoFactorRoute.POST("/authorize.json", bindApi(api.Authorizations.TwoFactorAuthorizeHandler))
|
twoFactorRoute.POST("/authorize.json", bindApiWithTokenUpdate(api.Authorizations.TwoFactorAuthorizeHandler, config))
|
||||||
twoFactorRoute.POST("/recovery.json", bindApi(api.Authorizations.TwoFactorAuthorizeByRecoveryCodeHandler))
|
twoFactorRoute.POST("/recovery.json", bindApiWithTokenUpdate(api.Authorizations.TwoFactorAuthorizeByRecoveryCodeHandler, config))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.EnableUserRegister {
|
if config.EnableUserRegister {
|
||||||
apiRoute.POST("/register.json", bindApi(api.Users.UserRegisterHandler))
|
apiRoute.POST("/register.json", bindApiWithTokenUpdate(api.Users.UserRegisterHandler, config))
|
||||||
}
|
}
|
||||||
|
|
||||||
apiRoute.GET("/logout.json", bindApi(api.Tokens.TokenRevokeCurrentHandler))
|
if config.EnableUserVerifyEmail {
|
||||||
|
apiRoute.POST("/verify_email/resend.json", bindApi(api.Users.UserSendVerifyEmailByUnloginUserHandler))
|
||||||
|
|
||||||
|
emailVerifyRoute := apiRoute.Group("/verify_email")
|
||||||
|
emailVerifyRoute.Use(bindMiddleware(middlewares.JWTEmailVerifyAuthorization))
|
||||||
|
{
|
||||||
|
emailVerifyRoute.POST("/by_token.json", bindApi(api.Users.UserEmailVerifyHandler))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.EnableUserForgetPassword {
|
||||||
|
apiRoute.POST("/forget_password/request.json", bindApi(api.ForgetPasswords.UserForgetPasswordRequestHandler))
|
||||||
|
|
||||||
|
resetPasswordRoute := apiRoute.Group("/forget_password/reset")
|
||||||
|
resetPasswordRoute.Use(bindMiddleware(middlewares.JWTResetPasswordAuthorization))
|
||||||
|
{
|
||||||
|
resetPasswordRoute.POST("/by_token.json", bindApi(api.ForgetPasswords.UserResetPasswordHandler))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apiRoute.GET("/logout.json", bindApiWithTokenUpdate(api.Tokens.TokenRevokeCurrentHandler, config))
|
||||||
|
|
||||||
apiV1Route := apiRoute.Group("/v1")
|
apiV1Route := apiRoute.Group("/v1")
|
||||||
apiV1Route.Use(bindMiddleware(middlewares.JWTAuthorization))
|
apiV1Route.Use(bindMiddleware(middlewares.JWTAuthorization))
|
||||||
@@ -181,17 +247,26 @@ func startWebServer(c *cli.Context) error {
|
|||||||
apiV1Route.GET("/tokens/list.json", bindApi(api.Tokens.TokenListHandler))
|
apiV1Route.GET("/tokens/list.json", bindApi(api.Tokens.TokenListHandler))
|
||||||
apiV1Route.POST("/tokens/revoke.json", bindApi(api.Tokens.TokenRevokeHandler))
|
apiV1Route.POST("/tokens/revoke.json", bindApi(api.Tokens.TokenRevokeHandler))
|
||||||
apiV1Route.POST("/tokens/revoke_all.json", bindApi(api.Tokens.TokenRevokeAllHandler))
|
apiV1Route.POST("/tokens/revoke_all.json", bindApi(api.Tokens.TokenRevokeAllHandler))
|
||||||
apiV1Route.POST("/tokens/refresh.json", bindApi(api.Tokens.TokenRefreshHandler))
|
apiV1Route.POST("/tokens/refresh.json", bindApiWithTokenUpdate(api.Tokens.TokenRefreshHandler, config))
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
apiV1Route.GET("/users/profile/get.json", bindApi(api.Users.UserProfileHandler))
|
apiV1Route.GET("/users/profile/get.json", bindApi(api.Users.UserProfileHandler))
|
||||||
apiV1Route.POST("/users/profile/update.json", bindApi(api.Users.UserUpdateProfileHandler))
|
apiV1Route.POST("/users/profile/update.json", bindApiWithTokenUpdate(api.Users.UserUpdateProfileHandler, config))
|
||||||
|
|
||||||
// Two Factor Authorization
|
if config.AvatarProvider == settings.InternalAvatarProvider {
|
||||||
|
apiV1Route.POST("/users/avatar/update.json", bindApi(api.Users.UserUpdateAvatarHandler))
|
||||||
|
apiV1Route.POST("/users/avatar/remove.json", bindApi(api.Users.UserRemoveAvatarHandler))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.EnableUserVerifyEmail {
|
||||||
|
apiV1Route.POST("/users/verify_email/resend.json", bindApi(api.Users.UserSendVerifyEmailByLoginedUserHandler))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two-Factor Authorization
|
||||||
if config.EnableTwoFactor {
|
if config.EnableTwoFactor {
|
||||||
apiV1Route.GET("/users/2fa/status.json", bindApi(api.TwoFactorAuthorizations.TwoFactorStatusHandler))
|
apiV1Route.GET("/users/2fa/status.json", bindApi(api.TwoFactorAuthorizations.TwoFactorStatusHandler))
|
||||||
apiV1Route.POST("/users/2fa/enable/request.json", bindApi(api.TwoFactorAuthorizations.TwoFactorEnableRequestHandler))
|
apiV1Route.POST("/users/2fa/enable/request.json", bindApi(api.TwoFactorAuthorizations.TwoFactorEnableRequestHandler))
|
||||||
apiV1Route.POST("/users/2fa/enable/confirm.json", bindApi(api.TwoFactorAuthorizations.TwoFactorEnableConfirmHandler))
|
apiV1Route.POST("/users/2fa/enable/confirm.json", bindApiWithTokenUpdate(api.TwoFactorAuthorizations.TwoFactorEnableConfirmHandler, config))
|
||||||
apiV1Route.POST("/users/2fa/disable.json", bindApi(api.TwoFactorAuthorizations.TwoFactorDisableHandler))
|
apiV1Route.POST("/users/2fa/disable.json", bindApi(api.TwoFactorAuthorizations.TwoFactorDisableHandler))
|
||||||
apiV1Route.POST("/users/2fa/recovery/regenerate.json", bindApi(api.TwoFactorAuthorizations.TwoFactorRecoveryCodeRegenerateHandler))
|
apiV1Route.POST("/users/2fa/recovery/regenerate.json", bindApi(api.TwoFactorAuthorizations.TwoFactorRecoveryCodeRegenerateHandler))
|
||||||
}
|
}
|
||||||
@@ -201,7 +276,8 @@ func startWebServer(c *cli.Context) error {
|
|||||||
apiV1Route.POST("/data/clear.json", bindApi(api.DataManagements.ClearDataHandler))
|
apiV1Route.POST("/data/clear.json", bindApi(api.DataManagements.ClearDataHandler))
|
||||||
|
|
||||||
if config.EnableDataExport {
|
if config.EnableDataExport {
|
||||||
apiV1Route.GET("/data/export.csv", bindCsv(api.DataManagements.ExportDataHandler))
|
apiV1Route.GET("/data/export.csv", bindCsv(api.DataManagements.ExportDataToEzbookkeepingCSVHandler))
|
||||||
|
apiV1Route.GET("/data/export.tsv", bindTsv(api.DataManagements.ExportDataToEzbookkeepingTSVHandler))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
@@ -218,8 +294,8 @@ func startWebServer(c *cli.Context) error {
|
|||||||
apiV1Route.GET("/transactions/list.json", bindApi(api.Transactions.TransactionListHandler))
|
apiV1Route.GET("/transactions/list.json", bindApi(api.Transactions.TransactionListHandler))
|
||||||
apiV1Route.GET("/transactions/list/by_month.json", bindApi(api.Transactions.TransactionMonthListHandler))
|
apiV1Route.GET("/transactions/list/by_month.json", bindApi(api.Transactions.TransactionMonthListHandler))
|
||||||
apiV1Route.GET("/transactions/statistics.json", bindApi(api.Transactions.TransactionStatisticsHandler))
|
apiV1Route.GET("/transactions/statistics.json", bindApi(api.Transactions.TransactionStatisticsHandler))
|
||||||
|
apiV1Route.GET("/transactions/statistics/trends.json", bindApi(api.Transactions.TransactionStatisticsTrendsHandler))
|
||||||
apiV1Route.GET("/transactions/amounts.json", bindApi(api.Transactions.TransactionAmountsHandler))
|
apiV1Route.GET("/transactions/amounts.json", bindApi(api.Transactions.TransactionAmountsHandler))
|
||||||
apiV1Route.GET("/transactions/amounts/by_month.json", bindApi(api.Transactions.TransactionMonthAmountsHandler))
|
|
||||||
apiV1Route.GET("/transactions/get.json", bindApi(api.Transactions.TransactionGetHandler))
|
apiV1Route.GET("/transactions/get.json", bindApi(api.Transactions.TransactionGetHandler))
|
||||||
apiV1Route.POST("/transactions/add.json", bindApi(api.Transactions.TransactionCreateHandler))
|
apiV1Route.POST("/transactions/add.json", bindApi(api.Transactions.TransactionCreateHandler))
|
||||||
apiV1Route.POST("/transactions/modify.json", bindApi(api.Transactions.TransactionModifyHandler))
|
apiV1Route.POST("/transactions/modify.json", bindApi(api.Transactions.TransactionModifyHandler))
|
||||||
@@ -244,6 +320,15 @@ func startWebServer(c *cli.Context) error {
|
|||||||
apiV1Route.POST("/transaction/tags/move.json", bindApi(api.TransactionTags.TagMoveHandler))
|
apiV1Route.POST("/transaction/tags/move.json", bindApi(api.TransactionTags.TagMoveHandler))
|
||||||
apiV1Route.POST("/transaction/tags/delete.json", bindApi(api.TransactionTags.TagDeleteHandler))
|
apiV1Route.POST("/transaction/tags/delete.json", bindApi(api.TransactionTags.TagDeleteHandler))
|
||||||
|
|
||||||
|
// Transaction Templates
|
||||||
|
apiV1Route.GET("/transaction/templates/list.json", bindApi(api.TransactionTemplates.TemplateListHandler))
|
||||||
|
apiV1Route.GET("/transaction/templates/get.json", bindApi(api.TransactionTemplates.TemplateGetHandler))
|
||||||
|
apiV1Route.POST("/transaction/templates/add.json", bindApi(api.TransactionTemplates.TemplateCreateHandler))
|
||||||
|
apiV1Route.POST("/transaction/templates/modify.json", bindApi(api.TransactionTemplates.TemplateModifyHandler))
|
||||||
|
apiV1Route.POST("/transaction/templates/hide.json", bindApi(api.TransactionTemplates.TemplateHideHandler))
|
||||||
|
apiV1Route.POST("/transaction/templates/move.json", bindApi(api.TransactionTemplates.TemplateMoveHandler))
|
||||||
|
apiV1Route.POST("/transaction/templates/delete.json", bindApi(api.TransactionTemplates.TemplateDeleteHandler))
|
||||||
|
|
||||||
// Exchange Rates
|
// Exchange Rates
|
||||||
apiV1Route.GET("/exchange_rates/latest.json", bindApi(api.ExchangeRates.LatestExchangeRateHandler))
|
apiV1Route.GET("/exchange_rates/latest.json", bindApi(api.ExchangeRates.LatestExchangeRateHandler))
|
||||||
}
|
}
|
||||||
@@ -252,20 +337,20 @@ func startWebServer(c *cli.Context) error {
|
|||||||
listenAddr := fmt.Sprintf("%s:%d", config.HttpAddr, config.HttpPort)
|
listenAddr := fmt.Sprintf("%s:%d", config.HttpAddr, config.HttpPort)
|
||||||
|
|
||||||
if config.Protocol == settings.SCHEME_SOCKET {
|
if config.Protocol == settings.SCHEME_SOCKET {
|
||||||
log.BootInfof("[server.startWebServer] will run at socks:%s", config.UnixSocketPath)
|
log.BootInfof("[webserver.startWebServer] will run at socks:%s", config.UnixSocketPath)
|
||||||
err = router.RunUnix(config.UnixSocketPath)
|
err = router.RunUnix(config.UnixSocketPath)
|
||||||
} else if config.Protocol == settings.SCHEME_HTTP {
|
} else if config.Protocol == settings.SCHEME_HTTP {
|
||||||
log.BootInfof("[server.startWebServer] will run at http://%s", listenAddr)
|
log.BootInfof("[webserver.startWebServer] will run at http://%s", listenAddr)
|
||||||
err = router.Run(listenAddr)
|
err = router.Run(listenAddr)
|
||||||
} else if config.Protocol == settings.SCHEME_HTTPS {
|
} else if config.Protocol == settings.SCHEME_HTTPS {
|
||||||
log.BootInfof("[server.startWebServer] will run at https://%s", listenAddr)
|
log.BootInfof("[webserver.startWebServer] will run at https://%s", listenAddr)
|
||||||
err = router.RunTLS(listenAddr, config.CertFile, config.CertKeyFile)
|
err = router.RunTLS(listenAddr, config.CertFile, config.CertKeyFile)
|
||||||
} else {
|
} else {
|
||||||
err = errs.ErrInvalidProtocol
|
err = errs.ErrInvalidProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[server.startWebServer] cannot start, because %s", err)
|
log.BootErrorf("[webserver.startWebServer] cannot start, because %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,6 +376,23 @@ func bindApi(fn core.ApiHandlerFunc) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bindApiWithTokenUpdate(fn core.ApiHandlerFunc, config *settings.Config) gin.HandlerFunc {
|
||||||
|
return func(ginCtx *gin.Context) {
|
||||||
|
c := core.WrapContext(ginCtx)
|
||||||
|
result, err := fn(c)
|
||||||
|
|
||||||
|
if err == nil && config.MapProvider == settings.AmapProvider && config.AmapSecurityVerificationMethod == settings.AmapSecurityVerificationInternalProxyMethod {
|
||||||
|
middlewares.AmapApiProxyAuthCookie(c, config)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintJsonErrorResult(c, err)
|
||||||
|
} else {
|
||||||
|
utils.PrintJsonSuccessResult(c, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func bindCsv(fn core.DataHandlerFunc) gin.HandlerFunc {
|
func bindCsv(fn core.DataHandlerFunc) gin.HandlerFunc {
|
||||||
return func(ginCtx *gin.Context) {
|
return func(ginCtx *gin.Context) {
|
||||||
c := core.WrapContext(ginCtx)
|
c := core.WrapContext(ginCtx)
|
||||||
@@ -304,6 +406,45 @@ func bindCsv(fn core.DataHandlerFunc) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bindTsv(fn core.DataHandlerFunc) gin.HandlerFunc {
|
||||||
|
return func(ginCtx *gin.Context) {
|
||||||
|
c := core.WrapContext(ginCtx)
|
||||||
|
result, fileName, err := fn(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintDataErrorResult(c, "text/text", err)
|
||||||
|
} else {
|
||||||
|
utils.PrintDataSuccessResult(c, "text/tab-separated-values", fileName, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func bindImage(fn core.ImageHandlerFunc) gin.HandlerFunc {
|
||||||
|
return func(ginCtx *gin.Context) {
|
||||||
|
c := core.WrapContext(ginCtx)
|
||||||
|
result, contentType, err := fn(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintDataErrorResult(c, "text/text", err)
|
||||||
|
} else {
|
||||||
|
utils.PrintDataSuccessResult(c, contentType, "", result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func bindCachedImage(fn core.ImageHandlerFunc, store persistence.CacheStore) gin.HandlerFunc {
|
||||||
|
return cache.CachePage(store, time.Minute, func(ginCtx *gin.Context) {
|
||||||
|
c := core.WrapContext(ginCtx)
|
||||||
|
result, contentType, err := fn(c)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintDataErrorResult(c, "text/text", err)
|
||||||
|
} else {
|
||||||
|
utils.PrintDataSuccessResult(c, contentType, "", result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func bindProxy(fn core.ProxyHandlerFunc) gin.HandlerFunc {
|
func bindProxy(fn core.ProxyHandlerFunc) gin.HandlerFunc {
|
||||||
return func(ginCtx *gin.Context) {
|
return func(ginCtx *gin.Context) {
|
||||||
c := core.WrapContext(ginCtx)
|
c := core.WrapContext(ginCtx)
|
||||||
|
|||||||
+190
-11
@@ -25,7 +25,7 @@ root_url = %(protocol)s://%(domain)s:%(http_port)s/
|
|||||||
cert_file =
|
cert_file =
|
||||||
cert_key_file =
|
cert_key_file =
|
||||||
|
|
||||||
# Unix socket path, for "socket" only
|
# Unix socket path, for "socket" protocol only
|
||||||
unix_socket =
|
unix_socket =
|
||||||
|
|
||||||
# Static file root path (relative or absolute path)
|
# Static file root path (relative or absolute path)
|
||||||
@@ -47,10 +47,10 @@ name = ezbookkeeping
|
|||||||
user = root
|
user = root
|
||||||
passwd =
|
passwd =
|
||||||
|
|
||||||
# For "postgres" only, Either "disable", "require" or "verify-full"
|
# For "postgres" database only, Either "disable", "require" or "verify-full"
|
||||||
ssl_mode = disable
|
ssl_mode = disable
|
||||||
|
|
||||||
# For "sqlite3" only, db file path (relative or absolute path)
|
# For "sqlite3" database only, database file path (relative or absolute path)
|
||||||
db_path = data/ezbookkeeping.db
|
db_path = data/ezbookkeeping.db
|
||||||
|
|
||||||
# Max idle connection number (0 - 65535, 0 means no idle connections are retained), default is 2
|
# Max idle connection number (0 - 65535, 0 means no idle connections are retained), default is 2
|
||||||
@@ -68,6 +68,19 @@ log_query = false
|
|||||||
# Set to true to automatically update database structure when starting web server
|
# Set to true to automatically update database structure when starting web server
|
||||||
auto_update_database = true
|
auto_update_database = true
|
||||||
|
|
||||||
|
[mail]
|
||||||
|
# Set to true to enable sending mail by SMTP server
|
||||||
|
enable_smtp = false
|
||||||
|
|
||||||
|
# SMTP Server connection configuration
|
||||||
|
smtp_host = 127.0.0.1:25
|
||||||
|
smtp_user =
|
||||||
|
smtp_passwd =
|
||||||
|
smtp_skip_tls_verify = false
|
||||||
|
|
||||||
|
# Mail from address. This can be just an email address, or the "Name" <user@domain.com> format.
|
||||||
|
from_address =
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
# Either "console", "file", default is "console"
|
# Either "console", "file", default is "console"
|
||||||
# Use space to separate multiple modes, e.g. "console file"
|
# Use space to separate multiple modes, e.g. "console file"
|
||||||
@@ -76,29 +89,90 @@ mode = console file
|
|||||||
# Either "debug", "info", "warn", "error", default is "info"
|
# Either "debug", "info", "warn", "error", default is "info"
|
||||||
level = info
|
level = info
|
||||||
|
|
||||||
# For "file" only, log file path (relative or absolute path)
|
# For "file" mode only, log file path (relative or absolute path)
|
||||||
log_path = log/ezbookkeeping.log
|
log_path = log/ezbookkeeping.log
|
||||||
|
|
||||||
|
# For "file" only, request log file path (relative or absolute path). Leave blank if you want to write request log in default log file
|
||||||
|
request_log_path =
|
||||||
|
|
||||||
|
# For "file" only, query log file path (relative or absolute path). Leave blank if you want to write query log in default log file
|
||||||
|
query_log_path =
|
||||||
|
|
||||||
|
# For "file" only, whether rotate the log files
|
||||||
|
log_file_rotate = false
|
||||||
|
|
||||||
|
# For "file" only, maximum size (1 - 4294967295 bytes) of the log file before it gets rotated
|
||||||
|
log_file_max_size = 104857600
|
||||||
|
|
||||||
|
# For "file" only, maximum number of days to retain old log files. Set to 0 to retain all logs
|
||||||
|
log_file_max_days = 7
|
||||||
|
|
||||||
|
[storage]
|
||||||
|
# Object storage type, supports "local_filesystem" and "minio" currently
|
||||||
|
type = local_filesystem
|
||||||
|
|
||||||
|
# For "local_filesystem" storage only, the storage root path (relative or absolute path)
|
||||||
|
local_filesystem_path = storage/
|
||||||
|
|
||||||
|
# For "minio" storage only, the minio connection configuration
|
||||||
|
minio_endpoint = 127.0.0.1:9000
|
||||||
|
minio_location =
|
||||||
|
minio_access_key_id =
|
||||||
|
minio_secret_access_key =
|
||||||
|
|
||||||
|
# For "minio" storage only, whether enable ssl for minio connection
|
||||||
|
minio_use_ssl = false
|
||||||
|
|
||||||
|
# For "minio" storage only, set to true to skip tls verification when connect minio
|
||||||
|
minio_skip_tls_verify = false
|
||||||
|
|
||||||
|
# For "minio" storage only, the minio bucket
|
||||||
|
minio_bucket = ezbookkeeping
|
||||||
|
|
||||||
|
# For "minio" storage only, the root path to store files in minio
|
||||||
|
minio_root_path = /
|
||||||
|
|
||||||
[uuid]
|
[uuid]
|
||||||
# Uuid generator type, supports "internal" currently
|
# Uuid generator type, supports "internal" currently
|
||||||
generator_type = internal
|
generator_type = internal
|
||||||
|
|
||||||
# For "internal" only, each server must have unique id (0 - 255)
|
# For "internal" uuid generator only, each server must have unique id (0 - 255)
|
||||||
server_id = 0
|
server_id = 0
|
||||||
|
|
||||||
|
[duplicate_checker]
|
||||||
|
# Duplicate checker type, supports "in_memory" currently
|
||||||
|
checker_type = in_memory
|
||||||
|
|
||||||
|
# For "in_memory" duplicate checker only, cleanup expired data interval seconds (1 - 4294967295), default is 60 (1 minutes)
|
||||||
|
cleanup_interval = 60
|
||||||
|
|
||||||
|
# The minimum interval seconds (0 - 4294967295) between duplicate submissions on the same page (exiting and re-entering the page is considered as a new session)
|
||||||
|
# Set to 0 to disable duplicate checker for new data submissions, default is 300 (5 minutes)
|
||||||
|
duplicate_submissions_interval = 300
|
||||||
|
|
||||||
[security]
|
[security]
|
||||||
# Used for signing, you must change it to keep your user data safe before you first run ezBookkeeping
|
# Used for signing, you must change it to keep your user data safe before you first run ezBookkeeping
|
||||||
secret_key =
|
secret_key =
|
||||||
|
|
||||||
# Set to true to enable two factor authorization
|
# Set to true to enable two-factor authorization
|
||||||
enable_two_factor = true
|
enable_two_factor = true
|
||||||
|
|
||||||
# Token expired seconds (0 - 4294967295), default is 2592000 (30 days)
|
# Token expired seconds (60 - 4294967295), default is 2592000 (30 days)
|
||||||
token_expired_time = 2592000
|
token_expired_time = 2592000
|
||||||
|
|
||||||
# Temporary token expired seconds (0 - 4294967295), default is 300 (5 minutes)
|
# Token minimum refresh interval (0 - 4294967295), the value should be less than token expired time
|
||||||
|
# Set to 0 to refresh the token every time when refreshing the front end, default is 86400 (1 day)
|
||||||
|
token_min_refresh_interval = 86400
|
||||||
|
|
||||||
|
# Temporary token expired seconds (60 - 4294967295), default is 300 (5 minutes)
|
||||||
temporary_token_expired_time = 300
|
temporary_token_expired_time = 300
|
||||||
|
|
||||||
|
# Email verify token expired seconds (60 - 4294967295), default is 3600 (60 minutes)
|
||||||
|
email_verify_token_expired_time = 3600
|
||||||
|
|
||||||
|
# Password reset token expired seconds (60 - 4294967295), default is 3600 (60 minutes)
|
||||||
|
password_reset_token_expired_time = 3600
|
||||||
|
|
||||||
# Add X-Request-Id header to response to track user request or error, default is true
|
# Add X-Request-Id header to response to track user request or error, default is true
|
||||||
request_id_header = true
|
request_id_header = true
|
||||||
|
|
||||||
@@ -106,17 +180,115 @@ request_id_header = true
|
|||||||
# Set to true to allow users to register account by themselves
|
# Set to true to allow users to register account by themselves
|
||||||
enable_register = true
|
enable_register = true
|
||||||
|
|
||||||
|
# Set to true to allow users to verify email address
|
||||||
|
enable_email_verify = false
|
||||||
|
|
||||||
|
# Set to true to require email must be verified when login
|
||||||
|
enable_force_email_verify = false
|
||||||
|
|
||||||
|
# Set to true to allow users to reset password
|
||||||
|
enable_forget_password = true
|
||||||
|
|
||||||
|
# Set to true to require email must be verified when use forget password
|
||||||
|
forget_password_require_email_verify = false
|
||||||
|
|
||||||
|
# User avatar provider, supports the following types:
|
||||||
|
# "internal": Use the internal object storage to store user avatar (refer to "storage" settings), supports updating avatar by user self
|
||||||
|
# "gravatar": https://gravatar.com
|
||||||
|
# Leave blank if you want to disable user avatar
|
||||||
|
avatar_provider = internal
|
||||||
|
|
||||||
[data]
|
[data]
|
||||||
# Set to true to allow users to export their data
|
# Set to true to allow users to export their data
|
||||||
enable_export = true
|
enable_export = true
|
||||||
|
|
||||||
|
[notification]
|
||||||
|
# Set to true to display custom notification in home page every time users register
|
||||||
|
enable_notification_after_register = false
|
||||||
|
|
||||||
|
# The notification content displayed each time users register, it supports multi-language configuration
|
||||||
|
# Add an underscore and a language tag after the setting key to configure the notification content in that language, the same below
|
||||||
|
# For example, after_login_notification_content_zh_hans means the notification content in Simplified Chinese
|
||||||
|
after_register_notification_content =
|
||||||
|
|
||||||
|
# Set to true to display custom notification in home page every time users login
|
||||||
|
enable_notification_after_login = false
|
||||||
|
|
||||||
|
# The notification content displayed each time users log in, it supports multi-language configuration
|
||||||
|
after_login_notification_content =
|
||||||
|
|
||||||
|
# Set to true to display custom notification in home page every time users open the app
|
||||||
|
enable_notification_after_open = false
|
||||||
|
|
||||||
|
# The notification content displayed each time users open the app, it supports multi-language configuration
|
||||||
|
after_open_notification_content =
|
||||||
|
|
||||||
[map]
|
[map]
|
||||||
# Map provider, supports `openstreetmap`
|
# Map provider, supports the following types:
|
||||||
|
# "openstreetmap": https://www.openstreetmap.org
|
||||||
|
# "openstreetmap_humanitarian": http://map.hotosm.org
|
||||||
|
# "opentopomap": https://opentopomap.org
|
||||||
|
# "opnvkarte": https://publictransportmap.org
|
||||||
|
# "cyclosm": https://www.cyclosm.org
|
||||||
|
# "cartodb": https://carto.com/basemaps
|
||||||
|
# "tomtom": https://www.tomtom.com
|
||||||
|
# "tianditu": https://www.tianditu.gov.cn
|
||||||
|
# "googlemap": https://map.google.com
|
||||||
|
# "baidumap": https://map.baidu.com
|
||||||
|
# "amap": https://amap.com
|
||||||
|
# "custom": custom map tile server url
|
||||||
|
# Leave blank if you want to disable map
|
||||||
map_provider = openstreetmap
|
map_provider = openstreetmap
|
||||||
|
|
||||||
# Set to true to use the ezbookkeeping server to proxy map data requests, for "openstreetmap"
|
# Set to true to use the ezbookkeeping server to forward map data requests, for "openstreetmap", "openstreetmap_humanitarian", "opentopomap", "opnvkarte", "cyclosm", "cartodb", "tomtom", "tianditu" or "custom"
|
||||||
map_data_fetch_proxy = false
|
map_data_fetch_proxy = false
|
||||||
|
|
||||||
|
# Proxy for ezbookkeeping server requesting original map data when map_data_fetch_proxy is set to true, supports "system" (use system proxy), "none" (do not use proxy), or proxy URL which starts with "http://", "https://" or "socks5://", default is "system"
|
||||||
|
proxy = system
|
||||||
|
|
||||||
|
# For "tomtom" map provider only, TomTom map API key, please visit https://developer.tomtom.com/how-to-get-tomtom-api-key for more information
|
||||||
|
tomtom_map_api_key =
|
||||||
|
|
||||||
|
# For "tianditu" map provider only, TianDiTu map application key, please visit https://console.tianditu.gov.cn/api/register for more information
|
||||||
|
tianditu_map_app_key =
|
||||||
|
|
||||||
|
# For "googlemap" map provider only, Google map JavaScript API key, please visit https://developers.google.com/maps/get-started for more information
|
||||||
|
google_map_api_key =
|
||||||
|
|
||||||
|
# For "baidumap" map provider only, Baidu map JavaScript API application key, please visit https://lbsyun.baidu.com/index.php?title=jspopular3.0/guide/getkey for more information
|
||||||
|
baidu_map_ak =
|
||||||
|
|
||||||
|
# For "amap" map provider only, Amap JavaScript API application key, please visit https://lbs.amap.com/api/javascript-api/guide/abc/prepare for more information
|
||||||
|
amap_application_key =
|
||||||
|
|
||||||
|
# For "amap" map provider only, Amap JavaScript API security verification method, supports the following methods:
|
||||||
|
# "internal_proxy": use the internal proxy to request amap api with amap application secret (default)
|
||||||
|
# "external_proxy": use an external proxy to request amap api (amap application secret should be set by external proxy)
|
||||||
|
# "plain_text": append amap application secret to frontend request directly (insecurity for public network)
|
||||||
|
# Please visit https://developer.amap.com/api/jsapi-v2/guide/abc/load for more information
|
||||||
|
amap_security_verification_method = plain_text
|
||||||
|
|
||||||
|
# For "amap" map provider only, Amap JavaScript API application secret, this setting must be provided when "amap_security_verification_method" is set to "internal_proxy" or "plain_text", please visit https://lbs.amap.com/api/javascript-api/guide/abc/prepare for more information
|
||||||
|
amap_application_secret =
|
||||||
|
|
||||||
|
# For "amap" map provider only, Amap JavaScript API external proxy url, this setting must be provided when "amap_security_verification_method" is set to "external_proxy"
|
||||||
|
amap_api_external_proxy_url =
|
||||||
|
|
||||||
|
# For "custom" map provider only, the tile layer url of custom map tile server, supports {x}, {y} (coordinates) and {z} (zoom level) placeholders, like "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
|
custom_map_tile_server_url =
|
||||||
|
|
||||||
|
# For "custom" map provider only, the optional annotation layer url of custom map tile server, supports {x}, {y} (coordinates) and {z} (zoom level) placeholders
|
||||||
|
custom_map_tile_server_annotation_url =
|
||||||
|
|
||||||
|
# For "custom" map provider only, the min zoom level (0 - 255) for custom map tile server, default is 1
|
||||||
|
custom_map_tile_server_min_zoom_level = 1
|
||||||
|
|
||||||
|
# For "custom" map provider only, the max zoom level (0 - 255) for custom map tile server, default is 18
|
||||||
|
custom_map_tile_server_max_zoom_level = 18
|
||||||
|
|
||||||
|
# For "custom" map provider only, the default zoom level (0 - 255) for custom map tile server, default is 14
|
||||||
|
custom_map_tile_server_default_zoom_level = 14
|
||||||
|
|
||||||
[exchange_rates]
|
[exchange_rates]
|
||||||
# Exchange rates data source, supports the following types:
|
# Exchange rates data source, supports the following types:
|
||||||
# "euro_central_bank"
|
# "euro_central_bank"
|
||||||
@@ -127,5 +299,12 @@ map_data_fetch_proxy = false
|
|||||||
# "monetary_authority_of_singapore"
|
# "monetary_authority_of_singapore"
|
||||||
data_source = euro_central_bank
|
data_source = euro_central_bank
|
||||||
|
|
||||||
# Requesting exchange rates data timeout (0 - 4294967295 milliseconds), default is 10000 (10 seconds)
|
# Requesting exchange rates data timeout (0 - 4294967295 milliseconds)
|
||||||
|
# Set to 0 to disable timeout for requesting exchange rates data, default is 10000 (10 seconds)
|
||||||
request_timeout = 10000
|
request_timeout = 10000
|
||||||
|
|
||||||
|
# Proxy for ezbookkeeping server requesting exchange rates data, supports "system" (use system proxy), "none" (do not use proxy), or proxy URL which starts with "http://", "https://" or "socks5://", default is "system"
|
||||||
|
proxy = system
|
||||||
|
|
||||||
|
# Set to true to skip tls verification when request exchange rates data
|
||||||
|
skip_tls_verify = false
|
||||||
|
|||||||
@@ -37,12 +37,17 @@ func main() {
|
|||||||
cmd.Database,
|
cmd.Database,
|
||||||
cmd.UserData,
|
cmd.UserData,
|
||||||
cmd.SecurityUtils,
|
cmd.SecurityUtils,
|
||||||
|
cmd.Utilities,
|
||||||
},
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "conf-path",
|
Name: "conf-path",
|
||||||
Usage: "Custom config `FILE` path",
|
Usage: "Custom config `FILE` path",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "no-boot-log",
|
||||||
|
Usage: "Disable boot log",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +1,78 @@
|
|||||||
module github.com/mayswind/ezbookkeeping
|
module github.com/mayswind/ezbookkeeping
|
||||||
|
|
||||||
go 1.20
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-contrib/gzip v0.0.6
|
github.com/boombuler/barcode v1.0.2
|
||||||
github.com/gin-gonic/gin v1.9.0
|
github.com/gin-contrib/cache v1.3.0
|
||||||
github.com/go-playground/validator/v10 v10.14.0
|
github.com/gin-contrib/gzip v1.0.1
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/gin-gonic/gin v1.10.0
|
||||||
github.com/golang-jwt/jwt/v5 v5.0.0
|
github.com/go-playground/validator/v10 v10.22.0
|
||||||
|
github.com/go-sql-driver/mysql v1.8.1
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||||
github.com/lib/pq v1.10.9
|
github.com/lib/pq v1.10.9
|
||||||
github.com/mattn/go-sqlite3 v1.14.16
|
github.com/mattn/go-sqlite3 v1.14.22
|
||||||
|
github.com/minio/minio-go/v7 v7.0.74
|
||||||
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/pquerna/otp v1.4.0
|
github.com/pquerna/otp v1.4.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/urfave/cli/v2 v2.25.4
|
github.com/urfave/cli/v2 v2.27.1
|
||||||
golang.org/x/crypto v0.9.0
|
github.com/wk8/go-ordered-map/v2 v2.1.8
|
||||||
|
golang.org/x/crypto v0.25.0
|
||||||
gopkg.in/ini.v1 v1.67.0
|
gopkg.in/ini.v1 v1.67.0
|
||||||
xorm.io/xorm v1.3.2
|
gopkg.in/mail.v2 v2.3.1
|
||||||
|
xorm.io/builder v0.3.13
|
||||||
|
xorm.io/xorm v1.3.9
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/boombuler/barcode v1.0.1 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/bytedance/sonic v1.8.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 // indirect
|
||||||
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
|
github.com/bytedance/sonic v1.11.6 // indirect
|
||||||
|
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||||
|
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||||
|
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||||
|
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||||
|
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
|
github.com/go-ini/ini v1.67.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/goccy/go-json v0.10.0 // indirect
|
github.com/goccy/go-json v0.10.3 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
|
github.com/gomodule/redigo v1.8.9 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/memcachier/mc/v3 v3.0.3 // indirect
|
||||||
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62 // indirect
|
||||||
|
github.com/rs/xid v1.5.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/syndtr/goleveldb v1.0.0 // indirect
|
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.9 // indirect
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
golang.org/x/arch v0.8.0 // indirect
|
||||||
golang.org/x/net v0.10.0 // indirect
|
golang.org/x/net v0.26.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.22.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.16.0 // indirect
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.34.1 // indirect
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
xorm.io/builder v0.3.12 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,713 +1,182 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||||
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
|
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
|
||||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
|
||||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
|
||||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
|
||||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
|
||||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
|
||||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
|
||||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
|
||||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
|
||||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
|
||||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
|
||||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
|
||||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||||
github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs=
|
github.com/boombuler/barcode v1.0.2 h1:79yrbttoZrLGkL/oOI8hBrUKucwOL0oOjUgEguGMcJ4=
|
||||||
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
github.com/boombuler/barcode v1.0.2/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||||
|
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous=
|
||||||
|
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c=
|
||||||
|
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||||
|
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||||
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
|
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
||||||
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
|
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
|
||||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
|
||||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
|
||||||
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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
|
||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
|
||||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
|
||||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
|
||||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
|
||||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
|
||||||
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/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
|
||||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
|
||||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/gin-contrib/cache v1.3.0 h1:wEEw38uvb4rTraQJVpd9ex4ZotXNlc0fSaSUsuPXS/w=
|
||||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
github.com/gin-contrib/cache v1.3.0/go.mod h1:EA63LrWGI5vwSI95TS5fgBrtxZ1tM2NKx+NrEeyEDcU=
|
||||||
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
github.com/gin-contrib/gzip v1.0.1 h1:HQ8ENHODeLY7a4g1Au/46Z92bdGFl74OhxcZble9WJE=
|
||||||
|
github.com/gin-contrib/gzip v1.0.1/go.mod h1:njt428fdUNRvjuJf16tZMYZ2Yl+WQB53X5wmhDwXvC4=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
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-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||||
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
|
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
|
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
|
||||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
|
||||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
|
||||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
|
||||||
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
|
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||||
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
||||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
|
||||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
|
||||||
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
|
|
||||||
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
|
||||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
|
||||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
|
||||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
|
||||||
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
|
|
||||||
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
|
||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
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.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.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
||||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
|
||||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
|
||||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
|
||||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
|
||||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
|
||||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
|
||||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
|
||||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
|
||||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
|
||||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
|
||||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
|
||||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
|
||||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
|
||||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
|
||||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
|
||||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
|
||||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
|
||||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
|
||||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
|
||||||
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
|
||||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
|
||||||
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
|
||||||
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
|
||||||
github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk=
|
|
||||||
github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
|
||||||
github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
|
||||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
|
||||||
github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
|
|
||||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
|
||||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
|
||||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
|
||||||
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
|
||||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
|
||||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
|
||||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
|
||||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
|
||||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
|
||||||
github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0=
|
|
||||||
github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po=
|
|
||||||
github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
|
|
||||||
github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
|
|
||||||
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
|
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
|
||||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
|
||||||
github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA=
|
|
||||||
github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
|
|
||||||
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
|
|
||||||
github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
|
|
||||||
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
|
|
||||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
|
||||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
|
||||||
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
|
||||||
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
|
||||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.8/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 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
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/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
||||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
|
||||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
|
||||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
|
||||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
|
||||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
|
||||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
|
||||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
|
||||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
|
||||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/memcachier/mc/v3 v3.0.3 h1:qii+lDiPKi36O4Xg+HVKwHu6Oq+Gt17b+uEiA0Drwv4=
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/memcachier/mc/v3 v3.0.3/go.mod h1:GzjocBahcXPxt2cmqzknrgqCOmMxiSzhVKPOe90Tpug=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/minio/minio-go/v7 v7.0.74 h1:fTo/XlPBTSpo3BAMshlwKL5RspXRv9us5UeHEGYCFe0=
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/minio/minio-go/v7 v7.0.74/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8=
|
||||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
|
||||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
|
||||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
|
||||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
|
||||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
|
||||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
|
||||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
|
||||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
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 h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
|
||||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
|
||||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
|
||||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
|
||||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
|
||||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
|
||||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
|
||||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
|
||||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
|
||||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
|
||||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
|
||||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
|
||||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
|
||||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
|
||||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
|
||||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
|
||||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
|
||||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
|
||||||
github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg=
|
github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg=
|
||||||
github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62 h1:pyecQtsPmlkCsMkYhT5iZ+sUXuwee+OvfuJjinEA3ko=
|
||||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
github.com/robfig/go-cache v0.0.0-20130306151617-9fc39e0dbf62/go.mod h1:65XQgovT59RWatovFwnwocoUxiI/eENTnOY5GK3STuY=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
|
||||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
|
||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
|
||||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
|
||||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
|
||||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
|
||||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
|
||||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
|
||||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
|
||||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
|
||||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
|
||||||
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
|
||||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
|
||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
|
||||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
|
||||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
|
||||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
|
||||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
|
||||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
|
||||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
|
||||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
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/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
|
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
|
||||||
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
github.com/urfave/cli/v2 v2.25.4 h1:HyYwPrTO3im9rYhUff/ZNs78eolxt0nJ4LN+9yJKSH4=
|
|
||||||
github.com/urfave/cli/v2 v2.25.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
|
||||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
|
||||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
|
||||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
|
||||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
|
||||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
|
||||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|
||||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
|
||||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
|
||||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
|
||||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
|
||||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
|
||||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|
||||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
|
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
|
||||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
|
||||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
|
||||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
|
||||||
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=
|
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
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-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
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=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201126233918-771906719818/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-20210630005230-0f9fa26af87c/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-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
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.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.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
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-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
|
||||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
|
||||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
|
||||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
|
||||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
|
||||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
|
||||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
|
||||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
|
||||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
|
||||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
|
||||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
|
||||||
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/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
|
||||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
|
||||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk=
|
||||||
|
gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
|
||||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
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-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||||
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=
|
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
|
||||||
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
|
||||||
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.34.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.4/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.5/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.8/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
|
||||||
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
|
||||||
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
|
||||||
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
|
|
||||||
modernc.org/ccgo/v3 v3.11.1/go.mod h1:lWHxfsn13L3f7hgGsGlU28D9eUOf6y3ZYHKoPaKU0ag=
|
|
||||||
modernc.org/ccgo/v3 v3.11.3/go.mod h1:0oHunRBMBiXOKdaglfMlRPBALQqsfrCKXgw9okQ3GEw=
|
|
||||||
modernc.org/ccgo/v3 v3.12.4/go.mod h1:Bk+m6m2tsooJchP/Yk5ji56cClmN6R1cqc9o/YtbgBQ=
|
|
||||||
modernc.org/ccgo/v3 v3.12.6/go.mod h1:0Ji3ruvpFPpz+yu+1m0wk68pdr/LENABhTrDkMDWH6c=
|
|
||||||
modernc.org/ccgo/v3 v3.12.8/go.mod h1:Hq9keM4ZfjCDuDXxaHptpv9N24JhgBZmUG5q60iLgUo=
|
|
||||||
modernc.org/ccgo/v3 v3.12.11/go.mod h1:0jVcmyDwDKDGWbcrzQ+xwJjbhZruHtouiBEvDfoIsdg=
|
|
||||||
modernc.org/ccgo/v3 v3.12.14/go.mod h1:GhTu1k0YCpJSuWwtRAEHAol5W7g1/RRfS4/9hc9vF5I=
|
|
||||||
modernc.org/ccgo/v3 v3.12.18/go.mod h1:jvg/xVdWWmZACSgOiAhpWpwHWylbJaSzayCqNOJKIhs=
|
|
||||||
modernc.org/ccgo/v3 v3.12.20/go.mod h1:aKEdssiu7gVgSy/jjMastnv/q6wWGRbszbheXgWRHc8=
|
|
||||||
modernc.org/ccgo/v3 v3.12.21/go.mod h1:ydgg2tEprnyMn159ZO/N4pLBqpL7NOkJ88GT5zNU2dE=
|
|
||||||
modernc.org/ccgo/v3 v3.12.22/go.mod h1:nyDVFMmMWhMsgQw+5JH6B6o4MnZ+UQNw1pp52XYFPRk=
|
|
||||||
modernc.org/ccgo/v3 v3.12.25/go.mod h1:UaLyWI26TwyIT4+ZFNjkyTbsPsY3plAEB6E7L/vZV3w=
|
|
||||||
modernc.org/ccgo/v3 v3.12.29/go.mod h1:FXVjG7YLf9FetsS2OOYcwNhcdOLGt8S9bQ48+OP75cE=
|
|
||||||
modernc.org/ccgo/v3 v3.12.36/go.mod h1:uP3/Fiezp/Ga8onfvMLpREq+KUjUmYMxXPO8tETHtA8=
|
|
||||||
modernc.org/ccgo/v3 v3.12.38/go.mod h1:93O0G7baRST1vNj4wnZ49b1kLxt0xCW5Hsa2qRaZPqc=
|
|
||||||
modernc.org/ccgo/v3 v3.12.43/go.mod h1:k+DqGXd3o7W+inNujK15S5ZYuPoWYLpF5PYougCmthU=
|
|
||||||
modernc.org/ccgo/v3 v3.12.46/go.mod h1:UZe6EvMSqOxaJ4sznY7b23/k13R8XNlyWsO5bAmSgOE=
|
|
||||||
modernc.org/ccgo/v3 v3.12.47/go.mod h1:m8d6p0zNps187fhBwzY/ii6gxfjob1VxWb919Nk1HUk=
|
|
||||||
modernc.org/ccgo/v3 v3.12.50/go.mod h1:bu9YIwtg+HXQxBhsRDE+cJjQRuINuT9PUK4orOco/JI=
|
|
||||||
modernc.org/ccgo/v3 v3.12.51/go.mod h1:gaIIlx4YpmGO2bLye04/yeblmvWEmE4BBBls4aJXFiE=
|
|
||||||
modernc.org/ccgo/v3 v3.12.53/go.mod h1:8xWGGTFkdFEWBEsUmi+DBjwu/WLy3SSOrqEmKUjMeEg=
|
|
||||||
modernc.org/ccgo/v3 v3.12.54/go.mod h1:yANKFTm9llTFVX1FqNKHE0aMcQb1fuPJx6p8AcUx+74=
|
|
||||||
modernc.org/ccgo/v3 v3.12.55/go.mod h1:rsXiIyJi9psOwiBkplOaHye5L4MOOaCjHg1Fxkj7IeU=
|
|
||||||
modernc.org/ccgo/v3 v3.12.56/go.mod h1:ljeFks3faDseCkr60JMpeDb2GSO3TKAmrzm7q9YOcMU=
|
|
||||||
modernc.org/ccgo/v3 v3.12.57/go.mod h1:hNSF4DNVgBl8wYHpMvPqQWDQx8luqxDnNGCMM4NFNMc=
|
|
||||||
modernc.org/ccgo/v3 v3.12.60/go.mod h1:k/Nn0zdO1xHVWjPYVshDeWKqbRWIfif5dtsIOCUVMqM=
|
|
||||||
modernc.org/ccgo/v3 v3.12.65/go.mod h1:D6hQtKxPNZiY6wDBtehSGKFKmyXn53F8nGTpH+POmS4=
|
|
||||||
modernc.org/ccgo/v3 v3.12.66/go.mod h1:jUuxlCFZTUZLMV08s7B1ekHX5+LIAurKTTaugUr/EhQ=
|
|
||||||
modernc.org/ccgo/v3 v3.12.67/go.mod h1:Bll3KwKvGROizP2Xj17GEGOTrlvB1XcVaBrC90ORO84=
|
|
||||||
modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3cQ=
|
|
||||||
modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
|
|
||||||
modernc.org/ccgo/v3 v3.12.82/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w=
|
|
||||||
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
|
||||||
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
|
||||||
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
|
|
||||||
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
|
|
||||||
modernc.org/libc v1.11.0/go.mod h1:2lOfPmj7cz+g1MrPNmX65QCzVxgNq2C5o0jdLY2gAYg=
|
|
||||||
modernc.org/libc v1.11.2/go.mod h1:ioIyrl3ETkugDO3SGZ+6EOKvlP3zSOycUETe4XM4n8M=
|
|
||||||
modernc.org/libc v1.11.5/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
|
|
||||||
modernc.org/libc v1.11.6/go.mod h1:ddqmzR6p5i4jIGK1d/EiSw97LBcE3dK24QEwCFvgNgE=
|
|
||||||
modernc.org/libc v1.11.11/go.mod h1:lXEp9QOOk4qAYOtL3BmMve99S5Owz7Qyowzvg6LiZso=
|
|
||||||
modernc.org/libc v1.11.13/go.mod h1:ZYawJWlXIzXy2Pzghaf7YfM8OKacP3eZQI81PDLFdY8=
|
|
||||||
modernc.org/libc v1.11.16/go.mod h1:+DJquzYi+DMRUtWI1YNxrlQO6TcA5+dRRiq8HWBWRC8=
|
|
||||||
modernc.org/libc v1.11.19/go.mod h1:e0dgEame6mkydy19KKaVPBeEnyJB4LGNb0bBH1EtQ3I=
|
|
||||||
modernc.org/libc v1.11.24/go.mod h1:FOSzE0UwookyT1TtCJrRkvsOrX2k38HoInhw+cSCUGk=
|
|
||||||
modernc.org/libc v1.11.26/go.mod h1:SFjnYi9OSd2W7f4ct622o/PAYqk7KHv6GS8NZULIjKY=
|
|
||||||
modernc.org/libc v1.11.27/go.mod h1:zmWm6kcFXt/jpzeCgfvUNswM0qke8qVwxqZrnddlDiE=
|
|
||||||
modernc.org/libc v1.11.28/go.mod h1:Ii4V0fTFcbq3qrv3CNn+OGHAvzqMBvC7dBNyC4vHZlg=
|
|
||||||
modernc.org/libc v1.11.31/go.mod h1:FpBncUkEAtopRNJj8aRo29qUiyx5AvAlAxzlx9GNaVM=
|
|
||||||
modernc.org/libc v1.11.34/go.mod h1:+Tzc4hnb1iaX/SKAutJmfzES6awxfU1BPvrrJO0pYLg=
|
|
||||||
modernc.org/libc v1.11.37/go.mod h1:dCQebOwoO1046yTrfUE5nX1f3YpGZQKNcITUYWlrAWo=
|
|
||||||
modernc.org/libc v1.11.39/go.mod h1:mV8lJMo2S5A31uD0k1cMu7vrJbSA3J3waQJxpV4iqx8=
|
|
||||||
modernc.org/libc v1.11.42/go.mod h1:yzrLDU+sSjLE+D4bIhS7q1L5UwXDOw99PLSX0BlZvSQ=
|
|
||||||
modernc.org/libc v1.11.44/go.mod h1:KFq33jsma7F5WXiYelU8quMJasCCTnHK0mkri4yPHgA=
|
|
||||||
modernc.org/libc v1.11.45/go.mod h1:Y192orvfVQQYFzCNsn+Xt0Hxt4DiO4USpLNXBlXg/tM=
|
|
||||||
modernc.org/libc v1.11.47/go.mod h1:tPkE4PzCTW27E6AIKIR5IwHAQKCAtudEIeAV1/SiyBg=
|
|
||||||
modernc.org/libc v1.11.49/go.mod h1:9JrJuK5WTtoTWIFQ7QjX2Mb/bagYdZdscI3xrvHbXjE=
|
|
||||||
modernc.org/libc v1.11.51/go.mod h1:R9I8u9TS+meaWLdbfQhq2kFknTW0O3aw3kEMqDDxMaM=
|
|
||||||
modernc.org/libc v1.11.53/go.mod h1:5ip5vWYPAoMulkQ5XlSJTy12Sz5U6blOQiYasilVPsU=
|
|
||||||
modernc.org/libc v1.11.54/go.mod h1:S/FVnskbzVUrjfBqlGFIPA5m7UwB3n9fojHhCNfSsnw=
|
|
||||||
modernc.org/libc v1.11.55/go.mod h1:j2A5YBRm6HjNkoSs/fzZrSxCuwWqcMYTDPLNx0URn3M=
|
|
||||||
modernc.org/libc v1.11.56/go.mod h1:pakHkg5JdMLt2OgRadpPOTnyRXm/uzu+Yyg/LSLdi18=
|
|
||||||
modernc.org/libc v1.11.58/go.mod h1:ns94Rxv0OWyoQrDqMFfWwka2BcaF6/61CqJRK9LP7S8=
|
|
||||||
modernc.org/libc v1.11.70/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw=
|
|
||||||
modernc.org/libc v1.11.71/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw=
|
|
||||||
modernc.org/libc v1.11.75/go.mod h1:dGRVugT6edz361wmD9gk6ax1AbDSe0x5vji0dGJiPT0=
|
|
||||||
modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI=
|
|
||||||
modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE=
|
|
||||||
modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY=
|
|
||||||
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
|
||||||
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
|
||||||
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
|
||||||
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
|
||||||
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
|
|
||||||
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
|
|
||||||
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
|
||||||
modernc.org/sqlite v1.14.2/go.mod h1:yqfn85u8wVOE6ub5UT8VI9JjhrwBUUCNyTACN0h6Sx8=
|
|
||||||
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
|
||||||
modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY=
|
|
||||||
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
|
||||||
modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY=
|
|
||||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
|
||||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
xorm.io/xorm v1.3.9 h1:TUovzS0ko+IQ1XnNLfs5dqK1cJl1H5uHpWbWqAQ04nU=
|
||||||
xorm.io/builder v0.3.12 h1:ASZYX7fQmy+o8UJdhlLHSW57JDOkM8DNhcAF5d0LiJM=
|
xorm.io/xorm v1.3.9/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
|
||||||
xorm.io/builder v0.3.12/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
|
||||||
xorm.io/xorm v1.3.2 h1:uTRRKF2jYzbZ5nsofXVUx6ncMaek+SHjWYtCXyZo1oM=
|
|
||||||
xorm.io/xorm v1.3.2/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw=
|
|
||||||
|
|||||||
Generated
+3939
-2462
File diff suppressed because it is too large
Load Diff
+28
-20
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ezbookkeeping",
|
"name": "ezbookkeeping",
|
||||||
"version": "0.3.0",
|
"version": "0.5.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -18,38 +18,46 @@
|
|||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vuepic/vue-datepicker": "^5.1.2",
|
"@mdi/js": "^7.4.47",
|
||||||
"axios": "^1.4.0",
|
"@vuepic/vue-datepicker": "^8.8.1",
|
||||||
|
"axios": "^1.7.2",
|
||||||
"cbor-js": "^0.1.0",
|
"cbor-js": "^0.1.0",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.2.0",
|
||||||
"dom7": "^4.0.6",
|
"dom7": "^4.0.6",
|
||||||
"framework7": "^8.0.5",
|
"echarts": "^5.5.1",
|
||||||
|
"framework7": "^8.3.3",
|
||||||
"framework7-icons": "^5.0.5",
|
"framework7-icons": "^5.0.5",
|
||||||
"framework7-vue": "^8.0.5",
|
"framework7-vue": "^8.3.3",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"line-awesome": "^1.3.0",
|
"line-awesome": "^1.3.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.30.1",
|
||||||
"moment-timezone": "^0.5.43",
|
"moment-timezone": "^0.5.45",
|
||||||
|
"pinia": "^2.1.7",
|
||||||
"register-service-worker": "^1.7.2",
|
"register-service-worker": "^1.7.2",
|
||||||
"skeleton-elements": "^4.0.1",
|
"skeleton-elements": "^4.0.1",
|
||||||
"swiper": "^9.3.2",
|
"swiper": "^10.2.0",
|
||||||
"ua-parser-js": "^1.0.35",
|
"ua-parser-js": "^1.0.38",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.4.31",
|
||||||
"vue-i18n": "^9.2.2",
|
"vue-echarts": "^6.7.3",
|
||||||
"vuex": "^4.1.0"
|
"vue-i18n": "^9.13.1",
|
||||||
|
"vue-router": "^4.4.0",
|
||||||
|
"vue3-perfect-scrollbar": "^2.0.0",
|
||||||
|
"vuedraggable": "^4.1.0",
|
||||||
|
"vuetify": "^3.6.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.2.0",
|
"@vitejs/plugin-vue": "^5.0.5",
|
||||||
"@vue/compiler-sfc": "^3.3.4",
|
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^8.41.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-vue": "^9.14.1",
|
"eslint-plugin-vue": "^9.27.0",
|
||||||
"git-rev-sync": "^3.0.2",
|
"git-rev-sync": "^3.0.2",
|
||||||
"postcss-preset-env": "^8.4.1",
|
"postcss-preset-env": "^9.5.16",
|
||||||
"vite": "^4.3.5",
|
"sass": "^1.77.6",
|
||||||
"vite-plugin-pwa": "^0.15.1"
|
"vite": "^5.3.3",
|
||||||
|
"vite-plugin-pwa": "^0.20.0",
|
||||||
|
"vite-plugin-vuetify": "^2.0.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"> 1%",
|
"> 1%",
|
||||||
|
|||||||
+78
-21
@@ -4,10 +4,13 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/duplicatechecker"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +27,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AccountListHandler returns accounts list of current user
|
// AccountListHandler returns accounts list of current user
|
||||||
func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountListReq models.AccountListRequest
|
var accountListReq models.AccountListRequest
|
||||||
err := c.ShouldBindQuery(&accountListReq)
|
err := c.ShouldBindQuery(&accountListReq)
|
||||||
|
|
||||||
@@ -34,7 +37,7 @@ func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
accounts, err := a.accounts.GetAllAccountsByUid(uid)
|
accounts, err := a.accounts.GetAllAccountsByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountListHandler] failed to get all accounts for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountListHandler] failed to get all accounts for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -84,7 +87,7 @@ func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountGetHandler returns one specific account of current user
|
// AccountGetHandler returns one specific account of current user
|
||||||
func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountGetReq models.AccountGetRequest
|
var accountGetReq models.AccountGetRequest
|
||||||
err := c.ShouldBindQuery(&accountGetReq)
|
err := c.ShouldBindQuery(&accountGetReq)
|
||||||
|
|
||||||
@@ -94,7 +97,7 @@ func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Err
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
accountAndSubAccounts, err := a.accounts.GetAccountAndSubAccountsByAccountId(uid, accountGetReq.Id)
|
accountAndSubAccounts, err := a.accounts.GetAccountAndSubAccountsByAccountId(c, uid, accountGetReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountGetHandler] failed to get account \"id:%d\" for user \"uid:%d\", because %s", accountGetReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountGetHandler] failed to get account \"id:%d\" for user \"uid:%d\", because %s", accountGetReq.Id, uid, err.Error())
|
||||||
@@ -127,7 +130,7 @@ func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountCreateHandler saves a new account by request parameters for current user
|
// AccountCreateHandler saves a new account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountCreateReq models.AccountCreateRequest
|
var accountCreateReq models.AccountCreateRequest
|
||||||
err := c.ShouldBindJSON(&accountCreateReq)
|
err := c.ShouldBindJSON(&accountCreateReq)
|
||||||
|
|
||||||
@@ -136,9 +139,21 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utcOffset, err := c.GetClientTimezoneOffset()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] cannot get client timezone offset, because %s", err.Error())
|
||||||
|
return nil, errs.ErrClientTimezoneOffsetInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if accountCreateReq.Category < models.ACCOUNT_CATEGORY_CASH || accountCreateReq.Category > models.ACCOUNT_CATEGORY_INVESTMENT {
|
||||||
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account category invalid, category is %d", accountCreateReq.Category)
|
||||||
|
return nil, errs.ErrAccountCategoryInvalid
|
||||||
|
}
|
||||||
|
|
||||||
if accountCreateReq.Type == models.ACCOUNT_TYPE_SINGLE_ACCOUNT {
|
if accountCreateReq.Type == models.ACCOUNT_TYPE_SINGLE_ACCOUNT {
|
||||||
if len(accountCreateReq.SubAccounts) > 0 {
|
if len(accountCreateReq.SubAccounts) > 0 {
|
||||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot have any sub accounts")
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot have any sub-accounts")
|
||||||
return nil, errs.ErrAccountCannotHaveSubAccounts
|
return nil, errs.ErrAccountCannotHaveSubAccounts
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +163,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
} else if accountCreateReq.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
|
} else if accountCreateReq.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
|
||||||
if len(accountCreateReq.SubAccounts) < 1 {
|
if len(accountCreateReq.SubAccounts) < 1 {
|
||||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account does not have any sub accounts")
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account does not have any sub-accounts")
|
||||||
return nil, errs.ErrAccountHaveNoSubAccount
|
return nil, errs.ErrAccountHaveNoSubAccount
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,17 +181,17 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
subAccount := accountCreateReq.SubAccounts[i]
|
subAccount := accountCreateReq.SubAccounts[i]
|
||||||
|
|
||||||
if subAccount.Category != accountCreateReq.Category {
|
if subAccount.Category != accountCreateReq.Category {
|
||||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] category of sub account not equals to parent")
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] category of sub-account not equals to parent")
|
||||||
return nil, errs.ErrSubAccountCategoryNotEqualsToParent
|
return nil, errs.ErrSubAccountCategoryNotEqualsToParent
|
||||||
}
|
}
|
||||||
|
|
||||||
if subAccount.Type != models.ACCOUNT_TYPE_SINGLE_ACCOUNT {
|
if subAccount.Type != models.ACCOUNT_TYPE_SINGLE_ACCOUNT {
|
||||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account type invalid")
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub-account type invalid")
|
||||||
return nil, errs.ErrSubAccountTypeInvalid
|
return nil, errs.ErrSubAccountTypeInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
if subAccount.Currency == validators.ParentAccountCurrencyPlaceholder {
|
if subAccount.Currency == validators.ParentAccountCurrencyPlaceholder {
|
||||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account cannot set currency placeholder")
|
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub-account cannot set currency placeholder")
|
||||||
return nil, errs.ErrAccountCurrencyInvalid
|
return nil, errs.ErrAccountCurrencyInvalid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +201,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
maxOrderId, err := a.accounts.GetMaxDisplayOrder(uid, accountCreateReq.Category)
|
maxOrderId, err := a.accounts.GetMaxDisplayOrder(c, uid, accountCreateReq.Category)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountCreateHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountCreateHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -196,7 +211,43 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
mainAccount := a.createNewAccountModel(uid, &accountCreateReq, maxOrderId+1)
|
mainAccount := a.createNewAccountModel(uid, &accountCreateReq, maxOrderId+1)
|
||||||
childrenAccounts := a.createSubAccountModels(uid, &accountCreateReq)
|
childrenAccounts := a.createSubAccountModels(uid, &accountCreateReq)
|
||||||
|
|
||||||
err = a.accounts.CreateAccounts(mainAccount, childrenAccounts)
|
if settings.Container.Current.EnableDuplicateSubmissionsCheck && accountCreateReq.ClientSessionId != "" {
|
||||||
|
found, remark := duplicatechecker.Container.Get(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT, uid, accountCreateReq.ClientSessionId)
|
||||||
|
|
||||||
|
if found {
|
||||||
|
log.InfofWithRequestId(c, "[accounts.AccountCreateHandler] another account \"id:%s\" has been created for user \"uid:%d\"", remark, uid)
|
||||||
|
accountId, err := utils.StringToInt64(remark)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
accountAndSubAccounts, err := a.accounts.GetAccountAndSubAccountsByAccountId(c, uid, accountId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[accounts.AccountCreateHandler] failed to get existed account \"id:%d\" for user \"uid:%d\", because %s", accountId, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
accountMap := a.accounts.GetAccountMapByList(accountAndSubAccounts)
|
||||||
|
mainAccount, exists := accountMap[accountId]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
accountInfoResp := mainAccount.ToAccountInfoResponse()
|
||||||
|
|
||||||
|
for i := 0; i < len(accountAndSubAccounts); i++ {
|
||||||
|
if accountAndSubAccounts[i].ParentAccountId == mainAccount.AccountId {
|
||||||
|
subAccountResp := accountAndSubAccounts[i].ToAccountInfoResponse()
|
||||||
|
accountInfoResp.SubAccounts = append(accountInfoResp.SubAccounts, subAccountResp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountInfoResp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.accounts.CreateAccounts(c, mainAccount, childrenAccounts, utcOffset)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountCreateHandler] failed to create account \"id:%d\" for user \"uid:%d\", because %s", mainAccount.AccountId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountCreateHandler] failed to create account \"id:%d\" for user \"uid:%d\", because %s", mainAccount.AccountId, uid, err.Error())
|
||||||
@@ -205,6 +256,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
|
|
||||||
log.InfofWithRequestId(c, "[accounts.AccountCreateHandler] user \"uid:%d\" has created a new account \"id:%d\" successfully", uid, mainAccount.AccountId)
|
log.InfofWithRequestId(c, "[accounts.AccountCreateHandler] user \"uid:%d\" has created a new account \"id:%d\" successfully", uid, mainAccount.AccountId)
|
||||||
|
|
||||||
|
duplicatechecker.Container.Set(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT, uid, accountCreateReq.ClientSessionId, utils.Int64ToString(mainAccount.AccountId))
|
||||||
accountInfoResp := mainAccount.ToAccountInfoResponse()
|
accountInfoResp := mainAccount.ToAccountInfoResponse()
|
||||||
|
|
||||||
if len(childrenAccounts) > 0 {
|
if len(childrenAccounts) > 0 {
|
||||||
@@ -219,7 +271,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountModifyHandler saves an existed account by request parameters for current user
|
// AccountModifyHandler saves an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountModifyReq models.AccountModifyRequest
|
var accountModifyReq models.AccountModifyRequest
|
||||||
err := c.ShouldBindJSON(&accountModifyReq)
|
err := c.ShouldBindJSON(&accountModifyReq)
|
||||||
|
|
||||||
@@ -228,8 +280,13 @@ func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.
|
|||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if accountModifyReq.Category < models.ACCOUNT_CATEGORY_CASH || accountModifyReq.Category > models.ACCOUNT_CATEGORY_INVESTMENT {
|
||||||
|
log.WarnfWithRequestId(c, "[accounts.AccountModifyHandler] account category invalid, category is %d", accountModifyReq.Category)
|
||||||
|
return nil, errs.ErrAccountCategoryInvalid
|
||||||
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
accountAndSubAccounts, err := a.accounts.GetAccountAndSubAccountsByAccountId(uid, accountModifyReq.Id)
|
accountAndSubAccounts, err := a.accounts.GetAccountAndSubAccountsByAccountId(c, uid, accountModifyReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountModifyHandler] failed to get account \"id:%d\" for user \"uid:%d\", because %s", accountModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountModifyHandler] failed to get account \"id:%d\" for user \"uid:%d\", because %s", accountModifyReq.Id, uid, err.Error())
|
||||||
@@ -275,7 +332,7 @@ func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.
|
|||||||
return nil, errs.ErrNothingWillBeUpdated
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.accounts.ModifyAccounts(uid, toUpdateAccounts)
|
err = a.accounts.ModifyAccounts(c, uid, toUpdateAccounts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountModifyHandler] failed to update account \"id:%d\" for user \"uid:%d\", because %s", accountModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountModifyHandler] failed to update account \"id:%d\" for user \"uid:%d\", because %s", accountModifyReq.Id, uid, err.Error())
|
||||||
@@ -325,7 +382,7 @@ func (a *AccountsApi) AccountModifyHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountHideHandler hides an existed account by request parameters for current user
|
// AccountHideHandler hides an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountHideReq models.AccountHideRequest
|
var accountHideReq models.AccountHideRequest
|
||||||
err := c.ShouldBindJSON(&accountHideReq)
|
err := c.ShouldBindJSON(&accountHideReq)
|
||||||
|
|
||||||
@@ -335,7 +392,7 @@ func (a *AccountsApi) AccountHideHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
err = a.accounts.HideAccount(uid, []int64{accountHideReq.Id}, accountHideReq.Hidden)
|
err = a.accounts.HideAccount(c, uid, []int64{accountHideReq.Id}, accountHideReq.Hidden)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountHideHandler] failed to hide account \"id:%d\" for user \"uid:%d\", because %s", accountHideReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountHideHandler] failed to hide account \"id:%d\" for user \"uid:%d\", because %s", accountHideReq.Id, uid, err.Error())
|
||||||
@@ -347,7 +404,7 @@ func (a *AccountsApi) AccountHideHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountMoveHandler moves display order of existed accounts by request parameters for current user
|
// AccountMoveHandler moves display order of existed accounts by request parameters for current user
|
||||||
func (a *AccountsApi) AccountMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountMoveReq models.AccountMoveRequest
|
var accountMoveReq models.AccountMoveRequest
|
||||||
err := c.ShouldBindJSON(&accountMoveReq)
|
err := c.ShouldBindJSON(&accountMoveReq)
|
||||||
|
|
||||||
@@ -370,7 +427,7 @@ func (a *AccountsApi) AccountMoveHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
accounts[i] = account
|
accounts[i] = account
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.accounts.ModifyAccountDisplayOrders(uid, accounts)
|
err = a.accounts.ModifyAccountDisplayOrders(c, uid, accounts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountMoveHandler] failed to move accounts for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountMoveHandler] failed to move accounts for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -382,7 +439,7 @@ func (a *AccountsApi) AccountMoveHandler(c *core.Context) (interface{}, *errs.Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AccountDeleteHandler deletes an existed account by request parameters for current user
|
// AccountDeleteHandler deletes an existed account by request parameters for current user
|
||||||
func (a *AccountsApi) AccountDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AccountsApi) AccountDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var accountDeleteReq models.AccountDeleteRequest
|
var accountDeleteReq models.AccountDeleteRequest
|
||||||
err := c.ShouldBindJSON(&accountDeleteReq)
|
err := c.ShouldBindJSON(&accountDeleteReq)
|
||||||
|
|
||||||
@@ -392,7 +449,7 @@ func (a *AccountsApi) AccountDeleteHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
err = a.accounts.DeleteAccount(uid, accountDeleteReq.Id)
|
err = a.accounts.DeleteAccount(c, uid, accountDeleteReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[accounts.AccountDeleteHandler] failed to delete account \"id:%d\" for user \"uid:%d\", because %s", accountDeleteReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[accounts.AccountDeleteHandler] failed to delete account \"id:%d\" for user \"uid:%d\", because %s", accountDeleteReq.Id, uid, err.Error())
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const amapCustomMapStylesUrl = "https://webapi.amap.com/v4/map/styles"
|
||||||
|
const amapOverseasMapUrl = "https://fmap01.amap.com/v3/vectormap"
|
||||||
|
const amapRestApiUrl = "https://restapi.amap.com/"
|
||||||
|
|
||||||
|
// AmapApiProxy represents amap api proxy
|
||||||
|
type AmapApiProxy struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a amap api proxy singleton instance
|
||||||
|
var (
|
||||||
|
AmapApis = &AmapApiProxy{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// AmapApiProxyHandler returns amap api response
|
||||||
|
func (p *AmapApiProxy) AmapApiProxyHandler(c *core.Context) (*httputil.ReverseProxy, *errs.Error) {
|
||||||
|
var targetUrl string
|
||||||
|
|
||||||
|
if strings.HasPrefix(c.Request.RequestURI, "/_AMapService/v4/map/styles") {
|
||||||
|
targetUrl = amapCustomMapStylesUrl + strings.TrimPrefix(c.Request.URL.Path, "/_AMapService/v4/map/styles")
|
||||||
|
} else if strings.HasPrefix(c.Request.RequestURI, "/_AMapService/v3/vectormap") {
|
||||||
|
targetUrl = amapOverseasMapUrl + strings.TrimPrefix(c.Request.URL.Path, "/_AMapService/v3/vectormap")
|
||||||
|
} else {
|
||||||
|
targetUrl = amapRestApiUrl + strings.TrimPrefix(c.Request.URL.Path, "/_AMapService/")
|
||||||
|
}
|
||||||
|
|
||||||
|
director := func(req *http.Request) {
|
||||||
|
targetRawUrl := fmt.Sprintf("%s?%s&jscode=%s", targetUrl, req.URL.RawQuery, settings.Container.Current.AmapApplicationSecret)
|
||||||
|
targetUrl, _ := url.Parse(targetRawUrl)
|
||||||
|
|
||||||
|
oldCookies := req.Cookies()
|
||||||
|
req.Header.Del("Cookie")
|
||||||
|
|
||||||
|
for i := 0; i < len(oldCookies); i++ {
|
||||||
|
if strings.HasPrefix(oldCookies[i].Name, "ebk_") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
req.AddCookie(oldCookies[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
req.URL = targetUrl
|
||||||
|
req.RequestURI = req.URL.RequestURI()
|
||||||
|
req.Host = targetUrl.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
return &httputil.ReverseProxy{Director: director}, nil
|
||||||
|
}
|
||||||
+79
-30
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthorizationsApi represents authorization api
|
// AuthorizationsApi represents authorization api
|
||||||
@@ -27,7 +28,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthorizeHandler verifies and authorizes current login request
|
// AuthorizeHandler verifies and authorizes current login request
|
||||||
func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.UserLoginRequest
|
var credential models.UserLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
@@ -36,14 +37,35 @@ func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *err
|
|||||||
return nil, errs.ErrLoginNameOrPasswordInvalid
|
return nil, errs.ErrLoginNameOrPasswordInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := a.users.GetUserByUsernameOrEmailAndPassword(credential.LoginName, credential.Password)
|
user, err := a.users.GetUserByUsernameOrEmailAndPassword(c, credential.LoginName, credential.Password)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] login failed for user \"%s\", because %s", credential.LoginName, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] login failed for user \"%s\", because %s", credential.LoginName, err.Error())
|
||||||
return nil, errs.ErrLoginNameOrPasswordWrong
|
return nil, errs.ErrLoginNameOrPasswordWrong
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.users.UpdateUserLastLoginTime(user.Uid)
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] login failed for user \"%s\", because user is disabled", credential.LoginName)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableUserForceVerifyEmail && !user.EmailVerified {
|
||||||
|
hasValidEmailVerifyToken, err := a.tokens.ExistsValidTokenByType(c, user.Uid, core.USER_TOKEN_TYPE_EMAIL_VERIFY)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] failed check whether user \"uid:%d\" has valid verify email token, because %s", user.Uid, err.Error())
|
||||||
|
hasValidEmailVerifyToken = false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] login failed for user \"%s\", because user has not verified email", credential.LoginName)
|
||||||
|
|
||||||
|
return nil, errs.NewErrorWithContext(errs.ErrEmailIsNotVerified, map[string]any{
|
||||||
|
"email": user.Email,
|
||||||
|
"hasValidEmailVerifyToken": hasValidEmailVerifyToken,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.users.UpdateUserLastLoginTime(c, user.Uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] failed to update last login time for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.AuthorizeHandler] failed to update last login time for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
@@ -52,10 +74,10 @@ func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *err
|
|||||||
twoFactorEnable := a.tokens.CurrentConfig().EnableTwoFactor
|
twoFactorEnable := a.tokens.CurrentConfig().EnableTwoFactor
|
||||||
|
|
||||||
if twoFactorEnable {
|
if twoFactorEnable {
|
||||||
twoFactorEnable, err = a.twoFactorAuthorizations.ExistsTwoFactorSetting(user.Uid)
|
twoFactorEnable, err = a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, user.Uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.AuthorizeHandler] failed to check two factor setting for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.AuthorizeHandler] failed to check two-factor setting for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrSystemError)
|
return nil, errs.Or(err, errs.ErrSystemError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,9 +86,9 @@ func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *err
|
|||||||
var claims *core.UserTokenClaims
|
var claims *core.UserTokenClaims
|
||||||
|
|
||||||
if twoFactorEnable {
|
if twoFactorEnable {
|
||||||
token, claims, err = a.tokens.CreateRequire2FAToken(user, c)
|
token, claims, err = a.tokens.CreateRequire2FAToken(c, user)
|
||||||
} else {
|
} else {
|
||||||
token, claims, err = a.tokens.CreateToken(user, c)
|
token, claims, err = a.tokens.CreateToken(c, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,16 +96,20 @@ func (a *AuthorizationsApi) AuthorizeHandler(c *core.Context) (interface{}, *err
|
|||||||
return nil, errs.ErrTokenGenerating
|
return nil, errs.ErrTokenGenerating
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !twoFactorEnable {
|
||||||
|
c.SetTextualToken(token)
|
||||||
|
}
|
||||||
|
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[authorizations.AuthorizeHandler] user \"uid:%d\" has logined, token type is %d, token will be expired at %d", user.Uid, claims.Type, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[authorizations.AuthorizeHandler] user \"uid:%d\" has logined, token type is %d, token will be expired at %d", user.Uid, claims.Type, claims.ExpiresAt)
|
||||||
|
|
||||||
authResp := a.getAuthResponse(token, twoFactorEnable, user)
|
authResp := a.getAuthResponse(c, token, twoFactorEnable, user)
|
||||||
return authResp, nil
|
return authResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorAuthorizeHandler verifies and authorizes current 2fa login by passcode
|
// TwoFactorAuthorizeHandler verifies and authorizes current 2fa login by passcode
|
||||||
func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.TwoFactorLoginRequest
|
var credential models.TwoFactorLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
@@ -93,10 +119,10 @@ func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(uid)
|
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to get two factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to get two-factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrSystemError)
|
return nil, errs.Or(err, errs.ErrSystemError)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,37 +131,48 @@ func (a *AuthorizationsApi) TwoFactorAuthorizeHandler(c *core.Context) (interfac
|
|||||||
return nil, errs.ErrPasscodeInvalid
|
return nil, errs.ErrPasscodeInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to get user \"uid:%d\" info, because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to get user \"uid:%d\" info, because %s", user.Uid, err.Error())
|
||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableUserForceVerifyEmail && !user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] user \"uid:%d\" has not verified email", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsNotVerified
|
||||||
|
}
|
||||||
|
|
||||||
oldTokenClaims := c.GetTokenClaims()
|
oldTokenClaims := c.GetTokenClaims()
|
||||||
err = a.tokens.DeleteTokenByClaims(oldTokenClaims)
|
err = a.tokens.DeleteTokenByClaims(c, oldTokenClaims)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to revoke temporary token \"utid:%s\" for user \"uid:%d\", because %s", oldTokenClaims.UserTokenId, user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to revoke temporary token \"utid:%s\" for user \"uid:%d\", because %s", oldTokenClaims.UserTokenId, user.Uid, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
return nil, errs.ErrTokenGenerating
|
return nil, errs.ErrTokenGenerating
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] user \"uid:%d\" has authorized two factor via passcode, token will be expired at %d", user.Uid, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[authorizations.TwoFactorAuthorizeHandler] user \"uid:%d\" has authorized two-factor via passcode, token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
|
|
||||||
authResp := a.getAuthResponse(token, false, user)
|
authResp := a.getAuthResponse(c, token, false, user)
|
||||||
return authResp, nil
|
return authResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorAuthorizeByRecoveryCodeHandler verifies and authorizes current 2fa login by recovery code
|
// TwoFactorAuthorizeByRecoveryCodeHandler verifies and authorizes current 2fa login by recovery code
|
||||||
func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var credential models.TwoFactorRecoveryCodeLoginRequest
|
var credential models.TwoFactorRecoveryCodeLoginRequest
|
||||||
err := c.ShouldBindJSON(&credential)
|
err := c.ShouldBindJSON(&credential)
|
||||||
|
|
||||||
@@ -145,10 +182,10 @@ func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get two factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get two-factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrSystemError)
|
return nil, errs.Or(err, errs.ErrSystemError)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,46 +193,58 @@ func (a *AuthorizationsApi) TwoFactorAuthorizeByRecoveryCodeHandler(c *core.Cont
|
|||||||
return nil, errs.ErrTwoFactorIsNotEnabled
|
return nil, errs.ErrTwoFactorIsNotEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get user \"uid:%d\" info, because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get user \"uid:%d\" info, because %s", user.Uid, err.Error())
|
||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.GetAndUseUserTwoFactorRecoveryCode(uid, credential.RecoveryCode, user.Salt)
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableUserForceVerifyEmail && !user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] user \"uid:%d\" has not verified email", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsNotVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.twoFactorAuthorizations.GetAndUseUserTwoFactorRecoveryCode(c, uid, credential.RecoveryCode, user.Salt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get two factor recovery code for user \"uid:%d\", because %s", uid, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to get two-factor recovery code for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrTwoFactorRecoveryCodeNotExist)
|
return nil, errs.Or(err, errs.ErrTwoFactorRecoveryCodeNotExist)
|
||||||
}
|
}
|
||||||
|
|
||||||
oldTokenClaims := c.GetTokenClaims()
|
oldTokenClaims := c.GetTokenClaims()
|
||||||
err = a.tokens.DeleteTokenByClaims(oldTokenClaims)
|
err = a.tokens.DeleteTokenByClaims(c, oldTokenClaims)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to revoke temporary token \"utid:%s\" for user \"uid:%d\", because %s", oldTokenClaims.UserTokenId, user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to revoke temporary token \"utid:%s\" for user \"uid:%d\", because %s", oldTokenClaims.UserTokenId, user.Uid, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
return nil, errs.ErrTokenGenerating
|
return nil, errs.ErrTokenGenerating
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] user \"uid:%d\" has authorized two factor via recovery code \"%s\", token will be expired at %d", user.Uid, credential.RecoveryCode, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[authorizations.TwoFactorAuthorizeByRecoveryCodeHandler] user \"uid:%d\" has authorized two-factor via recovery code \"%s\", token will be expired at %d", user.Uid, credential.RecoveryCode, claims.ExpiresAt)
|
||||||
|
|
||||||
authResp := a.getAuthResponse(token, false, user)
|
authResp := a.getAuthResponse(c, token, false, user)
|
||||||
return authResp, nil
|
return authResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AuthorizationsApi) getAuthResponse(token string, need2FA bool, user *models.User) *models.AuthResponse {
|
func (a *AuthorizationsApi) getAuthResponse(c *core.Context, token string, need2FA bool, user *models.User) *models.AuthResponse {
|
||||||
return &models.AuthResponse{
|
return &models.AuthResponse{
|
||||||
Token: token,
|
Token: token,
|
||||||
Need2FA: need2FA,
|
Need2FA: need2FA,
|
||||||
User: user.ToUserBasicInfo(),
|
User: user.ToUserBasicInfo(),
|
||||||
|
NotificationContent: settings.Container.GetAfterLoginNotificationContent(user.Language, c.GetClientLocale()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+153
-117
@@ -19,30 +19,149 @@ const pageCountForDataExport = 1000
|
|||||||
|
|
||||||
// DataManagementsApi represents data management api
|
// DataManagementsApi represents data management api
|
||||||
type DataManagementsApi struct {
|
type DataManagementsApi struct {
|
||||||
exporter *converters.EzBookKeepingCSVFileExporter
|
ezBookKeepingCsvExporter *converters.EzBookKeepingCSVFileExporter
|
||||||
tokens *services.TokenService
|
ezBookKeepingTsvExporter *converters.EzBookKeepingTSVFileExporter
|
||||||
users *services.UserService
|
tokens *services.TokenService
|
||||||
accounts *services.AccountService
|
users *services.UserService
|
||||||
transactions *services.TransactionService
|
accounts *services.AccountService
|
||||||
categories *services.TransactionCategoryService
|
transactions *services.TransactionService
|
||||||
tags *services.TransactionTagService
|
categories *services.TransactionCategoryService
|
||||||
|
tags *services.TransactionTagService
|
||||||
|
templates *services.TransactionTemplateService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize a data management api singleton instance
|
// Initialize a data management api singleton instance
|
||||||
var (
|
var (
|
||||||
DataManagements = &DataManagementsApi{
|
DataManagements = &DataManagementsApi{
|
||||||
exporter: &converters.EzBookKeepingCSVFileExporter{},
|
ezBookKeepingCsvExporter: &converters.EzBookKeepingCSVFileExporter{},
|
||||||
tokens: services.Tokens,
|
ezBookKeepingTsvExporter: &converters.EzBookKeepingTSVFileExporter{},
|
||||||
users: services.Users,
|
tokens: services.Tokens,
|
||||||
accounts: services.Accounts,
|
users: services.Users,
|
||||||
transactions: services.Transactions,
|
accounts: services.Accounts,
|
||||||
categories: services.TransactionCategories,
|
transactions: services.Transactions,
|
||||||
tags: services.TransactionTags,
|
categories: services.TransactionCategories,
|
||||||
|
tags: services.TransactionTags,
|
||||||
|
templates: services.TransactionTemplates,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExportDataHandler returns exported data in csv format
|
// ExportDataToEzbookkeepingCSVHandler returns exported data in csv format
|
||||||
func (a *DataManagementsApi) ExportDataHandler(c *core.Context) ([]byte, string, *errs.Error) {
|
func (a *DataManagementsApi) ExportDataToEzbookkeepingCSVHandler(c *core.Context) ([]byte, string, *errs.Error) {
|
||||||
|
return a.getExportedFileContent(c, "csv")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportDataToEzbookkeepingTSVHandler returns exported data in csv format
|
||||||
|
func (a *DataManagementsApi) ExportDataToEzbookkeepingTSVHandler(c *core.Context) ([]byte, string, *errs.Error) {
|
||||||
|
return a.getExportedFileContent(c, "tsv")
|
||||||
|
}
|
||||||
|
|
||||||
|
// DataStatisticsHandler returns user data statistics
|
||||||
|
func (a *DataManagementsApi) DataStatisticsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
totalAccountCount, err := a.accounts.GetTotalAccountCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total account count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
totalTransactionCategoryCount, err := a.categories.GetTotalCategoryCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction category count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
totalTransactionTagCount, err := a.tags.GetTotalTagCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction tag count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
totalTransactionCount, err := a.transactions.GetTotalTransactionCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
totalTransactionTemplateCount, err := a.templates.GetTotalNormalTemplateCountByUid(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction template count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
dataStatisticsResp := &models.DataStatisticsResponse{
|
||||||
|
TotalAccountCount: totalAccountCount,
|
||||||
|
TotalTransactionCategoryCount: totalTransactionCategoryCount,
|
||||||
|
TotalTransactionTagCount: totalTransactionTagCount,
|
||||||
|
TotalTransactionCount: totalTransactionCount,
|
||||||
|
TotalTransactionTemplateCount: totalTransactionTemplateCount,
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataStatisticsResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDataHandler deletes all user data
|
||||||
|
func (a *DataManagementsApi) ClearDataHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var clearDataReq models.ClearDataRequest
|
||||||
|
err := c.ShouldBindJSON(&clearDataReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[data_managements.ClearDataHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.WarnfWithRequestId(c, "[data_managements.ClearDataHandler] failed to get user for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if !a.users.IsPasswordEqualsUserPassword(clearDataReq.Password, user) {
|
||||||
|
return nil, errs.ErrUserPasswordWrong
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.transactions.DeleteAllTransactions(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transactions, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.categories.DeleteAllCategories(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transaction categories, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.tags.DeleteAllTags(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transaction tags, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.templates.DeleteAllTemplates(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transaction templates, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[data_managements.ClearDataHandler] user \"uid:%d\" has cleared all data", uid)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *DataManagementsApi) getExportedFileContent(c *core.Context, fileType string) ([]byte, string, *errs.Error) {
|
||||||
if !settings.Container.Current.EnableDataExport {
|
if !settings.Container.Current.EnableDataExport {
|
||||||
return nil, "", errs.ErrDataExportNotAllowed
|
return nil, "", errs.ErrDataExportNotAllowed
|
||||||
}
|
}
|
||||||
@@ -57,7 +176,7 @@ func (a *DataManagementsApi) ExportDataHandler(c *core.Context) ([]byte, string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -67,28 +186,28 @@ func (a *DataManagementsApi) ExportDataHandler(c *core.Context) ([]byte, string,
|
|||||||
return nil, "", errs.ErrUserNotFound
|
return nil, "", errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts, err := a.accounts.GetAllAccountsByUid(uid)
|
accounts, err := a.accounts.GetAllAccountsByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get all accounts for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get all accounts for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, "", errs.ErrOperationFailed
|
return nil, "", errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
categories, err := a.categories.GetAllCategoriesByUid(uid, 0, -1)
|
categories, err := a.categories.GetAllCategoriesByUid(c, uid, 0, -1)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get categories for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get categories for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, "", errs.ErrOperationFailed
|
return nil, "", errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
tags, err := a.tags.GetAllTagsByUid(uid)
|
tags, err := a.tags.GetAllTagsByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get tags for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get tags for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, "", errs.ErrOperationFailed
|
return nil, "", errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
tagIndexs, err := a.tags.GetAllTagIdsOfAllTransactions(uid)
|
tagIndexes, err := a.tags.GetAllTagIdsMapOfAllTransactions(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get tag index for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get tag index for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -99,121 +218,38 @@ func (a *DataManagementsApi) ExportDataHandler(c *core.Context) ([]byte, string,
|
|||||||
categoryMap := a.categories.GetCategoryMapByList(categories)
|
categoryMap := a.categories.GetCategoryMapByList(categories)
|
||||||
tagMap := a.tags.GetTagMapByList(tags)
|
tagMap := a.tags.GetTagMapByList(tags)
|
||||||
|
|
||||||
allTransactions, err := a.transactions.GetAllTransactions(uid, pageCountForDataExport, true)
|
allTransactions, err := a.transactions.GetAllTransactions(c, uid, pageCountForDataExport, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to all transactions user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to all transactions user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, "", errs.ErrOperationFailed
|
return nil, "", errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := a.exporter.ToExportedContent(uid, timezone, allTransactions, accountMap, categoryMap, tagMap, tagIndexs)
|
var dataExporter converters.DataConverter
|
||||||
|
|
||||||
|
if fileType == "tsv" {
|
||||||
|
dataExporter = a.ezBookKeepingTsvExporter
|
||||||
|
} else {
|
||||||
|
dataExporter = a.ezBookKeepingCsvExporter
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexes)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get csv format exported data for \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get csv format exported data for \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, "", errs.Or(err, errs.ErrOperationFailed)
|
return nil, "", errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := a.getFileName(user, timezone)
|
fileName := a.getFileName(user, timezone, fileType)
|
||||||
|
|
||||||
return result, fileName, nil
|
return result, fileName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataStatisticsHandler returns user data statistics
|
func (a *DataManagementsApi) getFileName(user *models.User, timezone *time.Location, fileExtension string) string {
|
||||||
func (a *DataManagementsApi) DataStatisticsHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
totalAccountCount, err := a.accounts.GetTotalAccountCountByUid(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total account count for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.ErrOperationFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
totalTransactionCategoryCount, err := a.categories.GetTotalCategoryCountByUid(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction category count for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.ErrOperationFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
totalTransactionTagCount, err := a.tags.GetTotalTagCountByUid(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction tag count for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.ErrOperationFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
totalTransactionCount, err := a.transactions.GetTotalTransactionCountByUid(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.DataStatisticsHandler] failed to get total transaction count for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.ErrOperationFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
dataStatisticsResp := &models.DataStatisticsResponse{
|
|
||||||
TotalAccountCount: totalAccountCount,
|
|
||||||
TotalTransactionCategoryCount: totalTransactionCategoryCount,
|
|
||||||
TotalTransactionTagCount: totalTransactionTagCount,
|
|
||||||
TotalTransactionCount: totalTransactionCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataStatisticsResp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDataHandler deletes all user data
|
|
||||||
func (a *DataManagementsApi) ClearDataHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var clearDataReq models.ClearDataRequest
|
|
||||||
err := c.ShouldBindJSON(&clearDataReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[data_managements.ClearDataHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
user, err := a.users.GetUserById(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
if !errs.IsCustomError(err) {
|
|
||||||
log.WarnfWithRequestId(c, "[data_managements.ClearDataHandler] failed to get user for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, errs.ErrUserNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
if !a.users.IsPasswordEqualsUserPassword(clearDataReq.Password, user) {
|
|
||||||
return nil, errs.ErrUserPasswordWrong
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.transactions.DeleteAllTransactions(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transactions, because %s", err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.categories.DeleteAllCategories(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transaction categories, because %s", err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.tags.DeleteAllTags(uid)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[data_managements.ClearDataHandler] failed to delete all transaction tags, because %s", err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[data_managements.ClearDataHandler] user \"uid:%d\" has cleared all data", uid)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *DataManagementsApi) getFileName(user *models.User, timezone *time.Location) string {
|
|
||||||
currentTime := utils.FormatUnixTimeToLongDateTimeWithoutSecond(time.Now().Unix(), timezone)
|
currentTime := utils.FormatUnixTimeToLongDateTimeWithoutSecond(time.Now().Unix(), timezone)
|
||||||
currentTime = strings.Replace(currentTime, "-", "_", -1)
|
currentTime = strings.Replace(currentTime, "-", "_", -1)
|
||||||
currentTime = strings.Replace(currentTime, " ", "_", -1)
|
currentTime = strings.Replace(currentTime, " ", "_", -1)
|
||||||
currentTime = strings.Replace(currentTime, ":", "_", -1)
|
currentTime = strings.Replace(currentTime, ":", "_", -1)
|
||||||
|
|
||||||
return fmt.Sprintf("%s_%s.csv", user.Username, currentTime)
|
return fmt.Sprintf("%s_%s.%s", user.Username, currentTime, fileExtension)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -14,11 +14,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ApiNotFound returns api not found error
|
// ApiNotFound returns api not found error
|
||||||
func (a *DefaultApi) ApiNotFound(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DefaultApi) ApiNotFound(c *core.Context) (any, *errs.Error) {
|
||||||
return nil, errs.ErrApiNotFound
|
return nil, errs.ErrApiNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// MethodNotAllowed returns method not allowed error
|
// MethodNotAllowed returns method not allowed error
|
||||||
func (a *DefaultApi) MethodNotAllowed(c *core.Context) (interface{}, *errs.Error) {
|
func (a *DefaultApi) MethodNotAllowed(c *core.Context) (any, *errs.Error) {
|
||||||
return nil, errs.ErrMethodNotAllowed
|
return nil, errs.ErrMethodNotAllowed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -12,6 +14,7 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExchangeRatesApi represents exchange rate api
|
// ExchangeRatesApi represents exchange rate api
|
||||||
@@ -23,7 +26,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// LatestExchangeRateHandler returns latest exchange rate data
|
// LatestExchangeRateHandler returns latest exchange rate data
|
||||||
func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
dataSource := exchangerates.Container.Current
|
dataSource := exchangerates.Container.Current
|
||||||
|
|
||||||
if dataSource == nil {
|
if dataSource == nil {
|
||||||
@@ -32,15 +35,28 @@ func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (interface
|
|||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
|
transport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
utils.SetProxyUrl(transport, settings.Container.Current.ExchangeRatesProxy)
|
||||||
|
|
||||||
|
if settings.Container.Current.ExchangeRatesSkipTLSVerify {
|
||||||
|
transport.TLSClientConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Duration(settings.Container.Current.ExchangeRatesRequestTimeout) * time.Millisecond,
|
Transport: transport,
|
||||||
|
Timeout: time.Duration(settings.Container.Current.ExchangeRatesRequestTimeout) * time.Millisecond,
|
||||||
}
|
}
|
||||||
|
|
||||||
urls := dataSource.GetRequestUrls()
|
urls := dataSource.GetRequestUrls()
|
||||||
exchangeRateResps := make([]*models.LatestExchangeRateResponse, 0, len(urls))
|
exchangeRateResps := make([]*models.LatestExchangeRateResponse, 0, len(urls))
|
||||||
|
|
||||||
for i := 0; i < len(urls); i++ {
|
for i := 0; i < len(urls); i++ {
|
||||||
resp, err := client.Get(urls[i])
|
req, _ := http.NewRequest("GET", urls[i], nil)
|
||||||
|
req.Header.Set("User-Agent", fmt.Sprintf("ezBookkeeping/%s ", settings.Version))
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[exchange_rates.LatestExchangeRateHandler] failed to request latest exchange rate data for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[exchange_rates.LatestExchangeRateHandler] failed to request latest exchange rate data for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ForgetPasswordsApi represents user forget password api
|
||||||
|
type ForgetPasswordsApi struct {
|
||||||
|
users *services.UserService
|
||||||
|
tokens *services.TokenService
|
||||||
|
forgetPasswords *services.ForgetPasswordService
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a user api singleton instance
|
||||||
|
var (
|
||||||
|
ForgetPasswords = &ForgetPasswordsApi{
|
||||||
|
users: services.Users,
|
||||||
|
tokens: services.Tokens,
|
||||||
|
forgetPasswords: services.ForgetPasswords,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserForgetPasswordRequestHandler generates password reset link and send user an email with this link
|
||||||
|
func (a *ForgetPasswordsApi) UserForgetPasswordRequestHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var request models.ForgetPasswordRequest
|
||||||
|
err := c.ShouldBindJSON(&request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.ErrEmailIsEmptyOrInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := a.users.GetUserByEmail(c, request.Email)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.ForgetPasswordRequireVerifyEmail && !user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] user \"uid:%d\" has not verified email", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsNotVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
if !settings.Container.Current.EnableSMTP {
|
||||||
|
return nil, errs.ErrSMTPServerNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
token, _, err := a.tokens.CreatePasswordResetToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrTokenGenerating
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = a.forgetPasswords.SendPasswordResetEmail(c, user, token, c.GetClientLocale())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserForgetPasswordRequestHandler] cannot send email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserResetPasswordHandler resets user password by request parameters
|
||||||
|
func (a *ForgetPasswordsApi) UserResetPasswordHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var request models.PasswordResetRequest
|
||||||
|
err := c.ShouldBindJSON(&request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.ForgetPasswordRequireVerifyEmail && !user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] user \"uid:%d\" has not verified email", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsNotVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Email != request.Email {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] request email not equals the user email")
|
||||||
|
return nil, errs.ErrEmptyIsInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.users.IsPasswordEqualsUserPassword(request.Password, user) {
|
||||||
|
oldTokenClaims := c.GetTokenClaims()
|
||||||
|
err = a.tokens.DeleteTokenByClaims(c, oldTokenClaims)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] failed to revoke password reset token \"utid:%s\" for user \"uid:%d\", because %s", oldTokenClaims.UserTokenId, user.Uid, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrNewPasswordEqualsOldInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
userNew := &models.User{
|
||||||
|
Uid: user.Uid,
|
||||||
|
Salt: user.Salt,
|
||||||
|
Password: request.Password,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, err = a.users.UpdateUser(c, userNew, false)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] failed to update user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix()
|
||||||
|
err = a.tokens.DeleteTokensBeforeTime(c, uid, now)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
log.InfofWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] revoke old tokens before unix time \"%d\" for user \"uid:%d\"", now, user.Uid)
|
||||||
|
} else {
|
||||||
|
log.WarnfWithRequestId(c, "[forget_passwords.UserResetPasswordHandler] failed to revoke old tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
+1
-1
@@ -15,7 +15,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// HealthStatusHandler returns the health status of current service
|
// HealthStatusHandler returns the health status of current service
|
||||||
func (a *HealthsApi) HealthStatusHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *HealthsApi) HealthStatusHandler(c *core.Context) (any, *errs.Error) {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
|
|
||||||
result["version"] = settings.Version
|
result["version"] = settings.Version
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const openStreetMapTileImageUrlFormat = "https://tile.openstreetmap.org/%s/%s/%s" // https://tile.openstreetmap.org/{z}/{x}/{y}.png
|
const openStreetMapTileImageUrlFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" // https://tile.openstreetmap.org/{z}/{x}/{y}.png
|
||||||
|
const openStreetMapHumanitarianStyleTileImageUrlFormat = "https://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png" // https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png
|
||||||
|
const openTopoMapTileImageUrlFormat = "https://tile.opentopomap.org/{z}/{x}/{y}.png" // https://tile.opentopomap.org/{z}/{x}/{y}.png
|
||||||
|
const opnvKarteMapTileImageUrlFormat = "https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png" // https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png
|
||||||
|
const cyclOSMMapTileImageUrlFormat = "https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png" // https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png
|
||||||
|
const cartoDBMapTileImageUrlFormat = "https://a.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{scale}.png" // https://{s}.basemaps.cartocdn.com/{style}/{z}/{x}/{y}{scale}.png
|
||||||
|
const tomtomMapTileImageUrlFormat = "https://api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.png" // https://api.tomtom.com/map/{versionNumber}/tile/{layer}/{style}/{z}/{x}/{y}.png?key={key}&language={language}
|
||||||
|
const tianDiTuMapTileImageUrlFormat = "https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" // https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk={key}
|
||||||
|
const tianDiTuMapAnnotationUrlFormat = "https://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" // https://t{s}.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk={key}
|
||||||
|
|
||||||
// MapImageProxy represents map image proxy
|
// MapImageProxy represents map image proxy
|
||||||
type MapImageProxy struct {
|
type MapImageProxy struct {
|
||||||
@@ -21,14 +31,88 @@ var (
|
|||||||
MapImages = &MapImageProxy{}
|
MapImages = &MapImageProxy{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// OpenStreetMapTileImageProxyHandler returns open street map tile image
|
// MapTileImageProxyHandler returns map tile image
|
||||||
func (p *MapImageProxy) OpenStreetMapTileImageProxyHandler(c *core.Context) (*httputil.ReverseProxy, *errs.Error) {
|
func (p *MapImageProxy) MapTileImageProxyHandler(c *core.Context) (*httputil.ReverseProxy, *errs.Error) {
|
||||||
director := func(req *http.Request) {
|
return p.mapImageProxyHandler(c, func(c *core.Context, mapProvider string) (string, *errs.Error) {
|
||||||
zoomLevel := c.Param("zoomLevel")
|
if mapProvider == settings.OpenStreetMapProvider {
|
||||||
coordinateX := c.Param("coordinateX")
|
return openStreetMapTileImageUrlFormat, nil
|
||||||
fileName := c.Param("fileName")
|
} else if mapProvider == settings.OpenStreetMapHumanitarianStyleProvider {
|
||||||
|
return openStreetMapHumanitarianStyleTileImageUrlFormat, nil
|
||||||
|
} else if mapProvider == settings.OpenTopoMapProvider {
|
||||||
|
return openTopoMapTileImageUrlFormat, nil
|
||||||
|
} else if mapProvider == settings.OPNVKarteMapProvider {
|
||||||
|
return opnvKarteMapTileImageUrlFormat, nil
|
||||||
|
} else if mapProvider == settings.CyclOSMMapProvider {
|
||||||
|
return cyclOSMMapTileImageUrlFormat, nil
|
||||||
|
} else if mapProvider == settings.CartoDBMapProvider {
|
||||||
|
return cartoDBMapTileImageUrlFormat, nil
|
||||||
|
} else if mapProvider == settings.TomTomMapProvider {
|
||||||
|
targetUrl := tomtomMapTileImageUrlFormat + "?key=" + settings.Container.Current.TomTomMapAPIKey
|
||||||
|
language := c.Query("language")
|
||||||
|
|
||||||
imageRawUrl := fmt.Sprintf(openStreetMapTileImageUrlFormat, zoomLevel, coordinateX, fileName)
|
if language != "" {
|
||||||
|
targetUrl = targetUrl + "&language=" + language
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetUrl, nil
|
||||||
|
} else if mapProvider == settings.TianDiTuProvider {
|
||||||
|
return tianDiTuMapTileImageUrlFormat + "&tk=" + settings.Container.Current.TianDiTuAPIKey, nil
|
||||||
|
} else if mapProvider == settings.CustomProvider {
|
||||||
|
return settings.Container.Current.CustomMapTileServerTileLayerUrl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", errs.ErrParameterInvalid
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapAnnotationImageProxyHandler returns map annotation image
|
||||||
|
func (p *MapImageProxy) MapAnnotationImageProxyHandler(c *core.Context) (*httputil.ReverseProxy, *errs.Error) {
|
||||||
|
return p.mapImageProxyHandler(c, func(c *core.Context, mapProvider string) (string, *errs.Error) {
|
||||||
|
if mapProvider == settings.TianDiTuProvider {
|
||||||
|
return tianDiTuMapAnnotationUrlFormat + "&tk=" + settings.Container.Current.TianDiTuAPIKey, nil
|
||||||
|
} else if mapProvider == settings.CustomProvider {
|
||||||
|
return settings.Container.Current.CustomMapTileServerAnnotationLayerUrl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", errs.ErrParameterInvalid
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *MapImageProxy) mapImageProxyHandler(c *core.Context, fn func(c *core.Context, mapProvider string) (string, *errs.Error)) (*httputil.ReverseProxy, *errs.Error) {
|
||||||
|
mapProvider := strings.Replace(c.Query("provider"), "-", "_", -1)
|
||||||
|
targetUrl := ""
|
||||||
|
|
||||||
|
if mapProvider != settings.Container.Current.MapProvider {
|
||||||
|
return nil, errs.ErrMapProviderNotCurrent
|
||||||
|
}
|
||||||
|
|
||||||
|
zoomLevel := c.Param("zoomLevel")
|
||||||
|
coordinateX := c.Param("coordinateX")
|
||||||
|
fileName := c.Param("fileName")
|
||||||
|
fileNameParts := strings.Split(fileName, ".")
|
||||||
|
coordinateY := fileNameParts[0]
|
||||||
|
scale := c.Query("scale")
|
||||||
|
|
||||||
|
if len(fileNameParts) != 2 || fileNameParts[len(fileNameParts)-1] != "png" {
|
||||||
|
return nil, errs.ErrImageExtensionNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
var err *errs.Error
|
||||||
|
targetUrl, err = fn(c, mapProvider)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
transport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
utils.SetProxyUrl(transport, settings.Container.Current.MapProxy)
|
||||||
|
|
||||||
|
director := func(req *http.Request) {
|
||||||
|
imageRawUrl := targetUrl
|
||||||
|
imageRawUrl = strings.Replace(imageRawUrl, "{z}", zoomLevel, -1)
|
||||||
|
imageRawUrl = strings.Replace(imageRawUrl, "{x}", coordinateX, -1)
|
||||||
|
imageRawUrl = strings.Replace(imageRawUrl, "{y}", coordinateY, -1)
|
||||||
|
imageRawUrl = strings.Replace(imageRawUrl, "{scale}", scale, -1)
|
||||||
imageUrl, _ := url.Parse(imageRawUrl)
|
imageUrl, _ := url.Parse(imageRawUrl)
|
||||||
|
|
||||||
req.URL = imageUrl
|
req.URL = imageUrl
|
||||||
@@ -36,5 +120,8 @@ func (p *MapImageProxy) OpenStreetMapTileImageProxyHandler(c *core.Context) (*ht
|
|||||||
req.Host = imageUrl.Host
|
req.Host = imageUrl.Host
|
||||||
}
|
}
|
||||||
|
|
||||||
return &httputil.ReverseProxy{Director: director}, nil
|
return &httputil.ReverseProxy{
|
||||||
|
Transport: transport,
|
||||||
|
Director: director,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"image/png"
|
||||||
|
|
||||||
|
"github.com/boombuler/barcode"
|
||||||
|
"github.com/boombuler/barcode/qr"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
qrCodeDefaultWidth int = 320
|
||||||
|
qrCodeDefaultHeight int = 320
|
||||||
|
)
|
||||||
|
|
||||||
|
// QrCodesApi represents qrcode generator api
|
||||||
|
type QrCodesApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a qrcode generator api singleton instance
|
||||||
|
var (
|
||||||
|
QrCodes = &QrCodesApi{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// MobileUrlQrCodeHandler returns a mobile url qr code image
|
||||||
|
func (a *QrCodesApi) MobileUrlQrCodeHandler(c *core.Context) ([]byte, string, *errs.Error) {
|
||||||
|
fullUrl := settings.Container.Current.RootUrl + "mobile"
|
||||||
|
data, err := a.generateUrlQrCode(c, fullUrl)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
return data, "image/png", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *QrCodesApi) generateUrlQrCode(c *core.Context, url string) ([]byte, *errs.Error) {
|
||||||
|
qrCodeImg, _ := qr.Encode(url, qr.M, qr.Auto)
|
||||||
|
qrCodeImg, _ = barcode.Scale(qrCodeImg, qrCodeDefaultWidth, qrCodeDefaultHeight)
|
||||||
|
imgData := &bytes.Buffer{}
|
||||||
|
|
||||||
|
if err := png.Encode(imgData, qrCodeImg); err != nil {
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
return imgData.Bytes(), nil
|
||||||
|
}
|
||||||
+54
-18
@@ -2,12 +2,14 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,9 +28,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TokenListHandler returns available token list of current user
|
// TokenListHandler returns available token list of current user
|
||||||
func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tokens, err := a.tokens.GetAllUnexpiredNormalTokensByUid(uid)
|
tokens, err := a.tokens.GetAllUnexpiredNormalTokensByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[tokens.TokenListHandler] failed to get all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[tokens.TokenListHandler] failed to get all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -44,8 +46,7 @@ func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error)
|
|||||||
TokenId: a.tokens.GenerateTokenId(token),
|
TokenId: a.tokens.GenerateTokenId(token),
|
||||||
TokenType: token.TokenType,
|
TokenType: token.TokenType,
|
||||||
UserAgent: token.UserAgent,
|
UserAgent: token.UserAgent,
|
||||||
CreatedAt: token.CreatedUnixTime,
|
LastSeen: token.LastSeenUnixTime,
|
||||||
ExpiredAt: token.ExpiredUnixTime,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if token.Uid == claims.Uid && utils.Int64ToString(token.UserTokenId) == claims.UserTokenId && token.CreatedUnixTime == claims.IssuedAt {
|
if token.Uid == claims.Uid && utils.Int64ToString(token.UserTokenId) == claims.UserTokenId && token.CreatedUnixTime == claims.IssuedAt {
|
||||||
@@ -61,7 +62,7 @@ func (a *TokensApi) TokenListHandler(c *core.Context) (interface{}, *errs.Error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeCurrentHandler revokes current token of current user
|
// TokenRevokeCurrentHandler revokes current token of current user
|
||||||
func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (any, *errs.Error) {
|
||||||
_, claims, err := a.tokens.ParseTokenByHeader(c)
|
_, claims, err := a.tokens.ParseTokenByHeader(c)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -82,7 +83,7 @@ func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
tokenId := a.tokens.GenerateTokenId(tokenRecord)
|
tokenId := a.tokens.GenerateTokenId(tokenRecord)
|
||||||
err = a.tokens.DeleteToken(tokenRecord)
|
err = a.tokens.DeleteToken(c, tokenRecord)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[token.TokenRevokeCurrentHandler] failed to revoke token \"id:%s\" for user \"uid:%d\", because %s", tokenId, claims.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[token.TokenRevokeCurrentHandler] failed to revoke token \"id:%s\" for user \"uid:%d\", because %s", tokenId, claims.Uid, err.Error())
|
||||||
@@ -94,7 +95,7 @@ func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeHandler revokes specific token of current user
|
// TokenRevokeHandler revokes specific token of current user
|
||||||
func (a *TokensApi) TokenRevokeHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tokenRevokeReq models.TokenRevokeRequest
|
var tokenRevokeReq models.TokenRevokeRequest
|
||||||
err := c.ShouldBindJSON(&tokenRevokeReq)
|
err := c.ShouldBindJSON(&tokenRevokeReq)
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ func (a *TokensApi) TokenRevokeHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
return nil, errs.ErrInvalidTokenId
|
return nil, errs.ErrInvalidTokenId
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.tokens.DeleteToken(tokenRecord)
|
err = a.tokens.DeleteToken(c, tokenRecord)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[token.TokenRevokeHandler] failed to revoke token \"id:%s\" for user \"uid:%d\", because %s", tokenRevokeReq.TokenId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[token.TokenRevokeHandler] failed to revoke token \"id:%s\" for user \"uid:%d\", because %s", tokenRevokeReq.TokenId, uid, err.Error())
|
||||||
@@ -132,9 +133,9 @@ func (a *TokensApi) TokenRevokeHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeAllHandler revokes all tokens of current user except current token
|
// TokenRevokeAllHandler revokes all tokens of current user except current token
|
||||||
func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tokens, err := a.tokens.GetAllTokensByUid(uid)
|
tokens, err := a.tokens.GetAllTokensByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[tokens.TokenRevokeAllHandler] failed to get all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[tokens.TokenRevokeAllHandler] failed to get all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -155,7 +156,7 @@ func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (interface{}, *errs.E
|
|||||||
|
|
||||||
tokens = append(tokens[:currentTokenIndex], tokens[currentTokenIndex+1:]...)
|
tokens = append(tokens[:currentTokenIndex], tokens[currentTokenIndex+1:]...)
|
||||||
|
|
||||||
err = a.tokens.DeleteTokens(uid, tokens)
|
err = a.tokens.DeleteTokens(c, uid, tokens)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[token.TokenRevokeAllHandler] failed to revoke all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[token.TokenRevokeAllHandler] failed to revoke all tokens for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -167,23 +168,56 @@ func (a *TokensApi) TokenRevokeAllHandler(c *core.Context) (interface{}, *errs.E
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TokenRefreshHandler refresh current token of current user
|
// TokenRefreshHandler refresh current token of current user
|
||||||
func (a *TokensApi) TokenRefreshHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TokensApi) TokenRefreshHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[token.TokenRefreshHandler] failed to get user \"uid:%d\" info, because %s", uid, err.Error())
|
log.WarnfWithRequestId(c, "[token.TokenRefreshHandler] failed to get user \"uid:%d\" info, because %s", uid, err.Error())
|
||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
now := time.Now().Unix()
|
||||||
|
oldTokenClaims := c.GetTokenClaims()
|
||||||
|
|
||||||
|
if now-oldTokenClaims.IssuedAt < int64(settings.Container.Current.TokenMinRefreshInterval) {
|
||||||
|
log.InfofWithRequestId(c, "[token.TokenRefreshHandler] token of user \"uid:%d\" does not need to be refreshed", uid)
|
||||||
|
|
||||||
|
userTokenId, err := utils.StringToInt64(oldTokenClaims.UserTokenId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[tokens.TokenRefreshHandler] parse user token id failed, because %s", err.Error())
|
||||||
|
} else {
|
||||||
|
tokenRecord := &models.TokenRecord{
|
||||||
|
Uid: oldTokenClaims.Uid,
|
||||||
|
UserTokenId: userTokenId,
|
||||||
|
CreatedUnixTime: oldTokenClaims.IssuedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenId := a.tokens.GenerateTokenId(tokenRecord)
|
||||||
|
|
||||||
|
err = a.tokens.UpdateTokenLastSeen(c, tokenRecord)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[token.TokenRefreshHandler] failed to update last seen of token \"id:%s\" for user \"uid:%d\", because %s", tokenId, uid, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshResp := &models.TokenRefreshResponse{
|
||||||
|
User: user.ToUserBasicInfo(),
|
||||||
|
NotificationContent: settings.Container.GetAfterOpenNotificationContent(user.Language, c.GetClientLocale()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return refreshResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[token.TokenRefreshHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[token.TokenRefreshHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrTokenGenerating)
|
return nil, errs.Or(err, errs.ErrTokenGenerating)
|
||||||
}
|
}
|
||||||
|
|
||||||
oldTokenClaims := c.GetTokenClaims()
|
|
||||||
oldUserTokenId, _ := utils.StringToInt64(oldTokenClaims.UserTokenId)
|
oldUserTokenId, _ := utils.StringToInt64(oldTokenClaims.UserTokenId)
|
||||||
oldTokenRecord := &models.TokenRecord{
|
oldTokenRecord := &models.TokenRecord{
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
@@ -191,14 +225,16 @@ func (a *TokensApi) TokenRefreshHandler(c *core.Context) (interface{}, *errs.Err
|
|||||||
CreatedUnixTime: oldTokenClaims.IssuedAt,
|
CreatedUnixTime: oldTokenClaims.IssuedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[token.TokenRefreshHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[token.TokenRefreshHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
|
|
||||||
refreshResp := &models.TokenRefreshResponse{
|
refreshResp := &models.TokenRefreshResponse{
|
||||||
NewToken: token,
|
NewToken: token,
|
||||||
OldTokenId: a.tokens.GenerateTokenId(oldTokenRecord),
|
OldTokenId: a.tokens.GenerateTokenId(oldTokenRecord),
|
||||||
User: user.ToUserBasicInfo(),
|
User: user.ToUserBasicInfo(),
|
||||||
|
NotificationContent: settings.Container.GetAfterOpenNotificationContent(user.Language, c.GetClientLocale()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return refreshResp, nil
|
return refreshResp, nil
|
||||||
|
|||||||
+220
-148
@@ -3,11 +3,16 @@ package api
|
|||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/duplicatechecker"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransactionCategoriesApi represents transaction category api
|
// TransactionCategoriesApi represents transaction category api
|
||||||
@@ -23,7 +28,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CategoryListHandler returns transaction category list of current user
|
// CategoryListHandler returns transaction category list of current user
|
||||||
func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryListReq models.TransactionCategoryListRequest
|
var categoryListReq models.TransactionCategoryListRequest
|
||||||
err := c.ShouldBindQuery(&categoryListReq)
|
err := c.ShouldBindQuery(&categoryListReq)
|
||||||
|
|
||||||
@@ -33,7 +38,7 @@ func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
categories, err := a.categories.GetAllCategoriesByUid(uid, categoryListReq.Type, categoryListReq.ParentId)
|
categories, err := a.categories.GetAllCategoriesByUid(c, uid, categoryListReq.Type, categoryListReq.ParentId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryListHandler] failed to get categories for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryListHandler] failed to get categories for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -44,7 +49,7 @@ func (a *TransactionCategoriesApi) CategoryListHandler(c *core.Context) (interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryGetHandler returns one specific transaction category of current user
|
// CategoryGetHandler returns one specific transaction category of current user
|
||||||
func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryGetReq models.TransactionCategoryGetRequest
|
var categoryGetReq models.TransactionCategoryGetRequest
|
||||||
err := c.ShouldBindQuery(&categoryGetReq)
|
err := c.ShouldBindQuery(&categoryGetReq)
|
||||||
|
|
||||||
@@ -54,7 +59,7 @@ func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
category, err := a.categories.GetCategoryByCategoryId(uid, categoryGetReq.Id)
|
category, err := a.categories.GetCategoryByCategoryId(c, uid, categoryGetReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryGetHandler] failed to get category \"id:%d\" for user \"uid:%d\", because %s", categoryGetReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryGetHandler] failed to get category \"id:%d\" for user \"uid:%d\", because %s", categoryGetReq.Id, uid, err.Error())
|
||||||
@@ -67,7 +72,7 @@ func (a *TransactionCategoriesApi) CategoryGetHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CategoryCreateHandler saves a new transaction category by request parameters for current user
|
// CategoryCreateHandler saves a new transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryCreateReq models.TransactionCategoryCreateRequest
|
var categoryCreateReq models.TransactionCategoryCreateRequest
|
||||||
err := c.ShouldBindJSON(&categoryCreateReq)
|
err := c.ShouldBindJSON(&categoryCreateReq)
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (inter
|
|||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
if categoryCreateReq.ParentId > 0 {
|
if categoryCreateReq.ParentId > 0 {
|
||||||
parentCategory, err := a.categories.GetCategoryByCategoryId(uid, categoryCreateReq.ParentId)
|
parentCategory, err := a.categories.GetCategoryByCategoryId(c, uid, categoryCreateReq.ParentId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateHandler] failed to get parent category \"id:%d\" for user \"uid:%d\", because %s", categoryCreateReq.ParentId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateHandler] failed to get parent category \"id:%d\" for user \"uid:%d\", because %s", categoryCreateReq.ParentId, uid, err.Error())
|
||||||
@@ -105,9 +110,9 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (inter
|
|||||||
var maxOrderId int32
|
var maxOrderId int32
|
||||||
|
|
||||||
if categoryCreateReq.ParentId <= 0 {
|
if categoryCreateReq.ParentId <= 0 {
|
||||||
maxOrderId, err = a.categories.GetMaxDisplayOrder(uid, categoryCreateReq.Type)
|
maxOrderId, err = a.categories.GetMaxDisplayOrder(c, uid, categoryCreateReq.Type)
|
||||||
} else {
|
} else {
|
||||||
maxOrderId, err = a.categories.GetMaxSubCategoryDisplayOrder(uid, categoryCreateReq.Type, categoryCreateReq.ParentId)
|
maxOrderId, err = a.categories.GetMaxSubCategoryDisplayOrder(c, uid, categoryCreateReq.Type, categoryCreateReq.ParentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -117,7 +122,29 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (inter
|
|||||||
|
|
||||||
category := a.createNewCategoryModel(uid, &categoryCreateReq, maxOrderId+1)
|
category := a.createNewCategoryModel(uid, &categoryCreateReq, maxOrderId+1)
|
||||||
|
|
||||||
err = a.categories.CreateCategory(category)
|
if settings.Container.Current.EnableDuplicateSubmissionsCheck && categoryCreateReq.ClientSessionId != "" {
|
||||||
|
found, remark := duplicatechecker.Container.Get(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_CATEGORY, uid, categoryCreateReq.ClientSessionId)
|
||||||
|
|
||||||
|
if found {
|
||||||
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryCreateHandler] another category \"id:%s\" has been created for user \"uid:%d\"", remark, uid)
|
||||||
|
categoryId, err := utils.StringToInt64(remark)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
category, err = a.categories.GetCategoryByCategoryId(c, uid, categoryId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateHandler] failed to get existed category \"id:%d\" for user \"uid:%d\", because %s", categoryId, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
categoryResp := category.ToTransactionCategoryInfoResponse()
|
||||||
|
|
||||||
|
return categoryResp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.categories.CreateCategory(c, category)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateHandler] failed to create category \"id:%d\" for user \"uid:%d\", because %s", category.CategoryId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateHandler] failed to create category \"id:%d\" for user \"uid:%d\", because %s", category.CategoryId, uid, err.Error())
|
||||||
@@ -126,15 +153,16 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.Context) (inter
|
|||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryCreateHandler] user \"uid:%d\" has created a new category \"id:%d\" successfully", uid, category.CategoryId)
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryCreateHandler] user \"uid:%d\" has created a new category \"id:%d\" successfully", uid, category.CategoryId)
|
||||||
|
|
||||||
|
duplicatechecker.Container.Set(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_CATEGORY, uid, categoryCreateReq.ClientSessionId, utils.Int64ToString(category.CategoryId))
|
||||||
categoryResp := category.ToTransactionCategoryInfoResponse()
|
categoryResp := category.ToTransactionCategoryInfoResponse()
|
||||||
|
|
||||||
return categoryResp, nil
|
return categoryResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CategoryCreateBatchHandler saves some new transaction category by request parameters for current user
|
// CategoryCreateBatchHandler saves some new transaction category by request parameters for current user
|
||||||
func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var categoryCreateBatchReq models.TransactionCategoryCreateBatchRequest
|
var categoryCreateBatchReq models.TransactionCategoryCreateBatchRequest
|
||||||
err := c.ShouldBindJSON(&categoryCreateBatchReq)
|
err := c.ShouldBindBodyWith(&categoryCreateBatchReq, binding.JSON)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] parse request failed, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] parse request failed, because %s", err.Error())
|
||||||
@@ -143,6 +171,182 @@ func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (
|
|||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
|
categories, err := a.createBatchCategories(c, uid, &categoryCreateBatchReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.getTransactionCategoryListByTypeResponse(categories, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CategoryModifyHandler saves an existed transaction category by request parameters for current user
|
||||||
|
func (a *TransactionCategoriesApi) CategoryModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var categoryModifyReq models.TransactionCategoryModifyRequest
|
||||||
|
err := c.ShouldBindJSON(&categoryModifyReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
category, err := a.categories.GetCategoryByCategoryId(c, uid, categoryModifyReq.Id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to get category \"id:%d\" for user \"uid:%d\", because %s", categoryModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
newCategory := &models.TransactionCategory{
|
||||||
|
CategoryId: category.CategoryId,
|
||||||
|
Uid: uid,
|
||||||
|
ParentCategoryId: categoryModifyReq.ParentId,
|
||||||
|
Name: categoryModifyReq.Name,
|
||||||
|
Icon: categoryModifyReq.Icon,
|
||||||
|
Color: categoryModifyReq.Color,
|
||||||
|
Comment: categoryModifyReq.Comment,
|
||||||
|
Hidden: categoryModifyReq.Hidden,
|
||||||
|
}
|
||||||
|
|
||||||
|
if newCategory.ParentCategoryId == category.ParentCategoryId &&
|
||||||
|
newCategory.Name == category.Name &&
|
||||||
|
newCategory.Icon == category.Icon &&
|
||||||
|
newCategory.Color == category.Color &&
|
||||||
|
newCategory.Comment == category.Comment &&
|
||||||
|
newCategory.Hidden == category.Hidden {
|
||||||
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
|
}
|
||||||
|
|
||||||
|
if category.ParentCategoryId == 0 && newCategory.ParentCategoryId != 0 {
|
||||||
|
return nil, errs.Or(err, errs.ErrNotAllowChangePrimaryTransactionCategoryToSecondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
if category.ParentCategoryId != 0 && newCategory.ParentCategoryId == 0 {
|
||||||
|
return nil, errs.Or(err, errs.ErrNotAllowChangeSecondaryTransactionCategoryToPrimary)
|
||||||
|
}
|
||||||
|
|
||||||
|
if newCategory.ParentCategoryId != category.ParentCategoryId {
|
||||||
|
fromPrimaryCategory, err := a.categories.GetCategoryByCategoryId(c, uid, category.ParentCategoryId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to get old primary category \"id:%d\" of category \"id:%d\" for user \"uid:%d\", because %s", category.ParentCategoryId, categoryModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
toPrimaryCategory, err := a.categories.GetCategoryByCategoryId(c, uid, newCategory.ParentCategoryId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to get new primary category \"id:%d\" of category \"id:%d\" for user \"uid:%d\", because %s", newCategory.ParentCategoryId, categoryModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
if fromPrimaryCategory.Type != toPrimaryCategory.Type {
|
||||||
|
return nil, errs.Or(err, errs.ErrNotAllowChangePrimaryTransactionType)
|
||||||
|
}
|
||||||
|
|
||||||
|
if toPrimaryCategory.ParentCategoryId != 0 {
|
||||||
|
return nil, errs.Or(err, errs.ErrNotAllowUseSecondaryTransactionAsPrimaryCategory)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.categories.ModifyCategory(c, newCategory)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to update category \"id:%d\" for user \"uid:%d\", because %s", categoryModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryModifyHandler] user \"uid:%d\" has updated category \"id:%d\" successfully", uid, categoryModifyReq.Id)
|
||||||
|
|
||||||
|
newCategory.Type = category.Type
|
||||||
|
newCategory.DisplayOrder = category.DisplayOrder
|
||||||
|
categoryResp := newCategory.ToTransactionCategoryInfoResponse()
|
||||||
|
|
||||||
|
return categoryResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CategoryHideHandler hides an existed transaction category by request parameters for current user
|
||||||
|
func (a *TransactionCategoriesApi) CategoryHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var categoryHideReq models.TransactionCategoryHideRequest
|
||||||
|
err := c.ShouldBindJSON(&categoryHideReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_categories.CategoryHideHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
err = a.categories.HideCategory(c, uid, []int64{categoryHideReq.Id}, categoryHideReq.Hidden)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryHideHandler] failed to hide category \"id:%d\" for user \"uid:%d\", because %s", categoryHideReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryHideHandler] user \"uid:%d\" has hidden category \"id:%d\"", uid, categoryHideReq.Id)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CategoryMoveHandler moves display order of existed transaction categories by request parameters for current user
|
||||||
|
func (a *TransactionCategoriesApi) CategoryMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var categoryMoveReq models.TransactionCategoryMoveRequest
|
||||||
|
err := c.ShouldBindJSON(&categoryMoveReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_categories.CategoryMoveHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
categories := make([]*models.TransactionCategory, len(categoryMoveReq.NewDisplayOrders))
|
||||||
|
|
||||||
|
for i := 0; i < len(categoryMoveReq.NewDisplayOrders); i++ {
|
||||||
|
newDisplayOrder := categoryMoveReq.NewDisplayOrders[i]
|
||||||
|
category := &models.TransactionCategory{
|
||||||
|
Uid: uid,
|
||||||
|
CategoryId: newDisplayOrder.Id,
|
||||||
|
DisplayOrder: newDisplayOrder.DisplayOrder,
|
||||||
|
}
|
||||||
|
|
||||||
|
categories[i] = category
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.categories.ModifyCategoryDisplayOrders(c, uid, categories)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryMoveHandler] failed to move categories for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryMoveHandler] user \"uid:%d\" has moved categories", uid)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CategoryDeleteHandler deletes an existed transaction category by request parameters for current user
|
||||||
|
func (a *TransactionCategoriesApi) CategoryDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var categoryDeleteReq models.TransactionCategoryDeleteRequest
|
||||||
|
err := c.ShouldBindJSON(&categoryDeleteReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
err = a.categories.DeleteCategory(c, uid, categoryDeleteReq.Id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] failed to delete category \"id:%d\" for user \"uid:%d\", because %s", categoryDeleteReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] user \"uid:%d\" has deleted category \"id:%d\"", uid, categoryDeleteReq.Id)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *TransactionCategoriesApi) createBatchCategories(c *core.Context, uid int64, categoryCreateBatchReq *models.TransactionCategoryCreateBatchRequest) ([]*models.TransactionCategory, error) {
|
||||||
|
var err error
|
||||||
categoryTypeMaxOrderMap := make(map[models.TransactionCategoryType]int32)
|
categoryTypeMaxOrderMap := make(map[models.TransactionCategoryType]int32)
|
||||||
categoriesMap := make(map[*models.TransactionCategory][]*models.TransactionCategory)
|
categoriesMap := make(map[*models.TransactionCategory][]*models.TransactionCategory)
|
||||||
categoriesMap[nil] = make([]*models.TransactionCategory, len(categoryCreateBatchReq.Categories))
|
categoriesMap[nil] = make([]*models.TransactionCategory, len(categoryCreateBatchReq.Categories))
|
||||||
@@ -153,7 +357,7 @@ func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (
|
|||||||
var maxOrderId, exists = categoryTypeMaxOrderMap[categoryCreateReq.Type]
|
var maxOrderId, exists = categoryTypeMaxOrderMap[categoryCreateReq.Type]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
maxOrderId, err = a.categories.GetMaxDisplayOrder(uid, categoryCreateReq.Type)
|
maxOrderId, err = a.categories.GetMaxDisplayOrder(c, uid, categoryCreateReq.Type)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -181,148 +385,16 @@ func (a *TransactionCategoriesApi) CategoryCreateBatchHandler(c *core.Context) (
|
|||||||
totalCount++
|
totalCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
categories, err := a.categories.CreateCategories(uid, categoriesMap)
|
categories, err := a.categories.CreateCategories(c, uid, categoriesMap)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] failed to create categories for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_categories.createBatchCategories] failed to create categories for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryCreateBatchHandler] user \"uid:%d\" has created categoroies successfully", uid)
|
log.InfofWithRequestId(c, "[transaction_categories.createBatchCategories] user \"uid:%d\" has created categories successfully", uid)
|
||||||
|
|
||||||
return a.getTransactionCategoryListByTypeResponse(categories, 0)
|
return categories, nil
|
||||||
}
|
|
||||||
|
|
||||||
// CategoryModifyHandler saves an existed transaction category by request parameters for current user
|
|
||||||
func (a *TransactionCategoriesApi) CategoryModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var categoryModifyReq models.TransactionCategoryModifyRequest
|
|
||||||
err := c.ShouldBindJSON(&categoryModifyReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
category, err := a.categories.GetCategoryByCategoryId(uid, categoryModifyReq.Id)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to get category \"id:%d\" for user \"uid:%d\", because %s", categoryModifyReq.Id, uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
newCategory := &models.TransactionCategory{
|
|
||||||
CategoryId: category.CategoryId,
|
|
||||||
Uid: uid,
|
|
||||||
Name: categoryModifyReq.Name,
|
|
||||||
Icon: categoryModifyReq.Icon,
|
|
||||||
Color: categoryModifyReq.Color,
|
|
||||||
Comment: categoryModifyReq.Comment,
|
|
||||||
Hidden: categoryModifyReq.Hidden,
|
|
||||||
}
|
|
||||||
|
|
||||||
if newCategory.Name == category.Name &&
|
|
||||||
newCategory.Icon == category.Icon &&
|
|
||||||
newCategory.Color == category.Color &&
|
|
||||||
newCategory.Comment == category.Comment &&
|
|
||||||
newCategory.Hidden == category.Hidden {
|
|
||||||
return nil, errs.ErrNothingWillBeUpdated
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.categories.ModifyCategory(newCategory)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryModifyHandler] failed to update category \"id:%d\" for user \"uid:%d\", because %s", categoryModifyReq.Id, uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryModifyHandler] user \"uid:%d\" has updated category \"id:%d\" successfully", uid, categoryModifyReq.Id)
|
|
||||||
|
|
||||||
newCategory.Type = category.Type
|
|
||||||
newCategory.ParentCategoryId = category.ParentCategoryId
|
|
||||||
newCategory.DisplayOrder = category.DisplayOrder
|
|
||||||
categoryResp := newCategory.ToTransactionCategoryInfoResponse()
|
|
||||||
|
|
||||||
return categoryResp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CategoryHideHandler hides an existed transaction category by request parameters for current user
|
|
||||||
func (a *TransactionCategoriesApi) CategoryHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var categoryHideReq models.TransactionCategoryHideRequest
|
|
||||||
err := c.ShouldBindJSON(&categoryHideReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transaction_categories.CategoryHideHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
err = a.categories.HideCategory(uid, []int64{categoryHideReq.Id}, categoryHideReq.Hidden)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryHideHandler] failed to hide category \"id:%d\" for user \"uid:%d\", because %s", categoryHideReq.Id, uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryHideHandler] user \"uid:%d\" has hidden category \"id:%d\"", uid, categoryHideReq.Id)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CategoryMoveHandler moves display order of existed transaction categories by request parameters for current user
|
|
||||||
func (a *TransactionCategoriesApi) CategoryMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var categoryMoveReq models.TransactionCategoryMoveRequest
|
|
||||||
err := c.ShouldBindJSON(&categoryMoveReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transaction_categories.CategoryMoveHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
categories := make([]*models.TransactionCategory, len(categoryMoveReq.NewDisplayOrders))
|
|
||||||
|
|
||||||
for i := 0; i < len(categoryMoveReq.NewDisplayOrders); i++ {
|
|
||||||
newDisplayOrder := categoryMoveReq.NewDisplayOrders[i]
|
|
||||||
category := &models.TransactionCategory{
|
|
||||||
Uid: uid,
|
|
||||||
CategoryId: newDisplayOrder.Id,
|
|
||||||
DisplayOrder: newDisplayOrder.DisplayOrder,
|
|
||||||
}
|
|
||||||
|
|
||||||
categories[i] = category
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.categories.ModifyCategoryDisplayOrders(uid, categories)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryMoveHandler] failed to move categories for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryMoveHandler] user \"uid:%d\" has moved categories", uid)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CategoryDeleteHandler deletes an existed transaction category by request parameters for current user
|
|
||||||
func (a *TransactionCategoriesApi) CategoryDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var categoryDeleteReq models.TransactionCategoryDeleteRequest
|
|
||||||
err := c.ShouldBindJSON(&categoryDeleteReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
err = a.categories.DeleteCategory(uid, categoryDeleteReq.Id)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] failed to delete category \"id:%d\" for user \"uid:%d\", because %s", categoryDeleteReq.Id, uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_categories.CategoryDeleteHandler] user \"uid:%d\" has deleted category \"id:%d\"", uid, categoryDeleteReq.Id)
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *TransactionCategoriesApi) createNewCategoryModel(uid int64, categoryCreateReq *models.TransactionCategoryCreateRequest, order int32) *models.TransactionCategory {
|
func (a *TransactionCategoriesApi) createNewCategoryModel(uid int64, categoryCreateReq *models.TransactionCategoryCreateRequest, order int32) *models.TransactionCategory {
|
||||||
|
|||||||
+22
-22
@@ -23,9 +23,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TagListHandler returns transaction tag list of current user
|
// TagListHandler returns transaction tag list of current user
|
||||||
func (a *TransactionTagsApi) TagListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tags, err := a.tags.GetAllTagsByUid(uid)
|
tags, err := a.tags.GetAllTagsByUid(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagListHandler] failed to get tags for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagListHandler] failed to get tags for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -44,7 +44,7 @@ func (a *TransactionTagsApi) TagListHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagGetHandler returns one specific transaction tag of current user
|
// TagGetHandler returns one specific transaction tag of current user
|
||||||
func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagGetReq models.TransactionTagGetRequest
|
var tagGetReq models.TransactionTagGetRequest
|
||||||
err := c.ShouldBindQuery(&tagGetReq)
|
err := c.ShouldBindQuery(&tagGetReq)
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tag, err := a.tags.GetTagByTagId(uid, tagGetReq.Id)
|
tag, err := a.tags.GetTagByTagId(c, uid, tagGetReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagGetHandler] failed to get tag \"id:%d\" for user \"uid:%d\", because %s", tagGetReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagGetHandler] failed to get tag \"id:%d\" for user \"uid:%d\", because %s", tagGetReq.Id, uid, err.Error())
|
||||||
@@ -67,7 +67,7 @@ func (a *TransactionTagsApi) TagGetHandler(c *core.Context) (interface{}, *errs.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagCreateHandler saves a new transaction tag by request parameters for current user
|
// TagCreateHandler saves a new transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagCreateReq models.TransactionTagCreateRequest
|
var tagCreateReq models.TransactionTagCreateRequest
|
||||||
err := c.ShouldBindJSON(&tagCreateReq)
|
err := c.ShouldBindJSON(&tagCreateReq)
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *er
|
|||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
maxOrderId, err := a.tags.GetMaxDisplayOrder(uid)
|
maxOrderId, err := a.tags.GetMaxDisplayOrder(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagCreateHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagCreateHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -87,7 +87,7 @@ func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *er
|
|||||||
|
|
||||||
tag := a.createNewTagModel(uid, &tagCreateReq, maxOrderId+1)
|
tag := a.createNewTagModel(uid, &tagCreateReq, maxOrderId+1)
|
||||||
|
|
||||||
err = a.tags.CreateTag(tag)
|
err = a.tags.CreateTag(c, tag)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagCreateHandler] failed to create tag \"id:%d\" for user \"uid:%d\", because %s", tag.TagId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagCreateHandler] failed to create tag \"id:%d\" for user \"uid:%d\", because %s", tag.TagId, uid, err.Error())
|
||||||
@@ -102,7 +102,7 @@ func (a *TransactionTagsApi) TagCreateHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagModifyHandler saves an existed transaction tag by request parameters for current user
|
// TagModifyHandler saves an existed transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagModifyReq models.TransactionTagModifyRequest
|
var tagModifyReq models.TransactionTagModifyRequest
|
||||||
err := c.ShouldBindJSON(&tagModifyReq)
|
err := c.ShouldBindJSON(&tagModifyReq)
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
tag, err := a.tags.GetTagByTagId(uid, tagModifyReq.Id)
|
tag, err := a.tags.GetTagByTagId(c, uid, tagModifyReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagModifyHandler] failed to get tag \"id:%d\" for user \"uid:%d\", because %s", tagModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagModifyHandler] failed to get tag \"id:%d\" for user \"uid:%d\", because %s", tagModifyReq.Id, uid, err.Error())
|
||||||
@@ -129,7 +129,7 @@ func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *er
|
|||||||
return nil, errs.ErrNothingWillBeUpdated
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.tags.ModifyTag(newTag)
|
err = a.tags.ModifyTag(c, newTag)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagModifyHandler] failed to update tag \"id:%d\" for user \"uid:%d\", because %s", tagModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagModifyHandler] failed to update tag \"id:%d\" for user \"uid:%d\", because %s", tagModifyReq.Id, uid, err.Error())
|
||||||
@@ -145,34 +145,34 @@ func (a *TransactionTagsApi) TagModifyHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TagHideHandler hides an transaction tag by request parameters for current user
|
// TagHideHandler hides an transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagHideHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagHideReq models.TransactionTagHideRequest
|
var tagHideReq models.TransactionTagHideRequest
|
||||||
err := c.ShouldBindJSON(&tagHideReq)
|
err := c.ShouldBindJSON(&tagHideReq)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transaction_tags.CategoryHideHandler] parse request failed, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transaction_tags.TagHideHandler] parse request failed, because %s", err.Error())
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
err = a.tags.HideTag(uid, []int64{tagHideReq.Id}, tagHideReq.Hidden)
|
err = a.tags.HideTag(c, uid, []int64{tagHideReq.Id}, tagHideReq.Hidden)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.CategoryHideHandler] failed to hide tag \"id:%d\" for user \"uid:%d\", because %s", tagHideReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagHideHandler] failed to hide tag \"id:%d\" for user \"uid:%d\", because %s", tagHideReq.Id, uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_tags.CategoryHideHandler] user \"uid:%d\" has hidden category \"id:%d\"", uid, tagHideReq.Id)
|
log.InfofWithRequestId(c, "[transaction_tags.TagHideHandler] user \"uid:%d\" has hidden tag \"id:%d\"", uid, tagHideReq.Id)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TagMoveHandler moves display order of existed transaction tags by request parameters for current user
|
// TagMoveHandler moves display order of existed transaction tags by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagMoveReq models.TransactionTagMoveRequest
|
var tagMoveReq models.TransactionTagMoveRequest
|
||||||
err := c.ShouldBindJSON(&tagMoveReq)
|
err := c.ShouldBindJSON(&tagMoveReq)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transaction_tags.CategoryMoveHandler] parse request failed, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transaction_tags.TagMoveHandler] parse request failed, because %s", err.Error())
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,19 +190,19 @@ func (a *TransactionTagsApi) TagMoveHandler(c *core.Context) (interface{}, *errs
|
|||||||
tags[i] = tag
|
tags[i] = tag
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.tags.ModifyTagDisplayOrders(uid, tags)
|
err = a.tags.ModifyTagDisplayOrders(c, uid, tags)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.CategoryMoveHandler] failed to move tags for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagMoveHandler] failed to move tags for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[transaction_tags.CategoryMoveHandler] user \"uid:%d\" has moved categories", uid)
|
log.InfofWithRequestId(c, "[transaction_tags.TagMoveHandler] user \"uid:%d\" has moved tags", uid)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TagDeleteHandler deletes an existed transaction tag by request parameters for current user
|
// TagDeleteHandler deletes an existed transaction tag by request parameters for current user
|
||||||
func (a *TransactionTagsApi) TagDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionTagsApi) TagDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var tagDeleteReq models.TransactionTagDeleteRequest
|
var tagDeleteReq models.TransactionTagDeleteRequest
|
||||||
err := c.ShouldBindJSON(&tagDeleteReq)
|
err := c.ShouldBindJSON(&tagDeleteReq)
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ func (a *TransactionTagsApi) TagDeleteHandler(c *core.Context) (interface{}, *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
err = a.tags.DeleteTag(uid, tagDeleteReq.Id)
|
err = a.tags.DeleteTag(c, uid, tagDeleteReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transaction_tags.TagDeleteHandler] failed to delete tag \"id:%d\" for user \"uid:%d\", because %s", tagDeleteReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transaction_tags.TagDeleteHandler] failed to delete tag \"id:%d\" for user \"uid:%d\", because %s", tagDeleteReq.Id, uid, err.Error())
|
||||||
|
|||||||
@@ -0,0 +1,321 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/duplicatechecker"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TransactionTemplatesApi represents transaction template api
|
||||||
|
type TransactionTemplatesApi struct {
|
||||||
|
templates *services.TransactionTemplateService
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a transaction template api singleton instance
|
||||||
|
var (
|
||||||
|
TransactionTemplates = &TransactionTemplatesApi{
|
||||||
|
templates: services.TransactionTemplates,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// TemplateListHandler returns transaction template list of current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateListReq models.TransactionTemplateListRequest
|
||||||
|
err := c.ShouldBindQuery(&templateListReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateListHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if templateListReq.TemplateType < models.TRANSACTION_TEMPLATE_TYPE_NORMAL || templateListReq.TemplateType > models.TRANSACTION_TEMPLATE_TYPE_NORMAL {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateListHandler] template type invalid, type is %d", templateListReq.TemplateType)
|
||||||
|
return nil, errs.ErrTransactionTemplateTypeInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
templates, err := a.templates.GetAllTemplatesByUid(c, uid, templateListReq.TemplateType)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateListHandler] failed to get templates for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
templateResps := make(models.TransactionTemplateInfoResponseSlice, len(templates))
|
||||||
|
serverUtcOffset := utils.GetServerTimezoneOffsetMinutes()
|
||||||
|
|
||||||
|
for i := 0; i < len(templates); i++ {
|
||||||
|
templateResps[i] = templates[i].ToTransactionTemplateInfoResponse(serverUtcOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(templateResps)
|
||||||
|
|
||||||
|
return templateResps, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateGetHandler returns one specific transaction template of current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateGetReq models.TransactionTemplateGetRequest
|
||||||
|
err := c.ShouldBindQuery(&templateGetReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateGetHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
template, err := a.templates.GetTemplateByTemplateId(c, uid, templateGetReq.Id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateGetHandler] failed to get template \"id:%d\" for user \"uid:%d\", because %s", templateGetReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
serverUtcOffset := utils.GetServerTimezoneOffsetMinutes()
|
||||||
|
templateResp := template.ToTransactionTemplateInfoResponse(serverUtcOffset)
|
||||||
|
|
||||||
|
return templateResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateCreateHandler saves a new transaction template by request parameters for current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateCreateReq models.TransactionTemplateCreateRequest
|
||||||
|
err := c.ShouldBindJSON(&templateCreateReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if templateCreateReq.TemplateType < models.TRANSACTION_TEMPLATE_TYPE_NORMAL || templateCreateReq.TemplateType > models.TRANSACTION_TEMPLATE_TYPE_NORMAL {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] template type invalid, type is %d", templateCreateReq.TemplateType)
|
||||||
|
return nil, errs.ErrTransactionTemplateTypeInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if templateCreateReq.Type <= models.TRANSACTION_TYPE_MODIFY_BALANCE || templateCreateReq.Type > models.TRANSACTION_TYPE_TRANSFER {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] transaction type invalid, type is %d", templateCreateReq.Type)
|
||||||
|
return nil, errs.ErrTransactionTypeInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
|
maxOrderId, err := a.templates.GetMaxDisplayOrder(c, uid, templateCreateReq.TemplateType)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] failed to get max display order for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
serverUtcOffset := utils.GetServerTimezoneOffsetMinutes()
|
||||||
|
template := a.createNewTemplateModel(uid, &templateCreateReq, maxOrderId+1)
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableDuplicateSubmissionsCheck && templateCreateReq.ClientSessionId != "" {
|
||||||
|
found, remark := duplicatechecker.Container.Get(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE, uid, templateCreateReq.ClientSessionId)
|
||||||
|
|
||||||
|
if found {
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateCreateHandler] another template \"id:%s\" has been created for user \"uid:%d\"", remark, uid)
|
||||||
|
templateId, err := utils.StringToInt64(remark)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
template, err = a.templates.GetTemplateByTemplateId(c, uid, templateId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] failed to get existed template \"id:%d\" for user \"uid:%d\", because %s", templateId, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
templateResp := template.ToTransactionTemplateInfoResponse(serverUtcOffset)
|
||||||
|
|
||||||
|
return templateResp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.templates.CreateTemplate(c, template)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateCreateHandler] failed to create template \"id:%d\" for user \"uid:%d\", because %s", template.TemplateId, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateCreateHandler] user \"uid:%d\" has created a new template \"id:%d\" successfully", uid, template.TemplateId)
|
||||||
|
|
||||||
|
duplicatechecker.Container.Set(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE, uid, templateCreateReq.ClientSessionId, utils.Int64ToString(template.TemplateId))
|
||||||
|
templateResp := template.ToTransactionTemplateInfoResponse(serverUtcOffset)
|
||||||
|
|
||||||
|
return templateResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateModifyHandler saves an existed transaction template by request parameters for current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateModifyReq models.TransactionTemplateModifyRequest
|
||||||
|
err := c.ShouldBindJSON(&templateModifyReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateModifyHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if templateModifyReq.Type <= models.TRANSACTION_TYPE_MODIFY_BALANCE || templateModifyReq.Type > models.TRANSACTION_TYPE_TRANSFER {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateModifyHandler] transaction type invalid, type is %d", templateModifyReq.Type)
|
||||||
|
return nil, errs.ErrTransactionTypeInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
template, err := a.templates.GetTemplateByTemplateId(c, uid, templateModifyReq.Id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateModifyHandler] failed to get template \"id:%d\" for user \"uid:%d\", because %s", templateModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
newTemplate := &models.TransactionTemplate{
|
||||||
|
TemplateId: template.TemplateId,
|
||||||
|
Uid: uid,
|
||||||
|
Name: templateModifyReq.Name,
|
||||||
|
Type: templateModifyReq.Type,
|
||||||
|
CategoryId: templateModifyReq.CategoryId,
|
||||||
|
AccountId: templateModifyReq.SourceAccountId,
|
||||||
|
TagIds: strings.Join(templateModifyReq.TagIds, ","),
|
||||||
|
Amount: templateModifyReq.SourceAmount,
|
||||||
|
RelatedAccountId: templateModifyReq.DestinationAccountId,
|
||||||
|
RelatedAccountAmount: templateModifyReq.DestinationAmount,
|
||||||
|
HideAmount: templateModifyReq.HideAmount,
|
||||||
|
Comment: templateModifyReq.Comment,
|
||||||
|
}
|
||||||
|
|
||||||
|
if newTemplate.Name == template.Name &&
|
||||||
|
newTemplate.Type == template.Type &&
|
||||||
|
newTemplate.CategoryId == template.CategoryId &&
|
||||||
|
newTemplate.AccountId == template.AccountId &&
|
||||||
|
newTemplate.TagIds == template.TagIds &&
|
||||||
|
newTemplate.Amount == template.Amount &&
|
||||||
|
newTemplate.RelatedAccountId == template.RelatedAccountId &&
|
||||||
|
newTemplate.RelatedAccountAmount == template.RelatedAccountAmount &&
|
||||||
|
newTemplate.HideAmount == template.HideAmount &&
|
||||||
|
newTemplate.Comment == template.Comment {
|
||||||
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.templates.ModifyTemplate(c, newTemplate)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateModifyHandler] failed to update template \"id:%d\" for user \"uid:%d\", because %s", templateModifyReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateModifyHandler] user \"uid:%d\" has updated template \"id:%d\" successfully", uid, templateModifyReq.Id)
|
||||||
|
|
||||||
|
serverUtcOffset := utils.GetServerTimezoneOffsetMinutes()
|
||||||
|
newTemplate.TemplateType = template.TemplateType
|
||||||
|
newTemplate.DisplayOrder = template.DisplayOrder
|
||||||
|
newTemplate.Hidden = template.Hidden
|
||||||
|
templateResp := newTemplate.ToTransactionTemplateInfoResponse(serverUtcOffset)
|
||||||
|
|
||||||
|
return templateResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateHideHandler hides an transaction template by request parameters for current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateHideHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateHideReq models.TransactionTemplateHideRequest
|
||||||
|
err := c.ShouldBindJSON(&templateHideReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateHideHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
err = a.templates.HideTemplate(c, uid, []int64{templateHideReq.Id}, templateHideReq.Hidden)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateHideHandler] failed to hide template \"id:%d\" for user \"uid:%d\", because %s", templateHideReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateHideHandler] user \"uid:%d\" has hidden template \"id:%d\"", uid, templateHideReq.Id)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateMoveHandler moves display order of existed transaction templates by request parameters for current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateMoveHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateMoveReq models.TransactionTemplateMoveRequest
|
||||||
|
err := c.ShouldBindJSON(&templateMoveReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.CategoryMoveHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
templates := make([]*models.TransactionTemplate, len(templateMoveReq.NewDisplayOrders))
|
||||||
|
|
||||||
|
for i := 0; i < len(templateMoveReq.NewDisplayOrders); i++ {
|
||||||
|
newDisplayOrder := templateMoveReq.NewDisplayOrders[i]
|
||||||
|
template := &models.TransactionTemplate{
|
||||||
|
Uid: uid,
|
||||||
|
TemplateId: newDisplayOrder.Id,
|
||||||
|
DisplayOrder: newDisplayOrder.DisplayOrder,
|
||||||
|
}
|
||||||
|
|
||||||
|
templates[i] = template
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.templates.ModifyTemplateDisplayOrders(c, uid, templates)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateMoveHandler] failed to move templates for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateMoveHandler] user \"uid:%d\" has moved templates", uid)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateDeleteHandler deletes an existed transaction template by request parameters for current user
|
||||||
|
func (a *TransactionTemplatesApi) TemplateDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var templateDeleteReq models.TransactionTemplateDeleteRequest
|
||||||
|
err := c.ShouldBindJSON(&templateDeleteReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transaction_templates.TemplateDeleteHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
err = a.templates.DeleteTemplate(c, uid, templateDeleteReq.Id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transaction_templates.TemplateDeleteHandler] failed to delete template \"id:%d\" for user \"uid:%d\", because %s", templateDeleteReq.Id, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[transaction_templates.TemplateDeleteHandler] user \"uid:%d\" has deleted template \"id:%d\"", uid, templateDeleteReq.Id)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *TransactionTemplatesApi) createNewTemplateModel(uid int64, templateCreateReq *models.TransactionTemplateCreateRequest, order int32) *models.TransactionTemplate {
|
||||||
|
return &models.TransactionTemplate{
|
||||||
|
Uid: uid,
|
||||||
|
TemplateType: templateCreateReq.TemplateType,
|
||||||
|
Name: templateCreateReq.Name,
|
||||||
|
Type: templateCreateReq.Type,
|
||||||
|
CategoryId: templateCreateReq.CategoryId,
|
||||||
|
AccountId: templateCreateReq.SourceAccountId,
|
||||||
|
TagIds: strings.Join(templateCreateReq.TagIds, ","),
|
||||||
|
Amount: templateCreateReq.SourceAmount,
|
||||||
|
RelatedAccountId: templateCreateReq.DestinationAccountId,
|
||||||
|
RelatedAccountAmount: templateCreateReq.DestinationAmount,
|
||||||
|
HideAmount: templateCreateReq.HideAmount,
|
||||||
|
Comment: templateCreateReq.Comment,
|
||||||
|
DisplayOrder: order,
|
||||||
|
}
|
||||||
|
}
|
||||||
+290
-185
@@ -4,16 +4,18 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
orderedmap "github.com/wk8/go-ordered-map/v2"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/duplicatechecker"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pageCountForLoadTransactionAmounts = 1000
|
|
||||||
|
|
||||||
// TransactionsApi represents transaction api
|
// TransactionsApi represents transaction api
|
||||||
type TransactionsApi struct {
|
type TransactionsApi struct {
|
||||||
transactions *services.TransactionService
|
transactions *services.TransactionService
|
||||||
@@ -35,7 +37,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TransactionCountHandler returns transaction total count of current user
|
// TransactionCountHandler returns transaction total count of current user
|
||||||
func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionCountReq models.TransactionCountRequest
|
var transactionCountReq models.TransactionCountRequest
|
||||||
err := c.ShouldBindQuery(&transactionCountReq)
|
err := c.ShouldBindQuery(&transactionCountReq)
|
||||||
|
|
||||||
@@ -46,21 +48,33 @@ func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (interface{},
|
|||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
allAccountIds, err := a.getAccountOrSubAccountIds(transactionCountReq.AccountId, uid)
|
allAccountIds, err := a.getAccountOrSubAccountIds(c, transactionCountReq.AccountIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionCountHandler] get account error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionCountHandler] get account error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
allCategoryIds, err := a.getCategoryOrSubCategoryIds(transactionCountReq.CategoryId, uid)
|
allCategoryIds, err := a.getCategoryOrSubCategoryIds(c, transactionCountReq.CategoryIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionCountHandler] get transaction category error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionCountHandler] get transaction category error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
totalCount, err := a.transactions.GetTransactionCount(uid, transactionCountReq.MaxTime, transactionCountReq.MinTime, transactionCountReq.Type, allCategoryIds, allAccountIds, transactionCountReq.Keyword)
|
var allTagIds []int64
|
||||||
|
noTags := transactionCountReq.TagIds == "none"
|
||||||
|
|
||||||
|
if !noTags {
|
||||||
|
allTagIds, err = a.getTagIds(transactionCountReq.TagIds)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionCountHandler] get transaction tag ids error, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalCount, err := a.transactions.GetTransactionCount(c, uid, transactionCountReq.MaxTime, transactionCountReq.MinTime, transactionCountReq.Type, allCategoryIds, allAccountIds, allTagIds, noTags, transactionCountReq.AmountFilter, transactionCountReq.Keyword)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionCountHandler] failed to get transaction count for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionCountHandler] failed to get transaction count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -75,7 +89,7 @@ func (a *TransactionsApi) TransactionCountHandler(c *core.Context) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionListHandler returns transaction list of current user
|
// TransactionListHandler returns transaction list of current user
|
||||||
func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionListReq models.TransactionListByMaxTimeRequest
|
var transactionListReq models.TransactionListByMaxTimeRequest
|
||||||
err := c.ShouldBindQuery(&transactionListReq)
|
err := c.ShouldBindQuery(&transactionListReq)
|
||||||
|
|
||||||
@@ -92,7 +106,7 @@ func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -102,21 +116,44 @@ func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{},
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
allAccountIds, err := a.getAccountOrSubAccountIds(transactionListReq.AccountId, uid)
|
allAccountIds, err := a.getAccountOrSubAccountIds(c, transactionListReq.AccountIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionListHandler] get account error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionListHandler] get account error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
allCategoryIds, err := a.getCategoryOrSubCategoryIds(transactionListReq.CategoryId, uid)
|
allCategoryIds, err := a.getCategoryOrSubCategoryIds(c, transactionListReq.CategoryIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionListHandler] get transaction category error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionListHandler] get transaction category error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := a.transactions.GetTransactionsByMaxTime(uid, transactionListReq.MaxTime, transactionListReq.MinTime, transactionListReq.Type, allCategoryIds, allAccountIds, transactionListReq.Keyword, transactionListReq.Count+1, true)
|
var allTagIds []int64
|
||||||
|
noTags := transactionListReq.TagIds == "none"
|
||||||
|
|
||||||
|
if !noTags {
|
||||||
|
allTagIds, err = a.getTagIds(transactionListReq.TagIds)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionListHandler] get transaction tag ids error, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalCount int64
|
||||||
|
|
||||||
|
if transactionListReq.WithCount {
|
||||||
|
totalCount, err = a.transactions.GetTransactionCount(c, uid, transactionListReq.MaxTime, transactionListReq.MinTime, transactionListReq.Type, allCategoryIds, allAccountIds, allTagIds, noTags, transactionListReq.AmountFilter, transactionListReq.Keyword)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transactions.TransactionListHandler] failed to get transaction count for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions, err := a.transactions.GetTransactionsByMaxTime(c, uid, transactionListReq.MaxTime, transactionListReq.MinTime, transactionListReq.Type, allCategoryIds, allAccountIds, allTagIds, noTags, transactionListReq.AmountFilter, transactionListReq.Keyword, transactionListReq.Page, transactionListReq.Count, true, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionListHandler] failed to get transactions earlier than \"%d\" for user \"uid:%d\", because %s", transactionListReq.MaxTime, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionListHandler] failed to get transactions earlier than \"%d\" for user \"uid:%d\", because %s", transactionListReq.MaxTime, uid, err.Error())
|
||||||
@@ -147,11 +184,15 @@ func (a *TransactionsApi) TransactionListHandler(c *core.Context) (interface{},
|
|||||||
transactionResps.NextTimeSequenceId = nextTimeSequenceId
|
transactionResps.NextTimeSequenceId = nextTimeSequenceId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if transactionListReq.WithCount {
|
||||||
|
transactionResps.TotalCount = &totalCount
|
||||||
|
}
|
||||||
|
|
||||||
return transactionResps, nil
|
return transactionResps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionMonthListHandler returns transaction list of current user by month
|
// TransactionMonthListHandler returns all transaction list of current user by month
|
||||||
func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionListReq models.TransactionListInMonthByPageRequest
|
var transactionListReq models.TransactionListInMonthByPageRequest
|
||||||
err := c.ShouldBindQuery(&transactionListReq)
|
err := c.ShouldBindQuery(&transactionListReq)
|
||||||
|
|
||||||
@@ -168,7 +209,7 @@ func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -178,34 +219,39 @@ func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interfac
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
allAccountIds, err := a.getAccountOrSubAccountIds(transactionListReq.AccountId, uid)
|
allAccountIds, err := a.getAccountOrSubAccountIds(c, transactionListReq.AccountIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthListHandler] get account error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionMonthListHandler] get account error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
allCategoryIds, err := a.getCategoryOrSubCategoryIds(transactionListReq.CategoryId, uid)
|
allCategoryIds, err := a.getCategoryOrSubCategoryIds(c, transactionListReq.CategoryIds, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthListHandler] get transaction category error, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[transactions.TransactionMonthListHandler] get transaction category error, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := a.transactions.GetTransactionsInMonthByPage(uid, transactionListReq.Year, transactionListReq.Month, transactionListReq.Type, allCategoryIds, allAccountIds, transactionListReq.Keyword, transactionListReq.Page, transactionListReq.Count, utcOffset)
|
var allTagIds []int64
|
||||||
|
noTags := transactionListReq.TagIds == "none"
|
||||||
|
|
||||||
|
if !noTags {
|
||||||
|
allTagIds, err = a.getTagIds(transactionListReq.TagIds)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionMonthListHandler] get transaction tag ids error, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions, err := a.transactions.GetTransactionsInMonthByPage(c, uid, transactionListReq.Year, transactionListReq.Month, transactionListReq.Type, allCategoryIds, allAccountIds, allTagIds, noTags, transactionListReq.AmountFilter, transactionListReq.Keyword)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionMonthListHandler] failed to get transactions in month \"%d-%d\" for user \"uid:%d\", because %s", transactionListReq.Year, transactionListReq.Month, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionMonthListHandler] failed to get transactions in month \"%d-%d\" for user \"uid:%d\", because %s", transactionListReq.Year, transactionListReq.Month, uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
totalCount, err := a.transactions.GetMonthTransactionCount(uid, transactionListReq.Year, transactionListReq.Month, transactionListReq.Type, allCategoryIds, allAccountIds, transactionListReq.Keyword, utcOffset)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionMonthListHandler] failed to get transaction count in month \"%d-%d\" for user \"uid:%d\", because %s", transactionListReq.Year, transactionListReq.Month, uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
transactionResult, err := a.getTransactionListResult(c, user, transactions, utcOffset, transactionListReq.TrimAccount, transactionListReq.TrimCategory, transactionListReq.TrimTag)
|
transactionResult, err := a.getTransactionListResult(c, user, transactions, utcOffset, transactionListReq.TrimAccount, transactionListReq.TrimCategory, transactionListReq.TrimTag)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -215,14 +261,14 @@ func (a *TransactionsApi) TransactionMonthListHandler(c *core.Context) (interfac
|
|||||||
|
|
||||||
transactionResps := &models.TransactionInfoPageWrapperResponse2{
|
transactionResps := &models.TransactionInfoPageWrapperResponse2{
|
||||||
Items: transactionResult,
|
Items: transactionResult,
|
||||||
TotalCount: totalCount,
|
TotalCount: int64(transactionResult.Len()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return transactionResps, nil
|
return transactionResps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionStatisticsHandler returns transaction statistics of current user
|
// TransactionStatisticsHandler returns transaction statistics of current user
|
||||||
func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var statisticReq models.TransactionStatisticRequest
|
var statisticReq models.TransactionStatisticRequest
|
||||||
err := c.ShouldBindQuery(&statisticReq)
|
err := c.ShouldBindQuery(&statisticReq)
|
||||||
|
|
||||||
@@ -231,8 +277,15 @@ func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (interfa
|
|||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utcOffset, err := c.GetClientTimezoneOffset()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionStatisticsHandler] cannot get client timezone offset, because %s", err.Error())
|
||||||
|
return nil, errs.ErrClientTimezoneOffsetInvalid
|
||||||
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
totalAmounts, err := a.transactions.GetAccountsAndCategoriesTotalIncomeAndExpense(uid, statisticReq.StartTime, statisticReq.EndTime)
|
totalAmounts, err := a.transactions.GetAccountsAndCategoriesTotalIncomeAndExpense(c, uid, statisticReq.StartTime, statisticReq.EndTime, utcOffset, statisticReq.UseTransactionTimezone)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionStatisticsHandler] failed to get accounts and categories total income and expense for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionStatisticsHandler] failed to get accounts and categories total income and expense for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -258,8 +311,66 @@ func (a *TransactionsApi) TransactionStatisticsHandler(c *core.Context) (interfa
|
|||||||
return statisticResp, nil
|
return statisticResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactionStatisticsTrendsHandler returns transaction statistics trends of current user
|
||||||
|
func (a *TransactionsApi) TransactionStatisticsTrendsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var statisticTrendsReq models.TransactionStatisticTrendsRequest
|
||||||
|
err := c.ShouldBindQuery(&statisticTrendsReq)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionStatisticsTrendsHandler] parse request failed, because %s", err.Error())
|
||||||
|
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
utcOffset, err := c.GetClientTimezoneOffset()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionStatisticsTrendsHandler] cannot get client timezone offset, because %s", err.Error())
|
||||||
|
return nil, errs.ErrClientTimezoneOffsetInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
startYear, startMonth, endYear, endMonth, err := statisticTrendsReq.GetNumericYearMonthRange()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionStatisticsTrendsHandler] cannot parse year month, because %s", err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
allMonthlyTotalAmounts, err := a.transactions.GetAccountsAndCategoriesMonthlyIncomeAndExpense(c, uid, startYear, startMonth, endYear, endMonth, utcOffset, statisticTrendsReq.UseTransactionTimezone)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transactions.TransactionStatisticsTrendsHandler] failed to get accounts and categories total income and expense for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
statisticTrendsResp := make(models.TransactionStatisticTrendsItemSlice, 0, len(allMonthlyTotalAmounts))
|
||||||
|
|
||||||
|
for yearMonth, monthlyTotalAmounts := range allMonthlyTotalAmounts {
|
||||||
|
monthlyStatisticResp := &models.TransactionStatisticTrendsItem{
|
||||||
|
Year: yearMonth / 100,
|
||||||
|
Month: yearMonth % 100,
|
||||||
|
Items: make([]*models.TransactionStatisticResponseItem, len(monthlyTotalAmounts)),
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(monthlyTotalAmounts); i++ {
|
||||||
|
totalAmountItem := monthlyTotalAmounts[i]
|
||||||
|
monthlyStatisticResp.Items[i] = &models.TransactionStatisticResponseItem{
|
||||||
|
CategoryId: totalAmountItem.CategoryId,
|
||||||
|
AccountId: totalAmountItem.AccountId,
|
||||||
|
TotalAmount: totalAmountItem.Amount,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statisticTrendsResp = append(statisticTrendsResp, monthlyStatisticResp)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(statisticTrendsResp)
|
||||||
|
|
||||||
|
return statisticTrendsResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// TransactionAmountsHandler returns transaction amounts of current user
|
// TransactionAmountsHandler returns transaction amounts of current user
|
||||||
func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionAmountsReq models.TransactionAmountsRequest
|
var transactionAmountsReq models.TransactionAmountsRequest
|
||||||
err := c.ShouldBindQuery(&transactionAmountsReq)
|
err := c.ShouldBindQuery(&transactionAmountsReq)
|
||||||
|
|
||||||
@@ -280,14 +391,21 @@ func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{
|
|||||||
return nil, errs.ErrQueryItemsEmpty
|
return nil, errs.ErrQueryItemsEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(requestItems) > 5 {
|
if len(requestItems) > 20 {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionAmountsHandler] parse request failed, because there are too many items")
|
log.WarnfWithRequestId(c, "[transactions.TransactionAmountsHandler] parse request failed, because there are too many items")
|
||||||
return nil, errs.ErrQueryItemsTooMuch
|
return nil, errs.ErrQueryItemsTooMuch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utcOffset, err := c.GetClientTimezoneOffset()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[transactions.TransactionAmountsHandler] cannot get client timezone offset, because %s", err.Error())
|
||||||
|
return nil, errs.ErrClientTimezoneOffsetInvalid
|
||||||
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
accounts, err := a.accounts.GetAllAccountsByUid(uid)
|
accounts, err := a.accounts.GetAllAccountsByUid(c, uid)
|
||||||
accountMap := a.accounts.GetAccountMapByList(accounts)
|
accountMap := a.accounts.GetAccountMapByList(accounts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -295,12 +413,12 @@ func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{
|
|||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
amountsResp := make(map[string]*models.TransactionAmountsResponseItem)
|
amountsResp := orderedmap.New[string, *models.TransactionAmountsResponseItem]()
|
||||||
|
|
||||||
for i := 0; i < len(requestItems); i++ {
|
for i := 0; i < len(requestItems); i++ {
|
||||||
requestItem := requestItems[i]
|
requestItem := requestItems[i]
|
||||||
|
|
||||||
incomeAmounts, expenseAmounts, err := a.transactions.GetAccountsTotalIncomeAndExpense(uid, requestItem.StartTime, requestItem.EndTime)
|
incomeAmounts, expenseAmounts, err := a.transactions.GetAccountsTotalIncomeAndExpense(c, uid, requestItem.StartTime, requestItem.EndTime, utcOffset, transactionAmountsReq.UseTransactionTimezone)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionAmountsHandler] failed to get transaction amounts item for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionAmountsHandler] failed to get transaction amounts item for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -353,136 +471,26 @@ func (a *TransactionsApi) TransactionAmountsHandler(c *core.Context) (interface{
|
|||||||
amountsMap[account.Currency] = totalAmounts
|
amountsMap[account.Currency] = totalAmounts
|
||||||
}
|
}
|
||||||
|
|
||||||
allTotalAmounts := make([]*models.TransactionAmountsResponseItemAmountInfo, 0)
|
allTotalAmounts := make(models.TransactionAmountsResponseItemAmountInfoSlice, 0)
|
||||||
|
|
||||||
for _, totalAmounts := range amountsMap {
|
for _, totalAmounts := range amountsMap {
|
||||||
allTotalAmounts = append(allTotalAmounts, totalAmounts)
|
allTotalAmounts = append(allTotalAmounts, totalAmounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
amountsResp[requestItem.Name] = &models.TransactionAmountsResponseItem{
|
sort.Sort(allTotalAmounts)
|
||||||
|
|
||||||
|
amountsResp.Set(requestItem.Name, &models.TransactionAmountsResponseItem{
|
||||||
StartTime: requestItem.StartTime,
|
StartTime: requestItem.StartTime,
|
||||||
EndTime: requestItem.EndTime,
|
EndTime: requestItem.EndTime,
|
||||||
Amounts: allTotalAmounts,
|
Amounts: allTotalAmounts,
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return amountsResp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransactionMonthAmountsHandler returns every month transaction amounts of current user
|
|
||||||
func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (interface{}, *errs.Error) {
|
|
||||||
var transactionAmountsReq models.TransactionMonthAmountsRequest
|
|
||||||
err := c.ShouldBindQuery(&transactionAmountsReq)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] parse request failed, because %s", err.Error())
|
|
||||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
utcOffset, err := c.GetClientTimezoneOffset()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] cannot get client timezone offset, because %s", err.Error())
|
|
||||||
return nil, errs.ErrClientTimezoneOffsetInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
startTime, endTime, err := transactionAmountsReq.GetStartTimeAndEndTime(utcOffset)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] parse request start or end date failed, because %s", err.Error())
|
|
||||||
return nil, errs.ErrParameterInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
|
||||||
|
|
||||||
accounts, err := a.accounts.GetAllAccountsByUid(uid)
|
|
||||||
accountMap := a.accounts.GetAccountMapByList(accounts)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] failed to get all accounts for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
totalAmounts, err := a.transactions.GetAccountsMonthTotalIncomeAndExpense(uid, startTime, endTime, pageCountForLoadTransactionAmounts)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] failed to get accounts month total income and expense for user \"uid:%d\", because %s", uid, err.Error())
|
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
amountsMap := make(map[string]map[string]*models.TransactionAmountsResponseItemAmountInfo)
|
|
||||||
|
|
||||||
for yearMonth, monthAccountsAmounts := range totalAmounts {
|
|
||||||
for accountId, monthAccountAmounts := range monthAccountsAmounts {
|
|
||||||
account, exists := accountMap[accountId]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] cannot find account for account \"id:%d\" of user \"uid:%d\"", accountId, uid)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
monthTotalAmounts, exists := amountsMap[yearMonth]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
monthTotalAmounts = make(map[string]*models.TransactionAmountsResponseItemAmountInfo)
|
|
||||||
amountsMap[yearMonth] = monthTotalAmounts
|
|
||||||
}
|
|
||||||
|
|
||||||
monthTotalAmount, exists := monthTotalAmounts[account.Currency]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
monthTotalAmount = &models.TransactionAmountsResponseItemAmountInfo{
|
|
||||||
Currency: account.Currency,
|
|
||||||
IncomeAmount: 0,
|
|
||||||
ExpenseAmount: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
monthTotalAmount.IncomeAmount += monthAccountAmounts.TotalIncomeAmount
|
|
||||||
monthTotalAmount.ExpenseAmount += monthAccountAmounts.TotalExpenseAmount
|
|
||||||
|
|
||||||
monthTotalAmounts[account.Currency] = monthTotalAmount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
amountsResp := make(models.TransactionMonthAmountsResponseItemSlice, 0)
|
|
||||||
|
|
||||||
for yearMonth, monthTotalAmounts := range amountsMap {
|
|
||||||
yearMonthItems := strings.Split(yearMonth, "-")
|
|
||||||
year, err := utils.StringToInt32(yearMonthItems[0])
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] cannot get year from year-month item \"%s\" for user \"uid:%d\"", yearMonth, uid)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
month, err := utils.StringToInt32(yearMonthItems[1])
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionMonthAmountsHandler] cannot get month from year-month item \"%s\" for user \"uid:%d\"", yearMonth, uid)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
amounts := make([]*models.TransactionAmountsResponseItemAmountInfo, 0, len(monthTotalAmounts))
|
|
||||||
|
|
||||||
for _, monthTotalAmount := range monthTotalAmounts {
|
|
||||||
amounts = append(amounts, monthTotalAmount)
|
|
||||||
}
|
|
||||||
|
|
||||||
amountsResp = append(amountsResp, &models.TransactionMonthAmountsResponseItem{
|
|
||||||
Year: year,
|
|
||||||
Month: month,
|
|
||||||
Amounts: amounts,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(amountsResp)
|
|
||||||
|
|
||||||
return amountsResp, nil
|
return amountsResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionGetHandler returns one specific transaction of current user
|
// TransactionGetHandler returns one specific transaction of current user
|
||||||
func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionGetReq models.TransactionGetRequest
|
var transactionGetReq models.TransactionGetRequest
|
||||||
err := c.ShouldBindQuery(&transactionGetReq)
|
err := c.ShouldBindQuery(&transactionGetReq)
|
||||||
|
|
||||||
@@ -499,7 +507,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -509,7 +517,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction, err := a.transactions.GetTransactionByTransactionId(uid, transactionGetReq.Id)
|
transaction, err := a.transactions.GetTransactionByTransactionId(c, uid, transactionGetReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionGetReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionGetReq.Id, uid, err.Error())
|
||||||
@@ -528,7 +536,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
accountIds = utils.ToUniqueInt64Slice(accountIds)
|
accountIds = utils.ToUniqueInt64Slice(accountIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountMap, err := a.accounts.GetAccountsByAccountIds(uid, accountIds)
|
accountMap, err := a.accounts.GetAccountsByAccountIds(c, uid, accountIds)
|
||||||
|
|
||||||
if _, exists := accountMap[transaction.AccountId]; !exists {
|
if _, exists := accountMap[transaction.AccountId]; !exists {
|
||||||
log.WarnfWithRequestId(c, "[transactions.TransactionGetHandler] account of transaction \"id:%d\" does not exist for user \"uid:%d\"", transaction.TransactionId, uid)
|
log.WarnfWithRequestId(c, "[transactions.TransactionGetHandler] account of transaction \"id:%d\" does not exist for user \"uid:%d\"", transaction.TransactionId, uid)
|
||||||
@@ -542,7 +550,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(uid, []int64{transaction.TransactionId})
|
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(c, uid, []int64{transaction.TransactionId})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -553,7 +561,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
var tagMap map[int64]*models.TransactionTag
|
var tagMap map[int64]*models.TransactionTag
|
||||||
|
|
||||||
if !transactionGetReq.TrimCategory {
|
if !transactionGetReq.TrimCategory {
|
||||||
category, err = a.transactionCategories.GetCategoryByCategoryId(uid, transaction.CategoryId)
|
category, err = a.transactionCategories.GetCategoryByCategoryId(c, uid, transaction.CategoryId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions category for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions category for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -562,7 +570,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !transactionGetReq.TrimTag {
|
if !transactionGetReq.TrimTag {
|
||||||
tagMap, err = a.transactionTags.GetTagsByTagIds(uid, utils.ToUniqueInt64Slice(a.getTransactionTagIds(allTransactionTagIds)))
|
tagMap, err = a.transactionTags.GetTagsByTagIds(c, uid, utils.ToUniqueInt64Slice(a.getTransactionTagIds(allTransactionTagIds)))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions tags for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionGetHandler] failed to get transactions tags for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -598,7 +606,7 @@ func (a *TransactionsApi) TransactionGetHandler(c *core.Context) (interface{}, *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionCreateHandler saves a new transaction by request parameters for current user
|
// TransactionCreateHandler saves a new transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionCreateReq models.TransactionCreateRequest
|
var transactionCreateReq models.TransactionCreateRequest
|
||||||
err := c.ShouldBindJSON(&transactionCreateReq)
|
err := c.ShouldBindJSON(&transactionCreateReq)
|
||||||
|
|
||||||
@@ -638,7 +646,7 @@ func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -655,7 +663,29 @@ func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrCannotCreateTransactionWithThisTransactionTime
|
return nil, errs.ErrCannotCreateTransactionWithThisTransactionTime
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.transactions.CreateTransaction(transaction, tagIds)
|
if settings.Container.Current.EnableDuplicateSubmissionsCheck && transactionCreateReq.ClientSessionId != "" {
|
||||||
|
found, remark := duplicatechecker.Container.Get(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION, uid, transactionCreateReq.ClientSessionId)
|
||||||
|
|
||||||
|
if found {
|
||||||
|
log.InfofWithRequestId(c, "[transactions.TransactionCreateHandler] another transaction \"id:%s\" has been created for user \"uid:%d\"", remark, uid)
|
||||||
|
transactionId, err := utils.StringToInt64(remark)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
transaction, err = a.transactions.GetTransactionByTransactionId(c, uid, transactionId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[transactions.TransactionCreateHandler] failed to get existed transaction \"id:%d\" for user \"uid:%d\", because %s", transactionId, uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionResp := transaction.ToTransactionInfoResponse(tagIds, transactionEditable)
|
||||||
|
|
||||||
|
return transactionResp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.transactions.CreateTransaction(c, transaction, tagIds)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionCreateHandler] failed to create transaction \"id:%d\" for user \"uid:%d\", because %s", transaction.TransactionId, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionCreateHandler] failed to create transaction \"id:%d\" for user \"uid:%d\", because %s", transaction.TransactionId, uid, err.Error())
|
||||||
@@ -664,13 +694,14 @@ func (a *TransactionsApi) TransactionCreateHandler(c *core.Context) (interface{}
|
|||||||
|
|
||||||
log.InfofWithRequestId(c, "[transactions.TransactionCreateHandler] user \"uid:%d\" has created a new transaction \"id:%d\" successfully", uid, transaction.TransactionId)
|
log.InfofWithRequestId(c, "[transactions.TransactionCreateHandler] user \"uid:%d\" has created a new transaction \"id:%d\" successfully", uid, transaction.TransactionId)
|
||||||
|
|
||||||
|
duplicatechecker.Container.Set(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION, uid, transactionCreateReq.ClientSessionId, utils.Int64ToString(transaction.TransactionId))
|
||||||
transactionResp := transaction.ToTransactionInfoResponse(tagIds, transactionEditable)
|
transactionResp := transaction.ToTransactionInfoResponse(tagIds, transactionEditable)
|
||||||
|
|
||||||
return transactionResp, nil
|
return transactionResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionModifyHandler saves an existed transaction by request parameters for current user
|
// TransactionModifyHandler saves an existed transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionModifyReq models.TransactionModifyRequest
|
var transactionModifyReq models.TransactionModifyRequest
|
||||||
err := c.ShouldBindJSON(&transactionModifyReq)
|
err := c.ShouldBindJSON(&transactionModifyReq)
|
||||||
|
|
||||||
@@ -687,7 +718,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -697,7 +728,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction, err := a.transactions.GetTransactionByTransactionId(uid, transactionModifyReq.Id)
|
transaction, err := a.transactions.GetTransactionByTransactionId(c, uid, transactionModifyReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionModifyReq.Id, uid, err.Error())
|
||||||
@@ -709,7 +740,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrTransactionTypeInvalid
|
return nil, errs.ErrTransactionTypeInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(uid, []int64{transaction.TransactionId})
|
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(c, uid, []int64{transaction.TransactionId})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -774,7 +805,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrCannotModifyTransactionWithThisTransactionTime
|
return nil, errs.ErrCannotModifyTransactionWithThisTransactionTime
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.transactions.ModifyTransaction(newTransaction, addTransactionTagIds, removeTransactionTagIds)
|
err = a.transactions.ModifyTransaction(c, newTransaction, len(transactionTagIds), addTransactionTagIds, removeTransactionTagIds)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to update transaction \"id:%d\" for user \"uid:%d\", because %s", transactionModifyReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionModifyHandler] failed to update transaction \"id:%d\" for user \"uid:%d\", because %s", transactionModifyReq.Id, uid, err.Error())
|
||||||
@@ -790,7 +821,7 @@ func (a *TransactionsApi) TransactionModifyHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionDeleteHandler deletes an existed transaction by request parameters for current user
|
// TransactionDeleteHandler deletes an existed transaction by request parameters for current user
|
||||||
func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var transactionDeleteReq models.TransactionDeleteRequest
|
var transactionDeleteReq models.TransactionDeleteRequest
|
||||||
err := c.ShouldBindJSON(&transactionDeleteReq)
|
err := c.ShouldBindJSON(&transactionDeleteReq)
|
||||||
|
|
||||||
@@ -807,7 +838,7 @@ func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -817,7 +848,7 @@ func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction, err := a.transactions.GetTransactionByTransactionId(uid, transactionDeleteReq.Id)
|
transaction, err := a.transactions.GetTransactionByTransactionId(c, uid, transactionDeleteReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionDeleteHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionDeleteReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionDeleteHandler] failed to get transaction \"id:%d\" for user \"uid:%d\", because %s", transactionDeleteReq.Id, uid, err.Error())
|
||||||
@@ -835,7 +866,7 @@ func (a *TransactionsApi) TransactionDeleteHandler(c *core.Context) (interface{}
|
|||||||
return nil, errs.ErrCannotDeleteTransactionWithThisTransactionTime
|
return nil, errs.ErrCannotDeleteTransactionWithThisTransactionTime
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.transactions.DeleteTransaction(uid, transactionDeleteReq.Id)
|
err = a.transactions.DeleteTransaction(c, uid, transactionDeleteReq.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.TransactionDeleteHandler] failed to delete transaction \"id:%d\" for user \"uid:%d\", because %s", transactionDeleteReq.Id, uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.TransactionDeleteHandler] failed to delete transaction \"id:%d\" for user \"uid:%d\", because %s", transactionDeleteReq.Id, uid, err.Error())
|
||||||
@@ -870,50 +901,124 @@ func (a *TransactionsApi) filterTransactions(c *core.Context, uid int64, transac
|
|||||||
return finalTransactions
|
return finalTransactions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *TransactionsApi) getAccountOrSubAccountIds(accountId int64, uid int64) ([]int64, error) {
|
func (a *TransactionsApi) getAccountOrSubAccountIds(c *core.Context, accountIds string, uid int64) ([]int64, error) {
|
||||||
|
if accountIds == "" || accountIds == "0" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAccountIds, err := utils.StringArrayToInt64Array(strings.Split(accountIds, ","))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.Or(err, errs.ErrAccountIdInvalid)
|
||||||
|
}
|
||||||
|
|
||||||
var allAccountIds []int64
|
var allAccountIds []int64
|
||||||
|
|
||||||
if accountId > 0 {
|
if len(requestAccountIds) > 0 {
|
||||||
allSubAccounts, err := a.accounts.GetSubAccountsByAccountId(uid, accountId)
|
allSubAccounts, err := a.accounts.GetSubAccountsByAccountIds(c, uid, requestAccountIds)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(allSubAccounts) > 0 {
|
accountIdsMap := make(map[int64]int32, len(requestAccountIds))
|
||||||
for i := 0; i < len(allSubAccounts); i++ {
|
|
||||||
allAccountIds = append(allAccountIds, allSubAccounts[i].AccountId)
|
for i := 0; i < len(requestAccountIds); i++ {
|
||||||
|
accountIdsMap[requestAccountIds[i]] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(allSubAccounts); i++ {
|
||||||
|
subAccount := allSubAccounts[i]
|
||||||
|
|
||||||
|
if refCount, exists := accountIdsMap[subAccount.ParentAccountId]; exists {
|
||||||
|
accountIdsMap[subAccount.ParentAccountId] = refCount + 1
|
||||||
|
} else {
|
||||||
|
accountIdsMap[subAccount.ParentAccountId] = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, exists := accountIdsMap[subAccount.AccountId]; exists {
|
||||||
|
delete(accountIdsMap, subAccount.AccountId)
|
||||||
|
}
|
||||||
|
|
||||||
|
allAccountIds = append(allAccountIds, subAccount.AccountId)
|
||||||
|
}
|
||||||
|
|
||||||
|
for accountId, refCount := range accountIdsMap {
|
||||||
|
if refCount < 1 {
|
||||||
|
allAccountIds = append(allAccountIds, accountId)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
allAccountIds = append(allAccountIds, accountId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allAccountIds, nil
|
return allAccountIds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *TransactionsApi) getCategoryOrSubCategoryIds(categoryId int64, uid int64) ([]int64, error) {
|
func (a *TransactionsApi) getCategoryOrSubCategoryIds(c *core.Context, categoryIds string, uid int64) ([]int64, error) {
|
||||||
|
if categoryIds == "" || categoryIds == "0" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
requestCategoryIds, err := utils.StringArrayToInt64Array(strings.Split(categoryIds, ","))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.Or(err, errs.ErrTransactionCategoryIdInvalid)
|
||||||
|
}
|
||||||
|
|
||||||
var allCategoryIds []int64
|
var allCategoryIds []int64
|
||||||
|
|
||||||
if categoryId > 0 {
|
if len(requestCategoryIds) > 0 {
|
||||||
allSubCategories, err := a.transactionCategories.GetAllCategoriesByUid(uid, 0, categoryId)
|
allSubCategories, err := a.transactionCategories.GetSubCategoriesByCategoryIds(c, uid, requestCategoryIds)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(allSubCategories) > 0 {
|
categoryIdsMap := make(map[int64]int32, len(requestCategoryIds))
|
||||||
for i := 0; i < len(allSubCategories); i++ {
|
|
||||||
allCategoryIds = append(allCategoryIds, allSubCategories[i].CategoryId)
|
for i := 0; i < len(requestCategoryIds); i++ {
|
||||||
|
categoryIdsMap[requestCategoryIds[i]] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(allSubCategories); i++ {
|
||||||
|
subCategory := allSubCategories[i]
|
||||||
|
|
||||||
|
if refCount, exists := categoryIdsMap[subCategory.ParentCategoryId]; exists {
|
||||||
|
categoryIdsMap[subCategory.ParentCategoryId] = refCount + 1
|
||||||
|
} else {
|
||||||
|
categoryIdsMap[subCategory.ParentCategoryId] = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, exists := categoryIdsMap[subCategory.CategoryId]; exists {
|
||||||
|
delete(categoryIdsMap, subCategory.CategoryId)
|
||||||
|
}
|
||||||
|
|
||||||
|
allCategoryIds = append(allCategoryIds, subCategory.CategoryId)
|
||||||
|
}
|
||||||
|
|
||||||
|
for accountId, refCount := range categoryIdsMap {
|
||||||
|
if refCount < 1 {
|
||||||
|
allCategoryIds = append(allCategoryIds, accountId)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
allCategoryIds = append(allCategoryIds, categoryId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allCategoryIds, nil
|
return allCategoryIds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *TransactionsApi) getTagIds(tagIds string) ([]int64, error) {
|
||||||
|
if tagIds == "" || tagIds == "0" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
requestTagIds, err := utils.StringArrayToInt64Array(strings.Split(tagIds, ","))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.Or(err, errs.ErrTransactionTagIdInvalid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestTagIds, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *TransactionsApi) getTransactionTagIds(allTransactionTagIds map[int64][]int64) []int64 {
|
func (a *TransactionsApi) getTransactionTagIds(allTransactionTagIds map[int64][]int64) []int64 {
|
||||||
allTagIds := make([]int64, 0, len(allTransactionTagIds))
|
allTagIds := make([]int64, 0, len(allTransactionTagIds))
|
||||||
|
|
||||||
@@ -963,7 +1068,7 @@ func (a *TransactionsApi) getTransactionListResult(c *core.Context, user *models
|
|||||||
categoryIds = append(categoryIds, transactions[i].CategoryId)
|
categoryIds = append(categoryIds, transactions[i].CategoryId)
|
||||||
}
|
}
|
||||||
|
|
||||||
allAccounts, err := a.accounts.GetAccountsByAccountIds(uid, utils.ToUniqueInt64Slice(accountIds))
|
allAccounts, err := a.accounts.GetAccountsByAccountIds(c, uid, utils.ToUniqueInt64Slice(accountIds))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get accounts for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get accounts for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -972,7 +1077,7 @@ func (a *TransactionsApi) getTransactionListResult(c *core.Context, user *models
|
|||||||
|
|
||||||
transactions = a.filterTransactions(c, uid, transactions, allAccounts)
|
transactions = a.filterTransactions(c, uid, transactions, allAccounts)
|
||||||
|
|
||||||
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(uid, transactionIds)
|
allTransactionTagIds, err := a.transactionTags.GetAllTagIdsOfTransactions(c, uid, transactionIds)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions tag ids for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -983,7 +1088,7 @@ func (a *TransactionsApi) getTransactionListResult(c *core.Context, user *models
|
|||||||
var tagMap map[int64]*models.TransactionTag
|
var tagMap map[int64]*models.TransactionTag
|
||||||
|
|
||||||
if !trimCategory {
|
if !trimCategory {
|
||||||
categoryMap, err = a.transactionCategories.GetCategoriesByCategoryIds(uid, utils.ToUniqueInt64Slice(categoryIds))
|
categoryMap, err = a.transactionCategories.GetCategoriesByCategoryIds(c, uid, utils.ToUniqueInt64Slice(categoryIds))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions categories for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions categories for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
@@ -992,7 +1097,7 @@ func (a *TransactionsApi) getTransactionListResult(c *core.Context, user *models
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !trimTag {
|
if !trimTag {
|
||||||
tagMap, err = a.transactionTags.GetTagsByTagIds(uid, utils.ToUniqueInt64Slice(a.getTransactionTagIds(allTransactionTagIds)))
|
tagMap, err = a.transactionTags.GetTagsByTagIds(c, uid, utils.ToUniqueInt64Slice(a.getTransactionTagIds(allTransactionTagIds)))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions tags for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[transactions.getTransactionListResult] failed to get transactions tags for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TwoFactorStatusHandler returns 2fa status of current user
|
// TwoFactorStatusHandler returns 2fa status of current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(uid)
|
twoFactorSetting, err := a.twoFactorAuthorizations.GetUserTwoFactorSettingByUid(c, uid)
|
||||||
|
|
||||||
if err == errs.ErrTwoFactorIsNotEnabled {
|
if err == errs.ErrTwoFactorIsNotEnabled {
|
||||||
statusResp := &models.TwoFactorStatusResponse{
|
statusResp := &models.TwoFactorStatusResponse{
|
||||||
@@ -45,7 +45,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorStatusHandler] failed to get two factor setting, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorStatusHandler] failed to get two-factor setting, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,12 +58,12 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorStatusHandler(c *core.Context) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorEnableRequestHandler returns a new 2fa secret and qr code for current user to set 2fa and verify passcode next
|
// TwoFactorEnableRequestHandler returns a new 2fa secret and qr code for current user to set 2fa and verify passcode next
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Context) (any, *errs.Error) {
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
enabled, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
enabled, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to check two factor setting, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to check two-factor setting, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Conte
|
|||||||
return nil, errs.ErrTwoFactorAlreadyEnabled
|
return nil, errs.ErrTwoFactorAlreadyEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -81,17 +81,17 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Conte
|
|||||||
return nil, errs.ErrUserNotFound
|
return nil, errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
key, err := a.twoFactorAuthorizations.GenerateTwoFactorSecret(user)
|
key, err := a.twoFactorAuthorizations.GenerateTwoFactorSecret(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to generate two factor secret, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to generate two-factor secret, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := key.Image(240, 240)
|
img, err := key.Image(240, 240)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to generate two factor qrcode, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableRequestHandler] failed to generate two-factor qrcode, because %s", err.Error())
|
||||||
return nil, errs.ErrOperationFailed
|
return nil, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableRequestHandler(c *core.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorEnableConfirmHandler enables 2fa for current user
|
// TwoFactorEnableConfirmHandler enables 2fa for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var confirmReq models.TwoFactorEnableConfirmRequest
|
var confirmReq models.TwoFactorEnableConfirmRequest
|
||||||
err := c.ShouldBindJSON(&confirmReq)
|
err := c.ShouldBindJSON(&confirmReq)
|
||||||
|
|
||||||
@@ -120,10 +120,10 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
exists, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
exists, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to check two factor setting, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to check two-factor setting, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
return nil, errs.ErrTwoFactorAlreadyEnabled
|
return nil, errs.ErrTwoFactorAlreadyEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -154,28 +154,28 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
recoveryCodes, err := a.twoFactorAuthorizations.GenerateTwoFactorRecoveryCodes()
|
recoveryCodes, err := a.twoFactorAuthorizations.GenerateTwoFactorRecoveryCodes()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to generate two factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to generate two-factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.CreateTwoFactorRecoveryCodes(uid, recoveryCodes, user.Salt)
|
err = a.twoFactorAuthorizations.CreateTwoFactorRecoveryCodes(c, uid, recoveryCodes, user.Salt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create two factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create two-factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.CreateTwoFactorSetting(twoFactorSetting)
|
err = a.twoFactorAuthorizations.CreateTwoFactorSetting(c, twoFactorSetting)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create two factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create two-factor setting for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] user \"uid:%d\" has enabled two factor authorization", uid)
|
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] user \"uid:%d\" has enabled two-factor authorization", uid)
|
||||||
|
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
err = a.tokens.DeleteTokensBeforeTime(uid, now)
|
err = a.tokens.DeleteTokensBeforeTime(c, uid, now)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] revoke old tokens before unix time \"%d\" for user \"uid:%d\"", now, user.Uid)
|
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] revoke old tokens before unix time \"%d\" for user \"uid:%d\"", now, user.Uid)
|
||||||
@@ -183,7 +183,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
log.WarnfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to revoke old tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to revoke old tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
@@ -195,6 +195,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
return confirmResp, nil
|
return confirmResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorEnableConfirmHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
@@ -208,7 +209,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorEnableConfirmHandler(c *core.Conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorDisableHandler disables 2fa for current user
|
// TwoFactorDisableHandler disables 2fa for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var disableReq models.TwoFactorDisableRequest
|
var disableReq models.TwoFactorDisableRequest
|
||||||
err := c.ShouldBindJSON(&disableReq)
|
err := c.ShouldBindJSON(&disableReq)
|
||||||
|
|
||||||
@@ -218,7 +219,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (i
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -232,10 +233,10 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (i
|
|||||||
return nil, errs.ErrUserPasswordWrong
|
return nil, errs.ErrUserPasswordWrong
|
||||||
}
|
}
|
||||||
|
|
||||||
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to check two factor setting, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to check two-factor setting, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,27 +244,27 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorDisableHandler(c *core.Context) (i
|
|||||||
return nil, errs.ErrTwoFactorIsNotEnabled
|
return nil, errs.ErrTwoFactorIsNotEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.DeleteTwoFactorRecoveryCodes(uid)
|
err = a.twoFactorAuthorizations.DeleteTwoFactorRecoveryCodes(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to delete two factor recovery codes for user \"uid:%d\"", uid)
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to delete two-factor recovery codes for user \"uid:%d\"", uid)
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.DeleteTwoFactorSetting(uid)
|
err = a.twoFactorAuthorizations.DeleteTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to delete two factor setting for user \"uid:%d\"", uid)
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] failed to delete two-factor setting for user \"uid:%d\"", uid)
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] user \"uid:%d\" has disabled two factor authorization", uid)
|
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorDisableHandler] user \"uid:%d\" has disabled two-factor authorization", uid)
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TwoFactorRecoveryCodeRegenerateHandler returns new 2fa recovery codes and revokes old recovery codes for current user
|
// TwoFactorRecoveryCodeRegenerateHandler returns new 2fa recovery codes and revokes old recovery codes for current user
|
||||||
func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var regenerateReq models.TwoFactorRegenerateRecoveryCodeRequest
|
var regenerateReq models.TwoFactorRegenerateRecoveryCodeRequest
|
||||||
err := c.ShouldBindJSON(®enerateReq)
|
err := c.ShouldBindJSON(®enerateReq)
|
||||||
|
|
||||||
@@ -273,7 +274,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -287,10 +288,10 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *c
|
|||||||
return nil, errs.ErrUserPasswordWrong
|
return nil, errs.ErrUserPasswordWrong
|
||||||
}
|
}
|
||||||
|
|
||||||
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
enableTwoFactor, err := a.twoFactorAuthorizations.ExistsTwoFactorSetting(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to check two factor setting, because %s", err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to check two-factor setting, because %s", err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,14 +302,14 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *c
|
|||||||
recoveryCodes, err := a.twoFactorAuthorizations.GenerateTwoFactorRecoveryCodes()
|
recoveryCodes, err := a.twoFactorAuthorizations.GenerateTwoFactorRecoveryCodes()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to generate two factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to generate two-factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.twoFactorAuthorizations.CreateTwoFactorRecoveryCodes(uid, recoveryCodes, user.Salt)
|
err = a.twoFactorAuthorizations.CreateTwoFactorRecoveryCodes(c, uid, recoveryCodes, user.Salt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to create two factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
log.ErrorfWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] failed to create two-factor recovery codes for user \"uid:%d\", because %s", uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +317,7 @@ func (a *TwoFactorAuthorizationsApi) TwoFactorRecoveryCodeRegenerateHandler(c *c
|
|||||||
RecoveryCodes: recoveryCodes,
|
RecoveryCodes: recoveryCodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] user \"uid:%d\" has regenerated two factor recovery codes", uid)
|
log.InfofWithRequestId(c, "[twofactor_authorizations.TwoFactorRecoveryCodeRegenerateHandler] user \"uid:%d\" has regenerated two-factor recovery codes", uid)
|
||||||
|
|
||||||
return recoveryCodesResp, nil
|
return recoveryCodesResp, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+515
-17
@@ -1,15 +1,22 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/locales"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/storage"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,13 +37,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UserRegisterHandler saves a new user by request parameters
|
// UserRegisterHandler saves a new user by request parameters
|
||||||
func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserRegisterHandler(c *core.Context) (any, *errs.Error) {
|
||||||
if !settings.Container.Current.EnableUserRegister {
|
if !settings.Container.Current.EnableUserRegister {
|
||||||
return nil, errs.ErrUserRegistrationNotAllowed
|
return nil, errs.ErrUserRegistrationNotAllowed
|
||||||
}
|
}
|
||||||
|
|
||||||
var userRegisterReq models.UserRegisterRequest
|
var userRegisterReq models.UserRegisterRequest
|
||||||
err := c.ShouldBindJSON(&userRegisterReq)
|
err := c.ShouldBindBodyWith(&userRegisterReq, binding.JSON)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] parse request failed, because %s", err.Error())
|
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] parse request failed, because %s", err.Error())
|
||||||
@@ -63,7 +70,7 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
TransactionEditScope: models.TRANSACTION_EDIT_SCOPE_ALL,
|
TransactionEditScope: models.TRANSACTION_EDIT_SCOPE_ALL,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.users.CreateUser(user)
|
err = a.users.CreateUser(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[users.UserRegisterHandler] failed to create user \"%s\", because %s", user.Username, err.Error())
|
log.ErrorfWithRequestId(c, "[users.UserRegisterHandler] failed to create user \"%s\", because %s", user.Username, err.Error())
|
||||||
@@ -72,12 +79,47 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
|
|
||||||
log.InfofWithRequestId(c, "[users.UserRegisterHandler] user \"%s\" has registered successfully, uid is %d", user.Username, user.Uid)
|
log.InfofWithRequestId(c, "[users.UserRegisterHandler] user \"%s\" has registered successfully, uid is %d", user.Username, user.Uid)
|
||||||
|
|
||||||
authResp := &models.AuthResponse{
|
presetCategoriesSaved := false
|
||||||
Need2FA: false,
|
|
||||||
User: user.ToUserBasicInfo(),
|
if len(userRegisterReq.Categories) > 0 {
|
||||||
|
_, err = TransactionCategories.createBatchCategories(c, user.Uid, &userRegisterReq.TransactionCategoryCreateBatchRequest)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
presetCategoriesSaved = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
authResp := &models.RegisterResponse{
|
||||||
|
AuthResponse: models.AuthResponse{
|
||||||
|
Need2FA: false,
|
||||||
|
User: user.ToUserBasicInfo(),
|
||||||
|
NotificationContent: settings.Container.GetAfterRegisterNotificationContent(user.Language, c.GetClientLocale()),
|
||||||
|
},
|
||||||
|
NeedVerifyEmail: settings.Container.Current.EnableUserVerifyEmail && settings.Container.Current.EnableUserForceVerifyEmail,
|
||||||
|
PresetCategoriesSaved: presetCategoriesSaved,
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableUserVerifyEmail && settings.Container.Current.EnableSMTP {
|
||||||
|
token, _, err := a.tokens.CreateEmailVerifyToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRegisterHandler] failed to create email verify token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
} else {
|
||||||
|
go func() {
|
||||||
|
err = a.users.SendVerifyEmail(user, token, c.GetClientLocale())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.EnableUserForceVerifyEmail {
|
||||||
|
return authResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
@@ -85,6 +127,7 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
authResp.Token = token
|
authResp.Token = token
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[users.UserRegisterHandler] user \"uid:%d\" has logined, token will be expired at %d", user.Uid, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[users.UserRegisterHandler] user \"uid:%d\" has logined, token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
@@ -92,10 +135,74 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
|||||||
return authResp, nil
|
return authResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserProfileHandler returns user profile of current user
|
// UserEmailVerifyHandler sets user email address verified
|
||||||
func (a *UsersApi) UserProfileHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserEmailVerifyHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
var userVerifyEmailReq models.UserVerifyEmailRequest
|
||||||
|
err := c.ShouldBindJSON(&userVerifyEmailReq)
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserEmailVerifyHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserEmailVerifyHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserEmailVerifyHandler] user \"uid:%d\" email has been verified", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.users.SetUserEmailVerified(c, user.Username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserEmailVerifyHandler] failed to update user \"uid:%d\" email address verified, because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.tokens.DeleteTokensByType(c, uid, core.USER_TOKEN_TYPE_EMAIL_VERIFY)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
log.InfofWithRequestId(c, "[users.UserEmailVerifyHandler] revoke old email verify tokens for user \"uid:%d\"", user.Uid)
|
||||||
|
} else {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserEmailVerifyHandler] failed to revoke old email verify tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := &models.UserVerifyEmailResponse{}
|
||||||
|
|
||||||
|
if userVerifyEmailReq.RequestNewToken {
|
||||||
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserEmailVerifyHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.NewToken = token
|
||||||
|
resp.User = user.ToUserBasicInfo()
|
||||||
|
resp.NotificationContent = settings.Container.GetAfterLoginNotificationContent(user.Language, c.GetClientLocale())
|
||||||
|
|
||||||
|
c.SetTextualToken(token)
|
||||||
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
|
log.InfofWithRequestId(c, "[users.UserEmailVerifyHandler] user \"uid:%d\" token created, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserProfileHandler returns user profile of current user
|
||||||
|
func (a *UsersApi) UserProfileHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -110,7 +217,7 @@ func (a *UsersApi) UserProfileHandler(c *core.Context) (interface{}, *errs.Error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdateProfileHandler saves user profile by request parameters for current user
|
// UserUpdateProfileHandler saves user profile by request parameters for current user
|
||||||
func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs.Error) {
|
func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (any, *errs.Error) {
|
||||||
var userUpdateReq models.UserProfileUpdateRequest
|
var userUpdateReq models.UserProfileUpdateRequest
|
||||||
err := c.ShouldBindJSON(&userUpdateReq)
|
err := c.ShouldBindJSON(&userUpdateReq)
|
||||||
|
|
||||||
@@ -120,7 +227,7 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
user, err := a.users.GetUserById(uid)
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.IsCustomError(err) {
|
if !errs.IsCustomError(err) {
|
||||||
@@ -163,12 +270,22 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userUpdateReq.DefaultAccountId > 0 && userUpdateReq.DefaultAccountId != user.DefaultAccountId {
|
if userUpdateReq.DefaultAccountId > 0 && userUpdateReq.DefaultAccountId != user.DefaultAccountId {
|
||||||
accounts, err := a.accounts.GetAccountsByAccountIds(uid, []int64{userUpdateReq.DefaultAccountId})
|
accountMap, err := a.accounts.GetAccountsByAccountIds(c, uid, []int64{userUpdateReq.DefaultAccountId})
|
||||||
|
|
||||||
if err != nil || len(accounts) < 1 {
|
if err != nil || len(accountMap) < 1 {
|
||||||
return nil, errs.Or(err, errs.ErrUserDefaultAccountIsInvalid)
|
return nil, errs.Or(err, errs.ErrUserDefaultAccountIsInvalid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, exists := accountMap[userUpdateReq.DefaultAccountId]; !exists {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] account \"id:%d\" does not exist for user \"uid:%d\"", userUpdateReq.DefaultAccountId, uid)
|
||||||
|
return nil, errs.ErrUserDefaultAccountIsInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if accountMap[userUpdateReq.DefaultAccountId].Hidden {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] account \"id:%d\" is hidden of user \"uid:%d\"", userUpdateReq.DefaultAccountId, uid)
|
||||||
|
return nil, errs.ErrUserDefaultAccountIsHidden
|
||||||
|
}
|
||||||
|
|
||||||
user.DefaultAccountId = userUpdateReq.DefaultAccountId
|
user.DefaultAccountId = userUpdateReq.DefaultAccountId
|
||||||
userNew.DefaultAccountId = userUpdateReq.DefaultAccountId
|
userNew.DefaultAccountId = userUpdateReq.DefaultAccountId
|
||||||
anythingUpdate = true
|
anythingUpdate = true
|
||||||
@@ -237,26 +354,127 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
userNew.ShortTimeFormat = models.SHORT_TIME_FORMAT_INVALID
|
userNew.ShortTimeFormat = models.SHORT_TIME_FORMAT_INVALID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.DecimalSeparator != nil && *userUpdateReq.DecimalSeparator != user.DecimalSeparator {
|
||||||
|
user.DecimalSeparator = *userUpdateReq.DecimalSeparator
|
||||||
|
userNew.DecimalSeparator = *userUpdateReq.DecimalSeparator
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.DecimalSeparator = core.DECIMAL_SEPARATOR_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.DigitGroupingSymbol != nil && *userUpdateReq.DigitGroupingSymbol != user.DigitGroupingSymbol {
|
||||||
|
user.DigitGroupingSymbol = *userUpdateReq.DigitGroupingSymbol
|
||||||
|
userNew.DigitGroupingSymbol = *userUpdateReq.DigitGroupingSymbol
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.DigitGroupingSymbol = core.DIGIT_GROUPING_SYMBOL_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.DigitGrouping != nil && *userUpdateReq.DigitGrouping != user.DigitGrouping {
|
||||||
|
user.DigitGrouping = *userUpdateReq.DigitGrouping
|
||||||
|
userNew.DigitGrouping = *userUpdateReq.DigitGrouping
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.DigitGrouping = core.DIGIT_GROUPING_TYPE_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.CurrencyDisplayType != nil && *userUpdateReq.CurrencyDisplayType != user.CurrencyDisplayType {
|
||||||
|
user.CurrencyDisplayType = *userUpdateReq.CurrencyDisplayType
|
||||||
|
userNew.CurrencyDisplayType = *userUpdateReq.CurrencyDisplayType
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.CurrencyDisplayType = models.CURRENCY_DISPLAY_TYPE_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.ExpenseAmountColor != nil && *userUpdateReq.ExpenseAmountColor != user.ExpenseAmountColor {
|
||||||
|
user.ExpenseAmountColor = *userUpdateReq.ExpenseAmountColor
|
||||||
|
userNew.ExpenseAmountColor = *userUpdateReq.ExpenseAmountColor
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.ExpenseAmountColor = models.AMOUNT_COLOR_TYPE_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if userUpdateReq.IncomeAmountColor != nil && *userUpdateReq.IncomeAmountColor != user.IncomeAmountColor {
|
||||||
|
user.IncomeAmountColor = *userUpdateReq.IncomeAmountColor
|
||||||
|
userNew.IncomeAmountColor = *userUpdateReq.IncomeAmountColor
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userNew.IncomeAmountColor = models.AMOUNT_COLOR_TYPE_INVALID
|
||||||
|
}
|
||||||
|
|
||||||
|
if modifyUserLanguage || userNew.DecimalSeparator != core.DECIMAL_SEPARATOR_INVALID || userNew.DigitGroupingSymbol != core.DIGIT_GROUPING_SYMBOL_INVALID {
|
||||||
|
decimalSeparator := userNew.DecimalSeparator
|
||||||
|
digitGroupingSymbol := userNew.DigitGroupingSymbol
|
||||||
|
|
||||||
|
if userNew.DecimalSeparator == core.DECIMAL_SEPARATOR_INVALID {
|
||||||
|
decimalSeparator = user.DecimalSeparator
|
||||||
|
}
|
||||||
|
|
||||||
|
if userNew.DigitGroupingSymbol == core.DIGIT_GROUPING_SYMBOL_INVALID {
|
||||||
|
digitGroupingSymbol = user.DigitGroupingSymbol
|
||||||
|
}
|
||||||
|
|
||||||
|
locale := user.Language
|
||||||
|
|
||||||
|
if modifyUserLanguage {
|
||||||
|
locale = userNew.Language
|
||||||
|
}
|
||||||
|
|
||||||
|
if locale == "" {
|
||||||
|
locale = c.GetClientLocale()
|
||||||
|
}
|
||||||
|
|
||||||
|
if locales.IsDecimalSeparatorEqualsDigitGroupingSymbol(decimalSeparator, digitGroupingSymbol, locale) {
|
||||||
|
return nil, errs.ErrDecimalSeparatorAndDigitGroupingSymbolCannotBeEqual
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !anythingUpdate {
|
if !anythingUpdate {
|
||||||
return nil, errs.ErrNothingWillBeUpdated
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
keyProfileUpdated, err := a.users.UpdateUser(userNew, modifyUserLanguage)
|
keyProfileUpdated, emailSetToUnverified, err := a.users.UpdateUser(c, userNew, modifyUserLanguage)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to update user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.ErrorfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to update user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if emailSetToUnverified {
|
||||||
|
user.EmailVerified = false
|
||||||
|
}
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] user \"uid:%d\" has updated successfully", user.Uid)
|
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] user \"uid:%d\" has updated successfully", user.Uid)
|
||||||
|
|
||||||
resp := &models.UserProfileUpdateResponse{
|
resp := &models.UserProfileUpdateResponse{
|
||||||
User: user.ToUserBasicInfo(),
|
User: user.ToUserBasicInfo(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if emailSetToUnverified && settings.Container.Current.EnableUserVerifyEmail && settings.Container.Current.EnableSMTP {
|
||||||
|
err = a.tokens.DeleteTokensByType(c, uid, core.USER_TOKEN_TYPE_EMAIL_VERIFY)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to revoke old email verify tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
} else {
|
||||||
|
token, _, err := a.tokens.CreateEmailVerifyToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to create email verify token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
} else {
|
||||||
|
go func() {
|
||||||
|
err = a.users.SendVerifyEmail(user, token, c.GetClientLocale())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] cannot send verify email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if keyProfileUpdated {
|
if keyProfileUpdated {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
err = a.tokens.DeleteTokensBeforeTime(uid, now)
|
err = a.tokens.DeleteTokensBeforeTime(c, uid, now)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] revoke old tokens before unix time \"%d\" for user \"uid:%d\"", now, user.Uid)
|
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] revoke old tokens before unix time \"%d\" for user \"uid:%d\"", now, user.Uid)
|
||||||
@@ -264,7 +482,7 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to revoke old tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to revoke old tokens for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
token, claims, err := a.tokens.CreateToken(user, c)
|
token, claims, err := a.tokens.CreateToken(c, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
log.WarnfWithRequestId(c, "[users.UserUpdateProfileHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
@@ -272,6 +490,7 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp.NewToken = token
|
resp.NewToken = token
|
||||||
|
c.SetTextualToken(token)
|
||||||
c.SetTokenClaims(claims)
|
c.SetTokenClaims(claims)
|
||||||
|
|
||||||
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
log.InfofWithRequestId(c, "[users.UserUpdateProfileHandler] user \"uid:%d\" token refreshed, new token will be expired at %d", user.Uid, claims.ExpiresAt)
|
||||||
@@ -281,3 +500,282 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserUpdateAvatarHandler saves user avatar by request parameters for current user
|
||||||
|
func (a *UsersApi) UserUpdateAvatarHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
form, err := c.MultipartForm()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to get multi-part form data for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrParameterInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
avatars := form.File["avatar"]
|
||||||
|
|
||||||
|
if len(avatars) < 1 {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateAvatarHandler] there is no user avatar in request for user \"uid:%d\"", user.Uid)
|
||||||
|
return nil, errs.ErrNoUserAvatar
|
||||||
|
}
|
||||||
|
|
||||||
|
if avatars[0].Size < 1 {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateAvatarHandler] the size of user avatar in request is zero for user \"uid:%d\"", user.Uid)
|
||||||
|
return nil, errs.ErrUserAvatarIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
fileExtension := utils.GetFileNameExtension(avatars[0].Filename)
|
||||||
|
|
||||||
|
if utils.GetImageContentType(fileExtension) == "" {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateAvatarHandler] the file extension \"%s\" of user avatar in request is not supported for user \"uid:%d\"", fileExtension, user.Uid)
|
||||||
|
return nil, errs.ErrImageTypeNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarFile, err := avatars[0].Open()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to get avatar file from request for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
defer avatarFile.Close()
|
||||||
|
|
||||||
|
err = storage.Container.SaveAvatar(user.Uid, avatarFile, fileExtension)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to save avatar file for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.users.UpdateUserAvatar(c, user.Uid, fileExtension)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to update user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
if fileExtension != user.CustomAvatarType {
|
||||||
|
err = storage.Container.DeleteAvatar(user.Uid, user.CustomAvatarType)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserUpdateAvatarHandler] failed to delete old avatar with extension \"%s\" for user \"uid:%d\", because %s", user.CustomAvatarType, user.Uid, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
user.CustomAvatarType = fileExtension
|
||||||
|
userResp := user.ToUserProfileResponse()
|
||||||
|
return userResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserRemoveAvatarHandler removes user avatar by request parameters for current user
|
||||||
|
func (a *UsersApi) UserRemoveAvatarHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRemoveAvatarHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.CustomAvatarType == "" {
|
||||||
|
return nil, errs.ErrNothingWillBeUpdated
|
||||||
|
}
|
||||||
|
|
||||||
|
err = storage.Container.DeleteAvatar(user.Uid, user.CustomAvatarType)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRemoveAvatarHandler] failed to delete avatar file for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
|
||||||
|
exists, err := storage.Container.ExistsAvatar(user.Uid, user.CustomAvatarType)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRemoveAvatarHandler] failed to check whether avatar file exist for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRemoveAvatarHandler] failed to delete whether avatar file exist for user \"uid:%d\", the avatar file still exist", user.Uid)
|
||||||
|
return nil, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.users.UpdateUserAvatar(c, user.Uid, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserRemoveAvatarHandler] failed to update user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
user.CustomAvatarType = ""
|
||||||
|
userResp := user.ToUserProfileResponse()
|
||||||
|
return userResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSendVerifyEmailByUnloginUserHandler sends unlogin user verify email
|
||||||
|
func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
if !settings.Container.Current.EnableUserVerifyEmail {
|
||||||
|
return nil, errs.ErrEmailValidationNotAllowed
|
||||||
|
}
|
||||||
|
|
||||||
|
var userResendVerifyEmailReq models.UserResendVerifyEmailRequest
|
||||||
|
err := c.ShouldBindJSON(&userResendVerifyEmailReq)
|
||||||
|
|
||||||
|
user, err := a.users.GetUserByEmail(c, userResendVerifyEmailReq.Email)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if !a.users.IsPasswordEqualsUserPassword(userResendVerifyEmailReq.Password, user) {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] request password not equals to the user password")
|
||||||
|
return nil, errs.ErrUserPasswordWrong
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Disabled {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] user \"uid:%d\" is disabled", user.Uid)
|
||||||
|
return nil, errs.ErrUserIsDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] user \"uid:%d\" email has been verified", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
if !settings.Container.Current.EnableSMTP {
|
||||||
|
return nil, errs.ErrSMTPServerNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
token, _, err := a.tokens.CreateEmailVerifyToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrTokenGenerating
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = a.users.SendVerifyEmail(user, token, c.GetClientLocale())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByUnloginUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSendVerifyEmailByLoginedUserHandler sends logined user verify email
|
||||||
|
func (a *UsersApi) UserSendVerifyEmailByLoginedUserHandler(c *core.Context) (any, *errs.Error) {
|
||||||
|
if !settings.Container.Current.EnableUserVerifyEmail {
|
||||||
|
return nil, errs.ErrEmailValidationNotAllowed
|
||||||
|
}
|
||||||
|
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.EmailVerified {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] user \"uid:%d\" email has been verified", user.Uid)
|
||||||
|
return nil, errs.ErrEmailIsVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
if !settings.Container.Current.EnableSMTP {
|
||||||
|
return nil, errs.ErrSMTPServerNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
token, _, err := a.tokens.CreateEmailVerifyToken(c, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, errs.ErrTokenGenerating
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = a.users.SendVerifyEmail(user, token, c.GetClientLocale())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserSendVerifyEmailByLoginedUserHandler] cannot send email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserGetAvatarHandler returns user avatar data for current user
|
||||||
|
func (a *UsersApi) UserGetAvatarHandler(c *core.Context) ([]byte, string, *errs.Error) {
|
||||||
|
uid := c.GetCurrentUid()
|
||||||
|
user, err := a.users.GetUserById(c, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if !errs.IsCustomError(err) {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserGetAvatarHandler] failed to get user, because %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, "", errs.ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.CustomAvatarType == "" {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserGetAvatarHandler] user does not have avatar for user \"uid:%d\"", user.Uid)
|
||||||
|
return nil, "", errs.ErrUserAvatarNoExists
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName := c.Param("fileName")
|
||||||
|
fileBaseName := utils.GetFileNameWithoutExtension(fileName)
|
||||||
|
|
||||||
|
if utils.Int64ToString(user.Uid) != fileBaseName {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserGetAvatarHandler] cannot get other user avatar \"uid:%s\" for user \"uid:%d\"", fileBaseName, user.Uid)
|
||||||
|
return nil, "", errs.ErrUserIdInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
fileExtension := utils.GetFileNameExtension(fileName)
|
||||||
|
|
||||||
|
if user.CustomAvatarType != fileExtension {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserGetAvatarHandler] user avatar extension is invalid \"%s\" for user \"uid:%d\"", fileExtension, user.Uid)
|
||||||
|
return nil, "", errs.ErrUserAvatarNoExists
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarFile, err := storage.Container.ReadAvatar(user.Uid, fileExtension)
|
||||||
|
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
log.WarnfWithRequestId(c, "[users.UserGetAvatarHandler] user avatar file not exist for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, "", errs.ErrUserAvatarNoExists
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserGetAvatarHandler] failed to get user avatar object for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, "", errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
defer avatarFile.Close()
|
||||||
|
|
||||||
|
avatarData, err := io.ReadAll(avatarFile)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorfWithRequestId(c, "[users.UserGetAvatarHandler] failed to read user avatar object data for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return nil, "", errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
return avatarData, utils.GetImageContentType(fileExtension), nil
|
||||||
|
}
|
||||||
|
|||||||
+276
-42
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/services"
|
"github.com/mayswind/ezbookkeeping/pkg/services"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ const pageCountForDataExport = 1000
|
|||||||
// UserDataCli represents user data cli
|
// UserDataCli represents user data cli
|
||||||
type UserDataCli struct {
|
type UserDataCli struct {
|
||||||
ezBookKeepingCsvExporter *converters.EzBookKeepingCSVFileExporter
|
ezBookKeepingCsvExporter *converters.EzBookKeepingCSVFileExporter
|
||||||
|
ezBookKeepingTsvExporter *converters.EzBookKeepingTSVFileExporter
|
||||||
accounts *services.AccountService
|
accounts *services.AccountService
|
||||||
transactions *services.TransactionService
|
transactions *services.TransactionService
|
||||||
categories *services.TransactionCategoryService
|
categories *services.TransactionCategoryService
|
||||||
@@ -26,12 +28,14 @@ type UserDataCli struct {
|
|||||||
users *services.UserService
|
users *services.UserService
|
||||||
twoFactorAuthorizations *services.TwoFactorAuthorizationService
|
twoFactorAuthorizations *services.TwoFactorAuthorizationService
|
||||||
tokens *services.TokenService
|
tokens *services.TokenService
|
||||||
|
forgetPasswords *services.ForgetPasswordService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize an user data cli singleton instance
|
// Initialize an user data cli singleton instance
|
||||||
var (
|
var (
|
||||||
UserData = &UserDataCli{
|
UserData = &UserDataCli{
|
||||||
ezBookKeepingCsvExporter: &converters.EzBookKeepingCSVFileExporter{},
|
ezBookKeepingCsvExporter: &converters.EzBookKeepingCSVFileExporter{},
|
||||||
|
ezBookKeepingTsvExporter: &converters.EzBookKeepingTSVFileExporter{},
|
||||||
accounts: services.Accounts,
|
accounts: services.Accounts,
|
||||||
transactions: services.Transactions,
|
transactions: services.Transactions,
|
||||||
categories: services.TransactionCategories,
|
categories: services.TransactionCategories,
|
||||||
@@ -39,6 +43,7 @@ var (
|
|||||||
users: services.Users,
|
users: services.Users,
|
||||||
twoFactorAuthorizations: services.TwoFactorAuthorizations,
|
twoFactorAuthorizations: services.TwoFactorAuthorizations,
|
||||||
tokens: services.Tokens,
|
tokens: services.Tokens,
|
||||||
|
forgetPasswords: services.ForgetPasswords,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ func (l *UserDataCli) AddNewUser(c *cli.Context, username string, email string,
|
|||||||
TransactionEditScope: models.TRANSACTION_EDIT_SCOPE_ALL,
|
TransactionEditScope: models.TRANSACTION_EDIT_SCOPE_ALL,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := l.users.CreateUser(user)
|
err := l.users.CreateUser(nil, user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.AddNewUser] failed to create user \"%s\", because %s", user.Username, err.Error())
|
log.BootErrorf("[user_data.AddNewUser] failed to create user \"%s\", because %s", user.Username, err.Error())
|
||||||
@@ -103,7 +108,7 @@ func (l *UserDataCli) GetUserByUsername(c *cli.Context, username string) (*model
|
|||||||
return nil, errs.ErrUsernameIsEmpty
|
return nil, errs.ErrUsernameIsEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := l.users.GetUserByUsername(username)
|
user, err := l.users.GetUserByUsername(nil, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.GetUserByUsername] failed to get user by user name \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.GetUserByUsername] failed to get user by user name \"%s\", because %s", username, err.Error())
|
||||||
@@ -125,7 +130,7 @@ func (l *UserDataCli) ModifyUserPassword(c *cli.Context, username string, passwo
|
|||||||
return errs.ErrPasswordIsEmpty
|
return errs.ErrPasswordIsEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := l.users.GetUserByUsername(username)
|
user, err := l.users.GetUserByUsername(nil, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ModifyUserPassword] failed to get user by user name \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ModifyUserPassword] failed to get user by user name \"%s\", because %s", username, err.Error())
|
||||||
@@ -142,7 +147,7 @@ func (l *UserDataCli) ModifyUserPassword(c *cli.Context, username string, passwo
|
|||||||
Password: password,
|
Password: password,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = l.users.UpdateUser(userNew, false)
|
_, _, err = l.users.UpdateUser(nil, userNew, false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ModifyUserPassword] failed to update user \"%s\" password, because %s", user.Username, err.Error())
|
log.BootErrorf("[user_data.ModifyUserPassword] failed to update user \"%s\" password, because %s", user.Username, err.Error())
|
||||||
@@ -150,7 +155,7 @@ func (l *UserDataCli) ModifyUserPassword(c *cli.Context, username string, passwo
|
|||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
err = l.tokens.DeleteTokensBeforeTime(user.Uid, now)
|
err = l.tokens.DeleteTokensBeforeTime(nil, user.Uid, now)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.BootInfof("[user_data.ModifyUserPassword] revoke old tokens before unix time \"%d\" for user \"%s\"", now, user.Username)
|
log.BootInfof("[user_data.ModifyUserPassword] revoke old tokens before unix time \"%d\" for user \"%s\"", now, user.Username)
|
||||||
@@ -161,6 +166,150 @@ func (l *UserDataCli) ModifyUserPassword(c *cli.Context, username string, passwo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendPasswordResetMail sends an email with password reset link
|
||||||
|
func (l *UserDataCli) SendPasswordResetMail(c *cli.Context, username string) error {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.SendPasswordResetMail] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := l.users.GetUserByUsername(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.SendPasswordResetMail] failed to get user by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.Container.Current.ForgetPasswordRequireVerifyEmail && !user.EmailVerified {
|
||||||
|
log.BootWarnf("[user_data.SendPasswordResetMail] user \"uid:%d\" has not verified email", user.Uid)
|
||||||
|
return errs.ErrEmailIsNotVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
token, _, err := l.tokens.CreatePasswordResetToken(nil, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.SendPasswordResetMail] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = l.forgetPasswords.SendPasswordResetEmail(nil, user, token, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootWarnf("[user_data.SendPasswordResetMail] cannot send email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableUser sets user enabled according to the specified user name
|
||||||
|
func (l *UserDataCli) EnableUser(c *cli.Context, username string) error {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.EnableUser] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
err := l.users.EnableUser(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.EnableUser] failed to set user enabled by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableUser sets user disabled according to the specified user name
|
||||||
|
func (l *UserDataCli) DisableUser(c *cli.Context, username string) error {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.DisableUser] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
err := l.users.DisableUser(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.DisableUser] failed to set user disabled by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResendVerifyEmail resends an email with account activation link
|
||||||
|
func (l *UserDataCli) ResendVerifyEmail(c *cli.Context, username string) error {
|
||||||
|
if !settings.Container.Current.EnableUserVerifyEmail {
|
||||||
|
return errs.ErrEmailValidationNotAllowed
|
||||||
|
}
|
||||||
|
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.ResendVerifyEmail] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := l.users.GetUserByUsername(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.ResendVerifyEmail] failed to get user by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.EmailVerified {
|
||||||
|
log.BootWarnf("[user_data.ResendVerifyEmail] user \"uid:%d\" email has been verified", user.Uid)
|
||||||
|
return errs.ErrEmailIsVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
token, _, err := l.tokens.CreateEmailVerifyToken(nil, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.ResendVerifyEmail] failed to create token for user \"uid:%d\", because %s", user.Uid, err.Error())
|
||||||
|
return errs.ErrTokenGenerating
|
||||||
|
}
|
||||||
|
|
||||||
|
err = l.users.SendVerifyEmail(user, token, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.ResendVerifyEmail] cannot send email to \"%s\", because %s", user.Email, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserEmailVerified sets user email address verified
|
||||||
|
func (l *UserDataCli) SetUserEmailVerified(c *cli.Context, username string) error {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.SetUserEmailVerified] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
err := l.users.SetUserEmailVerified(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.SetUserEmailVerified] failed to set user email address verified by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserEmailUnverified sets user email address unverified
|
||||||
|
func (l *UserDataCli) SetUserEmailUnverified(c *cli.Context, username string) error {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.SetUserEmailUnverified] user name is empty")
|
||||||
|
return errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
err := l.users.SetUserEmailUnverified(nil, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.SetUserEmailUnverified] failed to set user email address unverified by user name \"%s\", because %s", username, err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteUser deletes user according to the specified user name
|
// DeleteUser deletes user according to the specified user name
|
||||||
func (l *UserDataCli) DeleteUser(c *cli.Context, username string) error {
|
func (l *UserDataCli) DeleteUser(c *cli.Context, username string) error {
|
||||||
if username == "" {
|
if username == "" {
|
||||||
@@ -168,7 +317,7 @@ func (l *UserDataCli) DeleteUser(c *cli.Context, username string) error {
|
|||||||
return errs.ErrUsernameIsEmpty
|
return errs.ErrUsernameIsEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
err := l.users.DeleteUser(username)
|
err := l.users.DeleteUser(nil, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.DeleteUser] failed to delete user by user name \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.DeleteUser] failed to delete user by user name \"%s\", because %s", username, err.Error())
|
||||||
@@ -192,7 +341,7 @@ func (l *UserDataCli) ListUserTokens(c *cli.Context, username string) ([]*models
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens, err := l.tokens.GetAllUnexpiredNormalTokensByUid(uid)
|
tokens, err := l.tokens.GetAllUnexpiredNormalTokensByUid(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ListUserTokens] failed to get tokens of user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ListUserTokens] failed to get tokens of user \"%s\", because %s", username, err.Error())
|
||||||
@@ -217,7 +366,7 @@ func (l *UserDataCli) ClearUserTokens(c *cli.Context, username string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
err = l.tokens.DeleteTokensBeforeTime(uid, now)
|
err = l.tokens.DeleteTokensBeforeTime(nil, uid, now)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ClearUserTokens] failed to delete tokens of user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ClearUserTokens] failed to delete tokens of user \"%s\", because %s", username, err.Error())
|
||||||
@@ -241,10 +390,10 @@ func (l *UserDataCli) DisableUserTwoFactorAuthorization(c *cli.Context, username
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
enableTwoFactor, err := l.twoFactorAuthorizations.ExistsTwoFactorSetting(uid)
|
enableTwoFactor, err := l.twoFactorAuthorizations.ExistsTwoFactorSetting(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to check two factor setting, because %s", err.Error())
|
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to check two-factor setting, because %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,17 +401,17 @@ func (l *UserDataCli) DisableUserTwoFactorAuthorization(c *cli.Context, username
|
|||||||
return errs.ErrTwoFactorIsNotEnabled
|
return errs.ErrTwoFactorIsNotEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l.twoFactorAuthorizations.DeleteTwoFactorRecoveryCodes(uid)
|
err = l.twoFactorAuthorizations.DeleteTwoFactorRecoveryCodes(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to delete two factor recovery codes for user \"%s\"", username)
|
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to delete two-factor recovery codes for user \"%s\"", username)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l.twoFactorAuthorizations.DeleteTwoFactorSetting(uid)
|
err = l.twoFactorAuthorizations.DeleteTwoFactorSetting(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to delete two factor setting for user \"%s\"", username)
|
log.BootErrorf("[user_data.DisableUserTwoFactorAuthorization] failed to delete two-factor setting for user \"%s\"", username)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +432,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
accountMap, categoryMap, tagMap, tagIndexs, err := l.getUserEssentialData(uid, username)
|
accountMap, categoryMap, tagMap, tagIndexes, tagIndexesMap, err := l.getUserEssentialData(uid, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.CheckTransactionAndAccount] failed to get essential data for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] failed to get essential data for user \"%s\", because %s", username, err.Error())
|
||||||
@@ -298,7 +447,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allTransactions, err := l.transactions.GetAllTransactions(uid, pageCountForGettingTransactions, false)
|
allTransactions, err := l.transactions.GetAllTransactions(nil, uid, pageCountForGettingTransactions, false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.CheckTransactionAndAccount] failed to all transactions for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] failed to all transactions for user \"%s\", because %s", username, err.Error())
|
||||||
@@ -323,7 +472,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l.checkTransactionTag(c, transaction.TransactionId, tagIndexs, tagMap)
|
err = l.checkTransactionTag(c, transaction.TransactionId, tagIndexesMap, tagMap)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -352,7 +501,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
} else if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
} else if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
||||||
balance = balance + transaction.Amount
|
balance = balance + transaction.Amount
|
||||||
} else {
|
} else {
|
||||||
log.BootErrorf("[user_data.CheckAccountBalance] transaction type of transaction \"id:%d\" is invalid", transaction.TransactionId)
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] transaction type of transaction \"id:%d\" is invalid", transaction.TransactionId)
|
||||||
return false, errs.ErrOperationFailed
|
return false, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,12 +516,12 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !exists && account.Balance != 0 {
|
if !exists && account.Balance != 0 {
|
||||||
log.BootErrorf("[user_data.CheckAccountBalance] account \"id:%d\" balance is not correct, expected balance is %d, but there is no transaction actually", account.AccountId, account.Balance)
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] account \"id:%d\" balance is not correct, expected balance is %d, but there is no transaction actually", account.AccountId, account.Balance)
|
||||||
return false, errs.ErrOperationFailed
|
return false, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
if account.Balance != actualBalance {
|
if account.Balance != actualBalance {
|
||||||
log.BootErrorf("[user_data.CheckAccountBalance] account \"id:%d\" balance is not correct, expected balance is %d, but actual balance is %d", account.AccountId, account.Balance, actualBalance)
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] account \"id:%d\" balance is not correct, expected balance is %d, but actual balance is %d", account.AccountId, account.Balance, actualBalance)
|
||||||
return false, errs.ErrOperationFailed
|
return false, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,7 +530,16 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
_, exists := accountMap[accountId]
|
_, exists := accountMap[accountId]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
log.BootErrorf("[user_data.CheckAccountBalance] account \"id:%d\" does not exist, but there are some transactions of this account actually, and actual balance is %d", accountId, actualBalance)
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] account \"id:%d\" does not exist, but there are some transactions of this account actually, and actual balance is %d", accountId, actualBalance)
|
||||||
|
return false, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(tagIndexes); i++ {
|
||||||
|
tagIndex := tagIndexes[i]
|
||||||
|
|
||||||
|
if tagIndex.TransactionTime < 1 {
|
||||||
|
log.BootErrorf("[user_data.CheckTransactionAndAccount] transaction tag index \"id:%d\" does not have transaction time", tagIndex.TagIndexId)
|
||||||
return false, errs.ErrOperationFailed
|
return false, errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,8 +547,74 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FixTransactionTagIndexWithTransactionTime fixes user transaction tag index data with transaction time
|
||||||
|
func (l *UserDataCli) FixTransactionTagIndexWithTransactionTime(c *cli.Context, username string) (bool, error) {
|
||||||
|
if username == "" {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] user name is empty")
|
||||||
|
return false, errs.ErrUsernameIsEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
uid, err := l.getUserIdByUsername(c, username)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] error occurs when getting user id by user name")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tagIndexes, err := l.tags.GetAllTagIdsOfAllTransactions(nil, uid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] failed to get tag index for user \"%s\", because %s", username, err.Error())
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidTagIndexes := make([]*models.TransactionTagIndex, 0, len(tagIndexes))
|
||||||
|
|
||||||
|
for i := 0; i < len(tagIndexes); i++ {
|
||||||
|
tagIndex := tagIndexes[i]
|
||||||
|
|
||||||
|
if tagIndex.TransactionTime < 1 {
|
||||||
|
invalidTagIndexes = append(invalidTagIndexes, tagIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(invalidTagIndexes) < 1 {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] all user transaction tag index data has been checked, there is no problem with user data")
|
||||||
|
return false, errs.ErrOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
allTransactions, err := l.transactions.GetAllTransactions(nil, uid, pageCountForGettingTransactions, false)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] failed to all transactions for user \"%s\", because %s", username, err.Error())
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionMap := l.transactions.GetTransactionMapByList(allTransactions)
|
||||||
|
|
||||||
|
for i := 0; i < len(invalidTagIndexes); i++ {
|
||||||
|
tagIndex := invalidTagIndexes[i]
|
||||||
|
transaction, exists := transactionMap[tagIndex.TransactionId]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
tagIndex.TransactionTime = transaction.TransactionTime
|
||||||
|
}
|
||||||
|
|
||||||
|
err = l.tags.ModifyTagIndexTransactionTime(nil, uid, invalidTagIndexes)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] failed to update transaction tag index for user \"%s\", because %s", username, err.Error())
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ExportTransaction returns csv file content according user all transactions
|
// ExportTransaction returns csv file content according user all transactions
|
||||||
func (l *UserDataCli) ExportTransaction(c *cli.Context, username string) ([]byte, error) {
|
func (l *UserDataCli) ExportTransaction(c *cli.Context, username string, fileType string) ([]byte, error) {
|
||||||
if username == "" {
|
if username == "" {
|
||||||
log.BootErrorf("[user_data.ExportTransaction] user name is empty")
|
log.BootErrorf("[user_data.ExportTransaction] user name is empty")
|
||||||
return nil, errs.ErrUsernameIsEmpty
|
return nil, errs.ErrUsernameIsEmpty
|
||||||
@@ -403,21 +627,29 @@ func (l *UserDataCli) ExportTransaction(c *cli.Context, username string) ([]byte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
accountMap, categoryMap, tagMap, tagIndexs, err := l.getUserEssentialData(uid, username)
|
accountMap, categoryMap, tagMap, _, tagIndexesMap, err := l.getUserEssentialData(uid, username)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ExportTransaction] failed to get essential data for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ExportTransaction] failed to get essential data for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
allTransactions, err := l.transactions.GetAllTransactions(uid, pageCountForDataExport, true)
|
allTransactions, err := l.transactions.GetAllTransactions(nil, uid, pageCountForDataExport, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ExportTransaction] failed to all transactions for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ExportTransaction] failed to all transactions for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := l.ezBookKeepingCsvExporter.ToExportedContent(uid, time.Local, allTransactions, accountMap, categoryMap, tagMap, tagIndexs)
|
var dataExporter converters.DataConverter
|
||||||
|
|
||||||
|
if fileType == "tsv" {
|
||||||
|
dataExporter = l.ezBookKeepingTsvExporter
|
||||||
|
} else {
|
||||||
|
dataExporter = l.ezBookKeepingCsvExporter
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexesMap)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.ExportTransaction] failed to get csv format exported data for \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.ExportTransaction] failed to get csv format exported data for \"%s\", because %s", username, err.Error())
|
||||||
@@ -438,47 +670,49 @@ func (l *UserDataCli) getUserIdByUsername(c *cli.Context, username string) (int6
|
|||||||
return user.Uid, nil
|
return user.Uid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UserDataCli) getUserEssentialData(uid int64, username string) (accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, tagIndexs map[int64][]int64, err error) {
|
func (l *UserDataCli) getUserEssentialData(uid int64, username string) (accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, tagIndexes []*models.TransactionTagIndex, tagIndexesMap map[int64][]int64, err error) {
|
||||||
if uid <= 0 {
|
if uid <= 0 {
|
||||||
log.BootErrorf("[user_data.getUserEssentialData] user uid \"%d\" is invalid", uid)
|
log.BootErrorf("[user_data.getUserEssentialData] user uid \"%d\" is invalid", uid)
|
||||||
return nil, nil, nil, nil, errs.ErrUserIdInvalid
|
return nil, nil, nil, nil, nil, errs.ErrUserIdInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts, err := l.accounts.GetAllAccountsByUid(uid)
|
accounts, err := l.accounts.GetAllAccountsByUid(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.getUserEssentialData] failed to get accounts for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.getUserEssentialData] failed to get accounts for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
accountMap = l.accounts.GetAccountMapByList(accounts)
|
accountMap = l.accounts.GetAccountMapByList(accounts)
|
||||||
|
|
||||||
categories, err := l.categories.GetAllCategoriesByUid(uid, 0, -1)
|
categories, err := l.categories.GetAllCategoriesByUid(nil, uid, 0, -1)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.getUserEssentialData] failed to get categories for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.getUserEssentialData] failed to get categories for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
categoryMap = l.categories.GetCategoryMapByList(categories)
|
categoryMap = l.categories.GetCategoryMapByList(categories)
|
||||||
|
|
||||||
tags, err := l.tags.GetAllTagsByUid(uid)
|
tags, err := l.tags.GetAllTagsByUid(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.getUserEssentialData] failed to get tags for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.getUserEssentialData] failed to get tags for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tagMap = l.tags.GetTagMapByList(tags)
|
tagMap = l.tags.GetTagMapByList(tags)
|
||||||
|
|
||||||
tagIndexs, err = l.tags.GetAllTagIdsOfAllTransactions(uid)
|
tagIndexes, err = l.tags.GetAllTagIdsOfAllTransactions(nil, uid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.BootErrorf("[user_data.getUserEssentialData] failed to get tag index for user \"%s\", because %s", username, err.Error())
|
log.BootErrorf("[user_data.getUserEssentialData] failed to get tag index for user \"%s\", because %s", username, err.Error())
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountMap, categoryMap, tagMap, tagIndexs, nil
|
tagIndexesMap = l.tags.GetGroupedTransactionTagIds(tagIndexes)
|
||||||
|
|
||||||
|
return accountMap, categoryMap, tagMap, tagIndexes, tagIndexesMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UserDataCli) checkTransactionAccount(c *cli.Context, transaction *models.Transaction, accountMap map[int64]*models.Account, accountHasChild map[int64]bool) error {
|
func (l *UserDataCli) checkTransactionAccount(c *cli.Context, transaction *models.Transaction, accountMap map[int64]*models.Account, accountHasChild map[int64]bool) error {
|
||||||
@@ -490,7 +724,7 @@ func (l *UserDataCli) checkTransactionAccount(c *cli.Context, transaction *model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if account.ParentAccountId == models.LevelOneAccountParentId && accountHasChild[account.AccountId] {
|
if account.ParentAccountId == models.LevelOneAccountParentId && accountHasChild[account.AccountId] {
|
||||||
log.BootErrorf("[user_data.checkTransactionAccount] the account \"id:%d\" of transaction \"id:%d\" is not a sub account", transaction.AccountId, transaction.TransactionId)
|
log.BootErrorf("[user_data.checkTransactionAccount] the account \"id:%d\" of transaction \"id:%d\" is not a sub-account", transaction.AccountId, transaction.TransactionId)
|
||||||
return errs.ErrOperationFailed
|
return errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,7 +737,7 @@ func (l *UserDataCli) checkTransactionAccount(c *cli.Context, transaction *model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if relatedAccount.ParentAccountId == models.LevelOneAccountParentId && accountHasChild[relatedAccount.AccountId] {
|
if relatedAccount.ParentAccountId == models.LevelOneAccountParentId && accountHasChild[relatedAccount.AccountId] {
|
||||||
log.BootErrorf("[user_data.checkTransactionAccount] the related account \"id:%d\" of transaction \"id:%d\" is not a sub account", transaction.RelatedAccountId, transaction.TransactionId)
|
log.BootErrorf("[user_data.checkTransactionAccount] the related account \"id:%d\" of transaction \"id:%d\" is not a sub-account", transaction.RelatedAccountId, transaction.TransactionId)
|
||||||
return errs.ErrOperationFailed
|
return errs.ErrOperationFailed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -536,15 +770,15 @@ func (l *UserDataCli) checkTransactionCategory(c *cli.Context, transaction *mode
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UserDataCli) checkTransactionTag(c *cli.Context, transactionId int64, allTagIndexs map[int64][]int64, tagMap map[int64]*models.TransactionTag) error {
|
func (l *UserDataCli) checkTransactionTag(c *cli.Context, transactionId int64, allTagIndexesMap map[int64][]int64, tagMap map[int64]*models.TransactionTag) error {
|
||||||
tagIndexs, exists := allTagIndexs[transactionId]
|
tagIndexes, exists := allTagIndexesMap[transactionId]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(tagIndexs); i++ {
|
for i := 0; i < len(tagIndexes); i++ {
|
||||||
tagIndex := tagIndexs[i]
|
tagIndex := tagIndexes[i]
|
||||||
tag, exists := tagMap[tagIndex]
|
tag, exists := tagMap[tagIndex]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package converters
|
package converters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DataConverter defines the structure of data exporter
|
// DataConverter defines the structure of data exporter
|
||||||
type DataConverter interface {
|
type DataConverter interface {
|
||||||
// ToExportedContent returns the exported data
|
// ToExportedContent returns the exported data
|
||||||
ToExportedContent(uid int64, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error)
|
ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,179 +1,17 @@
|
|||||||
package converters
|
package converters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// EzBookKeepingCSVFileExporter defines the structure of csv file exporter
|
// EzBookKeepingCSVFileExporter defines the structure of CSV file exporter
|
||||||
type EzBookKeepingCSVFileExporter struct {
|
type EzBookKeepingCSVFileExporter struct {
|
||||||
DataConverter
|
EzBookKeepingPlainFileExporter
|
||||||
}
|
}
|
||||||
|
|
||||||
const csvHeaderLine = "Time,Timezone,Type,Category,Sub Category,Account,Account Currency,Amount,Account2,Account2 Currency,Account2 Amount,Tags,Comment\n"
|
const csvSeparator = ","
|
||||||
const csvDataLineFormat = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n"
|
|
||||||
|
|
||||||
// ToExportedContent returns the exported csv data
|
// ToExportedContent returns the exported CSV data
|
||||||
func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) {
|
func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) {
|
||||||
var ret strings.Builder
|
return e.toExportedContent(uid, csvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexes)
|
||||||
|
|
||||||
ret.Grow(len(transactions) * 100)
|
|
||||||
ret.WriteString(csvHeaderLine)
|
|
||||||
|
|
||||||
for i := 0; i < len(transactions); i++ {
|
|
||||||
transaction := transactions[i]
|
|
||||||
|
|
||||||
if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
transactionTimeZone := time.FixedZone("Transaction Timezone", int(transaction.TimezoneUtcOffset)*60)
|
|
||||||
transactionTime := utils.FormatUnixTimeToLongDateTimeWithoutSecond(utils.GetUnixTimeFromTransactionTime(transaction.TransactionTime), transactionTimeZone)
|
|
||||||
transactionTimezone := utils.FormatTimezoneOffset(transactionTimeZone)
|
|
||||||
transactionType := e.getTransactionTypeName(transaction.Type)
|
|
||||||
category := e.getTransactionCategoryName(transaction.CategoryId, categoryMap)
|
|
||||||
subCategory := e.getTransactionSubCategoryName(transaction.CategoryId, categoryMap)
|
|
||||||
account := e.getAccountName(transaction.AccountId, accountMap)
|
|
||||||
accountCurrency := e.getAccountCurrency(transaction.AccountId, accountMap)
|
|
||||||
amount := e.getDisplayAmount(transaction.Amount)
|
|
||||||
account2 := ""
|
|
||||||
account2Currency := ""
|
|
||||||
account2Amount := ""
|
|
||||||
|
|
||||||
if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT {
|
|
||||||
account2 = e.getAccountName(transaction.RelatedAccountId, accountMap)
|
|
||||||
account2Currency = e.getAccountCurrency(transaction.RelatedAccountId, accountMap)
|
|
||||||
account2Amount = e.getDisplayAmount(transaction.RelatedAccountAmount)
|
|
||||||
}
|
|
||||||
|
|
||||||
tags := e.getTags(transaction.TransactionId, allTagIndexs, tagMap)
|
|
||||||
comment := e.getComment(transaction.Comment)
|
|
||||||
|
|
||||||
ret.WriteString(fmt.Sprintf(csvDataLineFormat, transactionTime, transactionTimezone, transactionType, category, subCategory, account, accountCurrency, amount, account2, account2Currency, account2Amount, tags, comment))
|
|
||||||
}
|
|
||||||
|
|
||||||
return []byte(ret.String()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getTransactionTypeName(transactionDbType models.TransactionDbType) string {
|
|
||||||
if transactionDbType == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
|
|
||||||
return "Balance Modification"
|
|
||||||
} else if transactionDbType == models.TRANSACTION_DB_TYPE_INCOME {
|
|
||||||
return "Income"
|
|
||||||
} else if transactionDbType == models.TRANSACTION_DB_TYPE_EXPENSE {
|
|
||||||
return "Expense"
|
|
||||||
} else if transactionDbType == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transactionDbType == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
|
||||||
return "Transfer"
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getTransactionCategoryName(categoryId int64, categoryMap map[int64]*models.TransactionCategory) string {
|
|
||||||
category, exists := categoryMap[categoryId]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if category.ParentCategoryId == 0 {
|
|
||||||
return category.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
parentCategory, exists := categoryMap[category.ParentCategoryId]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return parentCategory.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getTransactionSubCategoryName(categoryId int64, categoryMap map[int64]*models.TransactionCategory) string {
|
|
||||||
category, exists := categoryMap[categoryId]
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
return category.Name
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getAccountName(accountId int64, accountMap map[int64]*models.Account) string {
|
|
||||||
account, exists := accountMap[accountId]
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
return account.Name
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getAccountCurrency(accountId int64, accountMap map[int64]*models.Account) string {
|
|
||||||
account, exists := accountMap[accountId]
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
return account.Currency
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getDisplayAmount(amount int64) string {
|
|
||||||
displayAmount := utils.Int64ToString(amount)
|
|
||||||
integer := utils.SubString(displayAmount, 0, len(displayAmount)-2)
|
|
||||||
decimals := utils.SubString(displayAmount, -2, 2)
|
|
||||||
|
|
||||||
if integer == "" {
|
|
||||||
integer = "0"
|
|
||||||
} else if integer == "-" {
|
|
||||||
integer = "-0"
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(decimals) == 0 {
|
|
||||||
decimals = "00"
|
|
||||||
} else if len(decimals) == 1 {
|
|
||||||
decimals = "0" + decimals
|
|
||||||
}
|
|
||||||
|
|
||||||
return integer + "." + decimals
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getTags(transactionId int64, allTagIndexs map[int64][]int64, tagMap map[int64]*models.TransactionTag) string {
|
|
||||||
tagIndexs, exists := allTagIndexs[transactionId]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var ret strings.Builder
|
|
||||||
|
|
||||||
for i := 0; i < len(tagIndexs); i++ {
|
|
||||||
if i > 0 {
|
|
||||||
ret.WriteString(";")
|
|
||||||
}
|
|
||||||
|
|
||||||
tagIndex := tagIndexs[i]
|
|
||||||
tag, exists := tagMap[tagIndex]
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.WriteString(tag.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EzBookKeepingCSVFileExporter) getComment(comment string) string {
|
|
||||||
comment = strings.Replace(comment, ",", " ", -1)
|
|
||||||
comment = strings.Replace(comment, "\r\n", " ", -1)
|
|
||||||
comment = strings.Replace(comment, "\n", " ", -1)
|
|
||||||
|
|
||||||
return comment
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
package converters
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EzBookKeepingPlainFileExporter defines the structure of plain file exporter
|
||||||
|
type EzBookKeepingPlainFileExporter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
const lineSeparator = "\n"
|
||||||
|
const geoLocationSeparator = " "
|
||||||
|
const transactionTagSeparator = ";"
|
||||||
|
const headerLine = "Time,Timezone,Type,Category,Sub Category,Account,Account Currency,Amount,Account2,Account2 Currency,Account2 Amount,Geographic Location,Tags,Description" + lineSeparator
|
||||||
|
const dataLineFormat = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" + lineSeparator
|
||||||
|
|
||||||
|
// toExportedContent returns the exported plain data
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator string, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) {
|
||||||
|
var ret strings.Builder
|
||||||
|
|
||||||
|
ret.Grow(len(transactions) * 100)
|
||||||
|
|
||||||
|
actualHeaderLine := headerLine
|
||||||
|
actualDataLineFormat := dataLineFormat
|
||||||
|
|
||||||
|
if separator != "," {
|
||||||
|
actualHeaderLine = strings.Replace(headerLine, ",", separator, -1)
|
||||||
|
actualDataLineFormat = strings.Replace(dataLineFormat, ",", separator, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.WriteString(actualHeaderLine)
|
||||||
|
|
||||||
|
for i := 0; i < len(transactions); i++ {
|
||||||
|
transaction := transactions[i]
|
||||||
|
|
||||||
|
if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionTimeZone := time.FixedZone("Transaction Timezone", int(transaction.TimezoneUtcOffset)*60)
|
||||||
|
transactionTime := utils.FormatUnixTimeToLongDateTime(utils.GetUnixTimeFromTransactionTime(transaction.TransactionTime), transactionTimeZone)
|
||||||
|
transactionTimezone := utils.FormatTimezoneOffset(transactionTimeZone)
|
||||||
|
transactionType := e.getTransactionTypeName(transaction.Type)
|
||||||
|
category := e.replaceDelimiters(e.getTransactionCategoryName(transaction.CategoryId, categoryMap), separator)
|
||||||
|
subCategory := e.replaceDelimiters(e.getTransactionSubCategoryName(transaction.CategoryId, categoryMap), separator)
|
||||||
|
account := e.replaceDelimiters(e.getAccountName(transaction.AccountId, accountMap), separator)
|
||||||
|
accountCurrency := e.getAccountCurrency(transaction.AccountId, accountMap)
|
||||||
|
amount := e.getDisplayAmount(transaction.Amount)
|
||||||
|
account2 := ""
|
||||||
|
account2Currency := ""
|
||||||
|
account2Amount := ""
|
||||||
|
geoLocation := ""
|
||||||
|
|
||||||
|
if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT {
|
||||||
|
account2 = e.replaceDelimiters(e.getAccountName(transaction.RelatedAccountId, accountMap), separator)
|
||||||
|
account2Currency = e.getAccountCurrency(transaction.RelatedAccountId, accountMap)
|
||||||
|
account2Amount = e.getDisplayAmount(transaction.RelatedAccountAmount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if transaction.GeoLongitude != 0 || transaction.GeoLatitude != 0 {
|
||||||
|
geoLocation = fmt.Sprintf("%f%s%f", transaction.GeoLongitude, geoLocationSeparator, transaction.GeoLatitude)
|
||||||
|
}
|
||||||
|
|
||||||
|
tags := e.replaceDelimiters(e.getTags(transaction.TransactionId, allTagIndexes, tagMap), separator)
|
||||||
|
comment := e.replaceDelimiters(transaction.Comment, separator)
|
||||||
|
|
||||||
|
ret.WriteString(fmt.Sprintf(actualDataLineFormat, transactionTime, transactionTimezone, transactionType, category, subCategory, account, accountCurrency, amount, account2, account2Currency, account2Amount, geoLocation, tags, comment))
|
||||||
|
}
|
||||||
|
|
||||||
|
return []byte(ret.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getTransactionTypeName(transactionDbType models.TransactionDbType) string {
|
||||||
|
if transactionDbType == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
|
||||||
|
return "Balance Modification"
|
||||||
|
} else if transactionDbType == models.TRANSACTION_DB_TYPE_INCOME {
|
||||||
|
return "Income"
|
||||||
|
} else if transactionDbType == models.TRANSACTION_DB_TYPE_EXPENSE {
|
||||||
|
return "Expense"
|
||||||
|
} else if transactionDbType == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transactionDbType == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
|
||||||
|
return "Transfer"
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getTransactionCategoryName(categoryId int64, categoryMap map[int64]*models.TransactionCategory) string {
|
||||||
|
category, exists := categoryMap[categoryId]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if category.ParentCategoryId == 0 {
|
||||||
|
return category.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
parentCategory, exists := categoryMap[category.ParentCategoryId]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return parentCategory.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getTransactionSubCategoryName(categoryId int64, categoryMap map[int64]*models.TransactionCategory) string {
|
||||||
|
category, exists := categoryMap[categoryId]
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
return category.Name
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getAccountName(accountId int64, accountMap map[int64]*models.Account) string {
|
||||||
|
account, exists := accountMap[accountId]
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
return account.Name
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getAccountCurrency(accountId int64, accountMap map[int64]*models.Account) string {
|
||||||
|
account, exists := accountMap[accountId]
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
return account.Currency
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getDisplayAmount(amount int64) string {
|
||||||
|
displayAmount := utils.Int64ToString(amount)
|
||||||
|
integer := utils.SubString(displayAmount, 0, len(displayAmount)-2)
|
||||||
|
decimals := utils.SubString(displayAmount, -2, 2)
|
||||||
|
|
||||||
|
if integer == "" {
|
||||||
|
integer = "0"
|
||||||
|
} else if integer == "-" {
|
||||||
|
integer = "-0"
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(decimals) == 0 {
|
||||||
|
decimals = "00"
|
||||||
|
} else if len(decimals) == 1 {
|
||||||
|
decimals = "0" + decimals
|
||||||
|
}
|
||||||
|
|
||||||
|
return integer + "." + decimals
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) getTags(transactionId int64, allTagIndexes map[int64][]int64, tagMap map[int64]*models.TransactionTag) string {
|
||||||
|
tagIndexes, exists := allTagIndexes[transactionId]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
var ret strings.Builder
|
||||||
|
|
||||||
|
for i := 0; i < len(tagIndexes); i++ {
|
||||||
|
if i > 0 {
|
||||||
|
ret.WriteString(transactionTagSeparator)
|
||||||
|
}
|
||||||
|
|
||||||
|
tagIndex := tagIndexes[i]
|
||||||
|
tag, exists := tagMap[tagIndex]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.WriteString(tag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EzBookKeepingPlainFileExporter) replaceDelimiters(text string, separator string) string {
|
||||||
|
text = strings.Replace(text, separator, " ", -1)
|
||||||
|
text = strings.Replace(text, "\r\n", " ", -1)
|
||||||
|
text = strings.Replace(text, "\n", " ", -1)
|
||||||
|
|
||||||
|
return text
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package converters
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EzBookKeepingTSVFileExporter defines the structure of TSV file exporter
|
||||||
|
type EzBookKeepingTSVFileExporter struct {
|
||||||
|
EzBookKeepingPlainFileExporter
|
||||||
|
}
|
||||||
|
|
||||||
|
const tsvSeparator = "\t"
|
||||||
|
|
||||||
|
// ToExportedContent returns the exported TSV data
|
||||||
|
func (e *EzBookKeepingTSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) {
|
||||||
|
return e.toExportedContent(uid, tsvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexes)
|
||||||
|
}
|
||||||
+62
-1
@@ -1,6 +1,7 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -9,9 +10,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const requestIdFieldKey = "REQUEST_ID"
|
const requestIdFieldKey = "REQUEST_ID"
|
||||||
|
const textualTokenFieldKey = "TOKEN_STRING"
|
||||||
const tokenClaimsFieldKey = "TOKEN_CLAIMS"
|
const tokenClaimsFieldKey = "TOKEN_CLAIMS"
|
||||||
const responseErrorFieldKey = "RESPONSE_ERROR"
|
const responseErrorFieldKey = "RESPONSE_ERROR"
|
||||||
|
|
||||||
|
// AcceptLanguageHeaderName represents the header name of accept language
|
||||||
|
const AcceptLanguageHeaderName = "Accept-Language"
|
||||||
|
|
||||||
|
// RemoteClientPortHeader represents the header name of remote client source port
|
||||||
|
const RemoteClientPortHeader = "X-Real-Port"
|
||||||
|
|
||||||
// ClientTimezoneOffsetHeaderName represents the header name of client timezone offset
|
// ClientTimezoneOffsetHeaderName represents the header name of client timezone offset
|
||||||
const ClientTimezoneOffsetHeaderName = "X-Timezone-Offset"
|
const ClientTimezoneOffsetHeaderName = "X-Timezone-Offset"
|
||||||
|
|
||||||
@@ -21,6 +29,36 @@ type Context struct {
|
|||||||
// DO NOT ADD ANY FIELD IN THIS CONTEXT, THIS CONTEXT IS JUST A WRAPPER
|
// DO NOT ADD ANY FIELD IN THIS CONTEXT, THIS CONTEXT IS JUST A WRAPPER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Context) ClientPort() uint16 {
|
||||||
|
remotePort := c.GetHeader(RemoteClientPortHeader)
|
||||||
|
|
||||||
|
if remotePort != "" {
|
||||||
|
remotePortNum, err := strconv.ParseInt(remotePort, 10, 32)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
return uint16(remotePortNum)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Request == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_, remotePort, err := net.SplitHostPort(c.Request.RemoteAddr)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
remotePortNum, err := strconv.ParseInt(remotePort, 10, 32)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return uint16(remotePortNum)
|
||||||
|
}
|
||||||
|
|
||||||
// SetRequestId sets the given request id to context
|
// SetRequestId sets the given request id to context
|
||||||
func (c *Context) SetRequestId(requestId string) {
|
func (c *Context) SetRequestId(requestId string) {
|
||||||
c.Set(requestIdFieldKey, requestId)
|
c.Set(requestIdFieldKey, requestId)
|
||||||
@@ -37,7 +75,23 @@ func (c *Context) GetRequestId() string {
|
|||||||
return requestId.(string)
|
return requestId.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTokenClaims sets the given user token id to context
|
// SetTextualToken sets the given user token to context
|
||||||
|
func (c *Context) SetTextualToken(token string) {
|
||||||
|
c.Set(textualTokenFieldKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTextualToken returns the current user textual token
|
||||||
|
func (c *Context) GetTextualToken() string {
|
||||||
|
token, exists := c.Get(textualTokenFieldKey)
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return token.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTokenClaims sets the given user token to context
|
||||||
func (c *Context) SetTokenClaims(claims *UserTokenClaims) {
|
func (c *Context) SetTokenClaims(claims *UserTokenClaims) {
|
||||||
c.Set(tokenClaimsFieldKey, claims)
|
c.Set(tokenClaimsFieldKey, claims)
|
||||||
}
|
}
|
||||||
@@ -64,6 +118,13 @@ func (c *Context) GetCurrentUid() int64 {
|
|||||||
return claims.Uid
|
return claims.Uid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetClientLocale returns the client locale name
|
||||||
|
func (c *Context) GetClientLocale() string {
|
||||||
|
value := c.GetHeader(AcceptLanguageHeaderName)
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
// GetClientTimezoneOffset returns the client timezone offset
|
// GetClientTimezoneOffset returns the client timezone offset
|
||||||
func (c *Context) GetClientTimezoneOffset() (int16, error) {
|
func (c *Context) GetClientTimezoneOffset() (int16, error) {
|
||||||
value := c.GetHeader(ClientTimezoneOffsetHeaderName)
|
value := c.GetHeader(ClientTimezoneOffsetHeaderName)
|
||||||
|
|||||||
+5
-2
@@ -10,10 +10,13 @@ import (
|
|||||||
type MiddlewareHandlerFunc func(*Context)
|
type MiddlewareHandlerFunc func(*Context)
|
||||||
|
|
||||||
// ApiHandlerFunc represents the api handler function
|
// ApiHandlerFunc represents the api handler function
|
||||||
type ApiHandlerFunc func(*Context) (interface{}, *errs.Error)
|
type ApiHandlerFunc func(*Context) (any, *errs.Error)
|
||||||
|
|
||||||
// DataHandlerFunc represents the handler function that returns byte array
|
// DataHandlerFunc represents the handler function that returns file data byte array and file name
|
||||||
type DataHandlerFunc func(*Context) ([]byte, string, *errs.Error)
|
type DataHandlerFunc func(*Context) ([]byte, string, *errs.Error)
|
||||||
|
|
||||||
|
// ImageHandlerFunc represents the handler function that returns image byte array and content type
|
||||||
|
type ImageHandlerFunc func(*Context) ([]byte, string, *errs.Error)
|
||||||
|
|
||||||
// ProxyHandlerFunc represents the reverse proxy handler function
|
// ProxyHandlerFunc represents the reverse proxy handler function
|
||||||
type ProxyHandlerFunc func(*Context) (*httputil.ReverseProxy, *errs.Error)
|
type ProxyHandlerFunc func(*Context) (*httputil.ReverseProxy, *errs.Error)
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DecimalSeparator represents the type of decimal separator
|
||||||
|
type DecimalSeparator byte
|
||||||
|
|
||||||
|
// Decimal Separator
|
||||||
|
const (
|
||||||
|
DECIMAL_SEPARATOR_DEFAULT DecimalSeparator = 0
|
||||||
|
DECIMAL_SEPARATOR_DOT DecimalSeparator = 1
|
||||||
|
DECIMAL_SEPARATOR_COMMA DecimalSeparator = 2
|
||||||
|
DECIMAL_SEPARATOR_SPACE DecimalSeparator = 3
|
||||||
|
DECIMAL_SEPARATOR_INVALID DecimalSeparator = 255
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a textual representation of the decimal separator enum
|
||||||
|
func (f DecimalSeparator) String() string {
|
||||||
|
switch f {
|
||||||
|
case DECIMAL_SEPARATOR_DEFAULT:
|
||||||
|
return "Default"
|
||||||
|
case DECIMAL_SEPARATOR_DOT:
|
||||||
|
return "Dot"
|
||||||
|
case DECIMAL_SEPARATOR_COMMA:
|
||||||
|
return "Comma"
|
||||||
|
case DECIMAL_SEPARATOR_SPACE:
|
||||||
|
return "Space"
|
||||||
|
case DECIMAL_SEPARATOR_INVALID:
|
||||||
|
return "Invalid"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Invalid(%d)", int(f))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DigitGroupingSymbol represents the digit grouping symbol
|
||||||
|
type DigitGroupingSymbol byte
|
||||||
|
|
||||||
|
// Digit Grouping Symbol
|
||||||
|
const (
|
||||||
|
DIGIT_GROUPING_SYMBOL_DEFAULT DigitGroupingSymbol = 0
|
||||||
|
DIGIT_GROUPING_SYMBOL_DOT DigitGroupingSymbol = 1
|
||||||
|
DIGIT_GROUPING_SYMBOL_COMMA DigitGroupingSymbol = 2
|
||||||
|
DIGIT_GROUPING_SYMBOL_SPACE DigitGroupingSymbol = 3
|
||||||
|
DIGIT_GROUPING_SYMBOL_APOSTROPHE DigitGroupingSymbol = 4
|
||||||
|
DIGIT_GROUPING_SYMBOL_INVALID DigitGroupingSymbol = 255
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a textual representation of the digit grouping symbol enum
|
||||||
|
func (f DigitGroupingSymbol) String() string {
|
||||||
|
switch f {
|
||||||
|
case DIGIT_GROUPING_SYMBOL_DEFAULT:
|
||||||
|
return "Default"
|
||||||
|
case DIGIT_GROUPING_SYMBOL_DOT:
|
||||||
|
return "Dot"
|
||||||
|
case DIGIT_GROUPING_SYMBOL_COMMA:
|
||||||
|
return "Comma"
|
||||||
|
case DIGIT_GROUPING_SYMBOL_SPACE:
|
||||||
|
return "Space"
|
||||||
|
case DIGIT_GROUPING_SYMBOL_APOSTROPHE:
|
||||||
|
return "Apostrophe"
|
||||||
|
case DIGIT_GROUPING_SYMBOL_INVALID:
|
||||||
|
return "Invalid"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Invalid(%d)", int(f))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DigitGroupingType represents digit grouping type
|
||||||
|
type DigitGroupingType byte
|
||||||
|
|
||||||
|
// Digit Grouping Type
|
||||||
|
const (
|
||||||
|
DIGIT_GROUPING_TYPE_DEFAULT DigitGroupingType = 0
|
||||||
|
DIGIT_GROUPING_TYPE_NONE DigitGroupingType = 1
|
||||||
|
DIGIT_GROUPING_TYPE_THOUSANDS_SEPARATOR DigitGroupingType = 2
|
||||||
|
DIGIT_GROUPING_TYPE_INVALID DigitGroupingType = 255
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a textual representation of the digit grouping type enum
|
||||||
|
func (d DigitGroupingType) String() string {
|
||||||
|
switch d {
|
||||||
|
case DIGIT_GROUPING_TYPE_DEFAULT:
|
||||||
|
return "Default"
|
||||||
|
case DIGIT_GROUPING_TYPE_NONE:
|
||||||
|
return "None"
|
||||||
|
case DIGIT_GROUPING_TYPE_THOUSANDS_SEPARATOR:
|
||||||
|
return "Thousands Separator"
|
||||||
|
case DIGIT_GROUPING_TYPE_INVALID:
|
||||||
|
return "Invalid"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Invalid(%d)", int(d))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,10 @@ type TokenType byte
|
|||||||
|
|
||||||
// Token types
|
// Token types
|
||||||
const (
|
const (
|
||||||
USER_TOKEN_TYPE_NORMAL TokenType = 1
|
USER_TOKEN_TYPE_NORMAL TokenType = 1
|
||||||
USER_TOKEN_TYPE_REQUIRE_2FA TokenType = 2
|
USER_TOKEN_TYPE_REQUIRE_2FA TokenType = 2
|
||||||
|
USER_TOKEN_TYPE_EMAIL_VERIFY TokenType = 3
|
||||||
|
USER_TOKEN_TYPE_PASSWORD_RESET TokenType = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserTokenClaims represents user token
|
// UserTokenClaims represents user token
|
||||||
|
|||||||
@@ -1,15 +1,29 @@
|
|||||||
package datastore
|
package datastore
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import (
|
||||||
|
"xorm.io/xorm"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
// Database represents a database instance
|
// Database represents a database instance
|
||||||
type Database struct {
|
type Database struct {
|
||||||
*xorm.EngineGroup
|
engineGroup *xorm.EngineGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSession starts a new session with the specified context
|
||||||
|
func (db *Database) NewSession(c *core.Context) *xorm.Session {
|
||||||
|
return db.engineGroup.Context(NewXOrmContextAdapter(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoTransaction runs a new database transaction
|
// DoTransaction runs a new database transaction
|
||||||
func (db *Database) DoTransaction(fn func(sess *xorm.Session) error) (err error) {
|
func (db *Database) DoTransaction(c *core.Context, fn func(sess *xorm.Session) error) (err error) {
|
||||||
sess := db.NewSession()
|
sess := db.engineGroup.NewSession()
|
||||||
|
|
||||||
|
if c != nil {
|
||||||
|
sess.Context(NewXOrmContextAdapter(c))
|
||||||
|
}
|
||||||
|
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
if err = sess.Begin(); err != nil {
|
if err = sess.Begin(); err != nil {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package datastore
|
|||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,21 +18,21 @@ func (s *DataStore) Choose(key int64) *Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query returns a new database session in a specific database by sharding key
|
// Query returns a new database session in a specific database by sharding key
|
||||||
func (s *DataStore) Query(key int64) *xorm.Session {
|
func (s *DataStore) Query(c *core.Context, key int64) *xorm.Session {
|
||||||
return s.Choose(key).NewSession()
|
return s.Choose(key).NewSession(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoTransaction runs a new database transaction in a specific database by sharding key
|
// DoTransaction runs a new database transaction in a specific database by sharding key
|
||||||
func (s *DataStore) DoTransaction(key int64, fn func(sess *xorm.Session) error) (err error) {
|
func (s *DataStore) DoTransaction(key int64, c *core.Context, fn func(sess *xorm.Session) error) (err error) {
|
||||||
return s.Choose(key).DoTransaction(fn)
|
return s.Choose(key).DoTransaction(c, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncStructs updates database structs by database models
|
// SyncStructs updates database structs by database models
|
||||||
func (s *DataStore) SyncStructs(beans ...interface{}) error {
|
func (s *DataStore) SyncStructs(beans ...any) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
for i := 0; i < len(s.databases); i++ {
|
for i := 0; i < len(s.databases); i++ {
|
||||||
err = s.databases[i].Sync2(beans...)
|
err = s.databases[i].engineGroup.Sync2(beans...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package datastore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -103,14 +104,14 @@ func initializeDatabase(dbConfig *settings.DatabaseConfig) (*Database, error) {
|
|||||||
engineGroup.SetConnMaxLifetime(time.Duration(dbConfig.ConnectionMaxLifeTime) * time.Second)
|
engineGroup.SetConnMaxLifetime(time.Duration(dbConfig.ConnectionMaxLifeTime) * time.Second)
|
||||||
|
|
||||||
return &Database{
|
return &Database{
|
||||||
EngineGroup: engineGroup,
|
engineGroup: engineGroup,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDatabaseLogger(database *Database, config *settings.Config) {
|
func setDatabaseLogger(database *Database, config *settings.Config) {
|
||||||
if config.EnableQueryLog {
|
if config.EnableQueryLog {
|
||||||
database.SetLogger(NewXOrmLoggerAdapter(config.EnableQueryLog, config.LogLevel))
|
database.engineGroup.SetLogger(NewXOrmLoggerAdapter(config.EnableQueryLog, config.LogLevel))
|
||||||
database.ShowSQL(true)
|
database.engineGroup.ShowSQL(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,16 +127,12 @@ func getMysqlConnectionString(dbConfig *settings.DatabaseConfig) (string, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPostgresConnectionString(dbConfig *settings.DatabaseConfig) (string, error) {
|
func getPostgresConnectionString(dbConfig *settings.DatabaseConfig) (string, error) {
|
||||||
host, port := "", ""
|
host, port, err := net.SplitHostPort(dbConfig.DatabaseHost)
|
||||||
fields := strings.Split(dbConfig.DatabaseHost, ":")
|
|
||||||
|
|
||||||
if len(fields) != 2 {
|
if err != nil {
|
||||||
return "", errs.ErrDatabaseHostInvalid
|
return "", errs.ErrDatabaseHostInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
host = strings.TrimSpace(fields[0])
|
|
||||||
port = strings.TrimSpace(fields[1])
|
|
||||||
|
|
||||||
if strings.HasPrefix(dbConfig.DatabaseHost, "/") { // unix socket path
|
if strings.HasPrefix(dbConfig.DatabaseHost, "/") { // unix socket path
|
||||||
return fmt.Sprintf("postgres://%s:%s@:%s/%s?sslmode=%s&host=%s",
|
return fmt.Sprintf("postgres://%s:%s@:%s/%s?sslmode=%s&host=%s",
|
||||||
url.QueryEscape(dbConfig.DatabaseUser), url.QueryEscape(dbConfig.DatabasePassword), port, dbConfig.DatabaseName, dbConfig.DatabaseSSLMode, host), nil
|
url.QueryEscape(dbConfig.DatabaseUser), url.QueryEscape(dbConfig.DatabasePassword), port, dbConfig.DatabaseName, dbConfig.DatabaseSSLMode, host), nil
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package datastore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"xorm.io/xorm/log"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// XOrmContextAdapter represents the context adapter for xorm
|
||||||
|
type XOrmContextAdapter struct {
|
||||||
|
requestId string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deadline does nothing
|
||||||
|
func (c *XOrmContextAdapter) Deadline() (deadline time.Time, ok bool) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done always returns nil
|
||||||
|
func (c *XOrmContextAdapter) Done() <-chan struct{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Err always returns nil
|
||||||
|
func (c *XOrmContextAdapter) Err() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the value associated with this context for key, or nil
|
||||||
|
// if no value is associated with key.
|
||||||
|
func (c *XOrmContextAdapter) Value(key any) any {
|
||||||
|
if key == log.SessionIDKey && c.requestId != "" {
|
||||||
|
return fmt.Sprintf("%s", c.requestId)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewXOrmContextAdapter(c *core.Context) *XOrmContextAdapter {
|
||||||
|
if c != nil {
|
||||||
|
return &XOrmContextAdapter{
|
||||||
|
requestId: c.GetRequestId(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &XOrmContextAdapter{}
|
||||||
|
}
|
||||||
@@ -14,42 +14,42 @@ type XOrmLoggerAdapter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug logs debug log
|
// Debug logs debug log
|
||||||
func (logger XOrmLoggerAdapter) Debug(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Debug(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugf logs debug log with custom format
|
// Debugf logs debug log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Debugf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Debugf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info logs info log
|
// Info logs info log
|
||||||
func (logger XOrmLoggerAdapter) Info(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Info(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof logs info log with custom format
|
// Infof logs info log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Infof(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Infof(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn logs warn log
|
// Warn logs warn log
|
||||||
func (logger XOrmLoggerAdapter) Warn(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Warn(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf logs warn log with custom format
|
// Warnf logs warn log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Warnf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Warnf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error logs error log
|
// Error logs error log
|
||||||
func (logger XOrmLoggerAdapter) Error(v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Error(v ...any) {
|
||||||
log.SqlQuery(v...)
|
log.SqlQuery(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf logs error log with custom format
|
// Errorf logs error log with custom format
|
||||||
func (logger XOrmLoggerAdapter) Errorf(format string, v ...interface{}) {
|
func (logger XOrmLoggerAdapter) Errorf(format string, v ...any) {
|
||||||
log.SqlQueryf(format, v...)
|
log.SqlQueryf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package duplicatechecker
|
||||||
|
|
||||||
|
// DuplicateChecker is common duplicate checker interface
|
||||||
|
type DuplicateChecker interface {
|
||||||
|
Get(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string)
|
||||||
|
Set(checkerType DuplicateCheckerType, uid int64, identification string, remark string)
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package duplicatechecker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DuplicateCheckerContainer contains the current duplicate checker
|
||||||
|
type DuplicateCheckerContainer struct {
|
||||||
|
Current DuplicateChecker
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a duplicate checker container singleton instance
|
||||||
|
var (
|
||||||
|
Container = &DuplicateCheckerContainer{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitializeDuplicateChecker initializes the current duplicate checker according to the config
|
||||||
|
func InitializeDuplicateChecker(config *settings.Config) error {
|
||||||
|
if config.DuplicateCheckerType == settings.InMemoryDuplicateCheckerType {
|
||||||
|
checker, err := NewInMemoryDuplicateChecker(config)
|
||||||
|
Container.Current = checker
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return errs.ErrInvalidDuplicateCheckerType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns whether the same submission has been processed and related remark by the current duplicate checker
|
||||||
|
func (c *DuplicateCheckerContainer) Get(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string) {
|
||||||
|
return c.Current.Get(checkerType, uid, identification)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set saves the identification and remark to in-memory cache by the current duplicate checker
|
||||||
|
func (c *DuplicateCheckerContainer) Set(checkerType DuplicateCheckerType, uid int64, identification string, remark string) {
|
||||||
|
c.Current.Set(checkerType, uid, identification, remark)
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package duplicatechecker
|
||||||
|
|
||||||
|
// DuplicateCheckerType represents duplicate checker type
|
||||||
|
type DuplicateCheckerType uint8
|
||||||
|
|
||||||
|
// Types of uuid
|
||||||
|
const (
|
||||||
|
DUPLICATE_CHECKER_TYPE_DEFAULT DuplicateCheckerType = 0
|
||||||
|
DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT DuplicateCheckerType = 1
|
||||||
|
DUPLICATE_CHECKER_TYPE_NEW_CATEGORY DuplicateCheckerType = 2
|
||||||
|
DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION DuplicateCheckerType = 3
|
||||||
|
DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE DuplicateCheckerType = 4
|
||||||
|
)
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package duplicatechecker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InMemoryDuplicateChecker represents in-memory duplicate checker
|
||||||
|
type InMemoryDuplicateChecker struct {
|
||||||
|
cache *cache.Cache
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInMemoryDuplicateChecker returns a new in-memory duplicate checker
|
||||||
|
func NewInMemoryDuplicateChecker(config *settings.Config) (*InMemoryDuplicateChecker, error) {
|
||||||
|
checker := &InMemoryDuplicateChecker{
|
||||||
|
cache: cache.New(config.DuplicateSubmissionsIntervalDuration, config.InMemoryDuplicateCheckerCleanupIntervalDuration),
|
||||||
|
}
|
||||||
|
|
||||||
|
return checker, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns whether the same submission has been processed and related remark
|
||||||
|
func (c *InMemoryDuplicateChecker) Get(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string) {
|
||||||
|
existedRemark, found := c.cache.Get(c.getCacheKey(checkerType, uid, identification))
|
||||||
|
|
||||||
|
if found {
|
||||||
|
return true, existedRemark.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set saves the identification and remark to in-memory cache
|
||||||
|
func (c *InMemoryDuplicateChecker) Set(checkerType DuplicateCheckerType, uid int64, identification string, remark string) {
|
||||||
|
c.cache.Set(c.getCacheKey(checkerType, uid, identification), remark, cache.DefaultExpiration)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *InMemoryDuplicateChecker) getCacheKey(checkerType DuplicateCheckerType, uid int64, identification string) string {
|
||||||
|
return fmt.Sprintf("%d|%d|%s", checkerType, uid, identification)
|
||||||
|
}
|
||||||
+6
-5
@@ -8,14 +8,15 @@ var (
|
|||||||
ErrAccountNotFound = NewNormalError(NormalSubcategoryAccount, 1, http.StatusBadRequest, "account not found")
|
ErrAccountNotFound = NewNormalError(NormalSubcategoryAccount, 1, http.StatusBadRequest, "account not found")
|
||||||
ErrAccountTypeInvalid = NewNormalError(NormalSubcategoryAccount, 2, http.StatusBadRequest, "account type is invalid")
|
ErrAccountTypeInvalid = NewNormalError(NormalSubcategoryAccount, 2, http.StatusBadRequest, "account type is invalid")
|
||||||
ErrAccountCurrencyInvalid = NewNormalError(NormalSubcategoryAccount, 3, http.StatusBadRequest, "account currency is invalid")
|
ErrAccountCurrencyInvalid = NewNormalError(NormalSubcategoryAccount, 3, http.StatusBadRequest, "account currency is invalid")
|
||||||
ErrAccountHaveNoSubAccount = NewNormalError(NormalSubcategoryAccount, 4, http.StatusBadRequest, "account must have at least one sub account")
|
ErrAccountHaveNoSubAccount = NewNormalError(NormalSubcategoryAccount, 4, http.StatusBadRequest, "account must have at least one sub-account")
|
||||||
ErrAccountCannotHaveSubAccounts = NewNormalError(NormalSubcategoryAccount, 5, http.StatusBadRequest, "account cannot have sub accounts")
|
ErrAccountCannotHaveSubAccounts = NewNormalError(NormalSubcategoryAccount, 5, http.StatusBadRequest, "account cannot have sub-accounts")
|
||||||
ErrParentAccountCannotSetCurrency = NewNormalError(NormalSubcategoryAccount, 6, http.StatusBadRequest, "parent account cannot set currency")
|
ErrParentAccountCannotSetCurrency = NewNormalError(NormalSubcategoryAccount, 6, http.StatusBadRequest, "parent account cannot set currency")
|
||||||
ErrParentAccountCannotSetBalance = NewNormalError(NormalSubcategoryAccount, 7, http.StatusBadRequest, "parent account cannot set balance")
|
ErrParentAccountCannotSetBalance = NewNormalError(NormalSubcategoryAccount, 7, http.StatusBadRequest, "parent account cannot set balance")
|
||||||
ErrSubAccountCategoryNotEqualsToParent = NewNormalError(NormalSubcategoryAccount, 8, http.StatusBadRequest, "sub account category not equals to parent")
|
ErrSubAccountCategoryNotEqualsToParent = NewNormalError(NormalSubcategoryAccount, 8, http.StatusBadRequest, "sub-account category not equals to parent")
|
||||||
ErrSubAccountTypeInvalid = NewNormalError(NormalSubcategoryAccount, 9, http.StatusBadRequest, "sub account type invalid")
|
ErrSubAccountTypeInvalid = NewNormalError(NormalSubcategoryAccount, 9, http.StatusBadRequest, "sub-account type invalid")
|
||||||
ErrCannotAddOrDeleteSubAccountsWhenModify = NewNormalError(NormalSubcategoryAccount, 10, http.StatusBadRequest, "cannot add or delete sub accounts when modify account")
|
ErrCannotAddOrDeleteSubAccountsWhenModify = NewNormalError(NormalSubcategoryAccount, 10, http.StatusBadRequest, "cannot add or delete sub-accounts when modify account")
|
||||||
ErrSourceAccountNotFound = NewNormalError(NormalSubcategoryAccount, 11, http.StatusBadRequest, "source account not found")
|
ErrSourceAccountNotFound = NewNormalError(NormalSubcategoryAccount, 11, http.StatusBadRequest, "source account not found")
|
||||||
ErrDestinationAccountNotFound = NewNormalError(NormalSubcategoryAccount, 12, http.StatusBadRequest, "destination account not found")
|
ErrDestinationAccountNotFound = NewNormalError(NormalSubcategoryAccount, 12, http.StatusBadRequest, "destination account not found")
|
||||||
ErrAccountInUseCannotBeDeleted = NewNormalError(NormalSubcategoryAccount, 13, http.StatusBadRequest, "account is in use and cannot be deleted")
|
ErrAccountInUseCannotBeDeleted = NewNormalError(NormalSubcategoryAccount, 13, http.StatusBadRequest, "account is in use and cannot be deleted")
|
||||||
|
ErrAccountCategoryInvalid = NewNormalError(NormalSubcategoryAccount, 14, http.StatusBadRequest, "account category is invalid")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ const (
|
|||||||
SystemSubcategoryDefault = 0
|
SystemSubcategoryDefault = 0
|
||||||
SystemSubcategorySetting = 1
|
SystemSubcategorySetting = 1
|
||||||
SystemSubcategoryDatabase = 2
|
SystemSubcategoryDatabase = 2
|
||||||
|
SystemSubcategoryMail = 3
|
||||||
|
SystemSubcategoryLogging = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sub categories of normal error
|
// Sub categories of normal error
|
||||||
@@ -27,6 +29,8 @@ const (
|
|||||||
NormalSubcategoryCategory = 6
|
NormalSubcategoryCategory = 6
|
||||||
NormalSubcategoryTag = 7
|
NormalSubcategoryTag = 7
|
||||||
NormalSubcategoryDataManagement = 8
|
NormalSubcategoryDataManagement = 8
|
||||||
|
NormalSubcategoryMapProxy = 9
|
||||||
|
NormalSubcategoryTemplate = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error represents the specific error returned to user
|
// Error represents the specific error returned to user
|
||||||
@@ -37,6 +41,7 @@ type Error struct {
|
|||||||
HttpStatusCode int
|
HttpStatusCode int
|
||||||
Message string
|
Message string
|
||||||
BaseError []error
|
BaseError []error
|
||||||
|
Context any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns the error message
|
// Error returns the error message
|
||||||
@@ -71,6 +76,15 @@ func NewNormalError(subCategory int32, index int32, httpStatusCode int, message
|
|||||||
return New(CATEGORY_NORMAL, subCategory, index, httpStatusCode, message)
|
return New(CATEGORY_NORMAL, subCategory, index, httpStatusCode, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewLoggingError returns a new logging error instance
|
||||||
|
func NewLoggingError(message string, err ...error) *Error {
|
||||||
|
return New(ErrLoggingError.Category,
|
||||||
|
ErrLoggingError.SubCategory,
|
||||||
|
ErrLoggingError.Index,
|
||||||
|
ErrLoggingError.HttpStatusCode,
|
||||||
|
message, err...)
|
||||||
|
}
|
||||||
|
|
||||||
// NewIncompleteOrIncorrectSubmissionError returns a new incomplete or incorrect submission error instance
|
// NewIncompleteOrIncorrectSubmissionError returns a new incomplete or incorrect submission error instance
|
||||||
func NewIncompleteOrIncorrectSubmissionError(err error) *Error {
|
func NewIncompleteOrIncorrectSubmissionError(err error) *Error {
|
||||||
return New(ErrIncompleteOrIncorrectSubmission.Category,
|
return New(ErrIncompleteOrIncorrectSubmission.Category,
|
||||||
@@ -80,6 +94,19 @@ func NewIncompleteOrIncorrectSubmissionError(err error) *Error {
|
|||||||
ErrIncompleteOrIncorrectSubmission.Message, err)
|
ErrIncompleteOrIncorrectSubmission.Message, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewErrorWithContext returns a new error instance with specified context
|
||||||
|
func NewErrorWithContext(baseError *Error, context any) *Error {
|
||||||
|
return &Error{
|
||||||
|
Category: baseError.Category,
|
||||||
|
SubCategory: baseError.SubCategory,
|
||||||
|
Index: baseError.Index,
|
||||||
|
HttpStatusCode: baseError.HttpStatusCode,
|
||||||
|
Message: baseError.Message,
|
||||||
|
BaseError: baseError.BaseError,
|
||||||
|
Context: context,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Or would return the error from err parameter if the this error is defined in this project,
|
// Or would return the error from err parameter if the this error is defined in this project,
|
||||||
// or return the default error
|
// or return the default error
|
||||||
func Or(err error, defaultErr *Error) *Error {
|
func Or(err error, defaultErr *Error) *Error {
|
||||||
|
|||||||
+6
-1
@@ -16,7 +16,7 @@ var (
|
|||||||
ErrPageIndexInvalid = NewNormalError(NormalSubcategoryGlobal, 6, http.StatusBadRequest, "page index is invalid")
|
ErrPageIndexInvalid = NewNormalError(NormalSubcategoryGlobal, 6, http.StatusBadRequest, "page index is invalid")
|
||||||
ErrPageCountInvalid = NewNormalError(NormalSubcategoryGlobal, 7, http.StatusBadRequest, "page count is invalid")
|
ErrPageCountInvalid = NewNormalError(NormalSubcategoryGlobal, 7, http.StatusBadRequest, "page count is invalid")
|
||||||
ErrClientTimezoneOffsetInvalid = NewNormalError(NormalSubcategoryGlobal, 8, http.StatusBadRequest, "client timezone offset is invalid")
|
ErrClientTimezoneOffsetInvalid = NewNormalError(NormalSubcategoryGlobal, 8, http.StatusBadRequest, "client timezone offset is invalid")
|
||||||
ErrQueryItemsEmpty = NewNormalError(NormalSubcategoryGlobal, 9, http.StatusBadRequest, "query items cannot be empty")
|
ErrQueryItemsEmpty = NewNormalError(NormalSubcategoryGlobal, 9, http.StatusBadRequest, "query items cannot be blank")
|
||||||
ErrQueryItemsTooMuch = NewNormalError(NormalSubcategoryGlobal, 10, http.StatusBadRequest, "query items too much")
|
ErrQueryItemsTooMuch = NewNormalError(NormalSubcategoryGlobal, 10, http.StatusBadRequest, "query items too much")
|
||||||
ErrQueryItemsInvalid = NewNormalError(NormalSubcategoryGlobal, 11, http.StatusBadRequest, "query items have invalid item")
|
ErrQueryItemsInvalid = NewNormalError(NormalSubcategoryGlobal, 11, http.StatusBadRequest, "query items have invalid item")
|
||||||
ErrParameterInvalid = NewNormalError(NormalSubcategoryGlobal, 12, http.StatusBadRequest, "parameter invalid")
|
ErrParameterInvalid = NewNormalError(NormalSubcategoryGlobal, 12, http.StatusBadRequest, "parameter invalid")
|
||||||
@@ -82,3 +82,8 @@ func GetParameterInvalidCurrencyMessage(field string) string {
|
|||||||
func GetParameterInvalidHexRGBColorMessage(field string) string {
|
func GetParameterInvalidHexRGBColorMessage(field string) string {
|
||||||
return fmt.Sprintf("parameter \"%s\" is invalid color", field)
|
return fmt.Sprintf("parameter \"%s\" is invalid color", field)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetParameterInvalidAmountFilterMessage returns specific error message for invalid amount filter parameter error
|
||||||
|
func GetParameterInvalidAmountFilterMessage(field string) string {
|
||||||
|
return fmt.Sprintf("parameter \"%s\" is invalid amount filter", field)
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package errs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error codes related to logging
|
||||||
|
var (
|
||||||
|
ErrLoggingError = NewSystemError(SystemSubcategoryLogging, 0, http.StatusInternalServerError, "logging error")
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package errs
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
// Error codes related to mail
|
||||||
|
var (
|
||||||
|
ErrSMTPServerNotEnabled = NewSystemError(SystemSubcategoryMail, 0, http.StatusInternalServerError, "SMTP server is not enabled")
|
||||||
|
ErrSMTPServerHostInvalid = NewSystemError(SystemSubcategoryMail, 1, http.StatusInternalServerError, "SMTP server host is invalid")
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package errs
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
// Error codes related to map image proxy
|
||||||
|
var (
|
||||||
|
ErrMapProviderNotCurrent = NewNormalError(NormalSubcategoryMapProxy, 0, http.StatusBadRequest, "specified map provider is not set")
|
||||||
|
ErrImageExtensionNotSupported = NewNormalError(NormalSubcategoryMapProxy, 0, http.StatusNotFound, "specified image extension is not supported")
|
||||||
|
)
|
||||||
+19
-6
@@ -4,10 +4,23 @@ import "net/http"
|
|||||||
|
|
||||||
// Error codes related to settings
|
// Error codes related to settings
|
||||||
var (
|
var (
|
||||||
ErrInvalidProtocol = NewSystemError(SystemSubcategorySetting, 0, http.StatusInternalServerError, "invalid server protocol")
|
ErrInvalidServerMode = NewSystemError(SystemSubcategorySetting, 0, http.StatusInternalServerError, "invalid server mode")
|
||||||
ErrInvalidLogMode = NewSystemError(SystemSubcategorySetting, 1, http.StatusInternalServerError, "invalid log mode")
|
ErrInvalidProtocol = NewSystemError(SystemSubcategorySetting, 1, http.StatusInternalServerError, "invalid server protocol")
|
||||||
ErrGettingLocalAddress = NewSystemError(SystemSubcategorySetting, 2, http.StatusInternalServerError, "failed to get local address")
|
ErrInvalidLogMode = NewSystemError(SystemSubcategorySetting, 2, http.StatusInternalServerError, "invalid log mode")
|
||||||
ErrInvalidUuidMode = NewSystemError(SystemSubcategorySetting, 3, http.StatusInternalServerError, "invalid uuid mode")
|
ErrInvalidLogLevel = NewSystemError(SystemSubcategorySetting, 3, http.StatusInternalServerError, "invalid log level")
|
||||||
ErrInvalidExchangeRatesDataSource = NewSystemError(SystemSubcategorySetting, 4, http.StatusInternalServerError, "invalid exchange rates data source")
|
ErrGettingLocalAddress = NewSystemError(SystemSubcategorySetting, 4, http.StatusInternalServerError, "failed to get local address")
|
||||||
ErrInvalidMapProvider = NewSystemError(SystemSubcategorySetting, 5, http.StatusInternalServerError, "invalid map provider")
|
ErrInvalidStorageType = NewSystemError(SystemSubcategorySetting, 5, http.StatusInternalServerError, "invalid storage type")
|
||||||
|
ErrInvalidLocalFileSystemStoragePath = NewSystemError(SystemSubcategorySetting, 6, http.StatusInternalServerError, "invalid local file system storage path")
|
||||||
|
ErrInvalidUuidMode = NewSystemError(SystemSubcategorySetting, 7, http.StatusInternalServerError, "invalid uuid mode")
|
||||||
|
ErrInvalidDuplicateCheckerType = NewSystemError(SystemSubcategorySetting, 8, http.StatusInternalServerError, "invalid duplicate checker type")
|
||||||
|
ErrInvalidInMemoryDuplicateCheckerCleanupInterval = NewSystemError(SystemSubcategorySetting, 9, http.StatusInternalServerError, "invalid in-memory duplicate checker cleanup interval")
|
||||||
|
ErrInvalidTokenExpiredTime = NewSystemError(SystemSubcategorySetting, 10, http.StatusInternalServerError, "invalid token expired time")
|
||||||
|
ErrInvalidTokenMinRefreshInterval = NewSystemError(SystemSubcategorySetting, 11, http.StatusInternalServerError, "invalid token min refresh interval")
|
||||||
|
ErrInvalidTemporaryTokenExpiredTime = NewSystemError(SystemSubcategorySetting, 12, http.StatusInternalServerError, "invalid temporary token expired time")
|
||||||
|
ErrInvalidEmailVerifyTokenExpiredTime = NewSystemError(SystemSubcategorySetting, 13, http.StatusInternalServerError, "invalid email verify token expired time")
|
||||||
|
ErrInvalidAvatarProvider = NewSystemError(SystemSubcategorySetting, 14, http.StatusInternalServerError, "invalid avatar provider")
|
||||||
|
ErrInvalidMapProvider = NewSystemError(SystemSubcategorySetting, 15, http.StatusInternalServerError, "invalid map provider")
|
||||||
|
ErrInvalidAmapSecurityVerificationMethod = NewSystemError(SystemSubcategorySetting, 16, http.StatusInternalServerError, "invalid amap security verification method")
|
||||||
|
ErrInvalidPasswordResetTokenExpiredTime = NewSystemError(SystemSubcategorySetting, 17, http.StatusInternalServerError, "invalid password reset token expired time")
|
||||||
|
ErrInvalidExchangeRatesDataSource = NewSystemError(SystemSubcategorySetting, 18, http.StatusInternalServerError, "invalid exchange rates data source")
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-4
@@ -4,8 +4,11 @@ import "net/http"
|
|||||||
|
|
||||||
// Error codes related to transaction categories
|
// Error codes related to transaction categories
|
||||||
var (
|
var (
|
||||||
ErrSystemError = NewSystemError(SystemSubcategoryDefault, 0, http.StatusInternalServerError, "system error")
|
ErrSystemError = NewSystemError(SystemSubcategoryDefault, 0, http.StatusInternalServerError, "system error")
|
||||||
ErrApiNotFound = NewSystemError(SystemSubcategoryDefault, 1, http.StatusNotFound, "api not found")
|
ErrApiNotFound = NewSystemError(SystemSubcategoryDefault, 1, http.StatusNotFound, "api not found")
|
||||||
ErrMethodNotAllowed = NewSystemError(SystemSubcategoryDefault, 2, http.StatusMethodNotAllowed, "method not allowed")
|
ErrMethodNotAllowed = NewSystemError(SystemSubcategoryDefault, 2, http.StatusMethodNotAllowed, "method not allowed")
|
||||||
ErrNotImplemented = NewSystemError(SystemSubcategoryDefault, 3, http.StatusNotImplemented, "not implemented")
|
ErrNotImplemented = NewSystemError(SystemSubcategoryDefault, 3, http.StatusNotImplemented, "not implemented")
|
||||||
|
ErrSystemIsBusy = NewSystemError(SystemSubcategoryDefault, 4, http.StatusServiceUnavailable, "system is busy")
|
||||||
|
ErrNotSupported = NewSystemError(SystemSubcategoryDefault, 5, http.StatusBadRequest, "not supported")
|
||||||
|
ErrImageTypeNotSupported = NewSystemError(SystemSubcategoryDefault, 6, http.StatusBadRequest, "image type not supported")
|
||||||
)
|
)
|
||||||
|
|||||||
+15
-13
@@ -6,17 +6,19 @@ import (
|
|||||||
|
|
||||||
// Error codes related to tokens
|
// Error codes related to tokens
|
||||||
var (
|
var (
|
||||||
ErrTokenGenerating = NewNormalError(NormalSubcategoryToken, 0, http.StatusInternalServerError, "failed to generate token")
|
ErrTokenGenerating = NewNormalError(NormalSubcategoryToken, 0, http.StatusInternalServerError, "failed to generate token")
|
||||||
ErrUnauthorizedAccess = NewNormalError(NormalSubcategoryToken, 1, http.StatusUnauthorized, "unauthorized access")
|
ErrUnauthorizedAccess = NewNormalError(NormalSubcategoryToken, 1, http.StatusUnauthorized, "unauthorized access")
|
||||||
ErrCurrentInvalidToken = NewNormalError(NormalSubcategoryToken, 2, http.StatusUnauthorized, "current token is invalid")
|
ErrCurrentInvalidToken = NewNormalError(NormalSubcategoryToken, 2, http.StatusUnauthorized, "current token is invalid")
|
||||||
ErrCurrentTokenExpired = NewNormalError(NormalSubcategoryToken, 3, http.StatusUnauthorized, "current token is expired")
|
ErrCurrentTokenExpired = NewNormalError(NormalSubcategoryToken, 3, http.StatusUnauthorized, "current token is expired")
|
||||||
ErrCurrentInvalidTokenType = NewNormalError(NormalSubcategoryToken, 4, http.StatusUnauthorized, "current token type is invalid")
|
ErrCurrentInvalidTokenType = NewNormalError(NormalSubcategoryToken, 4, http.StatusUnauthorized, "current token type is invalid")
|
||||||
ErrCurrentTokenRequire2FA = NewNormalError(NormalSubcategoryToken, 5, http.StatusUnauthorized, "current token requires two factor authorization")
|
ErrCurrentTokenRequire2FA = NewNormalError(NormalSubcategoryToken, 5, http.StatusUnauthorized, "current token requires two-factor authorization")
|
||||||
ErrCurrentTokenNotRequire2FA = NewNormalError(NormalSubcategoryToken, 6, http.StatusUnauthorized, "current token does not require two factor authorization")
|
ErrCurrentTokenNotRequire2FA = NewNormalError(NormalSubcategoryToken, 6, http.StatusUnauthorized, "current token does not require two-factor authorization")
|
||||||
ErrInvalidToken = NewNormalError(NormalSubcategoryToken, 7, http.StatusBadRequest, "token is invalid")
|
ErrInvalidToken = NewNormalError(NormalSubcategoryToken, 7, http.StatusBadRequest, "token is invalid")
|
||||||
ErrInvalidTokenId = NewNormalError(NormalSubcategoryToken, 8, http.StatusBadRequest, "token id is invalid")
|
ErrInvalidTokenId = NewNormalError(NormalSubcategoryToken, 8, http.StatusBadRequest, "token id is invalid")
|
||||||
ErrInvalidUserTokenId = NewNormalError(NormalSubcategoryToken, 9, http.StatusBadRequest, "user token id is invalid")
|
ErrInvalidUserTokenId = NewNormalError(NormalSubcategoryToken, 9, http.StatusBadRequest, "user token id is invalid")
|
||||||
ErrTokenRecordNotFound = NewNormalError(NormalSubcategoryToken, 10, http.StatusBadRequest, "token is not found")
|
ErrTokenRecordNotFound = NewNormalError(NormalSubcategoryToken, 10, http.StatusBadRequest, "token is not found")
|
||||||
ErrTokenExpired = NewNormalError(NormalSubcategoryToken, 11, http.StatusBadRequest, "token is expired")
|
ErrTokenExpired = NewNormalError(NormalSubcategoryToken, 11, http.StatusBadRequest, "token is expired")
|
||||||
ErrTokenIsEmpty = NewNormalError(NormalSubcategoryToken, 12, http.StatusBadRequest, "token is empty")
|
ErrTokenIsEmpty = NewNormalError(NormalSubcategoryToken, 12, http.StatusBadRequest, "token is empty")
|
||||||
|
ErrEmailVerifyTokenIsInvalidOrExpired = NewNormalError(NormalSubcategoryToken, 13, http.StatusBadRequest, "email verify token is invalid or expired")
|
||||||
|
ErrPasswordResetTokenIsInvalidOrExpired = NewNormalError(NormalSubcategoryToken, 14, http.StatusBadRequest, "password reset token is invalid or expired")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,7 +18,13 @@ var (
|
|||||||
ErrCannotAddTransactionToHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 11, http.StatusBadRequest, "cannot add transaction to hidden account")
|
ErrCannotAddTransactionToHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 11, http.StatusBadRequest, "cannot add transaction to hidden account")
|
||||||
ErrCannotModifyTransactionInHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 12, http.StatusBadRequest, "cannot modify transaction of hidden account")
|
ErrCannotModifyTransactionInHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 12, http.StatusBadRequest, "cannot modify transaction of hidden account")
|
||||||
ErrCannotDeleteTransactionInHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 13, http.StatusBadRequest, "cannot delete transaction in hidden account")
|
ErrCannotDeleteTransactionInHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 13, http.StatusBadRequest, "cannot delete transaction in hidden account")
|
||||||
ErrCannotCreateTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 14, http.StatusBadRequest, "cannot add transaction with this transaction time")
|
ErrCannotAddTransactionToParentAccount = NewNormalError(NormalSubcategoryTransaction, 14, http.StatusBadRequest, "cannot add transaction to parent account")
|
||||||
ErrCannotModifyTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 15, http.StatusBadRequest, "cannot modify transaction with this transaction time")
|
ErrCannotModifyTransactionInParentAccount = NewNormalError(NormalSubcategoryTransaction, 15, http.StatusBadRequest, "cannot modify transaction of parent account")
|
||||||
ErrCannotDeleteTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 16, http.StatusBadRequest, "cannot delete transaction with this transaction time")
|
ErrCannotDeleteTransactionInParentAccount = NewNormalError(NormalSubcategoryTransaction, 16, http.StatusBadRequest, "cannot delete transaction in parent account")
|
||||||
|
ErrCannotCreateTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 17, http.StatusBadRequest, "cannot add transaction with this transaction time")
|
||||||
|
ErrCannotModifyTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 18, http.StatusBadRequest, "cannot modify transaction with this transaction time")
|
||||||
|
ErrCannotDeleteTransactionWithThisTransactionTime = NewNormalError(NormalSubcategoryTransaction, 19, http.StatusBadRequest, "cannot delete transaction with this transaction time")
|
||||||
|
ErrCannotUseHiddenAccount = NewNormalError(NormalSubcategoryTransaction, 20, http.StatusBadRequest, "cannot use hidden account")
|
||||||
|
ErrCannotUseHiddenTransactionCategory = NewNormalError(NormalSubcategoryTransaction, 21, http.StatusBadRequest, "cannot use hidden transaction category")
|
||||||
|
ErrCannotUseHiddenTransactionTag = NewNormalError(NormalSubcategoryTransaction, 22, http.StatusBadRequest, "cannot use hidden transaction tag")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ import "net/http"
|
|||||||
|
|
||||||
// Error codes related to transaction categories
|
// Error codes related to transaction categories
|
||||||
var (
|
var (
|
||||||
ErrTransactionCategoryIdInvalid = NewNormalError(NormalSubcategoryCategory, 0, http.StatusBadRequest, "transaction category id is invalid")
|
ErrTransactionCategoryIdInvalid = NewNormalError(NormalSubcategoryCategory, 0, http.StatusBadRequest, "transaction category id is invalid")
|
||||||
ErrTransactionCategoryNotFound = NewNormalError(NormalSubcategoryCategory, 1, http.StatusBadRequest, "transaction category not found")
|
ErrTransactionCategoryNotFound = NewNormalError(NormalSubcategoryCategory, 1, http.StatusBadRequest, "transaction category not found")
|
||||||
ErrTransactionCategoryTypeInvalid = NewNormalError(NormalSubcategoryCategory, 2, http.StatusBadRequest, "transaction category type is invalid")
|
ErrTransactionCategoryTypeInvalid = NewNormalError(NormalSubcategoryCategory, 2, http.StatusBadRequest, "transaction category type is invalid")
|
||||||
ErrParentTransactionCategoryNotFound = NewNormalError(NormalSubcategoryCategory, 3, http.StatusBadRequest, "parent transaction category not found")
|
ErrParentTransactionCategoryNotFound = NewNormalError(NormalSubcategoryCategory, 3, http.StatusBadRequest, "parent transaction category not found")
|
||||||
ErrCannotAddToSecondaryTransactionCategory = NewNormalError(NormalSubcategoryCategory, 4, http.StatusBadRequest, "cannot add to secondary transaction category")
|
ErrCannotAddToSecondaryTransactionCategory = NewNormalError(NormalSubcategoryCategory, 4, http.StatusBadRequest, "cannot add to secondary transaction category")
|
||||||
ErrCannotUsePrimaryCategoryForTransaction = NewNormalError(NormalSubcategoryCategory, 5, http.StatusBadRequest, "cannot use primary category for transaction category")
|
ErrCannotUsePrimaryCategoryForTransaction = NewNormalError(NormalSubcategoryCategory, 5, http.StatusBadRequest, "cannot use primary category for transaction category")
|
||||||
ErrTransactionCategoryInUseCannotBeDeleted = NewNormalError(NormalSubcategoryCategory, 6, http.StatusBadRequest, "transaction category is in use and cannot be deleted")
|
ErrTransactionCategoryInUseCannotBeDeleted = NewNormalError(NormalSubcategoryCategory, 6, http.StatusBadRequest, "transaction category is in use and cannot be deleted")
|
||||||
|
ErrNotAllowChangePrimaryTransactionCategoryToSecondary = NewNormalError(NormalSubcategoryCategory, 7, http.StatusBadRequest, "not allow to change primary category to secondary category")
|
||||||
|
ErrNotAllowChangeSecondaryTransactionCategoryToPrimary = NewNormalError(NormalSubcategoryCategory, 8, http.StatusBadRequest, "not allow to change secondary category to primary category")
|
||||||
|
ErrNotAllowChangePrimaryTransactionType = NewNormalError(NormalSubcategoryCategory, 9, http.StatusBadRequest, "not allow to change primary category with different type")
|
||||||
|
ErrNotAllowUseSecondaryTransactionAsPrimaryCategory = NewNormalError(NormalSubcategoryCategory, 10, http.StatusBadRequest, "not allow to use secondary category as primary category")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ var (
|
|||||||
ErrTransactionTagNameIsEmpty = NewNormalError(NormalSubcategoryTag, 2, http.StatusBadRequest, "transaction tag name is empty")
|
ErrTransactionTagNameIsEmpty = NewNormalError(NormalSubcategoryTag, 2, http.StatusBadRequest, "transaction tag name is empty")
|
||||||
ErrTransactionTagNameAlreadyExists = NewNormalError(NormalSubcategoryTag, 3, http.StatusBadRequest, "transaction tag name already exists")
|
ErrTransactionTagNameAlreadyExists = NewNormalError(NormalSubcategoryTag, 3, http.StatusBadRequest, "transaction tag name already exists")
|
||||||
ErrTransactionTagInUseCannotBeDeleted = NewNormalError(NormalSubcategoryTag, 4, http.StatusBadRequest, "transaction tag is in use and cannot be deleted")
|
ErrTransactionTagInUseCannotBeDeleted = NewNormalError(NormalSubcategoryTag, 4, http.StatusBadRequest, "transaction tag is in use and cannot be deleted")
|
||||||
|
ErrTransactionTagIndexNotFound = NewNormalError(NormalSubcategoryTag, 5, http.StatusBadRequest, "transaction tag index not found")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package errs
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
// Error codes related to transaction templates
|
||||||
|
var (
|
||||||
|
ErrTransactionTemplateIdInvalid = NewNormalError(NormalSubcategoryTemplate, 0, http.StatusBadRequest, "transaction template id is invalid")
|
||||||
|
ErrTransactionTemplateNotFound = NewNormalError(NormalSubcategoryTemplate, 1, http.StatusBadRequest, "transaction template not found")
|
||||||
|
ErrTransactionTemplateTypeInvalid = NewNormalError(NormalSubcategoryTemplate, 2, http.StatusBadRequest, "transaction template type is invalid")
|
||||||
|
)
|
||||||
@@ -2,11 +2,11 @@ package errs
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
// Error codes related to two factor authorization
|
// Error codes related to two-factor authorization
|
||||||
var (
|
var (
|
||||||
ErrPasscodeInvalid = NewNormalError(NormalSubcategoryTwofactor, 0, http.StatusUnauthorized, "passcode is invalid")
|
ErrPasscodeInvalid = NewNormalError(NormalSubcategoryTwofactor, 0, http.StatusUnauthorized, "passcode is invalid")
|
||||||
ErrTwoFactorRecoveryCodeInvalid = NewNormalError(NormalSubcategoryTwofactor, 1, http.StatusUnauthorized, "two factor backup code is invalid")
|
ErrTwoFactorRecoveryCodeInvalid = NewNormalError(NormalSubcategoryTwofactor, 1, http.StatusUnauthorized, "two-factor backup code is invalid")
|
||||||
ErrTwoFactorRecoveryCodeNotExist = NewNormalError(NormalSubcategoryTwofactor, 2, http.StatusUnauthorized, "two factor backup code does not exist")
|
ErrTwoFactorRecoveryCodeNotExist = NewNormalError(NormalSubcategoryTwofactor, 2, http.StatusUnauthorized, "two-factor backup code does not exist")
|
||||||
ErrTwoFactorIsNotEnabled = NewNormalError(NormalSubcategoryTwofactor, 3, http.StatusBadRequest, "two factor is not enabled")
|
ErrTwoFactorIsNotEnabled = NewNormalError(NormalSubcategoryTwofactor, 3, http.StatusBadRequest, "two-factor is not enabled")
|
||||||
ErrTwoFactorAlreadyEnabled = NewNormalError(NormalSubcategoryTwofactor, 4, http.StatusBadRequest, "two factor has already been enabled")
|
ErrTwoFactorAlreadyEnabled = NewNormalError(NormalSubcategoryTwofactor, 4, http.StatusBadRequest, "two-factor has already been enabled")
|
||||||
)
|
)
|
||||||
|
|||||||
+28
-16
@@ -6,20 +6,32 @@ import (
|
|||||||
|
|
||||||
// Error codes related to users
|
// Error codes related to users
|
||||||
var (
|
var (
|
||||||
ErrLoginNameInvalid = NewNormalError(NormalSubcategoryUser, 0, http.StatusUnauthorized, "login name is invalid")
|
ErrLoginNameInvalid = NewNormalError(NormalSubcategoryUser, 0, http.StatusUnauthorized, "login name is invalid")
|
||||||
ErrLoginNameOrPasswordInvalid = NewNormalError(NormalSubcategoryUser, 1, http.StatusUnauthorized, "login name or password is invalid")
|
ErrLoginNameOrPasswordInvalid = NewNormalError(NormalSubcategoryUser, 1, http.StatusUnauthorized, "login name or password is invalid")
|
||||||
ErrLoginNameOrPasswordWrong = NewNormalError(NormalSubcategoryUser, 2, http.StatusUnauthorized, "login name or password is wrong")
|
ErrLoginNameOrPasswordWrong = NewNormalError(NormalSubcategoryUser, 2, http.StatusUnauthorized, "login name or password is wrong")
|
||||||
ErrUserIdInvalid = NewNormalError(NormalSubcategoryUser, 3, http.StatusBadRequest, "user id is invalid")
|
ErrUserIdInvalid = NewNormalError(NormalSubcategoryUser, 3, http.StatusBadRequest, "user id is invalid")
|
||||||
ErrUsernameIsEmpty = NewNormalError(NormalSubcategoryUser, 4, http.StatusBadRequest, "username is empty")
|
ErrUsernameIsEmpty = NewNormalError(NormalSubcategoryUser, 4, http.StatusBadRequest, "username is empty")
|
||||||
ErrEmailIsEmpty = NewNormalError(NormalSubcategoryUser, 5, http.StatusBadRequest, "email is empty")
|
ErrEmailIsEmpty = NewNormalError(NormalSubcategoryUser, 5, http.StatusBadRequest, "email is empty")
|
||||||
ErrNicknameIsEmpty = NewNormalError(NormalSubcategoryUser, 6, http.StatusBadRequest, "nickname is empty")
|
ErrNicknameIsEmpty = NewNormalError(NormalSubcategoryUser, 6, http.StatusBadRequest, "nickname is empty")
|
||||||
ErrPasswordIsEmpty = NewNormalError(NormalSubcategoryUser, 7, http.StatusBadRequest, "password is empty")
|
ErrPasswordIsEmpty = NewNormalError(NormalSubcategoryUser, 7, http.StatusBadRequest, "password is empty")
|
||||||
ErrUserDefaultCurrencyIsEmpty = NewNormalError(NormalSubcategoryUser, 8, http.StatusBadRequest, "user default currency is empty")
|
ErrUserDefaultCurrencyIsEmpty = NewNormalError(NormalSubcategoryUser, 8, http.StatusBadRequest, "user default currency is empty")
|
||||||
ErrUserDefaultCurrencyIsInvalid = NewNormalError(NormalSubcategoryUser, 9, http.StatusBadRequest, "user default currency is invalid")
|
ErrUserDefaultCurrencyIsInvalid = NewNormalError(NormalSubcategoryUser, 9, http.StatusBadRequest, "user default currency is invalid")
|
||||||
ErrUserNotFound = NewNormalError(NormalSubcategoryUser, 10, http.StatusBadRequest, "user not found")
|
ErrUserNotFound = NewNormalError(NormalSubcategoryUser, 10, http.StatusBadRequest, "user not found")
|
||||||
ErrUserPasswordWrong = NewNormalError(NormalSubcategoryUser, 11, http.StatusBadRequest, "password is wrong")
|
ErrUserPasswordWrong = NewNormalError(NormalSubcategoryUser, 11, http.StatusBadRequest, "password is wrong")
|
||||||
ErrUsernameAlreadyExists = NewNormalError(NormalSubcategoryUser, 12, http.StatusBadRequest, "username already exists")
|
ErrUsernameAlreadyExists = NewNormalError(NormalSubcategoryUser, 12, http.StatusBadRequest, "username already exists")
|
||||||
ErrUserEmailAlreadyExists = NewNormalError(NormalSubcategoryUser, 13, http.StatusBadRequest, "email already exists")
|
ErrUserEmailAlreadyExists = NewNormalError(NormalSubcategoryUser, 13, http.StatusBadRequest, "email already exists")
|
||||||
ErrUserRegistrationNotAllowed = NewNormalError(NormalSubcategoryUser, 14, http.StatusBadRequest, "user registration not allowed")
|
ErrUserRegistrationNotAllowed = NewNormalError(NormalSubcategoryUser, 14, http.StatusBadRequest, "user registration not allowed")
|
||||||
ErrUserDefaultAccountIsInvalid = NewNormalError(NormalSubcategoryUser, 15, http.StatusBadRequest, "user default account is invalid")
|
ErrUserDefaultAccountIsInvalid = NewNormalError(NormalSubcategoryUser, 15, http.StatusBadRequest, "user default account is invalid")
|
||||||
|
ErrUserIsDisabled = NewNormalError(NormalSubcategoryUser, 16, http.StatusBadRequest, "user is disabled")
|
||||||
|
ErrEmptyIsInvalid = NewNormalError(NormalSubcategoryUser, 17, http.StatusBadRequest, "email is invalid")
|
||||||
|
ErrEmailIsEmptyOrInvalid = NewNormalError(NormalSubcategoryUser, 18, http.StatusBadRequest, "email is empty or invalid")
|
||||||
|
ErrNewPasswordEqualsOldInvalid = NewNormalError(NormalSubcategoryUser, 19, http.StatusBadRequest, "new password equals old password")
|
||||||
|
ErrEmailIsNotVerified = NewNormalError(NormalSubcategoryUser, 20, http.StatusBadRequest, "email is not verified")
|
||||||
|
ErrEmailIsVerified = NewNormalError(NormalSubcategoryUser, 21, http.StatusBadRequest, "email is verified")
|
||||||
|
ErrEmailValidationNotAllowed = NewNormalError(NormalSubcategoryUser, 22, http.StatusBadRequest, "email validation not allowed")
|
||||||
|
ErrDecimalSeparatorAndDigitGroupingSymbolCannotBeEqual = NewNormalError(NormalSubcategoryUser, 23, http.StatusBadRequest, "decimal separator and digit grouping symbol cannot be equal")
|
||||||
|
ErrUserDefaultAccountIsHidden = NewNormalError(NormalSubcategoryUser, 24, http.StatusBadRequest, "user default account is hidden")
|
||||||
|
ErrNoUserAvatar = NewNormalError(NormalSubcategoryUser, 25, http.StatusBadRequest, "no user avatar")
|
||||||
|
ErrUserAvatarIsEmpty = NewNormalError(NormalSubcategoryUser, 26, http.StatusBadRequest, "user avatar is empty")
|
||||||
|
ErrUserAvatarNoExists = NewNormalError(NormalSubcategoryUser, 27, http.StatusNotFound, "user avatar not exists")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type BankOfCanadaExchangeRateData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BankOfCanadaObservationData represents the observation data from bank of Canada
|
// BankOfCanadaObservationData represents the observation data from bank of Canada
|
||||||
type BankOfCanadaObservationData map[string]interface{}
|
type BankOfCanadaObservationData map[string]any
|
||||||
|
|
||||||
// ToLatestExchangeRateResponse returns a view-object according to original data from bank of Canada
|
// ToLatestExchangeRateResponse returns a view-object according to original data from bank of Canada
|
||||||
func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Context) *models.LatestExchangeRateResponse {
|
func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Context) *models.LatestExchangeRateResponse {
|
||||||
@@ -62,7 +62,7 @@ func (e *BankOfCanadaExchangeRateData) ToLatestExchangeRateResponse(c *core.Cont
|
|||||||
|
|
||||||
currencyCode := utils.SubString(typeName, 2, 3)
|
currencyCode := utils.SubString(typeName, 2, 3)
|
||||||
|
|
||||||
if data, ok := exchangeRateData.(map[string]interface{}); ok {
|
if data, ok := exchangeRateData.(map[string]any); ok {
|
||||||
exchangeRate := data["v"]
|
exchangeRate := data["v"]
|
||||||
|
|
||||||
if exchangeRateValue, ok2 := exchangeRate.(string); ok2 {
|
if exchangeRateValue, ok2 := exchangeRate.(string); ok2 {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
"github.com/mayswind/ezbookkeeping/pkg/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
const nationalBankOfPolandDailyExchangeRateUrl = "https://www.nbp.pl/kursy/xml/en/lastaen.xml"
|
const nationalBankOfPolandDailyExchangeRateUrl = "https://api.nbp.pl/api/exchangerates/tables/A?format=xml"
|
||||||
const nationalBankOfPolandInconvertibleCurrencyExchangeRateUrl = "https://www.nbp.pl/kursy/xml/en/lastben.xml"
|
const nationalBankOfPolandInconvertibleCurrencyExchangeRateUrl = "https://api.nbp.pl/api/exchangerates/tables/B?format=xml"
|
||||||
const nationalBankOfPolandExchangeRateReferenceUrl = "https://www.nbp.pl/homen.aspx?f=/kursy/kursyen.htm"
|
const nationalBankOfPolandExchangeRateReferenceUrl = "https://nbp.pl/en/statistic-and-financial-reporting/rates/"
|
||||||
const nationalBankOfPolandDataSource = "Narodowy Bank Polski"
|
const nationalBankOfPolandDataSource = "Narodowy Bank Polski"
|
||||||
const nationalBankOfPolandBaseCurrency = "PLN"
|
const nationalBankOfPolandBaseCurrency = "PLN"
|
||||||
|
|
||||||
@@ -30,16 +30,15 @@ type NationalBankOfPolandDataSource struct {
|
|||||||
|
|
||||||
// NationalBankOfPolandExchangeRateData represents the whole data from National Bank of Poland
|
// NationalBankOfPolandExchangeRateData represents the whole data from National Bank of Poland
|
||||||
type NationalBankOfPolandExchangeRateData struct {
|
type NationalBankOfPolandExchangeRateData struct {
|
||||||
XMLName xml.Name `xml:"exchange_rates"`
|
XMLName xml.Name `xml:"ArrayOfExchangeRatesTable"`
|
||||||
Date string `xml:"date,attr"`
|
Date string `xml:"ExchangeRatesTable>EffectiveDate"`
|
||||||
AllExchangeRates []*NationalBankOfPolandExchangeRate `xml:"mid-rate"`
|
AllExchangeRates []*NationalBankOfPolandExchangeRate `xml:"ExchangeRatesTable>Rates>Rate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NationalBankOfPolandExchangeRate represents the exchange rate data from National Bank of Poland
|
// NationalBankOfPolandExchangeRate represents the exchange rate data from National Bank of Poland
|
||||||
type NationalBankOfPolandExchangeRate struct {
|
type NationalBankOfPolandExchangeRate struct {
|
||||||
Currency string `xml:"code,attr"`
|
Currency string `xml:"Code"`
|
||||||
Units string `xml:"units,attr"`
|
Rate string `xml:"Mid"`
|
||||||
Rate string `xml:",chardata"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToLatestExchangeRateResponse returns a view-object according to original data from National Bank of Poland
|
// ToLatestExchangeRateResponse returns a view-object according to original data from National Bank of Poland
|
||||||
@@ -95,13 +94,6 @@ func (e *NationalBankOfPolandExchangeRateData) ToLatestExchangeRateResponse(c *c
|
|||||||
|
|
||||||
// ToLatestExchangeRate returns a data pair according to original data from National Bank of Poland
|
// ToLatestExchangeRate returns a data pair according to original data from National Bank of Poland
|
||||||
func (e *NationalBankOfPolandExchangeRate) ToLatestExchangeRate(c *core.Context) *models.LatestExchangeRate {
|
func (e *NationalBankOfPolandExchangeRate) ToLatestExchangeRate(c *core.Context) *models.LatestExchangeRate {
|
||||||
amount, err := utils.StringToInt64(e.Units)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WarnfWithRequestId(c, "[national_bank_of_poland_datasource.ToLatestExchangeRate] failed to parse amount, currency is %s, amount is %s", e.Currency, e.Units)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
rate, err := utils.StringToFloat64(e.Rate)
|
rate, err := utils.StringToFloat64(e.Rate)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,7 +106,7 @@ func (e *NationalBankOfPolandExchangeRate) ToLatestExchangeRate(c *core.Context)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
finalRate := float64(amount) / rate
|
finalRate := 1 / rate
|
||||||
|
|
||||||
if math.IsInf(finalRate, 0) {
|
if math.IsInf(finalRate, 0) {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -10,11 +10,22 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
const nationalBankOfPolandMinimumRequiredContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
|
const nationalBankOfPolandMinimumRequiredContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||||
"<exchange_rates table=\"A\" date=\"2021-04-02\" number=\"064/A/NBP/2021\" uid=\"21a064\">\n" +
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
|
||||||
" <mid-rate currency=\"US Dollar\" units=\"1\" code=\"USD\">3.8986</mid-rate>\n" +
|
" <ExchangeRatesTable>\n" +
|
||||||
" <mid-rate currency=\"Yuan Renminbi\" units=\"1\" code=\"CNY\">0.5941</mid-rate>\n" +
|
" <EffectiveDate>2024-02-28</EffectiveDate>\n" +
|
||||||
"</exchange_rates>"
|
" <Rates>\n" +
|
||||||
|
" <Rate>\n" +
|
||||||
|
" <Code>USD</Code>\n" +
|
||||||
|
" <Mid>3.9922</Mid>\n" +
|
||||||
|
" </Rate>\n" +
|
||||||
|
" <Rate>\n" +
|
||||||
|
" <Code>CNY</Code>\n" +
|
||||||
|
" <Mid>0.5545</Mid>\n" +
|
||||||
|
" </Rate>\n" +
|
||||||
|
" </Rates>\n" +
|
||||||
|
" </ExchangeRatesTable>\n" +
|
||||||
|
"</ArrayOfExchangeRatesTable>"
|
||||||
|
|
||||||
func TestNationalBankOfPolandDataSource_StandardDataExtractBaseCurrency(t *testing.T) {
|
func TestNationalBankOfPolandDataSource_StandardDataExtractBaseCurrency(t *testing.T) {
|
||||||
dataSource := &NationalBankOfPolandDataSource{}
|
dataSource := &NationalBankOfPolandDataSource{}
|
||||||
@@ -37,11 +48,11 @@ func TestNationalBankOfPolandDataSource_StandardDataExtractExchangeRates(t *test
|
|||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
|
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
Rate: "0.25650233417124096",
|
Rate: "0.2504884524823406",
|
||||||
})
|
})
|
||||||
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
|
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
|
||||||
Currency: "CNY",
|
Currency: "CNY",
|
||||||
Rate: "1.68321831341525",
|
Rate: "1.8034265103697025",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +72,33 @@ func TestNationalBankOfPolandDataSource_OnlyXMLHeader(t *testing.T) {
|
|||||||
Context: &gin.Context{},
|
Context: &gin.Context{},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"))
|
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>"))
|
||||||
|
assert.NotEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNationalBankOfPolandDataSource_EmptyArrayOfExchangeRatesTable(t *testing.T) {
|
||||||
|
dataSource := &NationalBankOfPolandDataSource{}
|
||||||
|
context := &core.Context{
|
||||||
|
Context: &gin.Context{},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
|
assert.NotEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNationalBankOfPolandDataSource_EmptyExchangeRatesTable(t *testing.T) {
|
||||||
|
dataSource := &NationalBankOfPolandDataSource{}
|
||||||
|
context := &core.Context{
|
||||||
|
Context: &gin.Context{},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
|
" <ExchangeRatesTable>\n"+
|
||||||
|
" </ExchangeRatesTable>\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
assert.NotEqual(t, nil, err)
|
assert.NotEqual(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,9 +108,14 @@ func TestNationalBankOfPolandDataSource_EmptyExchangeRatesContent(t *testing.T)
|
|||||||
Context: &gin.Context{},
|
Context: &gin.Context{},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"+
|
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
"<exchange_rates table=\"A\" date=\"2021-04-02\" number=\"064/A/NBP/2021\" uid=\"21a064\">\n"+
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
"</exchange_rates>"))
|
" <ExchangeRatesTable>\n"+
|
||||||
|
" <EffectiveDate>2024-02-28</EffectiveDate>\n"+
|
||||||
|
" <Rates>\n"+
|
||||||
|
" </Rates>\n"+
|
||||||
|
" </ExchangeRatesTable>\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
assert.NotEqual(t, nil, err)
|
assert.NotEqual(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,10 +125,18 @@ func TestNationalBankOfPolandDataSource_InvalidCurrency(t *testing.T) {
|
|||||||
Context: &gin.Context{},
|
Context: &gin.Context{},
|
||||||
}
|
}
|
||||||
|
|
||||||
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"+
|
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
"<exchange_rates table=\"A\" date=\"2021-04-02\" number=\"064/A/NBP/2021\" uid=\"21a064\">\n"+
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
" <mid-rate currency=\"XXX\" units=\"1\" code=\"XXX\">1</mid-rate>\n"+
|
" <ExchangeRatesTable>\n"+
|
||||||
"</exchange_rates>"))
|
" <EffectiveDate>2024-02-28</EffectiveDate>\n"+
|
||||||
|
" <Rates>\n"+
|
||||||
|
" <Rate>\n"+
|
||||||
|
" <Code>XXX</Code>\n"+
|
||||||
|
" <Mid>1</Mid>\n"+
|
||||||
|
" </Rate>\n"+
|
||||||
|
" </Rates>\n"+
|
||||||
|
" </ExchangeRatesTable>\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
||||||
}
|
}
|
||||||
@@ -97,10 +147,18 @@ func TestNationalBankOfPolandDataSource_EmptyRate(t *testing.T) {
|
|||||||
Context: &gin.Context{},
|
Context: &gin.Context{},
|
||||||
}
|
}
|
||||||
|
|
||||||
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"+
|
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
"<exchange_rates table=\"A\" date=\"2021-04-02\" number=\"064/A/NBP/2021\" uid=\"21a064\">\n"+
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
" <mid-rate currency=\"US Dollar\" units=\"1\" code=\"USD\"></mid-rate>\n"+
|
" <ExchangeRatesTable>\n"+
|
||||||
"</exchange_rates>"))
|
" <EffectiveDate>2024-02-28</EffectiveDate>\n"+
|
||||||
|
" <Rates>\n"+
|
||||||
|
" <Rate>\n"+
|
||||||
|
" <Code>USD</Code>\n"+
|
||||||
|
" <Mid></Mid>\n"+
|
||||||
|
" </Rate>\n"+
|
||||||
|
" </Rates>\n"+
|
||||||
|
" </ExchangeRatesTable>\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
||||||
}
|
}
|
||||||
@@ -111,10 +169,18 @@ func TestNationalBankOfPolandDataSource_InvalidRate(t *testing.T) {
|
|||||||
Context: &gin.Context{},
|
Context: &gin.Context{},
|
||||||
}
|
}
|
||||||
|
|
||||||
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"+
|
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
|
||||||
"<exchange_rates table=\"A\" date=\"2021-04-02\" number=\"064/A/NBP/2021\" uid=\"21a064\">\n"+
|
"<ArrayOfExchangeRatesTable xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
|
||||||
" <mid-rate currency=\"US Dollar\" units=\"1\" code=\"USD\">null</mid-rate>\n"+
|
" <ExchangeRatesTable>\n"+
|
||||||
"</exchange_rates>"))
|
" <EffectiveDate>2024-02-28</EffectiveDate>\n"+
|
||||||
|
" <Rates>\n"+
|
||||||
|
" <Rate>\n"+
|
||||||
|
" <Code>USD</Code>\n"+
|
||||||
|
" <Mid>null</Mid>\n"+
|
||||||
|
" </Rate>\n"+
|
||||||
|
" </Rates>\n"+
|
||||||
|
" </ExchangeRatesTable>\n"+
|
||||||
|
"</ArrayOfExchangeRatesTable>"))
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package locales
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DefaultLanguage represents the default language
|
||||||
|
var DefaultLanguage = en
|
||||||
|
|
||||||
|
// AllLanguages represents all the supported language
|
||||||
|
// To add new languages, please refer to https://ezbookkeeping.mayswind.net/translating
|
||||||
|
var AllLanguages = map[string]*LocaleInfo{
|
||||||
|
"en": {
|
||||||
|
Content: en,
|
||||||
|
},
|
||||||
|
"zh-Hans": {
|
||||||
|
Content: zhHans,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetLocaleTextItems(locale string) *LocaleTextItems {
|
||||||
|
localeInfo, exists := AllLanguages[locale]
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
return localeInfo.Content
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefaultLanguage
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsDecimalSeparatorEqualsDigitGroupingSymbol(decimalSeparator core.DecimalSeparator, digitGroupingSymbol core.DigitGroupingSymbol, locale string) bool {
|
||||||
|
if decimalSeparator == core.DECIMAL_SEPARATOR_DEFAULT && digitGroupingSymbol == core.DIGIT_GROUPING_SYMBOL_DEFAULT {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if byte(decimalSeparator) == byte(digitGroupingSymbol) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
localeTextItems := GetLocaleTextItems(locale)
|
||||||
|
|
||||||
|
if decimalSeparator == core.DECIMAL_SEPARATOR_DEFAULT {
|
||||||
|
decimalSeparator = localeTextItems.DefaultTypes.DecimalSeparator
|
||||||
|
}
|
||||||
|
|
||||||
|
if digitGroupingSymbol == core.DIGIT_GROUPING_SYMBOL_DEFAULT {
|
||||||
|
digitGroupingSymbol = localeTextItems.DefaultTypes.DigitGroupingSymbol
|
||||||
|
}
|
||||||
|
|
||||||
|
return byte(decimalSeparator) == byte(digitGroupingSymbol)
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package locales
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LocaleTextItems represents all text items need to be translated
|
||||||
|
type LocaleTextItems struct {
|
||||||
|
DefaultTypes *DefaultTypes
|
||||||
|
VerifyEmailTextItems *VerifyEmailTextItems
|
||||||
|
ForgetPasswordMailTextItems *ForgetPasswordMailTextItems
|
||||||
|
}
|
||||||
|
|
||||||
|
type DefaultTypes struct {
|
||||||
|
DecimalSeparator core.DecimalSeparator
|
||||||
|
DigitGroupingSymbol core.DigitGroupingSymbol
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyEmailTextItems represents text items need to be translated in verify mail
|
||||||
|
type VerifyEmailTextItems struct {
|
||||||
|
Title string
|
||||||
|
SalutationFormat string
|
||||||
|
DescriptionAboveBtn string
|
||||||
|
VerifyEmail string
|
||||||
|
DescriptionBelowBtnFormat string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForgetPasswordMailTextItems represents text items need to be translated in forget password mail
|
||||||
|
type ForgetPasswordMailTextItems struct {
|
||||||
|
Title string
|
||||||
|
SalutationFormat string
|
||||||
|
DescriptionAboveBtn string
|
||||||
|
ResetPassword string
|
||||||
|
DescriptionBelowBtnFormat string
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package locales
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
var en = &LocaleTextItems{
|
||||||
|
DefaultTypes: &DefaultTypes{
|
||||||
|
DecimalSeparator: core.DECIMAL_SEPARATOR_DOT,
|
||||||
|
DigitGroupingSymbol: core.DIGIT_GROUPING_SYMBOL_COMMA,
|
||||||
|
},
|
||||||
|
VerifyEmailTextItems: &VerifyEmailTextItems{
|
||||||
|
Title: "Verify Email",
|
||||||
|
SalutationFormat: "Hi %s,",
|
||||||
|
DescriptionAboveBtn: "Please click the link below to confirm your email address.",
|
||||||
|
VerifyEmail: "Verify Email",
|
||||||
|
DescriptionBelowBtnFormat: "If you did not sign up for %s account, please simply disregard this email. If you cannot click the link above, please copy the above url and paste it into your browser. The verify email link will be expired after %v minutes.",
|
||||||
|
},
|
||||||
|
ForgetPasswordMailTextItems: &ForgetPasswordMailTextItems{
|
||||||
|
Title: "Reset Your Password",
|
||||||
|
SalutationFormat: "Hi %s,",
|
||||||
|
DescriptionAboveBtn: "We recently received a request to reset your password. You can click the link below to reset your password.",
|
||||||
|
ResetPassword: "Reset Password",
|
||||||
|
DescriptionBelowBtnFormat: "If you did not request to reset your password, please simply disregard this email. If you cannot click the link above, please copy the above url and paste it into your browser. The password reset link will be expired after %v minutes.",
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package locales
|
||||||
|
|
||||||
|
// LocaleInfo represents locale info
|
||||||
|
type LocaleInfo struct {
|
||||||
|
Aliases []string
|
||||||
|
Content *LocaleTextItems
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package locales
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
var zhHans = &LocaleTextItems{
|
||||||
|
DefaultTypes: &DefaultTypes{
|
||||||
|
DecimalSeparator: core.DECIMAL_SEPARATOR_DOT,
|
||||||
|
DigitGroupingSymbol: core.DIGIT_GROUPING_SYMBOL_COMMA,
|
||||||
|
},
|
||||||
|
VerifyEmailTextItems: &VerifyEmailTextItems{
|
||||||
|
Title: "验证邮箱",
|
||||||
|
SalutationFormat: "%s 您好,",
|
||||||
|
DescriptionAboveBtn: "请点击下方的链接确认您的邮箱地址。",
|
||||||
|
VerifyEmail: "验证邮箱",
|
||||||
|
DescriptionBelowBtnFormat: "如果您没有注册 %s 账户,请直接忽略本邮件。如果您无法点击上述链接,请复制下方的地址然后在您的浏览器中粘贴。邮箱验证链接将在 %v 分钟后过期。",
|
||||||
|
},
|
||||||
|
ForgetPasswordMailTextItems: &ForgetPasswordMailTextItems{
|
||||||
|
Title: "重置密码",
|
||||||
|
SalutationFormat: "%s 您好,",
|
||||||
|
DescriptionAboveBtn: "我们刚才收到重置您密码的请求。您可以点击下方链接重置您的密码。",
|
||||||
|
ResetPassword: "重置密码",
|
||||||
|
DescriptionBelowBtnFormat: "如果您没有请求重置密码,请直接忽略本邮件。如果您无法点击上述链接,请复制下方的地址然后在您的浏览器中粘贴。重置密码链接将在 %v 分钟后过期。",
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -41,12 +41,12 @@ func (f *LogFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|||||||
b.WriteString("] ")
|
b.WriteString("] ")
|
||||||
}
|
}
|
||||||
|
|
||||||
b.WriteString(entry.Message)
|
|
||||||
|
|
||||||
if requestId, exists := entry.Data[logFieldRequestId]; exists {
|
if requestId, exists := entry.Data[logFieldRequestId]; exists {
|
||||||
b.WriteString(fmt.Sprintf(", r=%s", requestId))
|
b.WriteString(fmt.Sprintf("[%s] ", requestId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.WriteString(entry.Message)
|
||||||
|
|
||||||
b.WriteString("\n")
|
b.WriteString("\n")
|
||||||
|
|
||||||
if extra, exists := entry.Data[logFieldExtra]; exists {
|
if extra, exists := entry.Data[logFieldExtra]; exists {
|
||||||
|
|||||||
+80
-41
@@ -39,34 +39,73 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetLoggerConfiguration sets the logger according to the config
|
// SetLoggerConfiguration sets the logger according to the config
|
||||||
func SetLoggerConfiguration(config *settings.Config) error {
|
func SetLoggerConfiguration(config *settings.Config, isDisableBootLog bool) error {
|
||||||
var bootWriters []io.Writer
|
var bootWriters []io.Writer
|
||||||
var writers []io.Writer
|
var defaultWriters []io.Writer
|
||||||
|
var requestWriters []io.Writer
|
||||||
|
var queryWriters []io.Writer
|
||||||
|
|
||||||
bootWriters = append(bootWriters, os.Stdout)
|
if !isDisableBootLog {
|
||||||
|
bootWriters = append(bootWriters, os.Stdout)
|
||||||
|
}
|
||||||
|
|
||||||
if config.EnableConsoleLog {
|
if config.EnableConsoleLog {
|
||||||
writers = append(writers, os.Stdout)
|
defaultWriters = append(defaultWriters, os.Stdout)
|
||||||
|
requestWriters = append(requestWriters, os.Stdout)
|
||||||
|
queryWriters = append(queryWriters, os.Stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.EnableFileLog {
|
if config.EnableFileLog {
|
||||||
logFile, err := os.OpenFile(config.FileLogPath, os.O_CREATE|os.O_WRONLY, 0666)
|
defaultWriter, err := NewRotateFileWriter(config.FileLogPath, config.LogFileRotate, int64(config.LogFileMaxSize), config.LogFileMaxDays)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
bootWriters = append(bootWriters, logFile)
|
if !isDisableBootLog {
|
||||||
writers = append(writers, logFile)
|
bootWriters = append(bootWriters, defaultWriter)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultWriters = append(defaultWriters, defaultWriter)
|
||||||
|
|
||||||
|
if config.EnableRequestLog {
|
||||||
|
if config.RequestFileLogPath != "" && config.RequestFileLogPath != config.FileLogPath {
|
||||||
|
requestWriter, err := NewRotateFileWriter(config.RequestFileLogPath, config.LogFileRotate, int64(config.LogFileMaxSize), config.LogFileMaxDays)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
requestWriters = append(requestWriters, requestWriter)
|
||||||
|
} else {
|
||||||
|
requestWriters = append(requestWriters, defaultWriter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.EnableQueryLog {
|
||||||
|
if config.QueryFileLogPath != "" && config.QueryFileLogPath != config.FileLogPath {
|
||||||
|
queryWriter, err := NewRotateFileWriter(config.QueryFileLogPath, config.LogFileRotate, int64(config.LogFileMaxSize), config.LogFileMaxDays)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWriters = append(queryWriters, queryWriter)
|
||||||
|
} else {
|
||||||
|
queryWriters = append(queryWriters, defaultWriter)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bootMultipleWriter := io.MultiWriter(bootWriters...)
|
bootMultipleWriter := io.MultiWriter(bootWriters...)
|
||||||
multipleWriter := io.MultiWriter(writers...)
|
defaultMultipleWriter := io.MultiWriter(defaultWriters...)
|
||||||
|
requestMultipleWriter := io.MultiWriter(requestWriters...)
|
||||||
|
queryMultipleWriter := io.MultiWriter(queryWriters...)
|
||||||
|
|
||||||
bootLogger.SetOutput(bootMultipleWriter)
|
bootLogger.SetOutput(bootMultipleWriter)
|
||||||
defaultLogger.SetOutput(multipleWriter)
|
defaultLogger.SetOutput(defaultMultipleWriter)
|
||||||
requestLogger.SetOutput(multipleWriter)
|
requestLogger.SetOutput(requestMultipleWriter)
|
||||||
sqlQueryLogger.SetOutput(multipleWriter)
|
sqlQueryLogger.SetOutput(queryMultipleWriter)
|
||||||
|
|
||||||
if config.LogLevel == settings.LOGLEVEL_DEBUG {
|
if config.LogLevel == settings.LOGLEVEL_DEBUG {
|
||||||
bootLogger.SetLevel(logrus.DebugLevel)
|
bootLogger.SetLevel(logrus.DebugLevel)
|
||||||
@@ -94,93 +133,93 @@ func SetLoggerConfiguration(config *settings.Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debugf logs debug log with custom format
|
// Debugf logs debug log with custom format
|
||||||
func Debugf(format string, args ...interface{}) {
|
func Debugf(format string, args ...any) {
|
||||||
defaultLogger.Debugf(getFinalLog(format, args...))
|
defaultLogger.Debug(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugfWithRequestId logs debug log with custom format and request id
|
// DebugfWithRequestId logs debug log with custom format and request id
|
||||||
func DebugfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func DebugfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Debugf(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Debug(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof logs info log with custom format
|
// Infof logs info log with custom format
|
||||||
func Infof(format string, args ...interface{}) {
|
func Infof(format string, args ...any) {
|
||||||
defaultLogger.Infof(getFinalLog(format, args...))
|
defaultLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InfofWithRequestId logs info log with custom format and request id
|
// InfofWithRequestId logs info log with custom format and request id
|
||||||
func InfofWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func InfofWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Infof(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf logs warn log with custom format
|
// Warnf logs warn log with custom format
|
||||||
func Warnf(format string, args ...interface{}) {
|
func Warnf(format string, args ...any) {
|
||||||
defaultLogger.Warnf(getFinalLog(format, args...))
|
defaultLogger.Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarnfWithRequestId logs warn log with custom format and request id
|
// WarnfWithRequestId logs warn log with custom format and request id
|
||||||
func WarnfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func WarnfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Warnf(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf logs error log with custom format
|
// Errorf logs error log with custom format
|
||||||
func Errorf(format string, args ...interface{}) {
|
func Errorf(format string, args ...any) {
|
||||||
defaultLogger.Errorf(getFinalLog(format, args...))
|
defaultLogger.Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorfWithRequestId logs error log with custom format and request id
|
// ErrorfWithRequestId logs error log with custom format and request id
|
||||||
func ErrorfWithRequestId(c *core.Context, format string, args ...interface{}) {
|
func ErrorfWithRequestId(c *core.Context, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Errorf(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorfWithRequestIdAndExtra logs error log with custom format and request id and extra info
|
// ErrorfWithRequestIdAndExtra logs error log with custom format and request id and extra info
|
||||||
func ErrorfWithRequestIdAndExtra(c *core.Context, extraString string, format string, args ...interface{}) {
|
func ErrorfWithRequestIdAndExtra(c *core.Context, extraString string, format string, args ...any) {
|
||||||
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).WithField(logFieldExtra, extraString).Errorf(getFinalLog(format, args...))
|
defaultLogger.WithField(logFieldRequestId, c.GetRequestId()).WithField(logFieldExtra, extraString).Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootInfof logs boot info log
|
// BootInfof logs boot info log
|
||||||
func BootInfof(format string, args ...interface{}) {
|
func BootInfof(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Infof(getFinalLog(format, args...))
|
bootLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootWarnf logs boot warn log
|
// BootWarnf logs boot warn log
|
||||||
func BootWarnf(format string, args ...interface{}) {
|
func BootWarnf(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Warnf(getFinalLog(format, args...))
|
bootLogger.Warn(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootErrorf logs boot error log
|
// BootErrorf logs boot error log
|
||||||
func BootErrorf(format string, args ...interface{}) {
|
func BootErrorf(format string, args ...any) {
|
||||||
if bootLogger != nil {
|
if bootLogger != nil {
|
||||||
bootLogger.Errorf(getFinalLog(format, args...))
|
bootLogger.Error(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requestf logs http request log with custom format
|
// Requestf logs http request log with custom format
|
||||||
func Requestf(c *core.Context, format string, args ...interface{}) {
|
func Requestf(c *core.Context, format string, args ...any) {
|
||||||
if requestLogger != nil {
|
if requestLogger != nil {
|
||||||
requestLogger.WithField(logFieldRequestId, c.GetRequestId()).Infof(getFinalLog(format, args...))
|
requestLogger.WithField(logFieldRequestId, c.GetRequestId()).Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SqlQuery logs sql query log
|
// SqlQuery logs sql query log
|
||||||
func SqlQuery(args ...interface{}) {
|
func SqlQuery(args ...any) {
|
||||||
if sqlQueryLogger != nil {
|
if sqlQueryLogger != nil {
|
||||||
sqlQueryLogger.Info(args...)
|
sqlQueryLogger.Info(args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SqlQueryf logs sql query log with custom format
|
// SqlQueryf logs sql query log with custom format
|
||||||
func SqlQueryf(format string, args ...interface{}) {
|
func SqlQueryf(format string, args ...any) {
|
||||||
if sqlQueryLogger != nil {
|
if sqlQueryLogger != nil {
|
||||||
sqlQueryLogger.Infof(getFinalLog(format, args...))
|
sqlQueryLogger.Info(getFinalLog(format, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFinalLog(format string, args ...interface{}) string {
|
func getFinalLog(format string, args ...any) string {
|
||||||
result := fmt.Sprintf(format, args...)
|
result := fmt.Sprintf(format, args...)
|
||||||
result = strings.Replace(result, "\n", " ", -1)
|
result = strings.Replace(result, "\n", " ", -1)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
logRotateSuffixDateFormat = "20060102150405"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RotateFileWriter struct {
|
||||||
|
EnableRotate bool
|
||||||
|
MaxFileSize int64
|
||||||
|
MaxFileDays uint32
|
||||||
|
|
||||||
|
filePath string
|
||||||
|
file *os.File
|
||||||
|
totalSize int64
|
||||||
|
|
||||||
|
mutex sync.Mutex
|
||||||
|
lastRemoveOldFilesDay int
|
||||||
|
}
|
||||||
|
|
||||||
|
var logFallbackLogger = logrus.New()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
logFallbackLogger.SetFormatter(&LogFormatter{})
|
||||||
|
logFallbackLogger.SetOutput(os.Stdout)
|
||||||
|
logFallbackLogger.SetLevel(logrus.InfoLevel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRotateFileWriter returns a new rotate file writer
|
||||||
|
func NewRotateFileWriter(filePath string, enableRotate bool, maxFileSize int64, maxFileDays uint32) (*RotateFileWriter, error) {
|
||||||
|
writer := &RotateFileWriter{
|
||||||
|
EnableRotate: enableRotate,
|
||||||
|
MaxFileSize: maxFileSize,
|
||||||
|
MaxFileDays: maxFileDays,
|
||||||
|
filePath: filePath,
|
||||||
|
totalSize: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := writer.openFile()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return writer, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write does log data to specified file
|
||||||
|
func (w *RotateFileWriter) Write(p []byte) (n int, err error) {
|
||||||
|
dataSize := int64(len(p))
|
||||||
|
|
||||||
|
if w.EnableRotate && w.totalSize > 0 && w.totalSize+dataSize >= w.MaxFileSize {
|
||||||
|
w.mutex.Lock()
|
||||||
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
|
if w.EnableRotate && w.totalSize > 0 && w.totalSize+dataSize >= w.MaxFileSize {
|
||||||
|
err := w.rotateFile()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logFallbackLogger.Errorf("[rotate_file_writer.Write] cannot rotate log file \"%s\", because %s", w.file.Name(), err.Error())
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeSize, err := w.file.Write(p)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.totalSize += int64(writeSize)
|
||||||
|
|
||||||
|
if w.EnableRotate {
|
||||||
|
today := time.Now().Day()
|
||||||
|
|
||||||
|
if today != w.lastRemoveOldFilesDay && w.MaxFileDays > 0 {
|
||||||
|
w.lastRemoveOldFilesDay = today
|
||||||
|
go w.removeOldFiles()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return writeSize, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *RotateFileWriter) rotateFile() error {
|
||||||
|
currentFileName := w.file.Name()
|
||||||
|
err := w.file.Close()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errs.NewLoggingError(fmt.Sprintf("cannot close log file \"%s\", because %s", w.file.Name(), err.Error()), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.file = nil
|
||||||
|
archiveFileName := fmt.Sprintf("%s.%s", currentFileName, time.Now().Format(logRotateSuffixDateFormat))
|
||||||
|
err = os.Rename(currentFileName, archiveFileName)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errs.NewLoggingError(fmt.Sprintf("cannot rename log file \"%s\" to \"%s\", because %s", currentFileName, archiveFileName, err.Error()), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = w.openFile()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *RotateFileWriter) openFile() error {
|
||||||
|
if w.file != nil {
|
||||||
|
logFallbackLogger.Warnf("[rotate_file_writer.removeOldFiles] cannot reopen log file \"%s\"", w.file.Name())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
file, err := os.OpenFile(w.filePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errs.NewLoggingError(fmt.Sprintf("cannot open log file \"%s\", because %s", w.filePath, err.Error()), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.file = file
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *RotateFileWriter) removeOldFiles() {
|
||||||
|
dir := filepath.Dir(w.filePath)
|
||||||
|
logBaseFileName := filepath.Base(w.filePath) + "."
|
||||||
|
|
||||||
|
allLogFiles, err := os.ReadDir(dir)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
retainMinUnixTime := int64(0)
|
||||||
|
|
||||||
|
if w.MaxFileDays > 0 {
|
||||||
|
retainMinUnixTime = time.Now().AddDate(0, 0, -int(w.MaxFileDays)).Unix()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range allLogFiles {
|
||||||
|
if file.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
logFileName := filepath.Base(file.Name())
|
||||||
|
|
||||||
|
if !strings.HasPrefix(logFileName, logBaseFileName) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
rotateDate := logFileName[len(logBaseFileName):]
|
||||||
|
dotIndex := strings.Index(rotateDate, ".")
|
||||||
|
|
||||||
|
if dotIndex > 0 {
|
||||||
|
rotateDate = rotateDate[0:dotIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rotateDate) != len(logRotateSuffixDateFormat) {
|
||||||
|
logFallbackLogger.Errorf("[rotate_file_writer.removeOldFiles] date suffix of old log file \"%s\" is invalid", file.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
rotateDateTime, err := time.ParseInLocation(logRotateSuffixDateFormat, rotateDate, time.Now().Location())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logFallbackLogger.Errorf("[rotate_file_writer.removeOldFiles] cannot parse rotate date of old log file \"%s\", because %s", file.Name(), err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if rotateDateTime.Unix() >= retainMinUnixTime {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Remove(filepath.Join(dir, file.Name()))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logFallbackLogger.Errorf("[rotate_file_writer.removeOldFiles] cannot remove old log file \"%s\", because %s", file.Name(), err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package mail
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"gopkg.in/mail.v2"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DefaultMailer represents default mailer
|
||||||
|
type DefaultMailer struct {
|
||||||
|
dialer *mail.Dialer
|
||||||
|
fromAddress string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDefaultMailer returns a new default mailer
|
||||||
|
func NewDefaultMailer(smtpConfig *settings.SMTPConfig) (*DefaultMailer, error) {
|
||||||
|
host, portStr, err := net.SplitHostPort(smtpConfig.SMTPHost)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.ErrSMTPServerHostInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
port, err := utils.StringToInt(portStr)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.ErrSMTPServerHostInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
dialer := mail.NewDialer(host, port, smtpConfig.SMTPUser, smtpConfig.SMTPPasswd)
|
||||||
|
dialer.TLSConfig = &tls.Config{
|
||||||
|
ServerName: host,
|
||||||
|
InsecureSkipVerify: smtpConfig.SMTPSkipTLSVerify,
|
||||||
|
}
|
||||||
|
|
||||||
|
mailer := &DefaultMailer{
|
||||||
|
dialer: dialer,
|
||||||
|
fromAddress: smtpConfig.FromAddress,
|
||||||
|
}
|
||||||
|
|
||||||
|
return mailer, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMail sends an email according to argument
|
||||||
|
func (m *DefaultMailer) SendMail(message *MailMessage) error {
|
||||||
|
if m.dialer == nil {
|
||||||
|
return errs.ErrSMTPServerNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
mailMessage := mail.NewMessage()
|
||||||
|
mailMessage.SetHeader("From", m.fromAddress)
|
||||||
|
mailMessage.SetHeader("To", message.To)
|
||||||
|
mailMessage.SetHeader("Subject", message.Subject)
|
||||||
|
mailMessage.SetBody("text/html", message.Body)
|
||||||
|
|
||||||
|
err := m.dialer.DialAndSend(mailMessage)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package mail
|
||||||
|
|
||||||
|
// MailMessage represents an email entity
|
||||||
|
type MailMessage struct {
|
||||||
|
To string
|
||||||
|
Subject string
|
||||||
|
Body string
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package mail
|
||||||
|
|
||||||
|
// Mailer is email sender interface
|
||||||
|
type Mailer interface {
|
||||||
|
SendMail(message *MailMessage) error
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package mail
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MailerContainer contains the current mailer
|
||||||
|
type MailerContainer struct {
|
||||||
|
Current Mailer
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a mailer container singleton instance
|
||||||
|
var (
|
||||||
|
Container = &MailerContainer{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitializeMailer initializes the current mailer according to the config
|
||||||
|
func InitializeMailer(config *settings.Config) error {
|
||||||
|
if !config.EnableSMTP {
|
||||||
|
Container.Current = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
mailer, err := NewDefaultMailer(config.SMTPConfig)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
Container.Current = mailer
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMail sends an email according to argument
|
||||||
|
func (u *MailerContainer) SendMail(message *MailMessage) error {
|
||||||
|
return u.Current.SendMail(message)
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package middlewares
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const tokenCookieParam = "ebk_auth_token"
|
||||||
|
|
||||||
|
// AmapApiProxyAuthCookie adds amap api proxy auth cookie to cookies in response
|
||||||
|
func AmapApiProxyAuthCookie(c *core.Context, config *settings.Config) {
|
||||||
|
token := c.GetTextualToken()
|
||||||
|
|
||||||
|
if token != "" {
|
||||||
|
c.SetCookie(tokenCookieParam, token, int(config.TokenExpiredTime), "/_AMapService", "", false, true)
|
||||||
|
} else {
|
||||||
|
c.SetCookie(tokenCookieParam, "", -1, "/_AMapService", "", false, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,58 +17,24 @@ type TokenSourceType byte
|
|||||||
const (
|
const (
|
||||||
TOKEN_SOURCE_TYPE_HEADER TokenSourceType = 1
|
TOKEN_SOURCE_TYPE_HEADER TokenSourceType = 1
|
||||||
TOKEN_SOURCE_TYPE_ARGUMENT TokenSourceType = 2
|
TOKEN_SOURCE_TYPE_ARGUMENT TokenSourceType = 2
|
||||||
|
TOKEN_SOURCE_TYPE_COOKIE TokenSourceType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
const tokenQueryStringParam = "token"
|
const tokenQueryStringParam = "token"
|
||||||
|
|
||||||
// JWTAuthorization verifies whether current request is valid by jwt token
|
// JWTAuthorization verifies whether current request is valid by jwt token in header
|
||||||
func JWTAuthorization(c *core.Context) {
|
func JWTAuthorization(c *core.Context) {
|
||||||
claims, err := getTokenClaims(c, TOKEN_SOURCE_TYPE_HEADER)
|
jwtAuthorization(c, TOKEN_SOURCE_TYPE_HEADER)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
utils.PrintJsonErrorResult(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if claims.Type == core.USER_TOKEN_TYPE_REQUIRE_2FA {
|
|
||||||
log.WarnfWithRequestId(c, "[authorization.JWTAuthorization] user \"uid:%d\" token requires 2fa", claims.Uid)
|
|
||||||
utils.PrintJsonErrorResult(c, errs.ErrCurrentTokenRequire2FA)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if claims.Type != core.USER_TOKEN_TYPE_NORMAL {
|
|
||||||
log.WarnfWithRequestId(c, "[authorization.JWTAuthorization] user \"uid:%d\" token type is invalid", claims.Uid)
|
|
||||||
utils.PrintJsonErrorResult(c, errs.ErrCurrentInvalidTokenType)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.SetTokenClaims(claims)
|
|
||||||
c.Next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JWTAuthorizationByQueryString verifies whether current request is valid by jwt token
|
// JWTAuthorizationByQueryString verifies whether current request is valid by jwt token in query string
|
||||||
func JWTAuthorizationByQueryString(c *core.Context) {
|
func JWTAuthorizationByQueryString(c *core.Context) {
|
||||||
claims, err := getTokenClaims(c, TOKEN_SOURCE_TYPE_ARGUMENT)
|
jwtAuthorization(c, TOKEN_SOURCE_TYPE_ARGUMENT)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
// JWTAuthorizationByCookie verifies whether current request is valid by jwt token in cookie
|
||||||
utils.PrintJsonErrorResult(c, err)
|
func JWTAuthorizationByCookie(c *core.Context) {
|
||||||
return
|
jwtAuthorization(c, TOKEN_SOURCE_TYPE_COOKIE)
|
||||||
}
|
|
||||||
|
|
||||||
if claims.Type == core.USER_TOKEN_TYPE_REQUIRE_2FA {
|
|
||||||
log.WarnfWithRequestId(c, "[authorization.JWTAuthorizationByQueryString] user \"uid:%d\" token requires 2fa", claims.Uid)
|
|
||||||
utils.PrintJsonErrorResult(c, errs.ErrCurrentTokenRequire2FA)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if claims.Type != core.USER_TOKEN_TYPE_NORMAL {
|
|
||||||
log.WarnfWithRequestId(c, "[authorization.JWTAuthorizationByQueryString] user \"uid:%d\" token type is invalid", claims.Uid)
|
|
||||||
utils.PrintJsonErrorResult(c, errs.ErrCurrentInvalidTokenType)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.SetTokenClaims(claims)
|
|
||||||
c.Next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JWTTwoFactorAuthorization verifies whether current request is valid by 2fa passcode
|
// JWTTwoFactorAuthorization verifies whether current request is valid by 2fa passcode
|
||||||
@@ -81,7 +47,7 @@ func JWTTwoFactorAuthorization(c *core.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if claims.Type != core.USER_TOKEN_TYPE_REQUIRE_2FA {
|
if claims.Type != core.USER_TOKEN_TYPE_REQUIRE_2FA {
|
||||||
log.WarnfWithRequestId(c, "[authorization.JWTTwoFactorAuthorization] user \"uid:%d\" token is not need two factor authorization", claims.Uid)
|
log.WarnfWithRequestId(c, "[authorization.JWTTwoFactorAuthorization] user \"uid:%d\" token is not need two-factor authorization", claims.Uid)
|
||||||
utils.PrintJsonErrorResult(c, errs.ErrCurrentTokenNotRequire2FA)
|
utils.PrintJsonErrorResult(c, errs.ErrCurrentTokenNotRequire2FA)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -90,6 +56,68 @@ func JWTTwoFactorAuthorization(c *core.Context) {
|
|||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JWTEmailVerifyAuthorization verifies whether current request is email verification
|
||||||
|
func JWTEmailVerifyAuthorization(c *core.Context) {
|
||||||
|
claims, err := getTokenClaims(c, TOKEN_SOURCE_TYPE_ARGUMENT)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrEmailVerifyTokenIsInvalidOrExpired)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if claims.Type != core.USER_TOKEN_TYPE_EMAIL_VERIFY {
|
||||||
|
log.WarnfWithRequestId(c, "[authorization.JWTEmailVerifyAuthorization] user \"uid:%d\" token is not for email verification", claims.Uid)
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrCurrentInvalidToken)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.SetTokenClaims(claims)
|
||||||
|
c.Next()
|
||||||
|
}
|
||||||
|
|
||||||
|
// JWTResetPasswordAuthorization verifies whether current request is password reset
|
||||||
|
func JWTResetPasswordAuthorization(c *core.Context) {
|
||||||
|
claims, err := getTokenClaims(c, TOKEN_SOURCE_TYPE_ARGUMENT)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrPasswordResetTokenIsInvalidOrExpired)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if claims.Type != core.USER_TOKEN_TYPE_PASSWORD_RESET {
|
||||||
|
log.WarnfWithRequestId(c, "[authorization.JWTResetPasswordAuthorization] user \"uid:%d\" token is not for password request", claims.Uid)
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrCurrentInvalidToken)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.SetTokenClaims(claims)
|
||||||
|
c.Next()
|
||||||
|
}
|
||||||
|
|
||||||
|
func jwtAuthorization(c *core.Context, source TokenSourceType) {
|
||||||
|
claims, err := getTokenClaims(c, source)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.PrintJsonErrorResult(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if claims.Type == core.USER_TOKEN_TYPE_REQUIRE_2FA {
|
||||||
|
log.WarnfWithRequestId(c, "[authorization.jwtAuthorization] user \"uid:%d\" token requires 2fa", claims.Uid)
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrCurrentTokenRequire2FA)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if claims.Type != core.USER_TOKEN_TYPE_NORMAL {
|
||||||
|
log.WarnfWithRequestId(c, "[authorization.jwtAuthorization] user \"uid:%d\" token type is invalid", claims.Uid)
|
||||||
|
utils.PrintJsonErrorResult(c, errs.ErrCurrentInvalidTokenType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.SetTokenClaims(claims)
|
||||||
|
c.Next()
|
||||||
|
}
|
||||||
|
|
||||||
func getTokenClaims(c *core.Context, source TokenSourceType) (*core.UserTokenClaims, *errs.Error) {
|
func getTokenClaims(c *core.Context, source TokenSourceType) (*core.UserTokenClaims, *errs.Error) {
|
||||||
token, claims, err := parseToken(c, source)
|
token, claims, err := parseToken(c, source)
|
||||||
|
|
||||||
@@ -114,6 +142,8 @@ func getTokenClaims(c *core.Context, source TokenSourceType) (*core.UserTokenCla
|
|||||||
func parseToken(c *core.Context, source TokenSourceType) (*jwt.Token, *core.UserTokenClaims, error) {
|
func parseToken(c *core.Context, source TokenSourceType) (*jwt.Token, *core.UserTokenClaims, error) {
|
||||||
if source == TOKEN_SOURCE_TYPE_ARGUMENT {
|
if source == TOKEN_SOURCE_TYPE_ARGUMENT {
|
||||||
return services.Tokens.ParseTokenByArgument(c, tokenQueryStringParam)
|
return services.Tokens.ParseTokenByArgument(c, tokenQueryStringParam)
|
||||||
|
} else if source == TOKEN_SOURCE_TYPE_COOKIE {
|
||||||
|
return services.Tokens.ParseTokenByCookie(c, tokenCookieParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
return services.Tokens.ParseTokenByHeader(c)
|
return services.Tokens.ParseTokenByHeader(c)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func RequestId(config *settings.Config) core.MiddlewareHandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
requestId := requestid.Container.Current.GenerateRequestId(c.ClientIP())
|
requestId := requestid.Container.Current.GenerateRequestId(c.ClientIP(), c.ClientPort())
|
||||||
c.SetRequestId(requestId)
|
c.SetRequestId(requestId)
|
||||||
|
|
||||||
if config.EnableRequestIdHeader {
|
if config.EnableRequestIdHeader {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
@@ -15,9 +17,71 @@ func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
|
|||||||
return func(c *core.Context) {
|
return func(c *core.Context) {
|
||||||
settingsArr := []string{
|
settingsArr := []string{
|
||||||
buildBooleanSetting("r", config.EnableUserRegister),
|
buildBooleanSetting("r", config.EnableUserRegister),
|
||||||
|
buildBooleanSetting("f", config.EnableUserForgetPassword),
|
||||||
|
buildBooleanSetting("v", config.EnableUserVerifyEmail),
|
||||||
buildBooleanSetting("e", config.EnableDataExport),
|
buildBooleanSetting("e", config.EnableDataExport),
|
||||||
buildStringSetting("m", config.MapProvider),
|
buildStringSetting("m", strings.Replace(config.MapProvider, "_", "-", -1)),
|
||||||
buildBooleanSetting("mp", config.EnableMapDataFetchProxy),
|
}
|
||||||
|
|
||||||
|
if config.EnableMapDataFetchProxy &&
|
||||||
|
(config.MapProvider == settings.OpenStreetMapProvider ||
|
||||||
|
config.MapProvider == settings.OpenStreetMapHumanitarianStyleProvider ||
|
||||||
|
config.MapProvider == settings.OpenTopoMapProvider ||
|
||||||
|
config.MapProvider == settings.OPNVKarteMapProvider ||
|
||||||
|
config.MapProvider == settings.CyclOSMMapProvider ||
|
||||||
|
config.MapProvider == settings.CartoDBMapProvider ||
|
||||||
|
config.MapProvider == settings.TomTomMapProvider ||
|
||||||
|
config.MapProvider == settings.TianDiTuProvider ||
|
||||||
|
config.MapProvider == settings.CustomProvider) {
|
||||||
|
settingsArr = append(settingsArr, buildBooleanSetting("mp", config.EnableMapDataFetchProxy))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.CustomProvider {
|
||||||
|
settingsArr = append(settingsArr, buildStringSetting("cmzl", fmt.Sprintf("%d-%d-%d", config.CustomMapTileServerMinZoomLevel, config.CustomMapTileServerMaxZoomLevel, config.CustomMapTileServerDefaultZoomLevel)))
|
||||||
|
|
||||||
|
if !config.EnableMapDataFetchProxy {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("cmsu", config.CustomMapTileServerTileLayerUrl))
|
||||||
|
|
||||||
|
if config.CustomMapTileServerAnnotationLayerUrl != "" {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("cmau", config.CustomMapTileServerAnnotationLayerUrl))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if config.CustomMapTileServerAnnotationLayerUrl != "" {
|
||||||
|
settingsArr = append(settingsArr, buildBooleanSetting("cmap", config.EnableMapDataFetchProxy))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.TomTomMapProvider && config.TomTomMapAPIKey != "" && !config.EnableMapDataFetchProxy {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("tmak", config.TomTomMapAPIKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.TianDiTuProvider && config.TianDiTuAPIKey != "" && !config.EnableMapDataFetchProxy {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("tdak", config.TianDiTuAPIKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.GoogleMapProvider && config.GoogleMapAPIKey != "" {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("gmak", config.GoogleMapAPIKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.BaiduMapProvider && config.BaiduMapAK != "" {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("bmak", config.BaiduMapAK))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.AmapProvider && config.AmapApplicationKey != "" {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("amak", config.AmapApplicationKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.MapProvider == settings.AmapProvider && config.AmapSecurityVerificationMethod != "" {
|
||||||
|
settingsArr = append(settingsArr, buildStringSetting("amsv", strings.Replace(config.AmapSecurityVerificationMethod, "_", "", -1)))
|
||||||
|
|
||||||
|
if config.AmapSecurityVerificationMethod == settings.AmapSecurityVerificationExternalProxyMethod {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("amep", config.AmapApiExternalProxyUrl))
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.AmapSecurityVerificationMethod == settings.AmapSecurityVerificationPlainTextMethod {
|
||||||
|
settingsArr = append(settingsArr, buildEncodedStringSetting("amas", config.AmapApplicationSecret))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bundledSettings := strings.Join(settingsArr, "_")
|
bundledSettings := strings.Join(settingsArr, "_")
|
||||||
@@ -28,7 +92,13 @@ func ServerSettingsCookie(config *settings.Config) core.MiddlewareHandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildStringSetting(key string, value string) string {
|
func buildStringSetting(key string, value string) string {
|
||||||
return fmt.Sprintf("%s.%s", key, strings.Replace(value, ".", "-", -1))
|
return fmt.Sprintf("%s.%s", key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildEncodedStringSetting(key string, value string) string {
|
||||||
|
urlEncodedValue := url.QueryEscape(value)
|
||||||
|
base64Value := base64.StdEncoding.EncodeToString([]byte(urlEncodedValue))
|
||||||
|
return fmt.Sprintf("%s.%s", key, base64Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildBooleanSetting(key string, value bool) string {
|
func buildBooleanSetting(key string, value bool) string {
|
||||||
|
|||||||
+10
-9
@@ -69,15 +69,16 @@ type Account struct {
|
|||||||
|
|
||||||
// AccountCreateRequest represents all parameters of account creation request
|
// AccountCreateRequest represents all parameters of account creation request
|
||||||
type AccountCreateRequest struct {
|
type AccountCreateRequest struct {
|
||||||
Name string `json:"name" binding:"required,notBlank,max=32"`
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
Category AccountCategory `json:"category" binding:"required"`
|
Category AccountCategory `json:"category" binding:"required"`
|
||||||
Type AccountType `json:"type" binding:"required"`
|
Type AccountType `json:"type" binding:"required"`
|
||||||
Icon int64 `json:"icon,string" binding:"required,min=1"`
|
Icon int64 `json:"icon,string" binding:"required,min=1"`
|
||||||
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
||||||
Currency string `json:"currency" binding:"required,len=3,validCurrency"`
|
Currency string `json:"currency" binding:"required,len=3,validCurrency"`
|
||||||
Balance int64 `json:"balance"`
|
Balance int64 `json:"balance"`
|
||||||
Comment string `json:"comment" binding:"max=255"`
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
SubAccounts []*AccountCreateRequest `json:"subAccounts" binding:"omitempty"`
|
SubAccounts []*AccountCreateRequest `json:"subAccounts" binding:"omitempty"`
|
||||||
|
ClientSessionId string `json:"clientSessionId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountModifyRequest represents all parameters of account modification request
|
// AccountModifyRequest represents all parameters of account modification request
|
||||||
|
|||||||
@@ -2,7 +2,15 @@ package models
|
|||||||
|
|
||||||
// AuthResponse returns a view-object of user authorization
|
// AuthResponse returns a view-object of user authorization
|
||||||
type AuthResponse struct {
|
type AuthResponse struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Need2FA bool `json:"need2FA"`
|
Need2FA bool `json:"need2FA"`
|
||||||
User *UserBasicInfo `json:"user"`
|
User *UserBasicInfo `json:"user"`
|
||||||
|
NotificationContent string `json:"notificationContent,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterResponse returns a view-object of user register response
|
||||||
|
type RegisterResponse struct {
|
||||||
|
AuthResponse
|
||||||
|
NeedVerifyEmail bool `json:"needVerifyEmail"`
|
||||||
|
PresetCategoriesSaved bool `json:"presetCategoriesSaved"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
package models
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// CurrencyDisplayType represents the display type of amount with currency
|
||||||
|
type CurrencyDisplayType byte
|
||||||
|
|
||||||
|
// Currency Display Type
|
||||||
|
const (
|
||||||
|
CURRENCY_DISPLAY_TYPE_DEFAULT CurrencyDisplayType = 0
|
||||||
|
CURRENCY_DISPLAY_TYPE_NONE CurrencyDisplayType = 1
|
||||||
|
CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT CurrencyDisplayType = 2
|
||||||
|
CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT CurrencyDisplayType = 3
|
||||||
|
CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT_WITHOUT_SPACE CurrencyDisplayType = 4
|
||||||
|
CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT_WITHOUT_SPACE CurrencyDisplayType = 5
|
||||||
|
CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT CurrencyDisplayType = 6
|
||||||
|
CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT CurrencyDisplayType = 7
|
||||||
|
CURRENCY_DISPLAY_TYPE_UNIT_BEFORE_AMOUNT CurrencyDisplayType = 8
|
||||||
|
CURRENCY_DISPLAY_TYPE_UNIT_AFTER_AMOUNT CurrencyDisplayType = 9
|
||||||
|
CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT CurrencyDisplayType = 10
|
||||||
|
CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT CurrencyDisplayType = 11
|
||||||
|
CURRENCY_DISPLAY_TYPE_INVALID CurrencyDisplayType = 255
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a textual representation of the currency display type enum
|
||||||
|
func (d CurrencyDisplayType) String() string {
|
||||||
|
switch d {
|
||||||
|
case CURRENCY_DISPLAY_TYPE_DEFAULT:
|
||||||
|
return "Default"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_NONE:
|
||||||
|
return "None"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT:
|
||||||
|
return "Symbol Before Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT:
|
||||||
|
return "Symbol After Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT_WITHOUT_SPACE:
|
||||||
|
return "Symbol Before Amount Without Space"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT_WITHOUT_SPACE:
|
||||||
|
return "Symbol After Amount Without Space"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT:
|
||||||
|
return "Code Before Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT:
|
||||||
|
return "Code After Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_UNIT_BEFORE_AMOUNT:
|
||||||
|
return "Unit Before Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_UNIT_AFTER_AMOUNT:
|
||||||
|
return "Unit After Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT:
|
||||||
|
return "Name Before Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT:
|
||||||
|
return "Name After Amount"
|
||||||
|
case CURRENCY_DISPLAY_TYPE_INVALID:
|
||||||
|
return "Invalid"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Invalid(%d)", int(d))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,4 +11,5 @@ type DataStatisticsResponse struct {
|
|||||||
TotalTransactionCategoryCount int64 `json:"totalTransactionCategoryCount,string"`
|
TotalTransactionCategoryCount int64 `json:"totalTransactionCategoryCount,string"`
|
||||||
TotalTransactionTagCount int64 `json:"totalTransactionTagCount,string"`
|
TotalTransactionTagCount int64 `json:"totalTransactionTagCount,string"`
|
||||||
TotalTransactionCount int64 `json:"totalTransactionCount,string"`
|
TotalTransactionCount int64 `json:"totalTransactionCount,string"`
|
||||||
|
TotalTransactionTemplateCount int64 `json:"totalTransactionTemplateCount,string"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
// ForgetPasswordRequest represents all parameters of forget password request
|
||||||
|
type ForgetPasswordRequest struct {
|
||||||
|
Email string `json:"email" binding:"required,notBlank,max=100,validEmail"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordResetRequest represents all parameters of reset password request
|
||||||
|
type PasswordResetRequest struct {
|
||||||
|
Email string `json:"email" binding:"required,notBlank,max=100,validEmail"`
|
||||||
|
Password string `json:"password" binding:"required,min=6,max=128"`
|
||||||
|
}
|
||||||
+14
-13
@@ -7,13 +7,14 @@ const TokenMaxUserAgentLength = 255
|
|||||||
|
|
||||||
// TokenRecord represents token data stored in database
|
// TokenRecord represents token data stored in database
|
||||||
type TokenRecord struct {
|
type TokenRecord struct {
|
||||||
Uid int64 `xorm:"PK INDEX(IDX_token_record_uid_type_expired_time)"`
|
Uid int64 `xorm:"PK INDEX(IDX_token_record_uid_type_expired_time)"`
|
||||||
UserTokenId int64 `xorm:"PK"`
|
UserTokenId int64 `xorm:"PK"`
|
||||||
TokenType core.TokenType `xorm:"INDEX(IDX_token_record_uid_type_expired_time) TINYINT NOT NULL"`
|
TokenType core.TokenType `xorm:"INDEX(IDX_token_record_uid_type_expired_time) TINYINT NOT NULL"`
|
||||||
Secret string `xorm:"VARCHAR(10) NOT NULL"`
|
Secret string `xorm:"VARCHAR(10) NOT NULL"`
|
||||||
UserAgent string `xorm:"VARCHAR(255)"`
|
UserAgent string `xorm:"VARCHAR(255)"`
|
||||||
CreatedUnixTime int64 `xorm:"PK"`
|
CreatedUnixTime int64 `xorm:"PK"`
|
||||||
ExpiredUnixTime int64 `xorm:"INDEX(IDX_token_record_uid_type_expired_time)"`
|
ExpiredUnixTime int64 `xorm:"INDEX(IDX_token_record_uid_type_expired_time)"`
|
||||||
|
LastSeenUnixTime int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// TokenRevokeRequest represents all parameters of token revoking request
|
// TokenRevokeRequest represents all parameters of token revoking request
|
||||||
@@ -23,9 +24,10 @@ type TokenRevokeRequest struct {
|
|||||||
|
|
||||||
// TokenRefreshResponse represents all parameters of token refreshing request
|
// TokenRefreshResponse represents all parameters of token refreshing request
|
||||||
type TokenRefreshResponse struct {
|
type TokenRefreshResponse struct {
|
||||||
NewToken string `json:"newToken"`
|
NewToken string `json:"newToken,omitempty"`
|
||||||
OldTokenId string `json:"oldTokenId"`
|
OldTokenId string `json:"oldTokenId,omitempty"`
|
||||||
User *UserBasicInfo `json:"user"`
|
User *UserBasicInfo `json:"user"`
|
||||||
|
NotificationContent string `json:"notificationContent,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TokenInfoResponse represents a view-object of token
|
// TokenInfoResponse represents a view-object of token
|
||||||
@@ -33,8 +35,7 @@ type TokenInfoResponse struct {
|
|||||||
TokenId string `json:"tokenId"`
|
TokenId string `json:"tokenId"`
|
||||||
TokenType core.TokenType `json:"tokenType"`
|
TokenType core.TokenType `json:"tokenType"`
|
||||||
UserAgent string `json:"userAgent"`
|
UserAgent string `json:"userAgent"`
|
||||||
CreatedAt int64 `json:"createdAt"`
|
LastSeen int64 `json:"lastSeen"`
|
||||||
ExpiredAt int64 `json:"expiredAt"`
|
|
||||||
IsCurrent bool `json:"isCurrent"`
|
IsCurrent bool `json:"isCurrent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,5 +54,5 @@ func (a TokenInfoResponseSlice) Swap(i, j int) {
|
|||||||
|
|
||||||
// Less reports whether the first item is less than the second one
|
// Less reports whether the first item is less than the second one
|
||||||
func (a TokenInfoResponseSlice) Less(i, j int) bool {
|
func (a TokenInfoResponseSlice) Less(i, j int) bool {
|
||||||
return a[i].ExpiredAt > a[j].ExpiredAt
|
return a[i].LastSeen > a[j].LastSeen
|
||||||
}
|
}
|
||||||
|
|||||||
+77
-53
@@ -1,9 +1,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
@@ -76,6 +74,7 @@ type TransactionCreateRequest struct {
|
|||||||
TagIds []string `json:"tagIds"`
|
TagIds []string `json:"tagIds"`
|
||||||
Comment string `json:"comment" binding:"max=255"`
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
GeoLocation *TransactionGeoLocationRequest `json:"geoLocation" binding:"omitempty"`
|
GeoLocation *TransactionGeoLocationRequest `json:"geoLocation" binding:"omitempty"`
|
||||||
|
ClientSessionId string `json:"clientSessionId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionModifyRequest represents all parameters of transaction modification request
|
// TransactionModifyRequest represents all parameters of transaction modification request
|
||||||
@@ -96,23 +95,29 @@ type TransactionModifyRequest struct {
|
|||||||
|
|
||||||
// TransactionCountRequest represents transaction count request
|
// TransactionCountRequest represents transaction count request
|
||||||
type TransactionCountRequest struct {
|
type TransactionCountRequest struct {
|
||||||
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
||||||
CategoryId int64 `form:"category_id" binding:"min=0"`
|
CategoryIds string `form:"category_ids"`
|
||||||
AccountId int64 `form:"account_id" binding:"min=0"`
|
AccountIds string `form:"account_ids"`
|
||||||
Keyword string `form:"keyword"`
|
TagIds string `form:"tag_ids"`
|
||||||
MaxTime int64 `form:"max_time" binding:"min=0"`
|
AmountFilter string `form:"amount_filter" binding:"validAmountFilter"`
|
||||||
MinTime int64 `form:"min_time" binding:"min=0"`
|
Keyword string `form:"keyword"`
|
||||||
|
MaxTime int64 `form:"max_time" binding:"min=0"`
|
||||||
|
MinTime int64 `form:"min_time" binding:"min=0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionListByMaxTimeRequest represents all parameters of transaction listing by max time request
|
// TransactionListByMaxTimeRequest represents all parameters of transaction listing by max time request
|
||||||
type TransactionListByMaxTimeRequest struct {
|
type TransactionListByMaxTimeRequest struct {
|
||||||
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
||||||
CategoryId int64 `form:"category_id" binding:"min=0"`
|
CategoryIds string `form:"category_ids"`
|
||||||
AccountId int64 `form:"account_id" binding:"min=0"`
|
AccountIds string `form:"account_ids"`
|
||||||
|
TagIds string `form:"tag_ids"`
|
||||||
|
AmountFilter string `form:"amount_filter" binding:"validAmountFilter"`
|
||||||
Keyword string `form:"keyword"`
|
Keyword string `form:"keyword"`
|
||||||
MaxTime int64 `form:"max_time" binding:"min=0"`
|
MaxTime int64 `form:"max_time" binding:"min=0"`
|
||||||
MinTime int64 `form:"min_time" binding:"min=0"`
|
MinTime int64 `form:"min_time" binding:"min=0"`
|
||||||
|
Page int32 `form:"page" binding:"min=0"`
|
||||||
Count int32 `form:"count" binding:"required,min=1,max=50"`
|
Count int32 `form:"count" binding:"required,min=1,max=50"`
|
||||||
|
WithCount bool `form:"with_count"`
|
||||||
TrimAccount bool `form:"trim_account"`
|
TrimAccount bool `form:"trim_account"`
|
||||||
TrimCategory bool `form:"trim_category"`
|
TrimCategory bool `form:"trim_category"`
|
||||||
TrimTag bool `form:"trim_tag"`
|
TrimTag bool `form:"trim_tag"`
|
||||||
@@ -123,11 +128,11 @@ type TransactionListInMonthByPageRequest struct {
|
|||||||
Year int32 `form:"year" binding:"required,min=1"`
|
Year int32 `form:"year" binding:"required,min=1"`
|
||||||
Month int32 `form:"month" binding:"required,min=1"`
|
Month int32 `form:"month" binding:"required,min=1"`
|
||||||
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
Type TransactionDbType `form:"type" binding:"min=0,max=4"`
|
||||||
CategoryId int64 `form:"category_id" binding:"min=0"`
|
CategoryIds string `form:"category_ids"`
|
||||||
AccountId int64 `form:"account_id" binding:"min=0"`
|
AccountIds string `form:"account_ids"`
|
||||||
|
TagIds string `form:"tag_ids"`
|
||||||
|
AmountFilter string `form:"amount_filter" binding:"validAmountFilter"`
|
||||||
Keyword string `form:"keyword"`
|
Keyword string `form:"keyword"`
|
||||||
Page int32 `form:"page" binding:"required,min=1"`
|
|
||||||
Count int32 `form:"count" binding:"required,min=1,max=50"`
|
|
||||||
TrimAccount bool `form:"trim_account"`
|
TrimAccount bool `form:"trim_account"`
|
||||||
TrimCategory bool `form:"trim_category"`
|
TrimCategory bool `form:"trim_category"`
|
||||||
TrimTag bool `form:"trim_tag"`
|
TrimTag bool `form:"trim_tag"`
|
||||||
@@ -135,13 +140,21 @@ type TransactionListInMonthByPageRequest struct {
|
|||||||
|
|
||||||
// TransactionStatisticRequest represents all parameters of transaction statistic request
|
// TransactionStatisticRequest represents all parameters of transaction statistic request
|
||||||
type TransactionStatisticRequest struct {
|
type TransactionStatisticRequest struct {
|
||||||
StartTime int64 `form:"start_time" binding:"min=0"`
|
StartTime int64 `form:"start_time" binding:"min=0"`
|
||||||
EndTime int64 `form:"end_time" binding:"min=0"`
|
EndTime int64 `form:"end_time" binding:"min=0"`
|
||||||
|
UseTransactionTimezone bool `form:"use_transaction_timezone"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionStatisticTrendsRequest represents all parameters of transaction statistic trends request
|
||||||
|
type TransactionStatisticTrendsRequest struct {
|
||||||
|
YearMonthRangeRequest
|
||||||
|
UseTransactionTimezone bool `form:"use_transaction_timezone"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionAmountsRequest represents all parameters of transaction amounts request
|
// TransactionAmountsRequest represents all parameters of transaction amounts request
|
||||||
type TransactionAmountsRequest struct {
|
type TransactionAmountsRequest struct {
|
||||||
Query string `form:"query"`
|
Query string `form:"query"`
|
||||||
|
UseTransactionTimezone bool `form:"use_transaction_timezone"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionAmountsRequestItem represents an item of transaction amounts request
|
// TransactionAmountsRequestItem represents an item of transaction amounts request
|
||||||
@@ -151,12 +164,6 @@ type TransactionAmountsRequestItem struct {
|
|||||||
EndTime int64
|
EndTime int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionMonthAmountsRequest represents all parameters of transaction month amounts request
|
|
||||||
type TransactionMonthAmountsRequest struct {
|
|
||||||
StartYearMonth string `form:"start_year_month"`
|
|
||||||
EndYearMonth string `form:"end_year_month"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransactionGetRequest represents all parameters of transaction getting request
|
// TransactionGetRequest represents all parameters of transaction getting request
|
||||||
type TransactionGetRequest struct {
|
type TransactionGetRequest struct {
|
||||||
Id int64 `form:"id,string" binding:"required,min=1"`
|
Id int64 `form:"id,string" binding:"required,min=1"`
|
||||||
@@ -170,14 +177,10 @@ type TransactionDeleteRequest struct {
|
|||||||
Id int64 `json:"id,string" binding:"required,min=1"`
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionAccountsAmount represents transaction accounts amount map
|
// YearMonthRangeRequest represents all parameters of a request with year and month range
|
||||||
type TransactionAccountsAmount map[int64]*TransactionAccountAmount
|
type YearMonthRangeRequest struct {
|
||||||
|
StartYearMonth string `form:"start_year_month"`
|
||||||
// TransactionAccountAmount represents transaction account amount
|
EndYearMonth string `form:"end_year_month"`
|
||||||
type TransactionAccountAmount struct {
|
|
||||||
AccountId int64
|
|
||||||
TotalIncomeAmount int64
|
|
||||||
TotalExpenseAmount int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionGeoLocationResponse represents a view-object of transaction geographic location info
|
// TransactionGeoLocationResponse represents a view-object of transaction geographic location info
|
||||||
@@ -218,6 +221,7 @@ type TransactionCountResponse struct {
|
|||||||
type TransactionInfoPageWrapperResponse struct {
|
type TransactionInfoPageWrapperResponse struct {
|
||||||
Items TransactionInfoResponseSlice `json:"items"`
|
Items TransactionInfoResponseSlice `json:"items"`
|
||||||
NextTimeSequenceId *int64 `json:"nextTimeSequenceId,string"`
|
NextTimeSequenceId *int64 `json:"nextTimeSequenceId,string"`
|
||||||
|
TotalCount *int64 `json:"totalCount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionInfoPageWrapperResponse2 represents a response of transaction which contains items and count
|
// TransactionInfoPageWrapperResponse2 represents a response of transaction which contains items and count
|
||||||
@@ -226,7 +230,7 @@ type TransactionInfoPageWrapperResponse2 struct {
|
|||||||
TotalCount int64 `json:"totalCount"`
|
TotalCount int64 `json:"totalCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionStatisticResponse represents an item of transaction amounts
|
// TransactionStatisticResponse represents transaction statistic response
|
||||||
type TransactionStatisticResponse struct {
|
type TransactionStatisticResponse struct {
|
||||||
StartTime int64 `json:"startTime"`
|
StartTime int64 `json:"startTime"`
|
||||||
EndTime int64 `json:"endTime"`
|
EndTime int64 `json:"endTime"`
|
||||||
@@ -240,6 +244,13 @@ type TransactionStatisticResponseItem struct {
|
|||||||
TotalAmount int64 `json:"amount"`
|
TotalAmount int64 `json:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactionStatisticTrendsItem represents the data within each statistic interval
|
||||||
|
type TransactionStatisticTrendsItem struct {
|
||||||
|
Year int32 `json:"year"`
|
||||||
|
Month int32 `json:"month"`
|
||||||
|
Items []*TransactionStatisticResponseItem `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
// TransactionAmountsResponseItem represents an item of transaction amounts
|
// TransactionAmountsResponseItem represents an item of transaction amounts
|
||||||
type TransactionAmountsResponseItem struct {
|
type TransactionAmountsResponseItem struct {
|
||||||
StartTime int64 `json:"startTime"`
|
StartTime int64 `json:"startTime"`
|
||||||
@@ -379,33 +390,28 @@ func (t *TransactionAmountsRequest) GetTransactionAmountsRequestItems() ([]*Tran
|
|||||||
return requestItems, nil
|
return requestItems, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStartTimeAndEndTime returns start unix time and end unix time by request parameter
|
// GetNumericYearMonthRange returns numeric start year, start month, end year and end month
|
||||||
func (t *TransactionMonthAmountsRequest) GetStartTimeAndEndTime(utcOffset int16) (int64, int64, error) {
|
func (t *YearMonthRangeRequest) GetNumericYearMonthRange() (int32, int32, int32, int32, error) {
|
||||||
startUnixTime := int64(0)
|
var startYear, startMonth, endYear, endMonth int32
|
||||||
endUnixTime := time.Now().Unix()
|
var err error
|
||||||
|
|
||||||
if t.StartYearMonth != "" {
|
if t.StartYearMonth != "" {
|
||||||
startTime, err := utils.ParseFromShortDateTime(fmt.Sprintf("%s-1 0:0:0", t.StartYearMonth), utcOffset)
|
startYear, startMonth, err = utils.ParseNumericYearMonth(t.StartYearMonth)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
startUnixTime = startTime.Unix()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.EndYearMonth != "" {
|
if t.EndYearMonth != "" {
|
||||||
endTime, err := utils.ParseFromShortDateTime(fmt.Sprintf("%s-1 0:0:0", t.EndYearMonth), utcOffset)
|
endYear, endMonth, err = utils.ParseNumericYearMonth(t.EndYearMonth)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
endTime = endTime.AddDate(0, 1, 0)
|
|
||||||
endUnixTime = endTime.Unix() - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return startUnixTime, endUnixTime, nil
|
return startYear, startMonth, endYear, endMonth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionInfoResponseSlice represents the slice data structure of TransactionInfoResponse
|
// TransactionInfoResponseSlice represents the slice data structure of TransactionInfoResponse
|
||||||
@@ -430,24 +436,42 @@ func (s TransactionInfoResponseSlice) Less(i, j int) bool {
|
|||||||
return s[i].Id > s[j].Id
|
return s[i].Id > s[j].Id
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionMonthAmountsResponseItemSlice represents the slice data structure of TransactionMonthAmountsResponseItem
|
// TransactionStatisticTrendsItemSlice represents the slice data structure of TransactionStatisticTrendsItem
|
||||||
type TransactionMonthAmountsResponseItemSlice []*TransactionMonthAmountsResponseItem
|
type TransactionStatisticTrendsItemSlice []*TransactionStatisticTrendsItem
|
||||||
|
|
||||||
// Len returns the count of items
|
// Len returns the count of items
|
||||||
func (s TransactionMonthAmountsResponseItemSlice) Len() int {
|
func (s TransactionStatisticTrendsItemSlice) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap swaps two items
|
// Swap swaps two items
|
||||||
func (s TransactionMonthAmountsResponseItemSlice) Swap(i, j int) {
|
func (s TransactionStatisticTrendsItemSlice) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less reports whether the first item is less than the second one
|
// Less reports whether the first item is less than the second one
|
||||||
func (s TransactionMonthAmountsResponseItemSlice) Less(i, j int) bool {
|
func (s TransactionStatisticTrendsItemSlice) Less(i, j int) bool {
|
||||||
if s[i].Year != s[j].Year {
|
if s[i].Year != s[j].Year {
|
||||||
return s[i].Year > s[j].Year
|
return s[i].Year < s[j].Year
|
||||||
}
|
}
|
||||||
|
|
||||||
return s[i].Month > s[j].Month
|
return s[i].Month < s[j].Month
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionAmountsResponseItemAmountInfoSlice represents the slice data structure of TransactionAmountsResponseItemAmountInfo
|
||||||
|
type TransactionAmountsResponseItemAmountInfoSlice []*TransactionAmountsResponseItemAmountInfo
|
||||||
|
|
||||||
|
// Len returns the count of items
|
||||||
|
func (s TransactionAmountsResponseItemAmountInfoSlice) Len() int {
|
||||||
|
return len(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap swaps two items
|
||||||
|
func (s TransactionAmountsResponseItemAmountInfoSlice) Swap(i, j int) {
|
||||||
|
s[i], s[j] = s[j], s[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less reports whether the first item is less than the second one
|
||||||
|
func (s TransactionAmountsResponseItemAmountInfoSlice) Less(i, j int) bool {
|
||||||
|
return strings.Compare(s[i].Currency, s[j].Currency) < 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,13 @@ type TransactionCategoryGetRequest struct {
|
|||||||
|
|
||||||
// TransactionCategoryCreateRequest represents all parameters of single transaction category creation request
|
// TransactionCategoryCreateRequest represents all parameters of single transaction category creation request
|
||||||
type TransactionCategoryCreateRequest struct {
|
type TransactionCategoryCreateRequest struct {
|
||||||
Name string `json:"name" binding:"required,notBlank,max=32"`
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
Type TransactionCategoryType `json:"type" binding:"required"`
|
Type TransactionCategoryType `json:"type" binding:"required"`
|
||||||
ParentId int64 `json:"parentId,string" binding:"min=0"`
|
ParentId int64 `json:"parentId,string" binding:"min=0"`
|
||||||
Icon int64 `json:"icon,string" binding:"min=1"`
|
Icon int64 `json:"icon,string" binding:"min=1"`
|
||||||
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
||||||
Comment string `json:"comment" binding:"max=255"`
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
|
ClientSessionId string `json:"clientSessionId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionCategoryCreateBatchRequest represents all parameters of transaction category batch creation request
|
// TransactionCategoryCreateBatchRequest represents all parameters of transaction category batch creation request
|
||||||
@@ -69,12 +70,13 @@ type TransactionCategoryCreateWithSubCategories struct {
|
|||||||
|
|
||||||
// TransactionCategoryModifyRequest represents all parameters of transaction category modification request
|
// TransactionCategoryModifyRequest represents all parameters of transaction category modification request
|
||||||
type TransactionCategoryModifyRequest struct {
|
type TransactionCategoryModifyRequest struct {
|
||||||
Id int64 `json:"id,string" binding:"required,min=1"`
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
Name string `json:"name" binding:"required,notBlank,max=32"`
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
Icon int64 `json:"icon,string" binding:"min=1"`
|
ParentId int64 `json:"parentId,string" binding:"min=0"`
|
||||||
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
Icon int64 `json:"icon,string" binding:"min=1"`
|
||||||
Comment string `json:"comment" binding:"max=255"`
|
Color string `json:"color" binding:"required,len=6,validHexRGBColor"`
|
||||||
Hidden bool `json:"hidden"`
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
|
Hidden bool `json:"hidden"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionCategoryHideRequest represents all parameters of transaction category hiding request
|
// TransactionCategoryHideRequest represents all parameters of transaction category hiding request
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package models
|
|||||||
// TransactionTag represents transaction tag data stored in database
|
// TransactionTag represents transaction tag data stored in database
|
||||||
type TransactionTag struct {
|
type TransactionTag struct {
|
||||||
TagId int64 `xorm:"PK"`
|
TagId int64 `xorm:"PK"`
|
||||||
Uid int64 `xorm:"INDEX(IDX_tag_uid_deleted_name) NOT NULL"`
|
Uid int64 `xorm:"INDEX(IDX_tag_uid_deleted_order) NOT NULL"`
|
||||||
Deleted bool `xorm:"INDEX(IDX_tag_uid_deleted_name) NOT NULL"`
|
Deleted bool `xorm:"INDEX(IDX_tag_uid_deleted_order) NOT NULL"`
|
||||||
Name string `xorm:"INDEX(IDX_tag_uid_deleted_name) VARCHAR(32) NOT NULL"`
|
Name string `xorm:"VARCHAR(32) NOT NULL"`
|
||||||
DisplayOrder int32 `xorm:"NOT NULL"`
|
DisplayOrder int32 `xorm:"INDEX(IDX_tag_uid_deleted_order) NOT NULL"`
|
||||||
Hidden bool `xorm:"NOT NULL"`
|
Hidden bool `xorm:"NOT NULL"`
|
||||||
CreatedUnixTime int64
|
CreatedUnixTime int64
|
||||||
UpdatedUnixTime int64
|
UpdatedUnixTime int64
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package models
|
|||||||
// TransactionTagIndex represents transaction and transaction tag relation stored in database
|
// TransactionTagIndex represents transaction and transaction tag relation stored in database
|
||||||
type TransactionTagIndex struct {
|
type TransactionTagIndex struct {
|
||||||
TagIndexId int64 `xorm:"PK"`
|
TagIndexId int64 `xorm:"PK"`
|
||||||
Uid int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_time) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id)"`
|
Uid int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_time_tag_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id)"`
|
||||||
Deleted bool `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_time) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id) NOT NULL"`
|
Deleted bool `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_time_tag_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id) NOT NULL"`
|
||||||
TagId int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_time)"`
|
TransactionTime int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_transaction_time_tag_id) NOT NULL"`
|
||||||
|
TagId int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_time_tag_id)"`
|
||||||
TransactionId int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id)"`
|
TransactionId int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_id) INDEX(IDX_transaction_tag_index_uid_deleted_transaction_id)"`
|
||||||
TransactionTime int64 `xorm:"INDEX(IDX_transaction_tag_index_uid_deleted_tag_id_transaction_time) NOT NULL"`
|
|
||||||
CreatedUnixTime int64
|
CreatedUnixTime int64
|
||||||
UpdatedUnixTime int64
|
UpdatedUnixTime int64
|
||||||
DeletedUnixTime int64
|
DeletedUnixTime int64
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TransactionTemplateType represents transaction template type in database
|
||||||
|
type TransactionTemplateType byte
|
||||||
|
|
||||||
|
// Transaction template types
|
||||||
|
const (
|
||||||
|
TRANSACTION_TEMPLATE_TYPE_NORMAL TransactionTemplateType = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// TransactionTemplate represents transaction template stored in database
|
||||||
|
type TransactionTemplate struct {
|
||||||
|
TemplateId int64 `xorm:"PK"`
|
||||||
|
Uid int64 `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||||
|
Deleted bool `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||||
|
TemplateType TransactionTemplateType `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||||
|
Name string `xorm:"VARCHAR(32) NOT NULL"`
|
||||||
|
Type TransactionType `xorm:"NOT NULL"`
|
||||||
|
CategoryId int64 `xorm:"NOT NULL"`
|
||||||
|
AccountId int64 `xorm:"NOT NULL"`
|
||||||
|
TagIds string `xorm:"VARCHAR(255) NOT NULL"`
|
||||||
|
Amount int64 `xorm:"NOT NULL"`
|
||||||
|
RelatedAccountId int64 `xorm:"NOT NULL"`
|
||||||
|
RelatedAccountAmount int64 `xorm:"NOT NULL"`
|
||||||
|
HideAmount bool `xorm:"NOT NULL"`
|
||||||
|
Comment string `xorm:"VARCHAR(255) NOT NULL"`
|
||||||
|
DisplayOrder int32 `xorm:"INDEX(IDX_transaction_uid_deleted_template_type_order) NOT NULL"`
|
||||||
|
Hidden bool `xorm:"NOT NULL"`
|
||||||
|
CreatedUnixTime int64
|
||||||
|
UpdatedUnixTime int64
|
||||||
|
DeletedUnixTime int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateListRequest represents all parameters of transaction template list request
|
||||||
|
type TransactionTemplateListRequest struct {
|
||||||
|
TemplateType TransactionTemplateType `form:"templateType"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateGetRequest represents all parameters of transaction template getting request
|
||||||
|
type TransactionTemplateGetRequest struct {
|
||||||
|
Id int64 `form:"id,string" binding:"required,min=1"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateCreateRequest represents all parameters of transaction template creation request
|
||||||
|
type TransactionTemplateCreateRequest struct {
|
||||||
|
TemplateType TransactionTemplateType `json:"templateType"`
|
||||||
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
|
Type TransactionType `json:"type" binding:"required"`
|
||||||
|
CategoryId int64 `json:"categoryId,string" binding:"required,min=1"`
|
||||||
|
SourceAccountId int64 `json:"sourceAccountId,string" binding:"required,min=1"`
|
||||||
|
DestinationAccountId int64 `json:"destinationAccountId,string" binding:"min=0"`
|
||||||
|
SourceAmount int64 `json:"sourceAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
|
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
|
HideAmount bool `json:"hideAmount"`
|
||||||
|
TagIds []string `json:"tagIds"`
|
||||||
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
|
ClientSessionId string `json:"clientSessionId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateModifyNameRequest represents all parameters of transaction template name modification request
|
||||||
|
type TransactionTemplateModifyNameRequest struct {
|
||||||
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateModifyRequest represents all parameters of transaction template modification request
|
||||||
|
type TransactionTemplateModifyRequest struct {
|
||||||
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
|
Name string `json:"name" binding:"required,notBlank,max=32"`
|
||||||
|
Type TransactionType `json:"type" binding:"required"`
|
||||||
|
CategoryId int64 `json:"categoryId,string" binding:"required,min=1"`
|
||||||
|
SourceAccountId int64 `json:"sourceAccountId,string" binding:"required,min=1"`
|
||||||
|
DestinationAccountId int64 `json:"destinationAccountId,string" binding:"min=0"`
|
||||||
|
SourceAmount int64 `json:"sourceAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
|
DestinationAmount int64 `json:"destinationAmount" binding:"min=-99999999999,max=99999999999"`
|
||||||
|
HideAmount bool `json:"hideAmount"`
|
||||||
|
TagIds []string `json:"tagIds"`
|
||||||
|
Comment string `json:"comment" binding:"max=255"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateHideRequest represents all parameters of transaction template hiding request
|
||||||
|
type TransactionTemplateHideRequest struct {
|
||||||
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
|
Hidden bool `json:"hidden"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateMoveRequest represents all parameters of transaction template moving request
|
||||||
|
type TransactionTemplateMoveRequest struct {
|
||||||
|
NewDisplayOrders []*TransactionTemplateNewDisplayOrderRequest `json:"newDisplayOrders"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateNewDisplayOrderRequest represents a data pair of id and display order
|
||||||
|
type TransactionTemplateNewDisplayOrderRequest struct {
|
||||||
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
|
DisplayOrder int32 `json:"displayOrder"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateDeleteRequest represents all parameters of transaction template deleting request
|
||||||
|
type TransactionTemplateDeleteRequest struct {
|
||||||
|
Id int64 `json:"id,string" binding:"required,min=1"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TransactionTemplateInfoResponse struct {
|
||||||
|
*TransactionInfoResponse
|
||||||
|
TemplateType TransactionTemplateType `json:"templateType"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DisplayOrder int32 `json:"displayOrder"`
|
||||||
|
Hidden bool `json:"hidden"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToTransactionInfoResponse returns a view-object according to database model
|
||||||
|
func (t *TransactionTemplate) ToTransactionInfoResponse(utcOffset int16) *TransactionInfoResponse {
|
||||||
|
tagIds := make([]string, 0, 0)
|
||||||
|
|
||||||
|
if t.TagIds != "" {
|
||||||
|
tagIds = strings.Split(t.TagIds, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &TransactionInfoResponse{
|
||||||
|
Id: t.TemplateId,
|
||||||
|
TimeSequenceId: utils.GetMinTransactionTimeFromUnixTime(t.CreatedUnixTime),
|
||||||
|
Type: t.Type,
|
||||||
|
CategoryId: t.CategoryId,
|
||||||
|
Time: 0,
|
||||||
|
UtcOffset: utcOffset,
|
||||||
|
SourceAccountId: t.AccountId,
|
||||||
|
DestinationAccountId: t.RelatedAccountId,
|
||||||
|
SourceAmount: t.Amount,
|
||||||
|
DestinationAmount: t.RelatedAccountAmount,
|
||||||
|
HideAmount: t.HideAmount,
|
||||||
|
TagIds: tagIds,
|
||||||
|
Comment: t.Comment,
|
||||||
|
GeoLocation: nil,
|
||||||
|
Editable: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToTransactionTemplateInfoResponse returns a view-object according to database model
|
||||||
|
func (t *TransactionTemplate) ToTransactionTemplateInfoResponse(utcOffset int16) *TransactionTemplateInfoResponse {
|
||||||
|
return &TransactionTemplateInfoResponse{
|
||||||
|
TransactionInfoResponse: t.ToTransactionInfoResponse(utcOffset),
|
||||||
|
TemplateType: t.TemplateType,
|
||||||
|
Name: t.Name,
|
||||||
|
DisplayOrder: t.DisplayOrder,
|
||||||
|
Hidden: t.Hidden,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransactionTemplateInfoResponseSlice represents the slice data structure of TransactionTemplateInfoResponse
|
||||||
|
type TransactionTemplateInfoResponseSlice []*TransactionTemplateInfoResponse
|
||||||
|
|
||||||
|
// Len returns the count of items
|
||||||
|
func (s TransactionTemplateInfoResponseSlice) Len() int {
|
||||||
|
return len(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap swaps two items
|
||||||
|
func (s TransactionTemplateInfoResponseSlice) Swap(i, j int) {
|
||||||
|
s[i], s[j] = s[j], s[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less reports whether the first item is less than the second one
|
||||||
|
func (s TransactionTemplateInfoResponseSlice) Less(i, j int) bool {
|
||||||
|
return s[i].DisplayOrder < s[j].DisplayOrder
|
||||||
|
}
|
||||||
+143
-63
@@ -4,13 +4,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/settings"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransactionEditScope represents the scope which transaction can be edited
|
// TransactionEditScope represents the scope which transaction can be edited
|
||||||
type TransactionEditScope byte
|
type TransactionEditScope byte
|
||||||
|
|
||||||
// Editable Transaction Scopes
|
// Editable Transaction Ranges
|
||||||
const (
|
const (
|
||||||
TRANSACTION_EDIT_SCOPE_NONE TransactionEditScope = 0
|
TRANSACTION_EDIT_SCOPE_NONE TransactionEditScope = 0
|
||||||
TRANSACTION_EDIT_SCOPE_ALL TransactionEditScope = 1
|
TRANSACTION_EDIT_SCOPE_ALL TransactionEditScope = 1
|
||||||
@@ -22,7 +24,7 @@ const (
|
|||||||
TRANSACTION_EDIT_SCOPE_INVALID TransactionEditScope = 255
|
TRANSACTION_EDIT_SCOPE_INVALID TransactionEditScope = 255
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a textual representation of the editable transaction scopes enum
|
// String returns a textual representation of the editable transaction ranges enum
|
||||||
func (s TransactionEditScope) String() string {
|
func (s TransactionEditScope) String() string {
|
||||||
switch s {
|
switch s {
|
||||||
case TRANSACTION_EDIT_SCOPE_NONE:
|
case TRANSACTION_EDIT_SCOPE_NONE:
|
||||||
@@ -46,6 +48,39 @@ func (s TransactionEditScope) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AmountColorType represents the type of amount color in frontend
|
||||||
|
type AmountColorType byte
|
||||||
|
|
||||||
|
// Amount Color Types
|
||||||
|
const (
|
||||||
|
AMOUNT_COLOR_TYPE_DEFAULT AmountColorType = 0
|
||||||
|
AMOUNT_COLOR_TYPE_GREEN AmountColorType = 1
|
||||||
|
AMOUNT_COLOR_TYPE_RED AmountColorType = 2
|
||||||
|
AMOUNT_COLOR_TYPE_YELLOW AmountColorType = 3
|
||||||
|
AMOUNT_COLOR_TYPE_BLACK_OR_WHITE AmountColorType = 4
|
||||||
|
AMOUNT_COLOR_TYPE_INVALID AmountColorType = 255
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a textual representation of the amount color type enum
|
||||||
|
func (s AmountColorType) String() string {
|
||||||
|
switch s {
|
||||||
|
case AMOUNT_COLOR_TYPE_DEFAULT:
|
||||||
|
return "Default"
|
||||||
|
case AMOUNT_COLOR_TYPE_GREEN:
|
||||||
|
return "Green"
|
||||||
|
case AMOUNT_COLOR_TYPE_RED:
|
||||||
|
return "Red"
|
||||||
|
case AMOUNT_COLOR_TYPE_YELLOW:
|
||||||
|
return "Yellow"
|
||||||
|
case AMOUNT_COLOR_TYPE_BLACK_OR_WHITE:
|
||||||
|
return "Black or White"
|
||||||
|
case AMOUNT_COLOR_TYPE_INVALID:
|
||||||
|
return "Invalid"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Invalid(%d)", int(s))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// User represents user data stored in database
|
// User represents user data stored in database
|
||||||
type User struct {
|
type User struct {
|
||||||
Uid int64 `xorm:"PK"`
|
Uid int64 `xorm:"PK"`
|
||||||
@@ -54,17 +89,25 @@ type User struct {
|
|||||||
Nickname string `xorm:"VARCHAR(64) NOT NULL"`
|
Nickname string `xorm:"VARCHAR(64) NOT NULL"`
|
||||||
Password string `xorm:"VARCHAR(64) NOT NULL"`
|
Password string `xorm:"VARCHAR(64) NOT NULL"`
|
||||||
Salt string `xorm:"VARCHAR(10) NOT NULL"`
|
Salt string `xorm:"VARCHAR(10) NOT NULL"`
|
||||||
|
CustomAvatarType string `xorm:"VARCHAR(10)"`
|
||||||
DefaultAccountId int64
|
DefaultAccountId int64
|
||||||
TransactionEditScope TransactionEditScope `xorm:"TINYINT NOT NULL"`
|
TransactionEditScope TransactionEditScope `xorm:"TINYINT NOT NULL"`
|
||||||
Language string `xorm:"VARCHAR(10)"`
|
Language string `xorm:"VARCHAR(10)"`
|
||||||
DefaultCurrency string `xorm:"VARCHAR(3) NOT NULL"`
|
DefaultCurrency string `xorm:"VARCHAR(3) NOT NULL"`
|
||||||
FirstDayOfWeek WeekDay `xorm:"TINYINT NOT NULL"`
|
FirstDayOfWeek WeekDay `xorm:"TINYINT NOT NULL"`
|
||||||
LongDateFormat LongDateFormat `xorm:"TINYINT"`
|
LongDateFormat LongDateFormat `xorm:"TINYINT"`
|
||||||
ShortDateFormat ShortDateFormat `xorm:"TINYINT"`
|
ShortDateFormat ShortDateFormat `xorm:"TINYINT"`
|
||||||
LongTimeFormat LongTimeFormat `xorm:"TINYINT"`
|
LongTimeFormat LongTimeFormat `xorm:"TINYINT"`
|
||||||
ShortTimeFormat ShortTimeFormat `xorm:"TINYINT"`
|
ShortTimeFormat ShortTimeFormat `xorm:"TINYINT"`
|
||||||
Deleted bool `xorm:"NOT NULL"`
|
DecimalSeparator core.DecimalSeparator `xorm:"TINYINT"`
|
||||||
EmailVerified bool `xorm:"NOT NULL"`
|
DigitGroupingSymbol core.DigitGroupingSymbol `xorm:"TINYINT"`
|
||||||
|
DigitGrouping core.DigitGroupingType `xorm:"TINYINT"`
|
||||||
|
CurrencyDisplayType CurrencyDisplayType `xorm:"TINYINT"`
|
||||||
|
ExpenseAmountColor AmountColorType `xorm:"TINYINT"`
|
||||||
|
IncomeAmountColor AmountColorType `xorm:"TINYINT"`
|
||||||
|
Disabled bool
|
||||||
|
Deleted bool `xorm:"NOT NULL"`
|
||||||
|
EmailVerified bool `xorm:"NOT NULL"`
|
||||||
CreatedUnixTime int64
|
CreatedUnixTime int64
|
||||||
UpdatedUnixTime int64
|
UpdatedUnixTime int64
|
||||||
DeletedUnixTime int64
|
DeletedUnixTime int64
|
||||||
@@ -73,18 +116,27 @@ type User struct {
|
|||||||
|
|
||||||
// UserBasicInfo represents a view-object of user basic info
|
// UserBasicInfo represents a view-object of user basic info
|
||||||
type UserBasicInfo struct {
|
type UserBasicInfo struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
DefaultAccountId int64 `json:"defaultAccountId,string"`
|
AvatarUrl string `json:"avatar"`
|
||||||
TransactionEditScope TransactionEditScope `json:"transactionEditScope"`
|
AvatarProvider string `json:"avatarProvider,omitempty"`
|
||||||
Language string `json:"language"`
|
DefaultAccountId int64 `json:"defaultAccountId,string"`
|
||||||
DefaultCurrency string `json:"defaultCurrency"`
|
TransactionEditScope TransactionEditScope `json:"transactionEditScope"`
|
||||||
FirstDayOfWeek WeekDay `json:"firstDayOfWeek"`
|
Language string `json:"language"`
|
||||||
LongDateFormat LongDateFormat `json:"longDateFormat"`
|
DefaultCurrency string `json:"defaultCurrency"`
|
||||||
ShortDateFormat ShortDateFormat `json:"shortDateFormat"`
|
FirstDayOfWeek WeekDay `json:"firstDayOfWeek"`
|
||||||
LongTimeFormat LongTimeFormat `json:"longTimeFormat"`
|
LongDateFormat LongDateFormat `json:"longDateFormat"`
|
||||||
ShortTimeFormat ShortTimeFormat `json:"shortTimeFormat"`
|
ShortDateFormat ShortDateFormat `json:"shortDateFormat"`
|
||||||
|
LongTimeFormat LongTimeFormat `json:"longTimeFormat"`
|
||||||
|
ShortTimeFormat ShortTimeFormat `json:"shortTimeFormat"`
|
||||||
|
DecimalSeparator core.DecimalSeparator `json:"decimalSeparator"`
|
||||||
|
DigitGroupingSymbol core.DigitGroupingSymbol `json:"digitGroupingSymbol"`
|
||||||
|
DigitGrouping core.DigitGroupingType `json:"digitGrouping"`
|
||||||
|
CurrencyDisplayType CurrencyDisplayType `json:"currencyDisplayType"`
|
||||||
|
ExpenseAmountColor AmountColorType `json:"expenseAmountColor"`
|
||||||
|
IncomeAmountColor AmountColorType `json:"incomeAmountColor"`
|
||||||
|
EmailVerified bool `json:"emailVerified"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserLoginRequest represents all parameters of user login request
|
// UserLoginRequest represents all parameters of user login request
|
||||||
@@ -102,23 +154,48 @@ type UserRegisterRequest struct {
|
|||||||
Language string `json:"language" binding:"required,min=2,max=16"`
|
Language string `json:"language" binding:"required,min=2,max=16"`
|
||||||
DefaultCurrency string `json:"defaultCurrency" binding:"required,len=3,validCurrency"`
|
DefaultCurrency string `json:"defaultCurrency" binding:"required,len=3,validCurrency"`
|
||||||
FirstDayOfWeek WeekDay `json:"firstDayOfWeek" binding:"min=0,max=6"`
|
FirstDayOfWeek WeekDay `json:"firstDayOfWeek" binding:"min=0,max=6"`
|
||||||
|
TransactionCategoryCreateBatchRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserVerifyEmailRequest represents all parameters of user verify email request
|
||||||
|
type UserVerifyEmailRequest struct {
|
||||||
|
RequestNewToken bool `json:"requestNewToken" binding:"omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserVerifyEmailResponse represents all response parameters after user have verified email
|
||||||
|
type UserVerifyEmailResponse struct {
|
||||||
|
NewToken string `json:"newToken,omitempty"`
|
||||||
|
User *UserBasicInfo `json:"user"`
|
||||||
|
NotificationContent string `json:"notificationContent,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserResendVerifyEmailRequest represents all parameters of user resend verify email request
|
||||||
|
type UserResendVerifyEmailRequest struct {
|
||||||
|
Email string `json:"email" binding:"omitempty,max=100,validEmail"`
|
||||||
|
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserProfileUpdateRequest represents all parameters of user updating profile request
|
// UserProfileUpdateRequest represents all parameters of user updating profile request
|
||||||
type UserProfileUpdateRequest struct {
|
type UserProfileUpdateRequest struct {
|
||||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||||
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
||||||
DefaultAccountId int64 `json:"defaultAccountId,string" binding:"omitempty,min=1"`
|
DefaultAccountId int64 `json:"defaultAccountId,string" binding:"omitempty,min=1"`
|
||||||
TransactionEditScope *TransactionEditScope `json:"transactionEditScope" binding:"omitempty,min=0,max=7"`
|
TransactionEditScope *TransactionEditScope `json:"transactionEditScope" binding:"omitempty,min=0,max=6"`
|
||||||
Language string `json:"language" binding:"omitempty,min=2,max=16"`
|
Language string `json:"language" binding:"omitempty,min=2,max=16"`
|
||||||
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
||||||
FirstDayOfWeek *WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
FirstDayOfWeek *WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
||||||
LongDateFormat *LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
LongDateFormat *LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
||||||
ShortDateFormat *ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
ShortDateFormat *ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
||||||
LongTimeFormat *LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
LongTimeFormat *LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||||
ShortTimeFormat *ShortTimeFormat `json:"shortTimeFormat" binding:"omitempty,min=0,max=3"`
|
ShortTimeFormat *ShortTimeFormat `json:"shortTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||||
|
DecimalSeparator *core.DecimalSeparator `json:"decimalSeparator" binding:"omitempty,min=0,max=3"`
|
||||||
|
DigitGroupingSymbol *core.DigitGroupingSymbol `json:"digitGroupingSymbol" binding:"omitempty,min=0,max=4"`
|
||||||
|
DigitGrouping *core.DigitGroupingType `json:"digitGrouping" binding:"omitempty,min=0,max=2"`
|
||||||
|
CurrencyDisplayType *CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=11"`
|
||||||
|
ExpenseAmountColor *AmountColorType `json:"expenseAmountColor" binding:"omitempty,min=0,max=4"`
|
||||||
|
IncomeAmountColor *AmountColorType `json:"incomeAmountColor" binding:"omitempty,min=0,max=4"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserProfileUpdateResponse represents the data returns to frontend after updating profile
|
// UserProfileUpdateResponse represents the data returns to frontend after updating profile
|
||||||
@@ -129,19 +206,8 @@ type UserProfileUpdateResponse struct {
|
|||||||
|
|
||||||
// UserProfileResponse represents a view-object of user profile
|
// UserProfileResponse represents a view-object of user profile
|
||||||
type UserProfileResponse struct {
|
type UserProfileResponse struct {
|
||||||
Username string `json:"username"`
|
*UserBasicInfo
|
||||||
Email string `json:"email"`
|
LastLoginAt int64 `json:"lastLoginAt"`
|
||||||
Nickname string `json:"nickname"`
|
|
||||||
DefaultAccountId int64 `json:"defaultAccountId,string"`
|
|
||||||
TransactionEditScope TransactionEditScope `json:"transactionEditScope"`
|
|
||||||
Language string `json:"language"`
|
|
||||||
DefaultCurrency string `json:"defaultCurrency"`
|
|
||||||
FirstDayOfWeek WeekDay `json:"firstDayOfWeek"`
|
|
||||||
LongDateFormat LongDateFormat `json:"longDateFormat"`
|
|
||||||
ShortDateFormat ShortDateFormat `json:"shortDateFormat"`
|
|
||||||
LongTimeFormat LongTimeFormat `json:"longTimeFormat"`
|
|
||||||
ShortTimeFormat ShortTimeFormat `json:"shortTimeFormat"`
|
|
||||||
LastLoginAt int64 `json:"lastLoginAt"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanEditTransactionByTransactionTime returns whether this user can edit transaction with specified transaction time
|
// CanEditTransactionByTransactionTime returns whether this user can edit transaction with specified transaction time
|
||||||
@@ -192,6 +258,8 @@ func (u *User) ToUserBasicInfo() *UserBasicInfo {
|
|||||||
Username: u.Username,
|
Username: u.Username,
|
||||||
Email: u.Email,
|
Email: u.Email,
|
||||||
Nickname: u.Nickname,
|
Nickname: u.Nickname,
|
||||||
|
AvatarUrl: u.getAvatarUrl(),
|
||||||
|
AvatarProvider: u.getAvatarProvider(),
|
||||||
DefaultAccountId: u.DefaultAccountId,
|
DefaultAccountId: u.DefaultAccountId,
|
||||||
TransactionEditScope: u.TransactionEditScope,
|
TransactionEditScope: u.TransactionEditScope,
|
||||||
Language: u.Language,
|
Language: u.Language,
|
||||||
@@ -201,24 +269,36 @@ func (u *User) ToUserBasicInfo() *UserBasicInfo {
|
|||||||
ShortDateFormat: u.ShortDateFormat,
|
ShortDateFormat: u.ShortDateFormat,
|
||||||
LongTimeFormat: u.LongTimeFormat,
|
LongTimeFormat: u.LongTimeFormat,
|
||||||
ShortTimeFormat: u.ShortTimeFormat,
|
ShortTimeFormat: u.ShortTimeFormat,
|
||||||
|
DecimalSeparator: u.DecimalSeparator,
|
||||||
|
DigitGroupingSymbol: u.DigitGroupingSymbol,
|
||||||
|
DigitGrouping: u.DigitGrouping,
|
||||||
|
CurrencyDisplayType: u.CurrencyDisplayType,
|
||||||
|
ExpenseAmountColor: u.ExpenseAmountColor,
|
||||||
|
IncomeAmountColor: u.IncomeAmountColor,
|
||||||
|
EmailVerified: u.EmailVerified,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToUserProfileResponse returns a user profile view-object according to database model
|
// ToUserProfileResponse returns a user profile view-object according to database model
|
||||||
func (u *User) ToUserProfileResponse() *UserProfileResponse {
|
func (u *User) ToUserProfileResponse() *UserProfileResponse {
|
||||||
return &UserProfileResponse{
|
return &UserProfileResponse{
|
||||||
Username: u.Username,
|
UserBasicInfo: u.ToUserBasicInfo(),
|
||||||
Email: u.Email,
|
LastLoginAt: u.LastLoginUnixTime,
|
||||||
Nickname: u.Nickname,
|
|
||||||
DefaultAccountId: u.DefaultAccountId,
|
|
||||||
TransactionEditScope: u.TransactionEditScope,
|
|
||||||
Language: u.Language,
|
|
||||||
DefaultCurrency: u.DefaultCurrency,
|
|
||||||
FirstDayOfWeek: u.FirstDayOfWeek,
|
|
||||||
LongDateFormat: u.LongDateFormat,
|
|
||||||
ShortDateFormat: u.ShortDateFormat,
|
|
||||||
LongTimeFormat: u.LongTimeFormat,
|
|
||||||
ShortTimeFormat: u.ShortTimeFormat,
|
|
||||||
LastLoginAt: u.LastLoginUnixTime,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) getAvatarProvider() string {
|
||||||
|
return settings.Container.Current.AvatarProvider
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) getAvatarUrl() string {
|
||||||
|
avatarProvider := settings.Container.Current.AvatarProvider
|
||||||
|
|
||||||
|
if avatarProvider == settings.InternalAvatarProvider {
|
||||||
|
return utils.GetInternalAvatarUrl(u.Uid, u.CustomAvatarType, settings.Container.Current.RootUrl)
|
||||||
|
} else if avatarProvider == settings.GravatarProvider {
|
||||||
|
return utils.GetGravatarUrl(u.Email)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user