Compare commits

...

10 Commits

Author SHA1 Message Date
Zhaolong
05bb3a767a fix: flask bind ip 2022-02-08 09:52:21 +08:00
Zhaolong
5f69da9f20 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app.py
2022-02-08 09:30:57 +08:00
Zhaolong
5f1c11aa6d fix: flask bind ip 2022-02-08 09:30:29 +08:00
Zhaolong
608dcae3ce feat: faker api: swagger 2022-02-07 22:16:52 +08:00
Zhaolong
5f56feffb2 feat: faker data: query 2022-02-07 16:28:14 +08:00
fallen-angle
a9c08e3257 feat: faker contacts 2022-02-06 20:01:51 +08:00
Zhaolong
82acef5765 fix: optimize insert 2022-01-27 22:54:19 +08:00
Zhaolong
c374acc1db feat: faker data: railway 2022-01-27 18:00:03 +08:00
Zhaolong
1e3d584870 feat: faker data: identification 2022-01-26 17:11:24 +08:00
Zhaolong
da9965e2ae fix: change project struct 2022-01-25 22:57:24 +08:00
15 changed files with 885 additions and 50 deletions

View File

@@ -27,8 +27,15 @@ Flask = "==2.0.2"
Jinja2 = "==3.0.3" Jinja2 = "==3.0.3"
MarkupSafe = "==2.0.1" MarkupSafe = "==2.0.1"
Werkzeug = "==2.0.2" Werkzeug = "==2.0.2"
sqlalchemy = "*"
flask-sqlalchemy = "*"
pymysql = "*"
cryptography = "*"
deprecated = "*"
setuptools = "*"
flasgger = "*"
[dev-packages] [dev-packages]
[requires] [requires]
python_version = "3.9" python_version = "3.10"

389
Pipfile.lock generated
View File

@@ -1,11 +1,11 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "4a47b97f72138e7bb325296307c18e4a2f16939eff82516c49da6630dd7c506b" "sha256": "9a94dd40b7d382b78f84e7ff24136ec2537b55efb11c31eeee80ab83a4bc8629"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
"python_version": "3.9" "python_version": "3.10"
}, },
"sources": [ "sources": [
{ {
@@ -16,6 +16,14 @@
] ]
}, },
"default": { "default": {
"attrs": {
"hashes": [
"sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4",
"sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.4.0"
},
"certifi": { "certifi": {
"hashes": [ "hashes": [
"sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
@@ -24,6 +32,61 @@
"index": "pypi", "index": "pypi",
"version": "==2021.10.8" "version": "==2021.10.8"
}, },
"cffi": {
"hashes": [
"sha256:00c878c90cb53ccfaae6b8bc18ad05d2036553e6d9d1d9dbcf323bbe83854ca3",
"sha256:0104fb5ae2391d46a4cb082abdd5c69ea4eab79d8d44eaaf79f1b1fd806ee4c2",
"sha256:06c48159c1abed75c2e721b1715c379fa3200c7784271b3c46df01383b593636",
"sha256:0808014eb713677ec1292301ea4c81ad277b6cdf2fdd90fd540af98c0b101d20",
"sha256:10dffb601ccfb65262a27233ac273d552ddc4d8ae1bf93b21c94b8511bffe728",
"sha256:14cd121ea63ecdae71efa69c15c5543a4b5fbcd0bbe2aad864baca0063cecf27",
"sha256:17771976e82e9f94976180f76468546834d22a7cc404b17c22df2a2c81db0c66",
"sha256:181dee03b1170ff1969489acf1c26533710231c58f95534e3edac87fff06c443",
"sha256:23cfe892bd5dd8941608f93348c0737e369e51c100d03718f108bf1add7bd6d0",
"sha256:263cc3d821c4ab2213cbe8cd8b355a7f72a8324577dc865ef98487c1aeee2bc7",
"sha256:2756c88cbb94231c7a147402476be2c4df2f6078099a6f4a480d239a8817ae39",
"sha256:27c219baf94952ae9d50ec19651a687b826792055353d07648a5695413e0c605",
"sha256:2a23af14f408d53d5e6cd4e3d9a24ff9e05906ad574822a10563efcef137979a",
"sha256:31fb708d9d7c3f49a60f04cf5b119aeefe5644daba1cd2a0fe389b674fd1de37",
"sha256:3415c89f9204ee60cd09b235810be700e993e343a408693e80ce7f6a40108029",
"sha256:3773c4d81e6e818df2efbc7dd77325ca0dcb688116050fb2b3011218eda36139",
"sha256:3b96a311ac60a3f6be21d2572e46ce67f09abcf4d09344c49274eb9e0bf345fc",
"sha256:3f7d084648d77af029acb79a0ff49a0ad7e9d09057a9bf46596dac9514dc07df",
"sha256:41d45de54cd277a7878919867c0f08b0cf817605e4eb94093e7516505d3c8d14",
"sha256:4238e6dab5d6a8ba812de994bbb0a79bddbdf80994e4ce802b6f6f3142fcc880",
"sha256:45db3a33139e9c8f7c09234b5784a5e33d31fd6907800b316decad50af323ff2",
"sha256:45e8636704eacc432a206ac7345a5d3d2c62d95a507ec70d62f23cd91770482a",
"sha256:4958391dbd6249d7ad855b9ca88fae690783a6be9e86df65865058ed81fc860e",
"sha256:4a306fa632e8f0928956a41fa8e1d6243c71e7eb59ffbd165fc0b41e316b2474",
"sha256:57e9ac9ccc3101fac9d6014fba037473e4358ef4e89f8e181f8951a2c0162024",
"sha256:59888172256cac5629e60e72e86598027aca6bf01fa2465bdb676d37636573e8",
"sha256:5e069f72d497312b24fcc02073d70cb989045d1c91cbd53979366077959933e0",
"sha256:64d4ec9f448dfe041705426000cc13e34e6e5bb13736e9fd62e34a0b0c41566e",
"sha256:6dc2737a3674b3e344847c8686cf29e500584ccad76204efea14f451d4cc669a",
"sha256:74fdfdbfdc48d3f47148976f49fab3251e550a8720bebc99bf1483f5bfb5db3e",
"sha256:75e4024375654472cc27e91cbe9eaa08567f7fbdf822638be2814ce059f58032",
"sha256:786902fb9ba7433aae840e0ed609f45c7bcd4e225ebb9c753aa39725bb3e6ad6",
"sha256:8b6c2ea03845c9f501ed1313e78de148cd3f6cad741a75d43a29b43da27f2e1e",
"sha256:91d77d2a782be4274da750752bb1650a97bfd8f291022b379bb8e01c66b4e96b",
"sha256:91ec59c33514b7c7559a6acda53bbfe1b283949c34fe7440bcf917f96ac0723e",
"sha256:920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954",
"sha256:a5263e363c27b653a90078143adb3d076c1a748ec9ecc78ea2fb916f9b861962",
"sha256:abb9a20a72ac4e0fdb50dae135ba5e77880518e742077ced47eb1499e29a443c",
"sha256:c2051981a968d7de9dd2d7b87bcb9c939c74a34626a6e2f8181455dd49ed69e4",
"sha256:c21c9e3896c23007803a875460fb786118f0cdd4434359577ea25eb556e34c55",
"sha256:c2502a1a03b6312837279c8c1bd3ebedf6c12c4228ddbad40912d671ccc8a962",
"sha256:d4d692a89c5cf08a8557fdeb329b82e7bf609aadfaed6c0d79f5a449a3c7c023",
"sha256:da5db4e883f1ce37f55c667e5c0de439df76ac4cb55964655906306918e7363c",
"sha256:e7022a66d9b55e93e1a845d8c9eba2a1bebd4966cd8bfc25d9cd07d515b33fa6",
"sha256:ef1f279350da2c586a69d32fc8733092fd32cc8ac95139a00377841f59a3f8d8",
"sha256:f54a64f8b0c8ff0b64d18aa76675262e1700f3995182267998c31ae974fbc382",
"sha256:f5c7150ad32ba43a07c4479f40241756145a1f03b43480e058cfd862bf5041c7",
"sha256:f6f824dc3bce0edab5f427efcfb1d63ee75b6fcb7282900ccaf925be84efb0fc",
"sha256:fd8a250edc26254fe5b33be00402e6d287f562b6a5b2152dec302fa15bb3e997",
"sha256:ffaa5c925128e29efbde7301d8ecaf35c8c60ffbcd6a1ffd3a552177c8e5e796"
],
"version": "==1.15.0"
},
"charset-normalizer": { "charset-normalizer": {
"hashes": [ "hashes": [
"sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd", "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd",
@@ -48,6 +111,40 @@
"index": "pypi", "index": "pypi",
"version": "==0.4.4" "version": "==0.4.4"
}, },
"cryptography": {
"hashes": [
"sha256:0a817b961b46894c5ca8a66b599c745b9a3d9f822725221f0e0fe49dc043a3a3",
"sha256:2d87cdcb378d3cfed944dac30596da1968f88fb96d7fc34fdae30a99054b2e31",
"sha256:30ee1eb3ebe1644d1c3f183d115a8c04e4e603ed6ce8e394ed39eea4a98469ac",
"sha256:391432971a66cfaf94b21c24ab465a4cc3e8bf4a939c1ca5c3e3a6e0abebdbcf",
"sha256:39bdf8e70eee6b1c7b289ec6e5d84d49a6bfa11f8b8646b5b3dfe41219153316",
"sha256:4caa4b893d8fad33cf1964d3e51842cd78ba87401ab1d2e44556826df849a8ca",
"sha256:53e5c1dc3d7a953de055d77bef2ff607ceef7a2aac0353b5d630ab67f7423638",
"sha256:596f3cd67e1b950bc372c33f1a28a0692080625592ea6392987dba7f09f17a94",
"sha256:5d59a9d55027a8b88fd9fd2826c4392bd487d74bf628bb9d39beecc62a644c12",
"sha256:6c0c021f35b421ebf5976abf2daacc47e235f8b6082d3396a2fe3ccd537ab173",
"sha256:73bc2d3f2444bcfeac67dd130ff2ea598ea5f20b40e36d19821b4df8c9c5037b",
"sha256:74d6c7e80609c0f4c2434b97b80c7f8fdfaa072ca4baab7e239a15d6d70ed73a",
"sha256:7be0eec337359c155df191d6ae00a5e8bbb63933883f4f5dffc439dac5348c3f",
"sha256:94ae132f0e40fe48f310bba63f477f14a43116f05ddb69d6fa31e93f05848ae2",
"sha256:bb5829d027ff82aa872d76158919045a7c1e91fbf241aec32cb07956e9ebd3c9",
"sha256:ca238ceb7ba0bdf6ce88c1b74a87bffcee5afbfa1e41e173b1ceb095b39add46",
"sha256:ca28641954f767f9822c24e927ad894d45d5a1e501767599647259cbf030b903",
"sha256:e0344c14c9cb89e76eb6a060e67980c9e35b3f36691e15e1b7a9e58a0a6c6dc3",
"sha256:ebc15b1c22e55c4d5566e3ca4db8689470a0ca2babef8e3a9ee057a8b82ce4b1",
"sha256:ec63da4e7e4a5f924b90af42eddf20b698a70e58d86a72d943857c4c6045b3ee"
],
"index": "pypi",
"version": "==36.0.1"
},
"deprecated": {
"hashes": [
"sha256:43ac5335da90c31c24ba028af536a91d41d53f9e6901ddb021bcc572ce44e38d",
"sha256:64756e3e14c8c5eea9795d93c524551432a0be75629f8f29e67ab8caf076c76d"
],
"index": "pypi",
"version": "==1.2.13"
},
"distlib": { "distlib": {
"hashes": [ "hashes": [
"sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b", "sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b",
@@ -72,6 +169,14 @@
"index": "pypi", "index": "pypi",
"version": "==3.4.2" "version": "==3.4.2"
}, },
"flasgger": {
"hashes": [
"sha256:0603941cf4003626b4ee551ca87331f1d17b8eecce500ccf1a1f1d3a332fc94a",
"sha256:6ebea406b5beecd77e8da42550f380d4d05a6107bc90b69ce9e77aee7612e2d0"
],
"index": "pypi",
"version": "==0.9.5"
},
"flask": { "flask": {
"hashes": [ "hashes": [
"sha256:7b2fb8e934ddd50731893bdcdb00fc8c0315916f9fcd50d22c7cc1a95ab634e2", "sha256:7b2fb8e934ddd50731893bdcdb00fc8c0315916f9fcd50d22c7cc1a95ab634e2",
@@ -80,6 +185,75 @@
"index": "pypi", "index": "pypi",
"version": "==2.0.2" "version": "==2.0.2"
}, },
"flask-sqlalchemy": {
"hashes": [
"sha256:2bda44b43e7cacb15d4e05ff3cc1f8bc97936cc464623424102bfc2c35e95912",
"sha256:f12c3d4cc5cc7fdcc148b9527ea05671718c3ea45d50c7e732cceb33f574b390"
],
"index": "pypi",
"version": "==2.5.1"
},
"greenlet": {
"hashes": [
"sha256:0051c6f1f27cb756ffc0ffbac7d2cd48cb0362ac1736871399a739b2885134d3",
"sha256:00e44c8afdbe5467e4f7b5851be223be68adb4272f44696ee71fe46b7036a711",
"sha256:013d61294b6cd8fe3242932c1c5e36e5d1db2c8afb58606c5a67efce62c1f5fd",
"sha256:049fe7579230e44daef03a259faa24511d10ebfa44f69411d99e6a184fe68073",
"sha256:14d4f3cd4e8b524ae9b8aa567858beed70c392fdec26dbdb0a8a418392e71708",
"sha256:166eac03e48784a6a6e0e5f041cfebb1ab400b394db188c48b3a84737f505b67",
"sha256:17ff94e7a83aa8671a25bf5b59326ec26da379ace2ebc4411d690d80a7fbcf23",
"sha256:1e12bdc622676ce47ae9abbf455c189e442afdde8818d9da983085df6312e7a1",
"sha256:21915eb821a6b3d9d8eefdaf57d6c345b970ad722f856cd71739493ce003ad08",
"sha256:288c6a76705dc54fba69fbcb59904ae4ad768b4c768839b8ca5fdadec6dd8cfd",
"sha256:2bde6792f313f4e918caabc46532aa64aa27a0db05d75b20edfc5c6f46479de2",
"sha256:32ca72bbc673adbcfecb935bb3fb1b74e663d10a4b241aaa2f5a75fe1d1f90aa",
"sha256:356b3576ad078c89a6107caa9c50cc14e98e3a6c4874a37c3e0273e4baf33de8",
"sha256:40b951f601af999a8bf2ce8c71e8aaa4e8c6f78ff8afae7b808aae2dc50d4c40",
"sha256:572e1787d1460da79590bf44304abbc0a2da944ea64ec549188fa84d89bba7ab",
"sha256:58df5c2a0e293bf665a51f8a100d3e9956febfbf1d9aaf8c0677cf70218910c6",
"sha256:64e6175c2e53195278d7388c454e0b30997573f3f4bd63697f88d855f7a6a1fc",
"sha256:7227b47e73dedaa513cdebb98469705ef0d66eb5a1250144468e9c3097d6b59b",
"sha256:7418b6bfc7fe3331541b84bb2141c9baf1ec7132a7ecd9f375912eca810e714e",
"sha256:7cbd7574ce8e138bda9df4efc6bf2ab8572c9aff640d8ecfece1b006b68da963",
"sha256:7ff61ff178250f9bb3cd89752df0f1dd0e27316a8bd1465351652b1b4a4cdfd3",
"sha256:833e1551925ed51e6b44c800e71e77dacd7e49181fdc9ac9a0bf3714d515785d",
"sha256:8639cadfda96737427330a094476d4c7a56ac03de7265622fcf4cfe57c8ae18d",
"sha256:8c5d5b35f789a030ebb95bff352f1d27a93d81069f2adb3182d99882e095cefe",
"sha256:8c790abda465726cfb8bb08bd4ca9a5d0a7bd77c7ac1ca1b839ad823b948ea28",
"sha256:8d2f1fb53a421b410751887eb4ff21386d119ef9cde3797bf5e7ed49fb51a3b3",
"sha256:903bbd302a2378f984aef528f76d4c9b1748f318fe1294961c072bdc7f2ffa3e",
"sha256:93f81b134a165cc17123626ab8da2e30c0455441d4ab5576eed73a64c025b25c",
"sha256:95e69877983ea39b7303570fa6760f81a3eec23d0e3ab2021b7144b94d06202d",
"sha256:9633b3034d3d901f0a46b7939f8c4d64427dfba6bbc5a36b1a67364cf148a1b0",
"sha256:97e5306482182170ade15c4b0d8386ded995a07d7cc2ca8f27958d34d6736497",
"sha256:9f3cba480d3deb69f6ee2c1825060177a22c7826431458c697df88e6aeb3caee",
"sha256:aa5b467f15e78b82257319aebc78dd2915e4c1436c3c0d1ad6f53e47ba6e2713",
"sha256:abb7a75ed8b968f3061327c433a0fbd17b729947b400747c334a9c29a9af6c58",
"sha256:aec52725173bd3a7b56fe91bc56eccb26fbdff1386ef123abb63c84c5b43b63a",
"sha256:b11548073a2213d950c3f671aa88e6f83cda6e2fb97a8b6317b1b5b33d850e06",
"sha256:b1692f7d6bc45e3200844be0dba153612103db241691088626a33ff1f24a0d88",
"sha256:b336501a05e13b616ef81ce329c0e09ac5ed8c732d9ba7e3e983fcc1a9e86965",
"sha256:b8c008de9d0daba7b6666aa5bbfdc23dcd78cafc33997c9b7741ff6353bafb7f",
"sha256:b92e29e58bef6d9cfd340c72b04d74c4b4e9f70c9fa7c78b674d1fec18896dc4",
"sha256:be5f425ff1f5f4b3c1e33ad64ab994eed12fc284a6ea71c5243fd564502ecbe5",
"sha256:dd0b1e9e891f69e7675ba5c92e28b90eaa045f6ab134ffe70b52e948aa175b3c",
"sha256:e30f5ea4ae2346e62cedde8794a56858a67b878dd79f7df76a0767e356b1744a",
"sha256:e6a36bb9474218c7a5b27ae476035497a6990e21d04c279884eb10d9b290f1b1",
"sha256:e859fcb4cbe93504ea18008d1df98dee4f7766db66c435e4882ab35cf70cac43",
"sha256:eb6ea6da4c787111adf40f697b4e58732ee0942b5d3bd8f435277643329ba627",
"sha256:ec8c433b3ab0419100bd45b47c9c8551248a5aee30ca5e9d399a0b57ac04651b",
"sha256:eff9d20417ff9dcb0d25e2defc2574d10b491bf2e693b4e491914738b7908168",
"sha256:f0214eb2a23b85528310dad848ad2ac58e735612929c8072f6093f3585fd342d",
"sha256:f276df9830dba7a333544bd41070e8175762a7ac20350786b322b714b0e654f5",
"sha256:f3acda1924472472ddd60c29e5b9db0cec629fbe3c5c5accb74d6d6d14773478",
"sha256:f70a9e237bb792c7cc7e44c531fd48f5897961701cdaa06cf22fc14965c496cf",
"sha256:f9d29ca8a77117315101425ec7ec2a47a22ccf59f5593378fc4077ac5b754fce",
"sha256:fa877ca7f6b48054f847b61d6fa7bed5cebb663ebc55e018fda12db09dcc664c",
"sha256:fdcec0b8399108577ec290f55551d926d9a1fa6cad45882093a7a07ac5ec147b"
],
"markers": "python_version >= '3' and platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))",
"version": "==1.1.2"
},
"idna": { "idna": {
"hashes": [ "hashes": [
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
@@ -104,6 +278,14 @@
"index": "pypi", "index": "pypi",
"version": "==3.0.3" "version": "==3.0.3"
}, },
"jsonschema": {
"hashes": [
"sha256:636694eb41b3535ed608fe04129f26542b59ed99808b4f688aa32dcf55317a83",
"sha256:77281a1f71684953ee8b3d488371b162419767973789272434bbc3f29d9c8823"
],
"markers": "python_version >= '3.7'",
"version": "==4.4.0"
},
"lxml": { "lxml": {
"hashes": [ "hashes": [
"sha256:0607ff0988ad7e173e5ddf7bf55ee65534bd18a5461183c33e8e41a59e89edf4", "sha256:0607ff0988ad7e173e5ddf7bf55ee65534bd18a5461183c33e8e41a59e89edf4",
@@ -245,13 +427,20 @@
"index": "pypi", "index": "pypi",
"version": "==2.0.1" "version": "==2.0.1"
}, },
"mistune": {
"hashes": [
"sha256:6bab6c6abd711c4604206c7d8cad5cd48b28f072b4bb75797d74146ba393a049",
"sha256:6fc88c3cb49dba8b16687b41725e661cf85784c12e8974a29b9d336dd596c3a1"
],
"version": "==2.0.2"
},
"pip": { "pip": {
"hashes": [ "hashes": [
"sha256:deaf32dcd9ab821e359cd8330786bcd077604b5c5730c0b096eda46f95c24a2d", "sha256:c146f331f0805c77017c6bb9740cec4a49a0d4582d0c3cc8244b057f83eca359",
"sha256:fd11ba3d0fdb4c07fbc5ecbba0b1b719809420f25038f8ee3cd913d3faa3033a" "sha256:f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
], ],
"markers": "python_version >= '3.6'", "markers": "python_version >= '3.7'",
"version": "==21.3.1" "version": "==22.0.3"
}, },
"pipenv": { "pipenv": {
"hashes": [ "hashes": [
@@ -269,6 +458,48 @@
"index": "pypi", "index": "pypi",
"version": "==2.4.1" "version": "==2.4.1"
}, },
"pycparser": {
"hashes": [
"sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9",
"sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"
],
"version": "==2.21"
},
"pymysql": {
"hashes": [
"sha256:41fc3a0c5013d5f039639442321185532e3e2c8924687abe6537de157d403641",
"sha256:816927a350f38d56072aeca5dfb10221fe1dc653745853d30a216637f5d7ad36"
],
"index": "pypi",
"version": "==1.0.2"
},
"pyrsistent": {
"hashes": [
"sha256:0e3e1fcc45199df76053026a51cc59ab2ea3fc7c094c6627e93b7b44cdae2c8c",
"sha256:1b34eedd6812bf4d33814fca1b66005805d3640ce53140ab8bbb1e2651b0d9bc",
"sha256:4ed6784ceac462a7d6fcb7e9b663e93b9a6fb373b7f43594f9ff68875788e01e",
"sha256:5d45866ececf4a5fff8742c25722da6d4c9e180daa7b405dc0a2a2790d668c26",
"sha256:636ce2dc235046ccd3d8c56a7ad54e99d5c1cd0ef07d9ae847306c91d11b5fec",
"sha256:6455fc599df93d1f60e1c5c4fe471499f08d190d57eca040c0ea182301321286",
"sha256:6bc66318fb7ee012071b2792024564973ecc80e9522842eb4e17743604b5e045",
"sha256:7bfe2388663fd18bd8ce7db2c91c7400bf3e1a9e8bd7d63bf7e77d39051b85ec",
"sha256:7ec335fc998faa4febe75cc5268a9eac0478b3f681602c1f27befaf2a1abe1d8",
"sha256:914474c9f1d93080338ace89cb2acee74f4f666fb0424896fcfb8d86058bf17c",
"sha256:b568f35ad53a7b07ed9b1b2bae09eb15cdd671a5ba5d2c66caee40dbf91c68ca",
"sha256:cdfd2c361b8a8e5d9499b9082b501c452ade8bbf42aef97ea04854f4a3f43b22",
"sha256:d1b96547410f76078eaf66d282ddca2e4baae8964364abb4f4dcdde855cd123a",
"sha256:d4d61f8b993a7255ba714df3aca52700f8125289f84f704cf80916517c46eb96",
"sha256:d7a096646eab884bf8bed965bad63ea327e0d0c38989fc83c5ea7b8a87037bfc",
"sha256:df46c854f490f81210870e509818b729db4488e1f30f2a1ce1698b2295a878d1",
"sha256:e24a828f57e0c337c8d8bb9f6b12f09dfdf0273da25fda9e314f0b684b415a07",
"sha256:e4f3149fd5eb9b285d6bfb54d2e5173f6a116fe19172686797c056672689daf6",
"sha256:e92a52c166426efbe0d1ec1332ee9119b6d32fc1f0bbfd55d5c1088070e7fc1b",
"sha256:f87cc2863ef33c709e237d4b5f4502a62a00fab450c9e020892e8e2ede5847f5",
"sha256:fd8da6d0124efa2f67d86fa70c851022f87c98e205f0594e1fae044e7119a5a6"
],
"markers": "python_version >= '3.7'",
"version": "==0.18.1"
},
"python-dateutil": { "python-dateutil": {
"hashes": [ "hashes": [
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
@@ -277,6 +508,45 @@
"index": "pypi", "index": "pypi",
"version": "==2.8.2" "version": "==2.8.2"
}, },
"pyyaml": {
"hashes": [
"sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",
"sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",
"sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",
"sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",
"sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",
"sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",
"sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",
"sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",
"sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",
"sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",
"sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",
"sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",
"sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",
"sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",
"sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",
"sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",
"sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",
"sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",
"sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",
"sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",
"sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",
"sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",
"sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",
"sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",
"sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",
"sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",
"sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",
"sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",
"sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",
"sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",
"sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",
"sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",
"sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"
],
"markers": "python_version >= '3.6'",
"version": "==6.0"
},
"requests": { "requests": {
"hashes": [ "hashes": [
"sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61", "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61",
@@ -287,11 +557,11 @@
}, },
"setuptools": { "setuptools": {
"hashes": [ "hashes": [
"sha256:2404879cda71495fc4d5cbc445ed52fdaddf352b36e40be8dcc63147cb4edabe", "sha256:07e97e2f1e5607d240454e98c75c7004560ac8417ca5ae1dbaa50811cb6cc95c",
"sha256:68eb94073fc486091447fcb0501efd6560a0e5a1839ba249e5ff3c4c93f05f90" "sha256:23aad87cc27f4ae704079618c1d117a71bd43d41e355f0698c35f6b1c796d26c"
], ],
"markers": "python_version >= '3.7'", "index": "pypi",
"version": "==60.5.0" "version": "==60.8.1"
}, },
"six": { "six": {
"hashes": [ "hashes": [
@@ -301,6 +571,48 @@
"index": "pypi", "index": "pypi",
"version": "==1.16.0" "version": "==1.16.0"
}, },
"sqlalchemy": {
"hashes": [
"sha256:05fa14f279d43df68964ad066f653193187909950aa0163320b728edfc400167",
"sha256:0ddc5e5ccc0160e7ad190e5c61eb57560f38559e22586955f205e537cda26034",
"sha256:15a03261aa1e68f208e71ae3cd845b00063d242cbf8c87348a0c2c0fc6e1f2ac",
"sha256:289465162b1fa1e7a982f8abe59d26a8331211cad4942e8031d2b7db1f75e649",
"sha256:2e216c13ecc7fcdcbb86bb3225425b3ed338e43a8810c7089ddb472676124b9b",
"sha256:2fd4d3ca64c41dae31228b80556ab55b6489275fb204827f6560b65f95692cf3",
"sha256:330eb45395874cc7787214fdd4489e2afb931bc49e0a7a8f9cd56d6e9c5b1639",
"sha256:3c7ed6c69debaf6198fadb1c16ae1253a29a7670bbf0646f92582eb465a0b999",
"sha256:4ad31cec8b49fd718470328ad9711f4dc703507d434fd45461096da0a7135ee0",
"sha256:57205844f246bab9b666a32f59b046add8995c665d9ecb2b7b837b087df90639",
"sha256:582b59d1e5780a447aada22b461e50b404a9dc05768da1d87368ad8190468418",
"sha256:5e9c7b3567edbc2183607f7d9f3e7e89355b8f8984eec4d2cd1e1513c8f7b43f",
"sha256:6a01ec49ca54ce03bc14e10de55dfc64187a2194b3b0e5ac0fdbe9b24767e79e",
"sha256:6f22c040d196f841168b1456e77c30a18a3dc16b336ddbc5a24ce01ab4e95ae0",
"sha256:81f2dd355b57770fdf292b54f3e0a9823ec27a543f947fa2eb4ec0df44f35f0d",
"sha256:85e4c244e1de056d48dae466e9baf9437980c19fcde493e0db1a0a986e6d75b4",
"sha256:8d0949b11681380b4a50ac3cd075e4816afe9fa4a8c8ae006c1ca26f0fa40ad8",
"sha256:975f5c0793892c634c4920057da0de3a48bbbbd0a5c86f5fcf2f2fedf41b76da",
"sha256:9e4fb2895b83993831ba2401b6404de953fdbfa9d7d4fa6a4756294a83bbc94f",
"sha256:b35dca159c1c9fa8a5f9005e42133eed82705bf8e243da371a5e5826440e65ca",
"sha256:b7b20c88873675903d6438d8b33fba027997193e274b9367421e610d9da76c08",
"sha256:bb4b15fb1f0aafa65cbdc62d3c2078bea1ceecbfccc9a1f23a2113c9ac1191fa",
"sha256:c0c7171aa5a57e522a04a31b84798b6c926234cb559c0939840c3235cf068813",
"sha256:c317ddd7c586af350a6aef22b891e84b16bff1a27886ed5b30f15c1ed59caeaa",
"sha256:c3abc34fed19fdeaead0ced8cf56dd121f08198008c033596aa6aae7cc58f59f",
"sha256:ca68c52e3cae491ace2bf39b35fef4ce26c192fd70b4cd90f040d419f70893b5",
"sha256:cf2cd387409b12d0a8b801610d6336ee7d24043b6dd965950eaec09b73e7262f",
"sha256:d046a9aeba9bc53e88a41e58beb72b6205abb9a20f6c136161adf9128e589db5",
"sha256:d5c20c8415173b119762b6110af64448adccd4d11f273fb9f718a9865b88a99c",
"sha256:d86132922531f0dc5a4f424c7580a472a924dd737602638e704841c9cb24aea2",
"sha256:dccff41478050e823271642837b904d5f9bda3f5cf7d371ce163f00a694118d6",
"sha256:de85c26a5a1c72e695ab0454e92f60213b4459b8d7c502e0be7a6369690eeb1a",
"sha256:e3a86b59b6227ef72ffc10d4b23f0fe994bef64d4667eab4fb8cd43de4223bec",
"sha256:e79e73d5ee24196d3057340e356e6254af4d10e1fc22d3207ea8342fc5ffb977",
"sha256:ea8210090a816d48a4291a47462bac750e3bc5c2442e6d64f7b8137a7c3f9ac5",
"sha256:f3b7ec97e68b68cb1f9ddb82eda17b418f19a034fa8380a0ac04e8fe01532875"
],
"index": "pypi",
"version": "==1.4.31"
},
"text-unidecode": { "text-unidecode": {
"hashes": [ "hashes": [
"sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8", "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8",
@@ -340,6 +652,63 @@
], ],
"index": "pypi", "index": "pypi",
"version": "==2.0.2" "version": "==2.0.2"
},
"wrapt": {
"hashes": [
"sha256:086218a72ec7d986a3eddb7707c8c4526d677c7b35e355875a0fe2918b059179",
"sha256:0877fe981fd76b183711d767500e6b3111378ed2043c145e21816ee589d91096",
"sha256:0a017a667d1f7411816e4bf214646d0ad5b1da2c1ea13dec6c162736ff25a374",
"sha256:0cb23d36ed03bf46b894cfec777eec754146d68429c30431c99ef28482b5c1df",
"sha256:1fea9cd438686e6682271d36f3481a9f3636195578bab9ca3382e2f5f01fc185",
"sha256:220a869982ea9023e163ba915077816ca439489de6d2c09089b219f4e11b6785",
"sha256:25b1b1d5df495d82be1c9d2fad408f7ce5ca8a38085e2da41bb63c914baadff7",
"sha256:2dded5496e8f1592ec27079b28b6ad2a1ef0b9296d270f77b8e4a3a796cf6909",
"sha256:2ebdde19cd3c8cdf8df3fc165bc7827334bc4e353465048b36f7deeae8ee0918",
"sha256:43e69ffe47e3609a6aec0fe723001c60c65305784d964f5007d5b4fb1bc6bf33",
"sha256:46f7f3af321a573fc0c3586612db4decb7eb37172af1bc6173d81f5b66c2e068",
"sha256:47f0a183743e7f71f29e4e21574ad3fa95676136f45b91afcf83f6a050914829",
"sha256:498e6217523111d07cd67e87a791f5e9ee769f9241fcf8a379696e25806965af",
"sha256:4b9c458732450ec42578b5642ac53e312092acf8c0bfce140ada5ca1ac556f79",
"sha256:51799ca950cfee9396a87f4a1240622ac38973b6df5ef7a41e7f0b98797099ce",
"sha256:5601f44a0f38fed36cc07db004f0eedeaadbdcec90e4e90509480e7e6060a5bc",
"sha256:5f223101f21cfd41deec8ce3889dc59f88a59b409db028c469c9b20cfeefbe36",
"sha256:610f5f83dd1e0ad40254c306f4764fcdc846641f120c3cf424ff57a19d5f7ade",
"sha256:6a03d9917aee887690aa3f1747ce634e610f6db6f6b332b35c2dd89412912bca",
"sha256:705e2af1f7be4707e49ced9153f8d72131090e52be9278b5dbb1498c749a1e32",
"sha256:766b32c762e07e26f50d8a3468e3b4228b3736c805018e4b0ec8cc01ecd88125",
"sha256:77416e6b17926d953b5c666a3cb718d5945df63ecf922af0ee576206d7033b5e",
"sha256:778fd096ee96890c10ce96187c76b3e99b2da44e08c9e24d5652f356873f6709",
"sha256:78dea98c81915bbf510eb6a3c9c24915e4660302937b9ae05a0947164248020f",
"sha256:7dd215e4e8514004c8d810a73e342c536547038fb130205ec4bba9f5de35d45b",
"sha256:7dde79d007cd6dfa65afe404766057c2409316135cb892be4b1c768e3f3a11cb",
"sha256:81bd7c90d28a4b2e1df135bfbd7c23aee3050078ca6441bead44c42483f9ebfb",
"sha256:85148f4225287b6a0665eef08a178c15097366d46b210574a658c1ff5b377489",
"sha256:865c0b50003616f05858b22174c40ffc27a38e67359fa1495605f96125f76640",
"sha256:87883690cae293541e08ba2da22cacaae0a092e0ed56bbba8d018cc486fbafbb",
"sha256:8aab36778fa9bba1a8f06a4919556f9f8c7b33102bd71b3ab307bb3fecb21851",
"sha256:8c73c1a2ec7c98d7eaded149f6d225a692caa1bd7b2401a14125446e9e90410d",
"sha256:936503cb0a6ed28dbfa87e8fcd0a56458822144e9d11a49ccee6d9a8adb2ac44",
"sha256:944b180f61f5e36c0634d3202ba8509b986b5fbaf57db3e94df11abee244ba13",
"sha256:96b81ae75591a795d8c90edc0bfaab44d3d41ffc1aae4d994c5aa21d9b8e19a2",
"sha256:981da26722bebb9247a0601e2922cedf8bb7a600e89c852d063313102de6f2cb",
"sha256:ae9de71eb60940e58207f8e71fe113c639da42adb02fb2bcbcaccc1ccecd092b",
"sha256:b73d4b78807bd299b38e4598b8e7bd34ed55d480160d2e7fdaabd9931afa65f9",
"sha256:d4a5f6146cfa5c7ba0134249665acd322a70d1ea61732723c7d3e8cc0fa80755",
"sha256:dd91006848eb55af2159375134d724032a2d1d13bcc6f81cd8d3ed9f2b8e846c",
"sha256:e05e60ff3b2b0342153be4d1b597bbcfd8330890056b9619f4ad6b8d5c96a81a",
"sha256:e6906d6f48437dfd80464f7d7af1740eadc572b9f7a4301e7dd3d65db285cacf",
"sha256:e92d0d4fa68ea0c02d39f1e2f9cb5bc4b4a71e8c442207433d8db47ee79d7aa3",
"sha256:e94b7d9deaa4cc7bac9198a58a7240aaf87fe56c6277ee25fa5b3aa1edebd229",
"sha256:ea3e746e29d4000cd98d572f3ee2a6050a4f784bb536f4ac1f035987fc1ed83e",
"sha256:ec7e20258ecc5174029a0f391e1b948bf2906cd64c198a9b8b281b811cbc04de",
"sha256:ec9465dd69d5657b5d2fa6133b3e1e989ae27d29471a672416fd729b429eb554",
"sha256:f122ccd12fdc69628786d0c947bdd9cb2733be8f800d88b5a37c57f1f1d73c10",
"sha256:f99c0489258086308aad4ae57da9e8ecf9e1f3f30fa35d5e170b4d4896554d80",
"sha256:f9c51d9af9abb899bd34ace878fbec8bf357b3194a10c4e8e0a25512826ef056",
"sha256:fd76c47f20984b43d93de9a82011bb6e5f8325df6c9ed4d8310029a55fa361ea"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==1.13.3"
} }
}, },
"develop": {} "develop": {}

164
app.py
View File

@@ -1,35 +1,155 @@
from flask import Flask from flask import Flask
from faker import Faker import config
import requests
from lxml import etree
import utils.response as response import utils.response as response
import service.faker_data as faker import service.faker_data as faker
from base import db
from flasgger import Swagger, swag_from
app = Flask(__name__) app = Flask(__name__)
config.init_config(app)
db.init_app(app)
swagger = Swagger(app)
@app.route('/') @app.route('/')
def hello_world(): # put application's code here def hello_world():
return 'Hello World!' return f'<h1>nConTrack_Faker<h1>'
@app.route("/faker") @app.route("/faker/railway/<number>")
def faker_data(): def faker_railway(number):
# for i in range(2): """Faker Railway Datas
# identification = faker.ssn(max_age=70) ---
# resp = requests.get("https://shenfenzheng.bmcx.com/" + identification + "__shenfenzheng/") parameters:
# html = etree.HTML(resp.text) - name: number
# infos = html.xpath('//table[@width="100%"]//tr[position()!=2]/td[@bgcolor="#FFFFFF"]//text()') in: path
# result = { type: number
# 'identification': infos[0], required: true
# 'originArea': infos[1], description: the number of to be generated
# 'sex': infos[3][0], responses:
# 'name': faker.last_name() + (faker.first_name_male() if infos[3][0] == '男' else faker.first_name_female()), 200:
# 'age': infos[4][0:-2] description: A list of railway
# } """
# faker_datas.append(result) return response.succ(faker.faker_railways(int(number)))
return response.succ(faker.faker_identifications(50))
@app.route("/faker/hotel/<number>")
def faker_hotel(number):
"""Faker Hotel Datas
---
parameters:
- name: number
in: path
type: number
required: true
description: the number of to be generated
responses:
200:
description: A list of hotel
"""
return response.succ(faker.faker_hotels(int(number)))
@app.route("/faker/contacts/<num_hotel>/<num_railway>")
def faker_contacts(num_hotel, num_railway):
"""Faker Contacts Datas
---
parameters:
- name: num_hotel
in: path
type: number
required: true
description: the number of hotel to be generated
- name: num_railway
in: path
type: number
required: true
description: the number of railway to be generated
responses:
200:
description: the contacts and patient
"""
return response.succ(faker.faker_contacts(int(num_hotel), int(num_railway)))
@app.route("/query/patient")
def query_patient():
"""Query Patients
---
responses:
200:
description: A list of patients
"""
return response.succ(faker.query_patients())
@app.route("/query/contacts/hotel/<identification>")
def query_contacts_hotel(identification):
"""Query Hotel Contacts by Patient's Identification
---
parameters:
- name: identification
in: path
type: number
required: true
description: the identification of patient
responses:
200:
description: A list of contacts
"""
return response.succ(faker.query_contacts_hotel(identification))
@app.route("/query/contacts/railway/<identification>")
def query_contacts_railway(identification):
"""Query Railway Contacts by Patient's Identification
---
parameters:
- name: identification
in: path
type: number
required: true
description: the identification of patient
responses:
200:
description: A list of contacts
"""
return response.succ(faker.query_contacts_railway(identification))
@app.route("/query/contacts/classify/<identification>")
def query_contacts_classify(identification):
"""Query Classified Hotel and Railway Contacts by Patient's Identification
---
parameters:
- name: identification
in: path
type: number
required: true
description: the identification of patient
responses:
200:
description: A list of contacts
"""
return response.succ(faker.query_contacts_classify(identification))
@app.route("/query/contacts/<identification>")
def query_contacts(identification):
"""Query All Contacts by Patient's Identification
---
parameters:
- name: identification
in: path
type: number
required: true
description: the identification of patient
responses:
200:
description: A list of contacts
"""
return response.succ(faker.query_contacts(identification))
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.run(host='0.0.0.0')

10
base/__init__.py Normal file
View File

@@ -0,0 +1,10 @@
from flask_sqlalchemy import SQLAlchemy
from base import database
db = SQLAlchemy()
def init_app(app):
global db
db = database.init_db(app)

5
base/database.py Normal file
View File

@@ -0,0 +1,5 @@
from flask_sqlalchemy import SQLAlchemy
def init_db(app):
return SQLAlchemy(app)

25
config.py Normal file
View File

@@ -0,0 +1,25 @@
DIALECT = 'mysql'
DRIVER = 'pymysql'
USERNAME = 'root'
PASSWORD = '13291004986'
HOST = 'myhost.fallen-angle.com'
PORT = '3306'
DATABASE = 'ncov_track'
SQLALCHEMY_DATABASE_URI = f'{DIALECT}+{DRIVER}://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = True
SWAGGER_CONFIG = {
"title": "nCovTrack-Faker",
"description": "API for nCovTrack-Faker",
'uiversion': 3,
"version": "0.0.1"
}
def init_config(app):
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SQLALCHEMY_ECHO"] = True
app.config["SWAGGER"] = SWAGGER_CONFIG

5
model/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from .person import Person
from .person import SexEnum
from .hotel import Hotel
from .city import City
from .railway import Railway

23
model/city.py Normal file
View File

@@ -0,0 +1,23 @@
from sqlalchemy import Column, String
from base import db
class City(db.Model):
__tablename__ = 'city'
city_id = Column(String(255), primary_key=True)
city_en = Column(String(255), nullable=False)
city_cn = Column(String(255), nullable=False)
country_code = Column(String(255))
country_en = Column(String(255))
country_cn = Column(String(255))
province_en = Column(String(255))
province_cn = Column(String(255))
admin_district_en = Column(String(255))
admin_district_cn = Column(String(255))
latitude = Column(String(255))
longitude = Column(String(255))
ad_code = Column(String(255))
def __to_dict__(self) -> dict:
return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}

17
model/hotel.py Normal file
View File

@@ -0,0 +1,17 @@
from sqlalchemy import Column, Date, Integer, String, text
from base import db
class Hotel(db.Model):
__tablename__ = 'faker_hotel'
id = Column(Integer, primary_key=True, comment='id')
hotel_code = Column(String(10), nullable=False, server_default=text("''"), comment='酒店编号')
hotel_name = Column(String(50), nullable=False, server_default=text("''"), comment='酒店名')
locate_city_id = Column(String(10), nullable=False, server_default=text("''"), comment='酒店所在城市ID')
identification = Column(String(18), server_default=text("''"), comment='入住者身份证号')
in_data = Column(Date, nullable=False, comment='入住日期')
out_data = Column(Date, nullable=False, comment='离开日期')
def __to_dict__(self) -> dict:
return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}

44
model/person.py Normal file
View File

@@ -0,0 +1,44 @@
from base import db
from enum import Enum
class Person(db.Model):
__tablename__ = 'faker_person'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(10), nullable=False)
sex = db.Column(db.SMALLINT, nullable=False)
age = db.Column(db.Integer, nullable=False)
address = db.Column(db.String(20), nullable=False)
identification = db.Column(db.String(18), nullable=False)
phone = db.Column(db.String(20), nullable=False)
@classmethod
def __from_dict__(cls, **data: dict):
obj = cls()
obj.__dict__.update(data)
return obj
def __to_dict__(self):
return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}
class SexEnum(Enum):
FEMALE = 0, ''
MALE = 1, ''
def __new__(cls, *values):
obj = object.__new__(cls)
# first value is canonical value
obj._value_ = values[0]
for other_value in values[1:]:
cls._value2member_map_[other_value] = obj
obj._all_values = values
obj.sex = values[1]
return obj
def __repr__(self):
return '<%s.%s: %s>' % (
self.__class__.__name__,
self._name_,
', '.join([repr(v) for v in self._all_values]),
)

16
model/railway.py Normal file
View File

@@ -0,0 +1,16 @@
from sqlalchemy import Column, Date, Integer, String, text
from base import db
class Railway(db.Model):
__tablename__ = 'faker_railway'
id = Column(Integer, primary_key=True)
name = Column(String(10), nullable=False, server_default=text("''"), comment='乘客姓名')
identification = Column(String(18), nullable=False, server_default=text("''"), comment='乘客身份证号码')
phone = Column(String(20), nullable=False, server_default=text("''"), comment='手机号码')
train = Column(String(10), nullable=False, server_default=text("''"), comment='车次')
launch = Column(Date, nullable=False, comment='发车时间')
def __to_dict__(self) -> dict:
return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}

0
service/__init__.py Normal file
View File

View File

@@ -1,35 +1,211 @@
import copy
import random
import requests import requests
import threading import threading
import random
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
from lxml import etree from lxml import etree
from faker import Faker from faker import Faker
import utils.model
from model import SexEnum, Person, Hotel, Railway, City
from base import db
from datetime import datetime, timedelta
from dateutil import parser, rrule
from deprecated import deprecated
executor = ThreadPoolExecutor(max_workers=10) executor = ThreadPoolExecutor(max_workers=10)
faker = Faker(["zh_CN"]) faker = Faker(["zh_CN"])
train_prefix = ['T', 'K', 'D', 'G', 'L', '']
faker_hotel_infos = [
Hotel(hotel_code='1150001', hotel_name='北京华侨大厦', locate_city_id='101011600'),
Hotel(hotel_code='3250069', hotel_name='南京绿地洲际酒店', locate_city_id='101190111'),
Hotel(hotel_code='3350039', hotel_name='义乌锦都酒店', locate_city_id='101210904'),
Hotel(hotel_code='3650011', hotel_name='九江信华建国酒店', locate_city_id='101240211'),
Hotel(hotel_code='3750005', hotel_name='青岛香格里拉大酒店', locate_city_id='101120203'),
Hotel(hotel_code='3250028', hotel_name='徐州开元名都大酒店', locate_city_id='101190811'),
]
faker_train_ids = ['D7359', 'T4108', 'D776', 'D3023', 'K1461', 'L1500', 'G662']
ident_valid_ratio = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
ident_valid_result = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
ident_area = ['320700', '320722', '320707', '320723', '320724', '320706', '320703', '320500', '320581', '320582',
'320583', '320506', '320505', '320509', '320585', '320507', '320508']
def faker_identification(): # Due to the limit of reptile, turn to query the city by city code
@deprecated
def faker_identification_old() -> Person:
identification = faker.ssn(max_age=70) identification = faker.ssn(max_age=70)
resp = requests.get("https://shenfenzheng.bmcx.com/" + identification + "__shenfenzheng/") resp = requests.get("https://shenfenzheng.bmcx.com/" + identification + "__shenfenzheng/")
html = etree.HTML(resp.text) html = etree.HTML(resp.text)
infos = html.xpath('//table[@width="100%"]//tr[position()!=2]/td[@bgcolor="#FFFFFF"]//text()') infos = html.xpath('//table[@width="100%"]//tr[position()!=2]/td[@bgcolor="#FFFFFF"]//text()')
result = { person = Person(
'identification': infos[0], identification=infos[0],
'originArea': infos[1], address=infos[1],
'sex': infos[3][0], sex=SexEnum(infos[3][0]).value,
'name': faker.last_name() + (faker.first_name_male() if infos[3][0] == '' else faker.first_name_female()), name=faker.last_name() + (
'age': infos[4][0:-2] faker.first_name_male() if infos[3][0] == SexEnum.MALE.sex else faker.first_name_female()),
age=infos[4][0:-2],
phone=faker.phone_number()
)
return person
def faker_identification() -> Person:
area = ident_area[random.randint(0, len(ident_area) - 1)]
birthdate = datetime(
year=2022 - random.randint(18, 70),
month=random.randint(1, 12),
day=random.randint(1, 28)
)
birthday = birthdate.__format__("%Y%m%d")
random_num = random.randint(100, 999).__str__()
identification = area + birthday + random_num
valid = ident_valid_result[sum([int(identification[i]) * ident_valid_ratio[i] for i in range(17)]) % 11]
identification = identification + valid
birthdate = parser.parse(identification[6:14])
age = rrule.rrule(rrule.YEARLY, dtstart=birthdate, until=datetime.today()).count()
sex = 0 if int(identification[16:17]) % 2 == 0 else 1
return Person(
identification=identification,
sex=sex,
name=faker.last_name() + (faker.first_name_male() if sex == SexEnum.MALE.sex else faker.first_name_female()),
age=age,
phone=faker.phone_number()
)
def faker_identifications(num: int) -> list[Person]:
persons = [faker_identification() for i in range(num)]
area_codes = [person.identification[0:6] for person in persons]
rows = City.query.filter(City.ad_code.in_(area_codes))
code_area_dict = {
row.ad_code: '{} {} {} {}'.format(row.country_cn, row.province_cn, row.admin_district_cn, row.city_cn) for row
in rows}
for person in persons:
person.address = code_area_dict[person.identification[0:6]]
db.session.bulk_save_objects(persons)
return persons
def faker_railways(num: int) -> list[Railway]:
persons = faker_identifications(num)
railways = [faker_railway(person) for person in persons]
db.session.bulk_save_objects(railways)
db.session.commit()
return railways
def faker_railway(person: Person) -> Railway:
return Railway(
identification=person.identification,
phone=person.phone,
name=person.name,
train=faker_train_ids[int(random.random() * len(faker_train_ids))],
launch=datetime.today() + timedelta(days=(int(random.random() * 21) - 10))
)
def generate_train_id():
prefix = train_prefix[int(random.random() * len(train_prefix))]
num = int(random.random() * 10000).__str__()
return prefix + num
def faker_hotels(num: int) -> list[Hotel]:
persons = faker_identifications(num)
hotels = [faker_hotel(person) for person in persons]
db.session.bulk_save_objects(hotels)
db.session.commit()
return hotels
def faker_hotel(person: Person) -> Hotel:
hotel = faker_hotel_infos[random.randint(0, len(faker_hotel_infos) - 1)]
hotel.identification = person.identification
hotel.in_data = datetime.today() + timedelta(days=(int(random.random() * 21) - 10))
hotel.out_data = hotel.in_data + timedelta(days=3)
return hotel
def faker_contacts(num_hotel: int, num_railway: int):
persons = faker_identifications(num_railway + num_hotel + 1)
patient = persons[0]
contacts_hotel = persons[1:1 + num_hotel]
contacts_railway = persons[0 - num_railway:]
hotel_patient = faker_hotel(patient)
railway_patient = faker_railway(patient)
def assemble_hotel(contact: Person) -> Hotel:
hotel_contact = copy.deepcopy(hotel_patient)
hotel_contact.identification = contact.identification
return hotel_contact
def assemble_railway(contact: Person) -> Railway:
railway_contact = copy.deepcopy(railway_patient)
railway_contact.identification = contact.identification
railway_contact.name = contact.name
return railway_contact
hotel_contacts = [assemble_hotel(contact) for contact in contacts_hotel]
railway_contacts = [assemble_railway(contact) for contact in contacts_railway]
hotels = [hotel_patient] + hotel_contacts
railways = [railway_patient] + railway_contacts
db.session.bulk_save_objects(hotels)
db.session.bulk_save_objects(railways)
db.session.commit()
return {
"patient": {
"hotel": utils.model.model2dict(hotel_patient),
"railway": utils.model.model2dict(railway_patient)
},
"contacts": {
"hotel": utils.model.models2dicts(hotel_contacts),
"railway": utils.model.models2dicts(railway_contacts)
}
} }
return result
def time(times): def query_patients() -> list[dict]:
return times patients = db.session.query(Person) \
.join(Hotel, Person.identification == Hotel.identification) \
.join(Railway, Person.identification == Railway.identification) \
.all()
return [patient.__to_dict__() for patient in patients]
def faker_identifications(num: int): def query_contacts_hotel(identification: str) -> list[dict]:
all_tasks = [executor.submit(faker_identification) for i in range(num)] patient_subquery = Hotel.query.filter(Hotel.identification == identification).subquery()
results = [] contacts = db.session.query(Hotel, Person) \
for future in as_completed(all_tasks): .join(Hotel, Hotel.identification == Person.identification) \
results.append(future.result()) .filter(Person.identification != identification) \
return results .filter(Hotel.out_data > patient_subquery.c.in_data)
return [merge_object2dict(hotel, person) for hotel, person in contacts]
def query_contacts_railway(identification: str) -> list[dict]:
patient_subquery = Railway.query.filter(Railway.identification == identification).subquery()
contacts = db.session.query(Railway, Person) \
.join(Railway, Railway.identification == Person.identification) \
.filter(Person.identification != identification) \
.filter(Railway.launch == patient_subquery.c.launch)
return [merge_object2dict(railway, person) for railway, person in contacts]
def query_contacts_classify(identification: str) -> dict[str, list[dict]]:
contacts = {'hotel': query_contacts_hotel(identification), 'railway': query_contacts_railway(identification)}
return contacts
def query_contacts(identification: str) -> list[dict]:
contacts = [*query_contacts_hotel(identification), *query_contacts_railway(identification)]
return contacts
def merge_object2dict(*objs: db.Model) -> dict:
res = {}
for obj in objs:
res.update(obj.__to_dict__())
return res

17
utils/model.py Normal file
View File

@@ -0,0 +1,17 @@
from base import db
def model2dict(row: db.Model):
return {c.name: str(getattr(row, c.name)) for c in row.__table__.columns}
def models2dicts(rows: list[db.Model]):
return [model2dict(row) for row in rows]
def convert2dict(data: object) -> object:
if isinstance(data, list) and len(data) > 0 and isinstance(data[0], db.Model):
data = models2dicts(data)
if isinstance(data, db.Model):
data = model2dict(data)
return data

View File

@@ -1,4 +1,4 @@
from __future__ import annotations from utils.model import convert2dict
def response(resp: dict, status: int, headers=None): def response(resp: dict, status: int, headers=None):
@@ -6,6 +6,7 @@ def response(resp: dict, status: int, headers=None):
def success(code: int, msg: str, data: object): def success(code: int, msg: str, data: object):
data = convert2dict(data)
resp = { resp = {
"code": code, "code": code,
"msg": msg, "msg": msg,