« Controller/Companies/CompaniesCompaniesList.pm
↑ Summary
Controller/Companies/CompaniesUsersList.pm »
| 1 | package Daje::Controller::Companies::CompaniesLoad; | ||
| 2 | use Mojo::Base 'Mojolicious::Controller', -base, -signatures; | ||
| 3 | use v5.42; | ||
| 4 | |||
| 5 | # NAME | ||
| 6 | # ==== | ||
| 7 | # | ||
| 8 | # Daje::Controller::CompaniesUsersList - Model class | ||
| 9 | # | ||
| 10 | # SYNOPSIS | ||
| 11 | # ======== | ||
| 12 | # | ||
| 13 | # use Daje::Controller::Companies::CompaniesUsersList; | ||
| 14 | # | ||
| 15 | # | ||
| 16 | # | ||
| 17 | # DESCRIPTION | ||
| 18 | # =========== | ||
| 19 | # | ||
| 20 | # Daje::Controller::Companies::vCompaniesUsersList is a standard controller | ||
| 21 | # | ||
| 22 | # METHODS | ||
| 23 | # ======= | ||
| 24 | # | ||
| 25 | # | ||
| 26 | # LICENSE | ||
| 27 | # ======= | ||
| 28 | # | ||
| 29 | # Copyright (C) janeskil1525. | ||
| 30 | # | ||
| 31 | # This library is free software; you can redistribute it and/or modify | ||
| 32 | # it under the same terms as Perl itself. | ||
| 33 | # | ||
| 34 | # AUTHOR | ||
| 35 | # ====== | ||
| 36 | # | ||
| 37 | # janeskil1525 E<lt>janeskil1525@gmail.com | ||
| 38 | # | ||
| 39 | |||
| 40 | # This file is generated automatically by Daje Tools 2026-02-02 15:02:14. | ||
| 41 | # It will not be re-generated by Daje Tools again. | ||
| 42 | # <!-- Autogenerated file 2026-02-02 15:02:14 --> | ||
| 43 | |||
| 44 | use Mojo::JSON qw{from_json}; | ||
| 45 | use Data::Dumper; | ||
| 46 | |||
| 47 | our $VERSION = '0.01'; | ||
| 48 | |||
| 49 | |||
| 50 | sub load_all_companies_for_user($self) { | ||
| 51 | |||
| 52 | $self->app->log->debug('Daje::Controller::Companies::CompaniesLoad::load_all_companies_for_user start '); | ||
| 53 | $self->render_later; | ||
| 54 | |||
| 55 | my ($companies_pkey, $users_pkey) = $self->jwt->companies_users_pkey( | ||
| 56 | $self->req->headers->header('X-Token-Check') | ||
| 57 | ); | ||
| 58 | my $data = from_json($self->req->body); | ||
| 59 | |||
| 60 | $self->companies->load_companies_from_user_mail_p($data->{mail})->then(sub($result) { | ||
| 61 | $self->render(json => { result => 'success', data => $result }); | ||
| 62 | })->catch(sub($err) { | ||
| 63 | $self->app->log->error('Daje::Controller::Companies::CompaniesLoad ' . $err); | ||
| 64 | $self->render(json => {result => 'failed', data => $err}); | ||
| 65 | }); | ||
| 66 | $self->app->log->debug('Daje::Controller::Companies::CompaniesLoad::load_all_companies_for_user end '); | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | 1; | ||
| 71 |