{"id":372680,"date":"2024-05-21T05:18:13","date_gmt":"2024-05-21T05:18:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=372680"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=372680","title":{"rendered":"<span>PrimeNG + NestJS + Yandex = \u0440\u0435\u0447\u0435\u0432\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0440\u0435\u0447\u0435\u0432\u0443\u044e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442-\u0446\u0435\u043d\u0442\u0440\u0430. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 Yandex Speechkit, \u0430 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0443\u0440\u0435, \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438. \u041f\u043e \u0445\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c.  <\/p>\n<p><strong>1. Yandex Speechkit<\/strong>. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0442\u0435\u043a\u0441\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0437\u0430\u0445\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043f\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u043f\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0442\u0438\u0445\u0438\u0435 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u043e\u0433\u0434\u0430 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0430 \u0435\u043b\u0435 \u0441\u043b\u044b\u0448\u043d\u043e, \u043d\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b, \u0432 \u043e\u0442\u0432\u0435\u0442\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0435 \u0432\u0441\u0435 \u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u0430\u0437\u0430\u0445\u0441\u043a\u0438\u0439 \u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a\u0438, \u0442\u043e \u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c lang = auto. \u0418 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f, \u043a\u0430\u043a\u0438\u0435 \u0432 \u0442\u0440\u0435\u043a\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u044f\u0437\u044b\u043a\u0438, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0438\u043f\u0430 [ ru, kz ], \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e [ kz ]. \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e [ ru ]. \u041d\u043e \u043f\u043e\u043a\u0430 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u043d\u0435\u0442, \u0445\u043e\u0442\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 \u043e\u0431\u0435\u0449\u0430\u0435\u0442.<\/p>\n<p><strong>2. \u041f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0443\u0434\u0438\u043e<\/strong> \u0432 <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/speech-transcript-form\/SP0003\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438<\/a>. \u041a\u0430\u0440\u0442\u043e\u0447\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0432\u0441\u0435 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u0445 ))), \u0432\u0432\u0435\u0440\u0445\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u0431\u0435\u0433\u0443\u043d\u043e\u043a \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u043d\u0438\u0437\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0434\u0438\u0430\u043b\u043e\u0433\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/12e\/1ec\/500\/12e1ec500367f14bd0aa08df1b434397.png\" width=\"1547\" height=\"896\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/12e\/1ec\/500\/12e1ec500367f14bd0aa08df1b434397.png\"\/><\/figure>\n<p>\u041f\u043e \u043a\u043b\u0438\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043b \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0430\u0443\u0434\u0438\u043e. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 audio, \u0438 \u0443 \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b. \u041a \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u043b\u0435 start_time, \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u043e \u043a\u043b\u0438\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 audio, \u0432 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b:<\/p>\n<p><code>this.audio = document.querySelector('audio');<\/p>\n<p>playAudioOnClickOnItem(time: number) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 this.audio.currentTime = time; \/\/ \u0412 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445<br \/>\u00a0 \u00a0 \u00a0 \u00a0 this.audio.play();<br \/>}<\/code><\/p>\n<p><strong>3. \u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432 \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445, \u0438 \u0442\u0435\u0433\u0438<\/strong>. \u0412 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c \u0441\u043b\u043e\u0432\u0430. \u0422\u0430\u043a\u0436\u0435 \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0442\u0435\u0433\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u0412\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441, \u0433\u0434\u0435 \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u044d\u0442\u0443 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a? \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0444\u0440\u043e\u043d\u0442\u0430. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0430 \u0431\u0435\u043a\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0435\u043f\u043b\u0438\u043a\u0438, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0437\u0430\u043e\u0434\u043d\u043e \u0438 \u0442\u0435\u0433\u0438 \u043d\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435, \u0442\u043e \u0441 \u0431\u0435\u043a\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0433\u0434\u0435 \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0441\u043b\u043e\u0432. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0431\u0435\u043a\u0435. \u0421 \u0431\u0435\u043a\u0430 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430\u044f html \u0441\u0442\u0440\u043e\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0442\u0438\u043b\u0438, \u0438 \u0444\u0440\u043e\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/30d\/32b\/434\/30d32b4342e89ff8f633fe861bc55b0a.png\" width=\"1253\" height=\"344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/30d\/32b\/434\/30d32b4342e89ff8f633fe861bc55b0a.png\"\/><\/figure>\n<p><strong>4. \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432 \u0432 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435.<\/strong> <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/fragment\" rel=\"noopener noreferrer nofollow\">\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b <\/a>\u043d\u0443\u0436\u043d\u044b \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430, \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435. \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u043b\u043e\u0432. \u0424\u0440\u043e\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0442 \u0431\u0435\u043a\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u043e\u0432, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u041d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0444\u043e\u0440\u043c\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u043e\u0432, \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u0430, \u0438 \u0442.\u043f. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 \u00ab\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c\u00bb \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u043b\u043e\u0432  \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u043a.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0a6\/d24\/986\/0a6d2498651dac973dd46fdfbf94318f.png\" width=\"1477\" height=\"929\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a6\/d24\/986\/0a6d2498651dac973dd46fdfbf94318f.png\"\/><\/figure>\n<p><strong>5. \u0412\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/strong>. \u041e\u0431\u044b\u0447\u043d\u043e \u0432 <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/speech-transcript\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/a> \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439. \u041d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0430\u0443\u0434\u0438\u043e, \u043f\u043e\u043b\u0435\u0439 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u00ab\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u00bb \u0438\u043b\u0438 \u00ab\u0418\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u00bb \u0437\u0432\u043e\u043d\u043e\u043a, \u0434\u043e \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0430, \u0433\u043e\u0440\u043e\u0434\u0430, \u0431\u0430\u043b\u043b\u043e\u0432 \u0437\u0430 \u0437\u0432\u043e\u043d\u043e\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438 \u0442.\u00a0\u0434.  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0432\u043e\u043d\u043a\u043e\u0432 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u043c\u0438. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430\u044f (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f) \u044d\u0442\u043e \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441 ID \u0437\u0432\u043e\u043d\u043a\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u0437\u0432\u043e\u043d\u043a\u0430. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3bf\/3fc\/8ca\/3bf3fc8caf5069fcf55b7364c33a9c2f.png\" width=\"1477\" height=\"929\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bf\/3fc\/8ca\/3bf3fc8caf5069fcf55b7364c33a9c2f.png\"\/><\/figure>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043a\u0443\u043a\u0430\u0445 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u0432\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435.<\/p>\n<p><strong>6. JWT \u0438 \u0443\u0447\u0435\u0442\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/strong> \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430\u0445 \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0440\u043e\u043b\u0438 \u0432 NestJs, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0442\u0435\u043c\u0430 \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0430\u0432\u0442\u043e\u0440 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d JWT, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 strategies \u0438 guards, \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442. \u041d\u043e \u044d\u0442\u043e \u0432\u0435\u0434\u044c \u0433\u0434\u0435 \u0442\u043e 5-10% \u043e\u0442 \u0442\u0435\u043c\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0430\u0447\u0430\u0442\u044c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e  \u043d\u0430 \u0431\u0435\u043a\u0435 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0441 \u044d\u0442\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0447\u0435\u0442\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0432\u043d\u0430 \u0435\u0433\u043e email. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 payload \u0432\u043d\u0443\u0442\u0440\u0438 JWT \u0442\u043e\u043a\u0435\u043d\u0430. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 JWT \u0442\u043e\u043a\u0435\u043d:  <\/p>\n<p><code>async login(user: any) {<\/p>\n<p>\u00a0 \u00a0 const payload = {  <br \/>\u00a0 \u00a0 \u00a0 email: user.email,  <br \/>\u00a0 \u00a0 \u00a0 username: user.username,<br \/>\u00a0 \u00a0 \u00a0 role: user.role<br \/>\u00a0 \u00a0 };<\/p>\n<p>\u00a0 \u00a0 return {<br \/>\u00a0 \u00a0 \u00a0 access_token: this.jwtService.sign(payload),<br \/>\u00a0 \u00a0 };<br \/>}<\/code><\/p>\n<p>\u0422\u043e \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043f\u043e\u043b\u0435 \u0438\u0437 payload, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 email:<\/p>\n<p> <code>export const User = createParamDecorator(<br \/>\u00a0 (data: any, ctx: ExecutionContext): string => {<br \/>\u00a0 const request = ctx.switchToHttp().getRequest();<\/p>\n<p>\u00a0 if(  <br \/>\u00a0 \u00a0 request.user !== undefined  <br \/>\u00a0 \u00a0 &amp;&amp;<br \/>\u00a0 \u00a0 request.user.email !== undefined<br \/>\u00a0 )<br \/>\u00a0 {<br \/>\u00a0 \u00a0 return request.user.email;<br \/>\u00a0 }<br \/>\u00a0 else {<br \/>\u00a0 \u00a0 return 'unknown_user'<br \/>\u00a0 }<br \/>});<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u0438 \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439:<\/p>\n<p><code>import { User } from '..\/user\/user.decorator';<\/p>\n<p>\u00a0 @Get()<br \/>\u00a0 @ApiOperation({ summary: '\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u043e\u0432' })<br \/>\u00a0 @ApiOkResponse({ description: '\u0421\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u043e\u0432', type: SpeechEntity, isArray: true })<br \/>\u00a0 findAll(@User() userMail: string): Promise&lt;SpeechEntity[]> {<br \/>\u00a0 \u00a0 return this.speechService.findAll( userMail );<br \/>\u00a0 }<\/code><\/p>\n<p><strong>7. \u0420\u043e\u043b\u0438 \u0438 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/strong> \u2014 \u0441\u0430\u043c\u0430\u044f \u0441\u043f\u043e\u0440\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0413\u0434\u0435 \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 NestJs \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430? \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0438\u043b\u0438 \u0432 \u0443\u0436\u0435 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435?<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435, \u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0434\u0435 \u043e\u043d \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439. \u0422\u043e\u0433\u0434\u0430:<\/p>\n<\/li>\n<\/ol>\n<p><code>@Get()<br \/>@ApiOperation({ summary: '\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432' })<br \/>@ApiOkResponse({ description: '\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432', type: ContactEntity, isArray: true })<br \/>findAll( @User() userMail: string ): Promise&lt;ContactEntity[]> {<br \/>\u00a0 \u00a0 const userAccessWhereOptions = this.userService.getUserAccessWhereOptions( userMail, controllerName );<br \/>\u00a0 \u00a0 return this.contactService.findAll( userAccessWhereOptions);<br \/>}<\/code><\/p>\n<ol start=\"3\">\n<li>\n<p>\u041d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 findAll \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 category = new, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0441\u0442\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443. \u0410 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u00ab\u0441\u0432\u043e\u0438\u00bb \u0437\u0430\u043f\u0438\u0441\u0438, \u044d\u0442\u043e \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043b\u0438 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0440. \u0422\u043e\u0433\u0434\u0430 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 findAll \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u0418\u041b\u0418, \u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 category = new \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. <\/p>\n<\/li>\n<li>\n<p>\u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0430 deleted = yes. \u0418 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u00ab\u0441\u0432\u043e\u0438\u00bb \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 deleted = no, \u0430 \u0430\u0434\u043c\u0438\u043d \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f find, \u0443\u0436\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0438 \u0432 \u043d\u0435\u043c \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<p><code>where = [<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'owner': userEmail,\u00a0\/\/ \u041e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u0437\u0430\u043f\u0438\u0441\u044c<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }, \/\/ \u0418\u041b\u0418<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'father': userEmail,\u00a0\/\/ \u0421\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>];<\/code><\/p>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438 findAll \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f  \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u043d\u0438\u043c\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f:<\/p>\n<p><code>async findAll( userAccessWhereOptions: {}[] ): Promise&lt;ContactEntity[]> {<br \/>\u00a0 \u00a0 const options: FindManyOptions = {  <br \/>\u00a0 \u00a0 \u00a0 where: UtilWhereAssign(<br \/>\u00a0 \u00a0 \u00a0 \u00a0  userAccessWhereOptions,<br \/>\u00a0 \u00a0 \u00a0 \u00a0  {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0  }<br \/>\u00a0 \u00a0 \u00a0 ),<br \/>\u00a0 \u00a0 \u00a0 order: { updated: 'DESC' },<br \/>\u00a0 \u00a0 };<br \/>  \u00a0 const result = await this.contactRepository.find( options );<br \/>  \u00a0 return result;<br \/>}<\/code><\/p>\n<p>\u0418\u0437 UtilWhereAssign  \u0434\u043b\u044f \u00ab\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u00bb \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f  \u043d\u043e\u0432\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<p><code>where = [<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'owner': userEmail,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no',<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }, \/\/ \u0418\u041b\u0418<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'father': userEmail,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no',<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>];<\/code><\/p>\n<p><strong>7. \u041d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/strong> \u041d\u043e \u0435\u0449\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041d\u0430 \u0431\u0435\u043a\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <a href=\"https:\/\/demo.crm.kz\/#\/role\" rel=\"noopener noreferrer nofollow\">\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/a>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0442\u043e \u0444\u0440\u043e\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c\u00bb, \u0438\u043b\u0438 \u00ab\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c\u00bb, \u0438 \u0442.\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6cc\/346\/d7b\/6cc346d7b78e21484d32f0f832303abd.png\" width=\"1477\" height=\"929\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6cc\/346\/d7b\/6cc346d7b78e21484d32f0f832303abd.png\"\/><\/figure>\n<p><strong>8. \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/strong> \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b, \u043a\u0442\u043e \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u043e\u0441\u0438\u043b \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c historyService, \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 create, update, remove \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 historyService, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e ID \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0441\u0434\u0435\u043b\u0430\u043d \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 calcChangeAndCreate \u0432 historyService, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0438 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 update \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430:<\/p>\n<p><code>async update(recordId: string, updateDto: ContactUpdateDTO, userMail: string): Promise&lt;ContactEntity>\u00a0 {<br \/>\u00a0 \u00a0 const options = {<br \/>  \u00a0 \u00a0 \u00a0 where: [{ 'id': recordId }]<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 const oldResult = await this.contactRepository.findOne( options );<br \/>    await this.contactRepository.update( { \"id\": recordId }, updateDto);<br \/>\u00a0 \u00a0 const newResult = await this.contactRepository.findOne( options );<\/p>\n<p>  \u00a0 await this.historyService.calcChangeAndCreate( 'contact', newResult, oldResult, userMail, recordId );<\/p>\n<p>\u00a0 \u00a0 return newResult;<br \/>}<\/code><\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 calcChangeAndCreate \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044f \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p><code>calcChange( newEntity: object, oldEntity: object ): HistoryRecordChange {<br \/>\u00a0 \u00a0 let result = {} as HistoryRecordChange;<br \/>  \u00a0 result.fieldChangeList = []; \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438, HistoryFieldChange<br \/>\u00a0 \u00a0 result.haveChange = false; \/\/ \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435\u0442<br \/>\u00a0 \u00a0 result.user = 'no_user';<br \/>\u00a0 \u00a0 result.table = 'no_table';<br \/>\u00a0 \u00a0 result.record = 'no_record';<\/code><\/p>\n<p><code><br \/>\u00a0 \u00a0 for( let key of Object.keys( newEntity) ) {<br \/>\u00a0 \u00a0 \u00a0 if( key != 'created' &amp;&amp; key != 'updated' \u00a0) { \/\/ \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u0432\u0442\u043e \u043f\u043e\u043b\u0435<br \/>  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0422\u0438\u043f \u0434\u0430\u0442\u0430 \u0438\u0437 mysql \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0430 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 let newValue: string;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if(<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 typeof newEntity[key] == 'object'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &amp;&amp;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 newEntity[key] != null<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 newValue = newEntity[key].toISOString() + ' (UTC)';<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 else {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 newValue = newEntity[key];<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0422\u0438\u043f \u0434\u0430\u0442\u0430 \u0438\u0437 mysql \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0430 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 let oldValue: string;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if(<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 typeof oldEntity[key] == 'object'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &amp;&amp;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 oldEntity[key] != null<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 oldValue = oldEntity[key].toISOString() + ' (UTC)';<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 else {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 oldValue = oldEntity[key];<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 if( newValue != oldValue ) { \/\/ \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0435 \u0435\u0441\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f<br \/>    \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 result.haveChange = true;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 let fieldChange = {} as HistoryFieldChange;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fieldChange.field = key;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fieldChange.oldValue = oldValue;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fieldChange.newValue = newValue;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 result.fieldChangeList.push( fieldChange );<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 }<\/p>\n<p>      return result;<br \/>}<\/code><\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0415\u0449\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430. \u041e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0438\u0448\u0435\u043c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0430\u0435\u043c <a href=\"https:\/\/demo.crm.kz\/#\/contact-form\/e9644875-2827-43ba-aee9-65b1607a9cf9\" rel=\"noopener noreferrer nofollow\">\u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u00ab\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439\u00bb<\/a>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/348\/93b\/98f\/34893b98f3f18de69d3258a22e6e6b47.png\" width=\"1477\" height=\"929\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/348\/93b\/98f\/34893b98f3f18de69d3258a22e6e6b47.png\"\/><\/figure>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0440\u0435\u043c\u044f, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0431\u0435\u043a\u0430 \u043d\u0430 NestJs \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0438 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0421\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a\u0438 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043a\u0430\u043d\u0430\u043b \u0435\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <s>\u043d\u043e\u0432\u043e\u0435 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e \u043a\u043e\u0442\u044f\u0442<\/s> ))) \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0431\u0435\u043a\u0430.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u043f\u044b \u043d\u0430 \u0433\u0438\u0442\u0435, \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438. \u041d\u043e \u044f \u0447\u0442\u043e \u0442\u043e \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043d\u0430 \u0433\u0438\u0442\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0431\u0435\u043a\u0430 \u043d\u0430 NestJs. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/805159\/\"> https:\/\/habr.com\/ru\/articles\/805159\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0440\u0435\u0447\u0435\u0432\u0443\u044e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442-\u0446\u0435\u043d\u0442\u0440\u0430. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 Yandex Speechkit, \u0430 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0443\u0440\u0435, \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438. \u041f\u043e \u0445\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c.  <\/p>\n<p><strong>1. Yandex Speechkit<\/strong>. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0442\u0435\u043a\u0441\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0437\u0430\u0445\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043f\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u043f\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0442\u0438\u0445\u0438\u0435 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u043e\u0433\u0434\u0430 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0430 \u0435\u043b\u0435 \u0441\u043b\u044b\u0448\u043d\u043e, \u043d\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b, \u0432 \u043e\u0442\u0432\u0435\u0442\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0435 \u0432\u0441\u0435 \u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u0430\u0437\u0430\u0445\u0441\u043a\u0438\u0439 \u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a\u0438, \u0442\u043e \u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c lang = auto. \u0418 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f, \u043a\u0430\u043a\u0438\u0435 \u0432 \u0442\u0440\u0435\u043a\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u044f\u0437\u044b\u043a\u0438, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0438\u043f\u0430 [ ru, kz ], \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e [ kz ]. \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e [ ru ]. \u041d\u043e \u043f\u043e\u043a\u0430 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u043d\u0435\u0442, \u0445\u043e\u0442\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 \u043e\u0431\u0435\u0449\u0430\u0435\u0442.<\/p>\n<p><strong>2. \u041f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0443\u0434\u0438\u043e<\/strong> \u0432 <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/speech-transcript-form\/SP0003\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438<\/a>. \u041a\u0430\u0440\u0442\u043e\u0447\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0432\u0441\u0435 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u0445 ))), \u0432\u0432\u0435\u0440\u0445\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u0431\u0435\u0433\u0443\u043d\u043e\u043a \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u043d\u0438\u0437\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0434\u0438\u0430\u043b\u043e\u0433\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e \u043a\u043b\u0438\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043b \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0430\u0443\u0434\u0438\u043e. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 audio, \u0438 \u0443 \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b. \u041a \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u043b\u0435 start_time, \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u0443\u0434\u0438\u043e \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u043e \u043a\u043b\u0438\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 audio, \u0432 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b:<\/p>\n<p><code>this.audio = document.querySelector('audio');<\/p>\n<p>playAudioOnClickOnItem(time: number) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 this.audio.currentTime = time; \/\/ \u0412 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445<br \/>\u00a0 \u00a0 \u00a0 \u00a0 this.audio.play();<br \/>}<\/code><\/p>\n<p><strong>3. \u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432 \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445, \u0438 \u0442\u0435\u0433\u0438<\/strong>. \u0412 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c \u0441\u043b\u043e\u0432\u0430. \u0422\u0430\u043a\u0436\u0435 \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0442\u0435\u0433\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u0412\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441, \u0433\u0434\u0435 \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u044d\u0442\u0443 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a? \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0444\u0440\u043e\u043d\u0442\u0430. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0430 \u0431\u0435\u043a\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0435\u043f\u043b\u0438\u043a\u0438, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0437\u0430\u043e\u0434\u043d\u043e \u0438 \u0442\u0435\u0433\u0438 \u043d\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435, \u0442\u043e \u0441 \u0431\u0435\u043a\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0433\u0434\u0435 \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0441\u043b\u043e\u0432. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0431\u0435\u043a\u0435. \u0421 \u0431\u0435\u043a\u0430 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430\u044f html \u0441\u0442\u0440\u043e\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0442\u0438\u043b\u0438, \u0438 \u0444\u0440\u043e\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>4. \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432 \u0432 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435.<\/strong> <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/fragment\" rel=\"noopener noreferrer nofollow\">\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b <\/a>\u043d\u0443\u0436\u043d\u044b \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430, \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435. \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u043b\u043e\u0432. \u0424\u0440\u043e\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0442 \u0431\u0435\u043a\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u043e\u0432, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u041d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0444\u043e\u0440\u043c\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u043e\u0432, \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u0430, \u0438 \u0442.\u043f. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 \u00ab\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c\u00bb \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441 \u043d\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u043b\u043e\u0432  \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u043a.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>5. \u0412\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/strong>. \u041e\u0431\u044b\u0447\u043d\u043e \u0432 <a href=\"https:\/\/speechkit-demo.crm.kz\/#\/speech-transcript\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/a> \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439. \u041d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0430\u0443\u0434\u0438\u043e, \u043f\u043e\u043b\u0435\u0439 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u00ab\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u00bb \u0438\u043b\u0438 \u00ab\u0418\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u00bb \u0437\u0432\u043e\u043d\u043e\u043a, \u0434\u043e \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0430, \u0433\u043e\u0440\u043e\u0434\u0430, \u0431\u0430\u043b\u043b\u043e\u0432 \u0437\u0430 \u0437\u0432\u043e\u043d\u043e\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438 \u0442.\u00a0\u0434.  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0437\u0432\u043e\u043d\u043a\u043e\u0432 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u043c\u0438. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430\u044f (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f) \u044d\u0442\u043e \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441 ID \u0437\u0432\u043e\u043d\u043a\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u0437\u0432\u043e\u043d\u043a\u0430. <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043a\u0443\u043a\u0430\u0445 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u0432\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435.<\/p>\n<p><strong>6. JWT \u0438 \u0443\u0447\u0435\u0442\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/strong> \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430\u0445 \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0440\u043e\u043b\u0438 \u0432 NestJs, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0442\u0435\u043c\u0430 \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0430\u0432\u0442\u043e\u0440 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d JWT, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 strategies \u0438 guards, \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442. \u041d\u043e \u044d\u0442\u043e \u0432\u0435\u0434\u044c \u0433\u0434\u0435 \u0442\u043e 5-10% \u043e\u0442 \u0442\u0435\u043c\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u043e\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0430\u0447\u0430\u0442\u044c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e  \u043d\u0430 \u0431\u0435\u043a\u0435 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0441 \u044d\u0442\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0447\u0435\u0442\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0432\u043d\u0430 \u0435\u0433\u043e email. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 payload \u0432\u043d\u0443\u0442\u0440\u0438 JWT \u0442\u043e\u043a\u0435\u043d\u0430. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 JWT \u0442\u043e\u043a\u0435\u043d:  <\/p>\n<p><code>async login(user: any) {<\/p>\n<p>\u00a0 \u00a0 const payload = {  <br \/>\u00a0 \u00a0 \u00a0 email: user.email,  <br \/>\u00a0 \u00a0 \u00a0 username: user.username,<br \/>\u00a0 \u00a0 \u00a0 role: user.role<br \/>\u00a0 \u00a0 };<\/p>\n<p>\u00a0 \u00a0 return {<br \/>\u00a0 \u00a0 \u00a0 access_token: this.jwtService.sign(payload),<br \/>\u00a0 \u00a0 };<br \/>}<\/code><\/p>\n<p>\u0422\u043e \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043f\u043e\u043b\u0435 \u0438\u0437 payload, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 email:<\/p>\n<p> <code>export const User = createParamDecorator(<br \/>\u00a0 (data: any, ctx: ExecutionContext): string => {<br \/>\u00a0 const request = ctx.switchToHttp().getRequest();<\/p>\n<p>\u00a0 if(  <br \/>\u00a0 \u00a0 request.user !== undefined  <br \/>\u00a0 \u00a0 &amp;&amp;<br \/>\u00a0 \u00a0 request.user.email !== undefined<br \/>\u00a0 )<br \/>\u00a0 {<br \/>\u00a0 \u00a0 return request.user.email;<br \/>\u00a0 }<br \/>\u00a0 else {<br \/>\u00a0 \u00a0 return 'unknown_user'<br \/>\u00a0 }<br \/>});<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u0438 \u0447\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439:<\/p>\n<p><code>import { User } from '..\/user\/user.decorator';<\/p>\n<p>\u00a0 @Get()<br \/>\u00a0 @ApiOperation({ summary: '\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u043e\u0432' })<br \/>\u00a0 @ApiOkResponse({ description: '\u0421\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u043e\u0432', type: SpeechEntity, isArray: true })<br \/>\u00a0 findAll(@User() userMail: string): Promise&lt;SpeechEntity[]> {<br \/>\u00a0 \u00a0 return this.speechService.findAll( userMail );<br \/>\u00a0 }<\/code><\/p>\n<p><strong>7. \u0420\u043e\u043b\u0438 \u0438 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/strong> \u2014 \u0441\u0430\u043c\u0430\u044f \u0441\u043f\u043e\u0440\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0413\u0434\u0435 \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 NestJs \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430? \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0438\u043b\u0438 \u0432 \u0443\u0436\u0435 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435?<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435, \u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0434\u0435 \u043e\u043d \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439. \u0422\u043e\u0433\u0434\u0430:<\/p>\n<\/li>\n<\/ol>\n<p><code>@Get()<br \/>@ApiOperation({ summary: '\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432' })<br \/>@ApiOkResponse({ description: '\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432', type: ContactEntity, isArray: true })<br \/>findAll( @User() userMail: string ): Promise&lt;ContactEntity[]> {<br \/>\u00a0 \u00a0 const userAccessWhereOptions = this.userService.getUserAccessWhereOptions( userMail, controllerName );<br \/>\u00a0 \u00a0 return this.contactService.findAll( userAccessWhereOptions);<br \/>}<\/code><\/p>\n<ol start=\"3\">\n<li>\n<p>\u041d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 findAll \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 category = new, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0441\u0442\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443. \u0410 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u00ab\u0441\u0432\u043e\u0438\u00bb \u0437\u0430\u043f\u0438\u0441\u0438, \u044d\u0442\u043e \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043b\u0438 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0440. \u0422\u043e\u0433\u0434\u0430 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 findAll \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u0418\u041b\u0418, \u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 category = new \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. <\/p>\n<\/li>\n<li>\n<p>\u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0430 deleted = yes. \u0418 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u00ab\u0441\u0432\u043e\u0438\u00bb \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 deleted = no, \u0430 \u0430\u0434\u043c\u0438\u043d \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f find, \u0443\u0436\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0438 \u0432 \u043d\u0435\u043c \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<p><code>where = [<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'owner': userEmail,\u00a0\/\/ \u041e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u0437\u0430\u043f\u0438\u0441\u044c<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }, \/\/ \u0418\u041b\u0418<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'father': userEmail,\u00a0\/\/ \u0421\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043f\u0438\u0441\u0438<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>];<\/code><\/p>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438 findAll \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f  \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u043d\u0438\u043c\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f:<\/p>\n<p><code>async findAll( userAccessWhereOptions: {}[] ): Promise&lt;ContactEntity[]> {<br \/>\u00a0 \u00a0 const options: FindManyOptions = {  <br \/>\u00a0 \u00a0 \u00a0 where: UtilWhereAssign(<br \/>\u00a0 \u00a0 \u00a0 \u00a0  userAccessWhereOptions,<br \/>\u00a0 \u00a0 \u00a0 \u00a0  {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0  }<br \/>\u00a0 \u00a0 \u00a0 ),<br \/>\u00a0 \u00a0 \u00a0 order: { updated: 'DESC' },<br \/>\u00a0 \u00a0 };<br \/>  \u00a0 const result = await this.contactRepository.find( options );<br \/>  \u00a0 return result;<br \/>}<\/code><\/p>\n<p>\u0418\u0437 UtilWhereAssign  \u0434\u043b\u044f \u00ab\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u00bb \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f  \u043d\u043e\u0432\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<p><code>where = [<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'owner': userEmail,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no',<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }, \/\/ \u0418\u041b\u0418<br \/>\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'father': userEmail,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'deleted': 'no',<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'category': 'new'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>];<\/code><\/p>\n<p><strong>7. \u041d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/strong> \u041d\u043e \u0435\u0449\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041d\u0430 \u0431\u0435\u043a\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <a href=\"https:\/\/demo.crm.kz\/#\/role\" rel=\"noopener noreferrer nofollow\">\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/a>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0442\u043e \u0444\u0440\u043e\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c\u00bb, \u0438\u043b\u0438 \u00ab\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c\u00bb, \u0438 \u0442.\u0434.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>8. \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/strong> \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b, \u043a\u0442\u043e \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u043e\u0441\u0438\u043b \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c historyService, \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 create, update, remove \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 historyService, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e ID \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0441\u0434\u0435\u043b\u0430\u043d \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 calcChangeAndCreate \u0432 historyService, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0438 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 update \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430:<\/p>\n<p><code>async update(recordId: string, updateDto: ContactUpdateDTO, userMail: string): Promise&lt;ContactEntity>\u00a0 {<br \/>\u00a0 \u00a0 const options = {<br \/>  \u00a0 \u00a0 \u00a0 where: [{ 'id': recordId }]<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 const oldResult = await this.contactRepository.findOne( options );<br \/>    await this.contactRepository.update( { \"id\": recordId }, updateDto);<br \/>\u00a0 \u00a0 const newResult = await this.contactRepository.findOne( options );<\/p>\n<p>  \u00a0 await this.historyService.calcChangeAndCreate( 'contact', newResult, oldResult, userMail, recordId );<\/p>\n<p>\u00a0 \u00a0 return newResult;<br \/>}<\/code><\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 calcChangeAndCreate \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044f \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p><code>calcChange( newEntity: object, oldEntity: object ): HistoryRecordChange {<br \/>\u00a0 \u00a0 let result = {} as HistoryRecordChange;<br \/>  \u00a0 result.fieldChangeList = []; \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438, HistoryFieldChange<br \/>\u00a0 \u00a0 result.haveChange = false; \/\/ \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435\u0442<br \/>\u00a0 \u00a0 result.user = 'no_user';<br \/>\u00a0 \u00a0 result.table = 'no_table';<br \/>\u00a0 \u00a0 result.record = 'no_record';<\/code><\/p>\n<p><code><br \/>\u00a0 \u00a0 for( let key of Object.keys( newEntity) ) {<br \/>\u00a0 \u00a0 \u00a0 if( key != 'created' &amp;&amp; key != 'updated' \u00a0) { \/\/ \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u0432\u0442\u043e \u043f\u043e\u043b\u0435<br \/>  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0422\u0438\u043f \u0434\u0430\u0442\u0430 \u0438\u0437 mysql \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0430 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 let newValue: string;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if(<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 typeof newEntity[key] == 'object'<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &amp;&amp;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 newEntity[key] != null<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 newValue = newEntity[key].toISOString() + ' (UTC)';<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 else {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/code><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-372680","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=372680"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372680\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=372680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=372680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=372680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}