Compare commits
12
Commits
7c34f8b986
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89acdb26d3 | ||
|
|
2dfc1dafec | ||
|
|
d856dc1887 | ||
|
|
e99524a157 | ||
|
|
95af6110ac | ||
|
|
99a37cd2ff | ||
|
|
73ac0f8049 | ||
|
|
32f8aca49e | ||
|
|
79255480bc | ||
|
|
e0cf2c00d6 | ||
|
|
fce8ada51e | ||
|
|
8d72401f74 |
No files matched your search
+1
-1
@@ -27,7 +27,7 @@
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"@nestjs/swagger": "^8.0.7",
|
||||
"@nestjs/typeorm": "^10.0.2",
|
||||
"bcrypt": "^5.1.1",
|
||||
"bcryptjs": "^3.0.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.1",
|
||||
"cos-nodejs-sdk-v5": "^2.14.6",
|
||||
|
||||
Generated
+7
-216
@@ -29,9 +29,9 @@ importers:
|
||||
'@nestjs/typeorm':
|
||||
specifier: ^10.0.2
|
||||
version: 10.0.2(@nestjs/common@10.4.7(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.7(@nestjs/common@10.4.7(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.7)(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2)(rxjs@7.8.1)(typeorm@0.3.20(mysql2@3.11.4)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)))
|
||||
bcrypt:
|
||||
specifier: ^5.1.1
|
||||
version: 5.1.1
|
||||
bcryptjs:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
class-transformer:
|
||||
specifier: ^0.5.1
|
||||
version: 0.5.1
|
||||
@@ -476,10 +476,6 @@ packages:
|
||||
resolution: {integrity: sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
'@mapbox/node-pre-gyp@1.0.11':
|
||||
resolution: {integrity: sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==}
|
||||
hasBin: true
|
||||
|
||||
'@microsoft/tsdoc@0.15.0':
|
||||
resolution: {integrity: sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==}
|
||||
|
||||
@@ -872,9 +868,6 @@ packages:
|
||||
'@xtuc/long@4.2.2':
|
||||
resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==}
|
||||
|
||||
abbrev@1.1.1:
|
||||
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
|
||||
|
||||
accepts@1.3.8:
|
||||
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -893,10 +886,6 @@ packages:
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
|
||||
agent-base@6.0.2:
|
||||
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
ajv-formats@1.6.1:
|
||||
resolution: {integrity: sha512-4CjkH20If1lhR5CGtqkrVg3bbOtFEG80X9v6jDOIUhbzzbB+UzPBGy8GQhUNVZ0yvMHdMpawCOcy5ydGMsagGQ==}
|
||||
peerDependencies:
|
||||
@@ -969,14 +958,6 @@ packages:
|
||||
append-field@1.0.0:
|
||||
resolution: {integrity: sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==}
|
||||
|
||||
aproba@2.0.0:
|
||||
resolution: {integrity: sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==}
|
||||
|
||||
are-we-there-yet@2.0.0:
|
||||
resolution: {integrity: sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: This package is no longer supported.
|
||||
|
||||
arg@4.1.3:
|
||||
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
|
||||
|
||||
@@ -1066,9 +1047,9 @@ packages:
|
||||
bcrypt-pbkdf@1.0.2:
|
||||
resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==}
|
||||
|
||||
bcrypt@5.1.1:
|
||||
resolution: {integrity: sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
bcryptjs@3.0.0:
|
||||
resolution: {integrity: sha512-Q2vVGpGC7B7m9wggpcA5lq4OYR5OS1nrXoUpnH9MmogXU8HpxzKg63uxtCrLebY5v/y3o0r7JcGCpR/vTGGn7A==}
|
||||
hasBin: true
|
||||
|
||||
binary-extensions@2.3.0:
|
||||
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
|
||||
@@ -1164,10 +1145,6 @@ packages:
|
||||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
|
||||
chownr@2.0.0:
|
||||
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
chrome-trace-event@1.0.4:
|
||||
resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==}
|
||||
engines: {node: '>=6.0'}
|
||||
@@ -1235,10 +1212,6 @@ packages:
|
||||
color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
|
||||
color-support@1.1.3:
|
||||
resolution: {integrity: sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==}
|
||||
hasBin: true
|
||||
|
||||
combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@@ -1271,9 +1244,6 @@ packages:
|
||||
consola@2.15.3:
|
||||
resolution: {integrity: sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==}
|
||||
|
||||
console-control-strings@1.1.0:
|
||||
resolution: {integrity: sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==}
|
||||
|
||||
content-disposition@0.5.4:
|
||||
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -1388,9 +1358,6 @@ packages:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
delegates@1.0.0:
|
||||
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}
|
||||
|
||||
denque@2.1.0:
|
||||
resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==}
|
||||
engines: {node: '>=0.10'}
|
||||
@@ -1403,10 +1370,6 @@ packages:
|
||||
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
|
||||
detect-libc@2.0.3:
|
||||
resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
detect-newline@3.1.0:
|
||||
resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -1740,10 +1703,6 @@ packages:
|
||||
resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
fs-minipass@2.1.0:
|
||||
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
fs-monkey@1.0.6:
|
||||
resolution: {integrity: sha512-b1FMfwetIKymC0eioW7mTywihSQE4oLzQn1dB6rZB5fx/3NpNEdAWeCSMB+60/AeT0TCXsxzAlcYVEFCTAksWg==}
|
||||
|
||||
@@ -1758,11 +1717,6 @@ packages:
|
||||
function-bind@1.1.2:
|
||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||
|
||||
gauge@3.0.2:
|
||||
resolution: {integrity: sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: This package is no longer supported.
|
||||
|
||||
generate-function@2.3.1:
|
||||
resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==}
|
||||
|
||||
@@ -1858,9 +1812,6 @@ packages:
|
||||
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
has-unicode@2.0.1:
|
||||
resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==}
|
||||
|
||||
hasown@2.0.2:
|
||||
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -1883,10 +1834,6 @@ packages:
|
||||
resolution: {integrity: sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==}
|
||||
engines: {node: '>=0.8', npm: '>=1.3.7'}
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
human-signals@2.1.0:
|
||||
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
||||
engines: {node: '>=10.17.0'}
|
||||
@@ -2420,31 +2367,14 @@ packages:
|
||||
minimist@1.2.8:
|
||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||
|
||||
minipass@3.3.6:
|
||||
resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
minipass@5.0.0:
|
||||
resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
minipass@7.1.2:
|
||||
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
minizlib@2.1.2:
|
||||
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
mkdirp@0.5.6:
|
||||
resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
|
||||
hasBin: true
|
||||
|
||||
mkdirp@1.0.4:
|
||||
resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
mkdirp@2.1.6:
|
||||
resolution: {integrity: sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -2500,9 +2430,6 @@ packages:
|
||||
node-abort-controller@3.1.1:
|
||||
resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==}
|
||||
|
||||
node-addon-api@5.1.0:
|
||||
resolution: {integrity: sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==}
|
||||
|
||||
node-emoji@1.11.0:
|
||||
resolution: {integrity: sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==}
|
||||
|
||||
@@ -2525,11 +2452,6 @@ packages:
|
||||
node-releases@2.0.18:
|
||||
resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==}
|
||||
|
||||
nopt@5.0.0:
|
||||
resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==}
|
||||
engines: {node: '>=6'}
|
||||
hasBin: true
|
||||
|
||||
normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -2538,10 +2460,6 @@ packages:
|
||||
resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
npmlog@5.0.1:
|
||||
resolution: {integrity: sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==}
|
||||
deprecated: This package is no longer supported.
|
||||
|
||||
oauth-sign@0.9.0:
|
||||
resolution: {integrity: sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==}
|
||||
|
||||
@@ -2870,9 +2788,6 @@ packages:
|
||||
resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
set-blocking@2.0.0:
|
||||
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
||||
|
||||
set-function-length@1.2.2:
|
||||
resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -3032,10 +2947,6 @@ packages:
|
||||
resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar@6.2.1:
|
||||
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
terser-webpack-plugin@5.3.10:
|
||||
resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==}
|
||||
engines: {node: '>= 10.13.0'}
|
||||
@@ -3359,9 +3270,6 @@ packages:
|
||||
engines: {node: '>= 8'}
|
||||
hasBin: true
|
||||
|
||||
wide-align@1.1.5:
|
||||
resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==}
|
||||
|
||||
word-wrap@1.2.5:
|
||||
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -3396,9 +3304,6 @@ packages:
|
||||
yallist@3.1.1:
|
||||
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
|
||||
|
||||
yallist@4.0.0:
|
||||
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
|
||||
|
||||
yargs-parser@20.2.9:
|
||||
resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -3905,21 +3810,6 @@ snapshots:
|
||||
|
||||
'@lukeed/csprng@1.1.0': {}
|
||||
|
||||
'@mapbox/node-pre-gyp@1.0.11':
|
||||
dependencies:
|
||||
detect-libc: 2.0.3
|
||||
https-proxy-agent: 5.0.1
|
||||
make-dir: 3.1.0
|
||||
node-fetch: 2.7.0
|
||||
nopt: 5.0.0
|
||||
npmlog: 5.0.1
|
||||
rimraf: 3.0.2
|
||||
semver: 7.6.3
|
||||
tar: 6.2.1
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
'@microsoft/tsdoc@0.15.0': {}
|
||||
|
||||
'@nestjs/cli@10.4.7':
|
||||
@@ -4407,8 +4297,6 @@ snapshots:
|
||||
|
||||
'@xtuc/long@4.2.2': {}
|
||||
|
||||
abbrev@1.1.1: {}
|
||||
|
||||
accepts@1.3.8:
|
||||
dependencies:
|
||||
mime-types: 2.1.35
|
||||
@@ -4424,12 +4312,6 @@ snapshots:
|
||||
|
||||
acorn@8.14.0: {}
|
||||
|
||||
agent-base@6.0.2:
|
||||
dependencies:
|
||||
debug: 4.3.7
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
ajv-formats@1.6.1(ajv@7.2.4):
|
||||
optionalDependencies:
|
||||
ajv: 7.2.4
|
||||
@@ -4492,13 +4374,6 @@ snapshots:
|
||||
|
||||
append-field@1.0.0: {}
|
||||
|
||||
aproba@2.0.0: {}
|
||||
|
||||
are-we-there-yet@2.0.0:
|
||||
dependencies:
|
||||
delegates: 1.0.0
|
||||
readable-stream: 3.6.2
|
||||
|
||||
arg@4.1.3: {}
|
||||
|
||||
argparse@1.0.10:
|
||||
@@ -4609,13 +4484,7 @@ snapshots:
|
||||
dependencies:
|
||||
tweetnacl: 0.14.5
|
||||
|
||||
bcrypt@5.1.1:
|
||||
dependencies:
|
||||
'@mapbox/node-pre-gyp': 1.0.11
|
||||
node-addon-api: 5.1.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
bcryptjs@3.0.0: {}
|
||||
|
||||
binary-extensions@2.3.0: {}
|
||||
|
||||
@@ -4731,8 +4600,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
chownr@2.0.0: {}
|
||||
|
||||
chrome-trace-event@1.0.4: {}
|
||||
|
||||
ci-info@3.9.0: {}
|
||||
@@ -4796,8 +4663,6 @@ snapshots:
|
||||
|
||||
color-name@1.1.4: {}
|
||||
|
||||
color-support@1.1.3: {}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
@@ -4841,8 +4706,6 @@ snapshots:
|
||||
|
||||
consola@2.15.3: {}
|
||||
|
||||
console-control-strings@1.1.0: {}
|
||||
|
||||
content-disposition@0.5.4:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
@@ -4943,16 +4806,12 @@ snapshots:
|
||||
|
||||
delayed-stream@1.0.0: {}
|
||||
|
||||
delegates@1.0.0: {}
|
||||
|
||||
denque@2.1.0: {}
|
||||
|
||||
depd@2.0.0: {}
|
||||
|
||||
destroy@1.2.0: {}
|
||||
|
||||
detect-libc@2.0.3: {}
|
||||
|
||||
detect-newline@3.1.0: {}
|
||||
|
||||
dezalgo@1.0.4:
|
||||
@@ -5340,10 +5199,6 @@ snapshots:
|
||||
jsonfile: 6.1.0
|
||||
universalify: 2.0.1
|
||||
|
||||
fs-minipass@2.1.0:
|
||||
dependencies:
|
||||
minipass: 3.3.6
|
||||
|
||||
fs-monkey@1.0.6: {}
|
||||
|
||||
fs.realpath@1.0.0: {}
|
||||
@@ -5353,18 +5208,6 @@ snapshots:
|
||||
|
||||
function-bind@1.1.2: {}
|
||||
|
||||
gauge@3.0.2:
|
||||
dependencies:
|
||||
aproba: 2.0.0
|
||||
color-support: 1.1.3
|
||||
console-control-strings: 1.1.0
|
||||
has-unicode: 2.0.1
|
||||
object-assign: 4.1.1
|
||||
signal-exit: 3.0.7
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
wide-align: 1.1.5
|
||||
|
||||
generate-function@2.3.1:
|
||||
dependencies:
|
||||
is-property: 1.0.2
|
||||
@@ -5459,8 +5302,6 @@ snapshots:
|
||||
|
||||
has-symbols@1.0.3: {}
|
||||
|
||||
has-unicode@2.0.1: {}
|
||||
|
||||
hasown@2.0.2:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
@@ -5485,13 +5326,6 @@ snapshots:
|
||||
jsprim: 1.4.2
|
||||
sshpk: 1.18.0
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
dependencies:
|
||||
agent-base: 6.0.2
|
||||
debug: 4.3.7
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
human-signals@2.1.0: {}
|
||||
|
||||
iconv-lite@0.4.24:
|
||||
@@ -6188,25 +6022,12 @@ snapshots:
|
||||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
minipass@3.3.6:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
minipass@5.0.0: {}
|
||||
|
||||
minipass@7.1.2: {}
|
||||
|
||||
minizlib@2.1.2:
|
||||
dependencies:
|
||||
minipass: 3.3.6
|
||||
yallist: 4.0.0
|
||||
|
||||
mkdirp@0.5.6:
|
||||
dependencies:
|
||||
minimist: 1.2.8
|
||||
|
||||
mkdirp@1.0.4: {}
|
||||
|
||||
mkdirp@2.1.6: {}
|
||||
|
||||
ms@2.0.0: {}
|
||||
@@ -6270,8 +6091,6 @@ snapshots:
|
||||
|
||||
node-abort-controller@3.1.1: {}
|
||||
|
||||
node-addon-api@5.1.0: {}
|
||||
|
||||
node-emoji@1.11.0:
|
||||
dependencies:
|
||||
lodash: 4.17.21
|
||||
@@ -6286,23 +6105,12 @@ snapshots:
|
||||
|
||||
node-releases@2.0.18: {}
|
||||
|
||||
nopt@5.0.0:
|
||||
dependencies:
|
||||
abbrev: 1.1.1
|
||||
|
||||
normalize-path@3.0.0: {}
|
||||
|
||||
npm-run-path@4.0.1:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
|
||||
npmlog@5.0.1:
|
||||
dependencies:
|
||||
are-we-there-yet: 2.0.0
|
||||
console-control-strings: 1.1.0
|
||||
gauge: 3.0.2
|
||||
set-blocking: 2.0.0
|
||||
|
||||
oauth-sign@0.9.0: {}
|
||||
|
||||
object-assign@4.1.1: {}
|
||||
@@ -6630,8 +6438,6 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
set-blocking@2.0.0: {}
|
||||
|
||||
set-function-length@1.2.2:
|
||||
dependencies:
|
||||
define-data-property: 1.1.4
|
||||
@@ -6799,15 +6605,6 @@ snapshots:
|
||||
|
||||
tapable@2.2.1: {}
|
||||
|
||||
tar@6.2.1:
|
||||
dependencies:
|
||||
chownr: 2.0.0
|
||||
fs-minipass: 2.1.0
|
||||
minipass: 5.0.0
|
||||
minizlib: 2.1.2
|
||||
mkdirp: 1.0.4
|
||||
yallist: 4.0.0
|
||||
|
||||
terser-webpack-plugin@5.3.10(webpack@5.96.1):
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.25
|
||||
@@ -7084,10 +6881,6 @@ snapshots:
|
||||
dependencies:
|
||||
isexe: 2.0.0
|
||||
|
||||
wide-align@1.1.5:
|
||||
dependencies:
|
||||
string-width: 4.2.3
|
||||
|
||||
word-wrap@1.2.5: {}
|
||||
|
||||
wrap-ansi@6.2.0:
|
||||
@@ -7121,8 +6914,6 @@ snapshots:
|
||||
|
||||
yallist@3.1.1: {}
|
||||
|
||||
yallist@4.0.0: {}
|
||||
|
||||
yargs-parser@20.2.9: {}
|
||||
|
||||
yargs-parser@21.1.1: {}
|
||||
|
||||
@@ -13,8 +13,8 @@ import { CreateCarousalRequest } from '../dto/create-carousal.request';
|
||||
import { ApiBearerAuth, ApiOkResponse, getSchemaPath } from '@nestjs/swagger';
|
||||
import { CarousalVo } from '../vo/carousal.vo';
|
||||
import { CarousalMapper } from '../mapper/carousal.mapper';
|
||||
import { PageResult } from '../../core/vo/page-result';
|
||||
import { PageResultMapper } from '../../core/mapper/page-result.mapper';
|
||||
import { PageResult } from '@/core/vo/page-result';
|
||||
import { PageResultMapper } from '@/core/mapper/page-result.mapper';
|
||||
import { SearchCarousalFilter } from '../dto/search-carousal.filter';
|
||||
import { UpdateCarousalRequest } from '../dto/update-carousal.request';
|
||||
|
||||
|
||||
@@ -4,16 +4,21 @@ import {
|
||||
ArgumentsHost,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import { ErrorResponse } from '../error/error.response';
|
||||
import * as process from 'node:process';
|
||||
|
||||
@Catch()
|
||||
export class GlobalExceptionFilter implements ExceptionFilter {
|
||||
private readonly logger = new Logger(GlobalExceptionFilter.name); // 使用 Logger
|
||||
|
||||
catch(exception: any, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
|
||||
const { status, errorResponse } = this.formatException(exception);
|
||||
this.logError(exception);
|
||||
|
||||
response.status(status).json(errorResponse);
|
||||
}
|
||||
@@ -68,4 +73,14 @@ export class GlobalExceptionFilter implements ExceptionFilter {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private logError(exception: any): void {
|
||||
// 记录错误信息
|
||||
this.logger.error(`Error: ${exception.message}`);
|
||||
|
||||
// 仅在开发或测试环境中打印堆栈跟踪
|
||||
if (['development', 'test'].includes(process.env.NODE_ENV)) {
|
||||
this.logger.error(`Stack Trace: ${exception.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { UserService } from './user.service';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { CreateTokenRequest } from '../dto/create-token.request';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { TokenVo } from '../vo/token.vo';
|
||||
import { JWT_SECRET } from '../constants/jwt';
|
||||
import { User } from '../entity/user.entity';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { User } from '../entity/user.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { SearchUserFilter } from '../dto/search-user.filter';
|
||||
import { JwtPayload } from 'jsonwebtoken';
|
||||
import { CreateUserRequest } from '../dto/create-user.request';
|
||||
|
||||
+8
-1
@@ -4,6 +4,7 @@ import { SnowflakeUtil } from './core/util/snowflake.util';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { GlobalExceptionFilter } from './core/exception/global-exception.filter';
|
||||
import { GlobalValidationPipe } from './core/pipe/global-validation.pipe';
|
||||
import * as process from 'node:process';
|
||||
|
||||
async function bootstrap() {
|
||||
SnowflakeUtil.initialize(
|
||||
@@ -30,6 +31,12 @@ async function bootstrap() {
|
||||
app.useGlobalPipes(new GlobalValidationPipe());
|
||||
app.useGlobalFilters(new GlobalExceptionFilter());
|
||||
|
||||
await app.listen(3000);
|
||||
// Enable CORS for frontend applications
|
||||
app.enableCors({
|
||||
origin: ['http://localhost:5173', 'http://localhost:5174', 'http://localhost:5175'],
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
await app.listen(process.env.APP_PORT || 3000);
|
||||
}
|
||||
bootstrap();
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common';
|
||||
import { CreateFeedingPlanRequest } from '@/pet-feeder/dto/create-feeding-plan.request';
|
||||
import { FeedingPlanService } from '@/pet-feeder/service/feeding-plan.service';
|
||||
import { FeedingPlanVo } from '@/pet-feeder/vo/feeding-plan.vo';
|
||||
import { FeedingPlanMapper } from '@/pet-feeder/mapper/feeding-plan.mapper';
|
||||
|
||||
@Controller('feeding-plans')
|
||||
export class FeedingPlanController {
|
||||
constructor(
|
||||
private readonly feedingPlanService: FeedingPlanService,
|
||||
private readonly feedingPlanMapper: FeedingPlanMapper,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Body() createFeedingPlanRequest: CreateFeedingPlanRequest,
|
||||
): Promise<FeedingPlanVo> {
|
||||
return this.feedingPlanMapper.toVo(
|
||||
await this.feedingPlanService.create(createFeedingPlanRequest),
|
||||
);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() updateFeedingRequest: CreateFeedingPlanRequest,
|
||||
) {
|
||||
return this.feedingPlanMapper.toVo(
|
||||
await this.feedingPlanService.update(id, updateFeedingRequest),
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async get(@Param('id') id: string): Promise<FeedingPlanVo> {
|
||||
return this.feedingPlanMapper.toVo(await this.feedingPlanService.get(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { PetVarietyVo } from '@/pet-feeder/vo/pet-variety.vo';
|
||||
import { PetVarietyService } from '@/pet-feeder/service/pet-variety.service';
|
||||
import { PetVarietyMapper } from '@/pet-feeder/mapper/pet-variety.mapper';
|
||||
import { PageResultMapper } from '@/core/mapper/page-result.mapper';
|
||||
import { SearchPetVarietyFilter } from '@/pet-feeder/dto/search-pet-variety.filter';
|
||||
|
||||
@Controller('/pet-varieties')
|
||||
export class PetVarietyController {
|
||||
constructor(
|
||||
private readonly petVarietyService: PetVarietyService,
|
||||
private readonly petVarietyMapper: PetVarietyMapper,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body('name') name: string) {
|
||||
return this.petVarietyMapper.toVo(
|
||||
await this.petVarietyService.create(name),
|
||||
);
|
||||
}
|
||||
|
||||
@Get('/list')
|
||||
async list() {
|
||||
return this.petVarietyMapper.toVos(await this.petVarietyService.list());
|
||||
}
|
||||
@Get('/:id')
|
||||
async get(@Param('id') id: string) {
|
||||
return this.petVarietyMapper.toVo(await this.petVarietyService.get(id));
|
||||
}
|
||||
|
||||
@Get()
|
||||
async search(@Query() searchPetVarietyFilter: SearchPetVarietyFilter) {
|
||||
const [data, total] = await this.petVarietyService.search(
|
||||
searchPetVarietyFilter,
|
||||
);
|
||||
return PageResultMapper.toPageResult<PetVarietyVo>(
|
||||
this.petVarietyMapper.toVos(data),
|
||||
searchPetVarietyFilter.getPage(),
|
||||
searchPetVarietyFilter.getSize(),
|
||||
total,
|
||||
);
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
async delete(@Param('id') id: string) {
|
||||
await this.petVarietyService.delete(id);
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
async update(@Param('id') id: string, @Body('name') name: string) {
|
||||
return this.petVarietyMapper.toVo(
|
||||
await this.petVarietyService.update(id, name),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Controller, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||
import { PetService } from '@/pet-feeder/service/pet.service';
|
||||
import { PetMapper } from '@/pet-feeder/mapper/pet.mapper';
|
||||
import { PetVo } from '@/pet-feeder/vo/pet.vo';
|
||||
import { CreatePetRequest } from '@/pet-feeder/dto/create-pet.request';
|
||||
import { ApiBearerAuth, ApiOkResponse } from '@nestjs/swagger';
|
||||
|
||||
@Controller('pets')
|
||||
export class PetController {
|
||||
@@ -12,7 +13,17 @@ export class PetController {
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
async create(createPetRequest: CreatePetRequest): Promise<PetVo> {
|
||||
@ApiOkResponse({
|
||||
type: PetVo,
|
||||
})
|
||||
@ApiBearerAuth()
|
||||
async create(@Body() createPetRequest: CreatePetRequest): Promise<PetVo> {
|
||||
return this.petMapper.toVo(await this.petService.create(createPetRequest));
|
||||
}
|
||||
|
||||
@Get('own')
|
||||
@ApiBearerAuth()
|
||||
async ownPetList(): Promise<PetVo[]> {
|
||||
return this.petMapper.toVos(await this.petService.ownPetList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { CreateProductRequest } from '@/pet-feeder/dto/create-product.request';
|
||||
import { ProductService } from '@/pet-feeder/service/product.service';
|
||||
import { ProductVo } from '@/pet-feeder/vo/product.vo';
|
||||
import { ProductMapper } from '@/pet-feeder/mapper/product.mapper';
|
||||
import { ApiBearerAuth, ApiOkResponse, getSchemaPath } from '@nestjs/swagger';
|
||||
import { UpdateProductRequest } from '@/pet-feeder/dto/update-product.request';
|
||||
import { PageResultMapper } from '@/core/mapper/page-result.mapper';
|
||||
import { SearchProductFilter } from '@/pet-feeder/dto/search-product.filter';
|
||||
import { PageResult } from '@/core/vo/page-result';
|
||||
|
||||
@Controller('products')
|
||||
export class ProductController {
|
||||
constructor(
|
||||
private readonly productService: ProductService,
|
||||
private readonly productMapper: ProductMapper,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
@ApiOkResponse({
|
||||
type: ProductVo,
|
||||
})
|
||||
@ApiBearerAuth()
|
||||
async create(
|
||||
@Body() createProductRequest: CreateProductRequest,
|
||||
): Promise<ProductVo> {
|
||||
return this.productMapper.toVo(
|
||||
await this.productService.create(createProductRequest),
|
||||
);
|
||||
}
|
||||
@Get('list')
|
||||
@ApiOkResponse({ type: Array<ProductVo> })
|
||||
async list(): Promise<ProductVo[]> {
|
||||
return this.productMapper.toVos(await this.productService.list());
|
||||
}
|
||||
@Put(':id')
|
||||
@ApiOkResponse({
|
||||
type: ProductVo,
|
||||
})
|
||||
@ApiBearerAuth()
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() updateProductRequest: UpdateProductRequest,
|
||||
): Promise<ProductVo> {
|
||||
return this.productMapper.toVo(
|
||||
await this.productService.update(id, updateProductRequest),
|
||||
);
|
||||
}
|
||||
@Get(':id')
|
||||
async get(@Param('id') id: string): Promise<ProductVo> {
|
||||
return this.productMapper.toVo(await this.productService.get(id));
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOkResponse({
|
||||
description: '产品分页列表',
|
||||
schema: {
|
||||
allOf: [
|
||||
{ $ref: getSchemaPath(PageResult) }, // 引用 PageResult 模型
|
||||
{
|
||||
properties: {
|
||||
data: {
|
||||
type: 'array',
|
||||
items: { $ref: getSchemaPath(ProductVo) }, // 泛型内容具体化
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
@ApiBearerAuth()
|
||||
async search(@Query() searchProductFilter: SearchProductFilter) {
|
||||
const [data, total] = await this.productService.search(searchProductFilter);
|
||||
return PageResultMapper.toPageResult<ProductVo>(
|
||||
this.productMapper.toVos(data),
|
||||
searchProductFilter.getPage(),
|
||||
searchProductFilter.getSize(),
|
||||
total,
|
||||
);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiBearerAuth()
|
||||
async delete(@Param('id') id: string): Promise<void> {
|
||||
await this.productService.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { FeedingGoal } from '@/pet-feeder/enum/feeding-goal';
|
||||
import { IsNotEmpty, IsNumber } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class CreateFeedingPlanRequest {
|
||||
@IsNotEmpty({
|
||||
message: '目标体重不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
targetWeight: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '喂养目标不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
feedingGoal: FeedingGoal;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '宠物 ID 不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
petId: string;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '产品 ID 不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
products: { id: string; dailyUsageWeight: number; percentage: number }[];
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PetType } from '@/pet-feeder/enum/pet-type';
|
||||
import { Gender } from '@/core/enum/Gender';
|
||||
import { PetBodyType } from '@/pet-feeder/enum/pet-body-type';
|
||||
import { IsNotEmpty } from 'class-validator';
|
||||
import { IsNotEmpty, IsOptional } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class CreatePetRequest {
|
||||
@@ -17,6 +17,12 @@ export class CreatePetRequest {
|
||||
@ApiProperty()
|
||||
type: PetType;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '请选择品种',
|
||||
})
|
||||
@ApiProperty()
|
||||
varietyName: string;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '请选择性别',
|
||||
})
|
||||
@@ -35,9 +41,7 @@ export class CreatePetRequest {
|
||||
@ApiProperty()
|
||||
weight: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '照片不能为空',
|
||||
})
|
||||
@IsOptional()
|
||||
@ApiProperty()
|
||||
photo: string;
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { IsNotEmpty, IsOptional } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ProductCategory } from '@/pet-feeder/enum/product-category';
|
||||
|
||||
export class CreateProductRequest {
|
||||
@IsNotEmpty({
|
||||
message: '产品名称不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '产品分类不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
category: ProductCategory;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '产品图片不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
photo: string;
|
||||
|
||||
@IsOptional()
|
||||
@ApiProperty()
|
||||
tags: string[] = [];
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '总重量不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
totalWeight: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '蛋白质百分比不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
protein: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '脂肪百分比不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
fat: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '粗纤维百分比不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
fiber: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '粗灰分百分比不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
ash: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: '水分百分比不能为空',
|
||||
})
|
||||
@ApiProperty()
|
||||
moisture: number;
|
||||
|
||||
@IsOptional()
|
||||
@ApiProperty({
|
||||
description: 'ME值(kcal/g),直接配置的代谢能,可选。如果提供则优先使用,否则通过营养成分计算',
|
||||
required: false,
|
||||
})
|
||||
meValue?: number;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { BaseFilter } from '@/core/dto/base.filter';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SearchPetVarietyFilter extends BaseFilter {
|
||||
@ApiProperty()
|
||||
order = ['-createdTime'];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { BaseFilter } from '@/core/dto/base.filter';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SearchProductFilter extends BaseFilter {
|
||||
@ApiProperty()
|
||||
order = ['-createdTime'];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { CreateProductRequest } from '@/pet-feeder/dto/create-product.request';
|
||||
|
||||
export class UpdateProductRequest extends CreateProductRequest {}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { BaseEntity } from '@/core/entity/base.entity';
|
||||
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
||||
import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
||||
import { Product } from '@/pet-feeder/entity/product.entity';
|
||||
|
||||
@Entity()
|
||||
export class FeedingPlanProduct extends BaseEntity {
|
||||
@Column()
|
||||
dailyUsageWeight: number;
|
||||
|
||||
@Column()
|
||||
percentage: number;
|
||||
|
||||
@ManyToOne(
|
||||
() => FeedingPlan,
|
||||
(feedingPlan) => feedingPlan.feedingPlanProducts,
|
||||
)
|
||||
@JoinColumn({
|
||||
name: 'feedingPlanId',
|
||||
})
|
||||
feedingPlan: FeedingPlan;
|
||||
|
||||
@ManyToOne(() => Product, (product) => product.feedingPlanProducts, {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'productId',
|
||||
})
|
||||
product: Product;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import { BaseEntity } from '@/core/entity/base.entity';
|
||||
import { Column, Entity, OneToOne } from 'typeorm';
|
||||
import { Column, Entity, OneToMany, OneToOne } from 'typeorm';
|
||||
import { Pet } from '@/pet-feeder/entity/pet.entity';
|
||||
import { FeedingGoal } from '@/pet-feeder/enum/feeding-goal';
|
||||
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
||||
|
||||
@Entity()
|
||||
export class FeedingPlan extends BaseEntity {
|
||||
@@ -14,4 +15,11 @@ export class FeedingPlan extends BaseEntity {
|
||||
// 反向一对一关系
|
||||
@OneToOne(() => Pet, (pet) => pet.feedingPlan)
|
||||
pet: Pet;
|
||||
|
||||
@OneToMany(
|
||||
() => FeedingPlanProduct,
|
||||
(feedingPlanProduct) => feedingPlanProduct.feedingPlan,
|
||||
{ eager: true },
|
||||
)
|
||||
feedingPlanProducts: FeedingPlanProduct[];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseEntity } from '@/core/entity/base.entity';
|
||||
|
||||
@Entity()
|
||||
export class PetVariety extends BaseEntity {
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { Gender } from '@/core/enum/Gender';
|
||||
import { PetBodyType } from '@/pet-feeder/enum/pet-body-type';
|
||||
import { Column, Entity, JoinColumn, OneToOne } from 'typeorm';
|
||||
import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
||||
import { PetVariety } from '@/pet-feeder/entity/pet-variety.entity';
|
||||
|
||||
@Entity()
|
||||
export class Pet extends TraceableEntity {
|
||||
@@ -17,6 +18,10 @@ export class Pet extends TraceableEntity {
|
||||
})
|
||||
type: PetType;
|
||||
|
||||
@OneToOne(() => PetVariety, { eager: true })
|
||||
@JoinColumn({ name: 'varietyId' })
|
||||
variety: PetVariety;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: PetType,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { BaseEntity } from '@/core/entity/base.entity';
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
||||
import { ProductCategory } from '@/pet-feeder/enum/product-category';
|
||||
|
||||
@Entity()
|
||||
export class Product extends BaseEntity {
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: ProductCategory,
|
||||
default: ProductCategory.DRY_FOOD,
|
||||
})
|
||||
category: ProductCategory;
|
||||
|
||||
@Column()
|
||||
photo: string;
|
||||
|
||||
@Column({
|
||||
type: 'json',
|
||||
})
|
||||
tags: string[];
|
||||
|
||||
@Column()
|
||||
totalWeight: number;
|
||||
|
||||
//蛋白质(百分比,如0.6表示60%)
|
||||
@Column({
|
||||
type: 'double',
|
||||
})
|
||||
protein: number;
|
||||
|
||||
// 脂肪(百分比)
|
||||
@Column({
|
||||
type: 'double',
|
||||
})
|
||||
fat: number;
|
||||
|
||||
// 粗纤维(百分比)
|
||||
@Column({
|
||||
type: 'double',
|
||||
})
|
||||
fiber: number;
|
||||
|
||||
// 粗灰分(百分比)
|
||||
@Column({
|
||||
type: 'double',
|
||||
})
|
||||
ash: number;
|
||||
|
||||
// 水分(百分比)
|
||||
@Column({
|
||||
type: 'double',
|
||||
})
|
||||
moisture: number;
|
||||
|
||||
// ME值(kcal/g),直接配置的代谢能,可选字段
|
||||
// 如果配置了此值,优先使用;否则通过营养成分计算
|
||||
@Column({
|
||||
type: 'double',
|
||||
nullable: true,
|
||||
comment: 'ME值(kcal/g),直接配置的代谢能',
|
||||
})
|
||||
meValue: number | null;
|
||||
|
||||
@OneToMany(
|
||||
() => FeedingPlanProduct,
|
||||
(feedingPlanProduct) => feedingPlanProduct.feedingPlan,
|
||||
{ cascade: true },
|
||||
)
|
||||
feedingPlanProducts: FeedingPlanProduct[];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export enum ProductCategory {
|
||||
DRY_FOOD,
|
||||
WET_FOOD,
|
||||
}
|
||||
|
||||
export const productCategoryLabels: Record<ProductCategory, string> = {
|
||||
[ProductCategory.DRY_FOOD]: '干粮',
|
||||
[ProductCategory.WET_FOOD]: '湿粮',
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ErrorResponse } from '@/core/error/error.response';
|
||||
|
||||
export const PRODUCT_NOT_FOUND: ErrorResponse = {
|
||||
code: 5001,
|
||||
message: 'Product not found',
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
import { BaseMapper } from '@/core/mapper/base.mapper';
|
||||
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
||||
import { FeedingPlanProductVo } from '@/pet-feeder/vo/feeding-plan-product.vo';
|
||||
import { ProductMapper } from '@/pet-feeder/mapper/product.mapper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class FeedingPlanProductMapper extends BaseMapper<
|
||||
FeedingPlanProduct,
|
||||
FeedingPlanProductVo
|
||||
> {
|
||||
constructor(private productMapper: ProductMapper) {
|
||||
super();
|
||||
}
|
||||
toVo(entity: FeedingPlanProduct): FeedingPlanProductVo {
|
||||
return {
|
||||
...super.toVo(entity),
|
||||
dailyUsageWeight: entity.dailyUsageWeight,
|
||||
percentage: entity.percentage,
|
||||
product: entity.product ? this.productMapper.toVo(entity.product) : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { BaseMapper } from '@/core/mapper/base.mapper';
|
||||
import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
||||
import { FeedingPlanVo } from '@/pet-feeder/vo/feeding-plan.vo';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ProductMapper } from '@/pet-feeder/mapper/product.mapper';
|
||||
import { FeedingPlanProductMapper } from '@/pet-feeder/mapper/feeding-plan-product.mapper';
|
||||
|
||||
@Injectable()
|
||||
export class FeedingPlanMapper extends BaseMapper<FeedingPlan, FeedingPlanVo> {
|
||||
constructor(private feedingPlanProductMapper: FeedingPlanProductMapper) {
|
||||
super();
|
||||
}
|
||||
toVo(entity: FeedingPlan): FeedingPlanVo {
|
||||
return {
|
||||
...super.toVo(entity),
|
||||
targetWeight: entity.targetWeight,
|
||||
feedingGoal: entity.feedingGoal,
|
||||
feedingPlanProducts: this.feedingPlanProductMapper.toVos(
|
||||
entity.feedingPlanProducts,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { BaseMapper } from '@/core/mapper/base.mapper';
|
||||
import { PetVariety } from '@/pet-feeder/entity/pet-variety.entity';
|
||||
import { PetVarietyVo } from '@/pet-feeder/vo/pet-variety.vo';
|
||||
|
||||
export class PetVarietyMapper extends BaseMapper<PetVariety, PetVarietyVo> {
|
||||
toVo(entity: PetVariety): PetVarietyVo {
|
||||
return {
|
||||
...super.toVo(entity),
|
||||
name: entity.name,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,23 @@ import { BaseMapper } from '@/core/mapper/base.mapper';
|
||||
import { Pet } from '@/pet-feeder/entity/pet.entity';
|
||||
import { PetVo } from '@/pet-feeder/vo/pet.vo';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DateUtil } from '@/core/util/date.util';
|
||||
import { FeedingPlanMapper } from '@/pet-feeder/mapper/feeding-plan.mapper';
|
||||
|
||||
@Injectable()
|
||||
export class PetMapper extends BaseMapper<Pet, PetVo> {
|
||||
constructor(private readonly feedingPlanMapper: FeedingPlanMapper) {
|
||||
super();
|
||||
}
|
||||
|
||||
toVo(entity: Pet): PetVo {
|
||||
return {
|
||||
...super.toVo(entity),
|
||||
name: entity.name,
|
||||
type: entity.type,
|
||||
varietyName: entity.variety ? entity.variety.name : '',
|
||||
gender: entity.gender,
|
||||
birthday: entity.birthday.toISOString(),
|
||||
birthday: DateUtil.format(entity.birthday),
|
||||
weight: entity.weight,
|
||||
photo: entity.photo,
|
||||
isActive: entity.isActive,
|
||||
@@ -19,6 +26,9 @@ export class PetMapper extends BaseMapper<Pet, PetVo> {
|
||||
isSterilization: entity.isSterilization,
|
||||
isLactation: entity.isLactation,
|
||||
bodyType: entity.bodyType,
|
||||
feedingPlan: entity.feedingPlan
|
||||
? this.feedingPlanMapper.toVo(entity.feedingPlan)
|
||||
: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { BaseMapper } from '@/core/mapper/base.mapper';
|
||||
import { Product } from '@/pet-feeder/entity/product.entity';
|
||||
import { ProductVo } from '@/pet-feeder/vo/product.vo';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { productCategoryLabels } from '@/pet-feeder/enum/product-category';
|
||||
|
||||
@Injectable()
|
||||
export class ProductMapper extends BaseMapper<Product, ProductVo> {
|
||||
/**
|
||||
* 计算产品的代谢能(ME - Metabolizable Energy)
|
||||
* 基于营养成分计算每克产品的能量值
|
||||
*
|
||||
* @param protein 蛋白质含量(百分比,如0.4表示40%)
|
||||
* @param fat 脂肪含量(百分比)
|
||||
* @param fiber 粗纤维含量(百分比)
|
||||
* @param ash 粗灰分含量(百分比)
|
||||
* @param moisture 水分含量(百分比)
|
||||
* @returns ME值 (kcal/g)
|
||||
*/
|
||||
private calculateME(
|
||||
protein: number,
|
||||
fat: number,
|
||||
fiber: number,
|
||||
ash: number,
|
||||
moisture: number,
|
||||
): number {
|
||||
// 步骤1: 计算干物质
|
||||
const dryMatter = 1 - moisture;
|
||||
|
||||
// 步骤2: 计算NEF(无氮浸出物)
|
||||
const nef =
|
||||
1 -
|
||||
protein * (1 - moisture) -
|
||||
fat * (1 - moisture) -
|
||||
fiber * (1 - moisture) -
|
||||
ash * (1 - moisture) -
|
||||
moisture;
|
||||
|
||||
// 步骤3: 计算各营养成分质量
|
||||
const proteinMass = protein * dryMatter;
|
||||
const fatMass = fat * dryMatter;
|
||||
const fiberMass = fiber * dryMatter;
|
||||
|
||||
// 步骤4: 计算干物质中粗纤维含量占比
|
||||
const fiberPercentageInDryMatter = (fiberMass / dryMatter) * 100;
|
||||
|
||||
// 步骤5: 计算GE(总能)
|
||||
const ge = 5.7 * proteinMass + 9.4 * fatMass + 4.1 * (nef + fiberMass);
|
||||
|
||||
// 步骤6: 计算能量消化率
|
||||
const digestibility = 87.9 - 0.88 * fiberPercentageInDryMatter;
|
||||
|
||||
// 步骤7: 计算DE(消化能)
|
||||
const de = (ge * digestibility) / 100;
|
||||
|
||||
// 步骤8: 计算ME(代谢能)
|
||||
const me = de - 0.77 * proteinMass;
|
||||
|
||||
return me;
|
||||
}
|
||||
|
||||
toVo(entity: Product): ProductVo {
|
||||
// ME值计算逻辑:
|
||||
// 1. 如果配置了meValue,优先使用配置值
|
||||
// 2. 否则通过营养成分计算
|
||||
let mePerGram: number;
|
||||
|
||||
if (entity.meValue !== null && entity.meValue !== undefined) {
|
||||
// 使用直接配置的ME值(kcal/g)
|
||||
mePerGram = entity.meValue;
|
||||
} else {
|
||||
// 通过营养成分计算ME值
|
||||
mePerGram = this.calculateME(
|
||||
entity.protein,
|
||||
entity.fat,
|
||||
entity.fiber,
|
||||
entity.ash,
|
||||
entity.moisture,
|
||||
);
|
||||
}
|
||||
|
||||
// 计算整包产品的总能量
|
||||
const totalCalories = mePerGram * entity.totalWeight;
|
||||
|
||||
return {
|
||||
...super.toVo(entity),
|
||||
name: entity.name,
|
||||
category: productCategoryLabels[entity.category],
|
||||
photo: entity.photo,
|
||||
tags: entity.tags,
|
||||
protein: entity.protein,
|
||||
fat: entity.fat,
|
||||
fiber: entity.fiber,
|
||||
ash: entity.ash,
|
||||
moisture: entity.moisture,
|
||||
totalWeight: entity.totalWeight,
|
||||
meValue: entity.meValue,
|
||||
totalCalories: Number(totalCalories.toFixed(2)), // 保留2位小数
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,48 @@ import { Pet } from '@/pet-feeder/entity/pet.entity';
|
||||
import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
||||
import { PetService } from '@/pet-feeder/service/pet.service';
|
||||
import { PetMapper } from '@/pet-feeder/mapper/pet.mapper';
|
||||
import { PetController } from '@/pet-feeder/controller/pet.controller';
|
||||
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
||||
import { Product } from '@/pet-feeder/entity/product.entity';
|
||||
import { ProductService } from '@/pet-feeder/service/product.service';
|
||||
import { ProductMapper } from '@/pet-feeder/mapper/product.mapper';
|
||||
import { ProductController } from '@/pet-feeder/controller/product.controller';
|
||||
import { FeedingPlanService } from '@/pet-feeder/service/feeding-plan.service';
|
||||
import { FeedingPlanMapper } from '@/pet-feeder/mapper/feeding-plan.mapper';
|
||||
import { FeedingPlanController } from '@/pet-feeder/controller/feeding-plan.controller';
|
||||
import { FeedingPlanProductMapper } from '@/pet-feeder/mapper/feeding-plan-product.mapper';
|
||||
import { PetVariety } from '@/pet-feeder/entity/pet-variety.entity';
|
||||
import { PetVarietyController } from '@/pet-feeder/controller/pet-variety.controller';
|
||||
import { PetVarietyService } from '@/pet-feeder/service/pet-variety.service';
|
||||
import { PetVarietyMapper } from '@/pet-feeder/mapper/pet-variety.mapper';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Pet, FeedingPlan])],
|
||||
controllers: [],
|
||||
providers: [PetService, PetMapper],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
Pet,
|
||||
FeedingPlan,
|
||||
FeedingPlanProduct,
|
||||
Product,
|
||||
PetVariety,
|
||||
]),
|
||||
],
|
||||
controllers: [
|
||||
PetController,
|
||||
ProductController,
|
||||
FeedingPlanController,
|
||||
PetVarietyController,
|
||||
],
|
||||
providers: [
|
||||
PetService,
|
||||
PetMapper,
|
||||
ProductService,
|
||||
ProductMapper,
|
||||
FeedingPlanService,
|
||||
FeedingPlanMapper,
|
||||
FeedingPlanProductMapper,
|
||||
PetVarietyService,
|
||||
PetVarietyMapper,
|
||||
],
|
||||
exports: [],
|
||||
})
|
||||
export class PetFeederModule {}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateFeedingPlanRequest } from '@/pet-feeder/dto/create-feeding-plan.request';
|
||||
import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
||||
import { PetService } from '@/pet-feeder/service/pet.service';
|
||||
import { ProductService } from '@/pet-feeder/service/product.service';
|
||||
|
||||
@Injectable()
|
||||
export class FeedingPlanService {
|
||||
constructor(
|
||||
@InjectRepository(FeedingPlan)
|
||||
private readonly feedingPlanRepository: Repository<FeedingPlan>,
|
||||
|
||||
@InjectRepository(FeedingPlanProduct)
|
||||
private readonly feedingPlanProductRepository: Repository<FeedingPlanProduct>,
|
||||
|
||||
private readonly petService: PetService,
|
||||
|
||||
private readonly productService: ProductService,
|
||||
) {}
|
||||
|
||||
async create(
|
||||
createFeedingPlanRequest: CreateFeedingPlanRequest,
|
||||
): Promise<FeedingPlan> {
|
||||
const feedingPlan = this.feedingPlanRepository.create({
|
||||
feedingGoal: createFeedingPlanRequest.feedingGoal,
|
||||
targetWeight: createFeedingPlanRequest.targetWeight,
|
||||
});
|
||||
feedingPlan.pet = await this.petService.get(createFeedingPlanRequest.petId);
|
||||
|
||||
const feedingPlanProducts: FeedingPlanProduct[] = [];
|
||||
|
||||
await Promise.all(
|
||||
createFeedingPlanRequest.products.map(async (product) => {
|
||||
const existProduct = await this.productService.get(product.id);
|
||||
const feedingPlanProduct = this.feedingPlanProductRepository.create({
|
||||
product: existProduct,
|
||||
dailyUsageWeight: product.dailyUsageWeight,
|
||||
percentage: product.percentage,
|
||||
});
|
||||
feedingPlanProducts.push(
|
||||
await this.feedingPlanProductRepository.save(feedingPlanProduct),
|
||||
);
|
||||
}),
|
||||
);
|
||||
feedingPlan.feedingPlanProducts = feedingPlanProducts;
|
||||
return this.feedingPlanRepository.save(feedingPlan);
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
updateFeedingPlanRequest: CreateFeedingPlanRequest,
|
||||
): Promise<FeedingPlan> {
|
||||
const feedingPlan = await this.get(id);
|
||||
feedingPlan.feedingGoal = updateFeedingPlanRequest.feedingGoal;
|
||||
feedingPlan.targetWeight = updateFeedingPlanRequest.targetWeight;
|
||||
const feedingPlanProducts: FeedingPlanProduct[] = [];
|
||||
|
||||
await Promise.all(
|
||||
updateFeedingPlanRequest.products.map(async (product) => {
|
||||
const existProduct = await this.productService.get(product.id);
|
||||
const exitFeedingPlanProduct =
|
||||
await this.feedingPlanProductRepository.findOneBy({
|
||||
product: existProduct,
|
||||
});
|
||||
if (exitFeedingPlanProduct) {
|
||||
exitFeedingPlanProduct.dailyUsageWeight = product.dailyUsageWeight;
|
||||
exitFeedingPlanProduct.percentage = product.percentage;
|
||||
feedingPlanProducts.push(
|
||||
await this.feedingPlanProductRepository.save(
|
||||
exitFeedingPlanProduct,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const feedingPlanProduct = this.feedingPlanProductRepository.create({
|
||||
product: existProduct,
|
||||
dailyUsageWeight: product.dailyUsageWeight,
|
||||
percentage: product.percentage,
|
||||
});
|
||||
feedingPlanProducts.push(
|
||||
await this.feedingPlanProductRepository.save(feedingPlanProduct),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
return this.feedingPlanRepository.save(feedingPlan);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<FeedingPlan> {
|
||||
const feedingPlan = await this.feedingPlanRepository.findOneBy({ id });
|
||||
if (!feedingPlan) {
|
||||
throw new Error('Feeding plan not found');
|
||||
}
|
||||
return feedingPlan;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { PetVariety } from '@/pet-feeder/entity/pet-variety.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { SearchPetVarietyFilter } from '@/pet-feeder/dto/search-pet-variety.filter';
|
||||
|
||||
@Injectable()
|
||||
export class PetVarietyService {
|
||||
constructor(
|
||||
@InjectRepository(PetVariety)
|
||||
private readonly petVarietyRepository: Repository<PetVariety>,
|
||||
) {}
|
||||
|
||||
async create(name: string): Promise<PetVariety> {
|
||||
const petVariety = this.petVarietyRepository.create({
|
||||
name,
|
||||
});
|
||||
return this.petVarietyRepository.save(petVariety);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<PetVariety> {
|
||||
const petVariety = await this.petVarietyRepository.findOneBy({
|
||||
id,
|
||||
});
|
||||
if (!petVariety) {
|
||||
throw new Error('PetVariety not found');
|
||||
}
|
||||
return petVariety;
|
||||
}
|
||||
|
||||
async search(searchPetVarietyFilter: SearchPetVarietyFilter) {
|
||||
return this.petVarietyRepository.findAndCount({
|
||||
where: searchPetVarietyFilter.getConditions(),
|
||||
skip: searchPetVarietyFilter.getSkip(),
|
||||
take: searchPetVarietyFilter.getSize(),
|
||||
order: searchPetVarietyFilter.getOrderBy(),
|
||||
});
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
const petVariety = await this.get(id);
|
||||
return this.petVarietyRepository.remove(petVariety);
|
||||
}
|
||||
|
||||
async update(id: string, name: string) {
|
||||
const petVariety = await this.get(id);
|
||||
petVariety.name = name;
|
||||
return this.petVarietyRepository.save(petVariety);
|
||||
}
|
||||
|
||||
async list() {
|
||||
return this.petVarietyRepository.find();
|
||||
}
|
||||
|
||||
getByName(name: string) {
|
||||
return this.petVarietyRepository.findOneBy({
|
||||
name,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,26 @@ import { CreatePetRequest } from '@/pet-feeder/dto/create-pet.request';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Pet } from '@/pet-feeder/entity/pet.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { RequestContext } from 'nestjs-request-context';
|
||||
import { PetVariety } from '@/pet-feeder/entity/pet-variety.entity';
|
||||
import { PetVarietyService } from '@/pet-feeder/service/pet-variety.service';
|
||||
|
||||
@Injectable()
|
||||
export class PetService {
|
||||
constructor(
|
||||
@InjectRepository(Pet)
|
||||
private readonly petRepository: Repository<Pet>,
|
||||
|
||||
private readonly petVarietyService: PetVarietyService,
|
||||
) {}
|
||||
|
||||
async create(createPetRequest: CreatePetRequest): Promise<Pet> {
|
||||
const pet = this.petRepository.create({
|
||||
name: createPetRequest.name,
|
||||
type: createPetRequest.type,
|
||||
variety: createPetRequest.varietyName
|
||||
? await this.petVarietyService.getByName(createPetRequest.varietyName)
|
||||
: null,
|
||||
gender: createPetRequest.gender,
|
||||
birthday: createPetRequest.birthday,
|
||||
weight: createPetRequest.weight,
|
||||
@@ -27,4 +35,22 @@ export class PetService {
|
||||
});
|
||||
return this.petRepository.save(pet);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<Pet> {
|
||||
const pet = await this.petRepository.findOneBy({
|
||||
id,
|
||||
});
|
||||
if (!pet) {
|
||||
throw new Error('Pet not found');
|
||||
}
|
||||
return pet;
|
||||
}
|
||||
|
||||
async ownPetList(): Promise<Pet[]> {
|
||||
const id = RequestContext.currentContext.req.user.id;
|
||||
return this.petRepository.find({
|
||||
where: { createBy: { id } },
|
||||
relations: ['feedingPlan'],
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Product } from '@/pet-feeder/entity/product.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CreateProductRequest } from '@/pet-feeder/dto/create-product.request';
|
||||
import { UpdateProductRequest } from '@/pet-feeder/dto/update-product.request';
|
||||
import { BizException } from '@/core/exception/biz.exception';
|
||||
import { PRODUCT_NOT_FOUND } from '@/pet-feeder/error/product.error';
|
||||
import { SearchProductFilter } from '@/pet-feeder/dto/search-product.filter';
|
||||
|
||||
@Injectable()
|
||||
export class ProductService {
|
||||
constructor(
|
||||
@InjectRepository(Product)
|
||||
private readonly productRepository: Repository<Product>,
|
||||
) {}
|
||||
|
||||
async create(createProductRequest: CreateProductRequest): Promise<Product> {
|
||||
const product = this.productRepository.create({
|
||||
...createProductRequest,
|
||||
});
|
||||
return this.productRepository.save(product);
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
updateProductRequest: UpdateProductRequest,
|
||||
): Promise<Product> {
|
||||
const product = await this.get(id);
|
||||
product.name = updateProductRequest.name;
|
||||
product.category = updateProductRequest.category;
|
||||
product.tags = updateProductRequest.tags;
|
||||
product.photo = updateProductRequest.photo;
|
||||
product.protein = updateProductRequest.protein;
|
||||
product.fat = updateProductRequest.fat;
|
||||
product.fiber = updateProductRequest.fiber;
|
||||
product.ash = updateProductRequest.ash;
|
||||
product.moisture = updateProductRequest.moisture;
|
||||
product.totalWeight = updateProductRequest.totalWeight;
|
||||
product.meValue = updateProductRequest.meValue ?? null;
|
||||
return this.productRepository.save(product);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<Product> {
|
||||
const product = await this.productRepository.findOneBy({ id });
|
||||
if (!product) {
|
||||
throw new BizException(PRODUCT_NOT_FOUND);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
async search(searchProductFilter: SearchProductFilter) {
|
||||
return this.productRepository.findAndCount({
|
||||
where: searchProductFilter.getConditions(),
|
||||
skip: searchProductFilter.getSkip(),
|
||||
take: searchProductFilter.getSize(),
|
||||
order: searchProductFilter.getOrderBy(),
|
||||
});
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
const product = await this.get(id);
|
||||
await this.productRepository.remove(product);
|
||||
}
|
||||
|
||||
async list() {
|
||||
return this.productRepository.find({
|
||||
order: { createdTime: 'DESC' },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { BaseVo } from '@/core/vo/base.vo';
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger';
|
||||
import { ProductVo } from '@/pet-feeder/vo/product.vo';
|
||||
|
||||
@ApiSchema({
|
||||
name: 'FeedingPlanProduct',
|
||||
})
|
||||
export class FeedingPlanProductVo extends BaseVo {
|
||||
@ApiProperty()
|
||||
dailyUsageWeight: number;
|
||||
|
||||
@ApiProperty()
|
||||
percentage: number;
|
||||
|
||||
@ApiProperty()
|
||||
product: ProductVo;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { BaseVo } from '@/core/vo/base.vo';
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger';
|
||||
import { FeedingGoal } from '@/pet-feeder/enum/feeding-goal';
|
||||
import { FeedingPlanProductVo } from '@/pet-feeder/vo/feeding-plan-product.vo';
|
||||
|
||||
@ApiSchema({
|
||||
name: 'FeedingPlan',
|
||||
})
|
||||
export class FeedingPlanVo extends BaseVo {
|
||||
@ApiProperty()
|
||||
targetWeight: number;
|
||||
|
||||
@ApiProperty()
|
||||
feedingGoal: FeedingGoal;
|
||||
|
||||
@ApiProperty()
|
||||
feedingPlanProducts: FeedingPlanProductVo[];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { BaseVo } from '@/core/vo/base.vo';
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger';
|
||||
|
||||
@ApiSchema({
|
||||
name: 'PetVariety',
|
||||
})
|
||||
export class PetVarietyVo extends BaseVo {
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { ApiProperty, ApiSchema } from '@nestjs/swagger';
|
||||
import { PetType } from '@/pet-feeder/enum/pet-type';
|
||||
import { Gender } from '@/core/enum/Gender';
|
||||
import { PetBodyType } from '@/pet-feeder/enum/pet-body-type';
|
||||
import { FeedingPlanVo } from '@/pet-feeder/vo/feeding-plan.vo';
|
||||
|
||||
@ApiSchema({
|
||||
name: 'Pet',
|
||||
@@ -15,6 +16,8 @@ export class PetVo extends TraceableVo {
|
||||
@ApiProperty()
|
||||
gender: Gender;
|
||||
@ApiProperty()
|
||||
varietyName: string;
|
||||
@ApiProperty()
|
||||
birthday: string;
|
||||
@ApiProperty()
|
||||
weight: number;
|
||||
@@ -32,4 +35,7 @@ export class PetVo extends TraceableVo {
|
||||
isLactation: boolean;
|
||||
@ApiProperty()
|
||||
bodyType: PetBodyType;
|
||||
|
||||
@ApiProperty()
|
||||
feedingPlan: FeedingPlanVo | null;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { BaseVo } from '@/core/vo/base.vo';
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger';
|
||||
import { ProductCategory } from '@/pet-feeder/enum/product-category';
|
||||
|
||||
@ApiSchema({
|
||||
name: 'Product',
|
||||
})
|
||||
export class ProductVo extends BaseVo {
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: [ProductCategory.DRY_FOOD, ProductCategory.WET_FOOD],
|
||||
})
|
||||
category: string;
|
||||
|
||||
@ApiProperty()
|
||||
photo: string;
|
||||
@ApiProperty()
|
||||
tags: string[];
|
||||
|
||||
@ApiProperty()
|
||||
totalWeight: number;
|
||||
|
||||
@ApiProperty()
|
||||
protein: number;
|
||||
|
||||
@ApiProperty()
|
||||
fat: number;
|
||||
|
||||
@ApiProperty()
|
||||
fiber: number;
|
||||
|
||||
@ApiProperty()
|
||||
ash: number;
|
||||
|
||||
@ApiProperty()
|
||||
moisture: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ME值(kcal/g),直接配置的代谢能,可选',
|
||||
required: false,
|
||||
})
|
||||
meValue: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: '产品总能量(kcal),基于ME算法计算或直接配置',
|
||||
})
|
||||
totalCalories: number;
|
||||
}
|
||||
Reference in new issue
Block a user