1 2(function () { 3 4 5 6 /*--------------------Inicio Services CCity --------------*/ 7 angular 8 .module( 'app.cModulo' ) 9 .service( 'cCityService', [ '$log', '$rootScope', '$location', '$http', 'urlService', function ( $log, $rootScope, $location, $http, urlService ) 10 { 11 // llamado para obtener la url dinamicamente 12 var urlHost = urlService.url(); 13 // llamado de patron rest 14 var patronREST = urlService.patron(); 15 // llamado para obtener la ip 16 var ipadd = urlService.ipadd(); 17 18 return{ 19 20 /** INICIO METODOS COMUNES **/ 21 22 // guardar un registro de CCity 23 guardar : function ( cCityData, usuarioData ) { 24 25 var url = urlHost + patronREST + 'ccity/guardar-service'; 26 var data = { 27 'usuario':usuarioData, 28 'objetoVO':cCityData 29 } 30 var config = { headers : { 'Content-Type':'application/json;charset=utf-8;', 'X-Http-adClientIdStr':usuarioData.adClientId, 'X-Http-adOrgIdStr':usuarioData.adOrgId, 'X-Http-userNameStr':usuarioData.username } }; 31 $log.debug('ccity-services guardar DATA_ENVIADA: url{} ',url,' - data{Object} ',data,' - config{} ',config); 32 33 return $http.put(url, data, config).then(requestCompleted, requestFailed); 34 35 function requestCompleted(response) { 36 37 $log.debug('ccity-services guardar then: response{} ',response); 38 urlService.updateTokenAuthorization(response); 39 return response.data; 40 } 41 42 function requestFailed(error) { 43 44 $log.debug('ccity-services guardar requestFailed: error{} ',error); 45 var newMessage = ''; 46 if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } } 47 if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); } 48 else if (error.status === 400) { if(!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; } 49 else if (error.status === 404) { if(!error.data) error.data = 'El recurso requerido no está disponible !'; } 50 else if (error.status < 500 || error.status > 500) { if(error.data=='No se encontró sesión activa, debes volver a ingresar.'){ urlService.cerrarSesion(); } else { if(!error.data) error.data = 'No fué posible realizar la operación !'; } } 51 else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); } 52 else { $rootScope.msgError = newMessage; $location.path('/infoPage'); } 53 urlService.updateTokenAuthorization(error); 54 return error; 55 56 } 57 }, 58 59 60 // actuliza un registro de CCity 61 actualizar : function ( cCityData, usuarioData ) { 62 63 var url = urlHost + patronREST + 'ccity/actualizar-service'; 64 var data = { 65 'usuario':usuarioData, 66 'objetoVO':cCityData 67 } 68 var config = { headers : { 'Content-Type':'application/json;charset=utf-8;', 'X-Http-adClientIdStr':usuarioData.adClientId, 'X-Http-adOrgIdStr':usuarioData.adOrgId, 'X-Http-userNameStr':usuarioData.username } }; 69 $log.debug('ccity-services actualizar DATA_ENVIADA: url{} ',url,' - data{Object} ',data,' - config{} ',config); 70 71 return $http.post(url, data, config).then(requestCompleted, requestFailed); 72 73 function requestCompleted(response) { 74 75 $log.debug('ccity-services actualizar then: response{} ',response); 76 urlService.updateTokenAuthorization(response); 77 return response.data; 78 } 79 80 function requestFailed(error) { 81 82 $log.debug('ccity-services actualizar requestFailed: error{} ',error); 83 var newMessage = ''; 84 if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } } 85 if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); } 86 else if (error.status === 400) { if(!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; } 87 else if (error.status === 404) { if(!error.data) error.data = 'El recurso requerido no está disponible !'; } 88 else if (error.status < 500 || error.status > 500) { if(error.data=='No se encontró sesión activa, debes volver a ingresar.'){ urlService.cerrarSesion(); } else { if(!error.data) error.data = 'No fué posible realizar la operación !'; } } 89 else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); } 90 else { $rootScope.msgError = newMessage; $location.path('/infoPage'); } 91 urlService.updateTokenAuthorization(error); 92 return error; 93 94 } 95 }, 96 97 98 // borrar un registro de CCity 99 borrar : function ( cCityData, usuarioData ) { 100 101 var url = urlHost + patronREST + 'ccity/borrar-service'; 102 var data = { 103 'usuario':usuarioData, 104 'objetoVO':cCityData 105 } 106 var config = { headers : { 'Content-Type':'application/json;charset=utf-8;', 'X-Http-adClientIdStr':usuarioData.adClientId, 'X-Http-adOrgIdStr':usuarioData.adOrgId, 'X-Http-userNameStr':usuarioData.username } }; 107 $log.debug('ccity-services borrar DATA_ENVIADA: url{} ',url,' - data{Object} ',data,' - config{} ',config); 108 109 return $http.post(url, data, config).then(requestCompleted, requestFailed); 110 111 function requestCompleted(response) { 112 113 $log.debug('ccity-services borrar then: response{} ',response); 114 urlService.updateTokenAuthorization(response); 115 return response.data; 116 } 117 118 function requestFailed(error) { 119 120 $log.debug('ccity-services borrar requestFailed: error{} ',error); 121 var newMessage = ''; 122 if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } } 123 if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); } 124 else if (error.status === 400) { if(!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; } 125 else if (error.status === 404) { if(!error.data) error.data = 'El recurso requerido no está disponible !'; } 126 else if (error.status < 500 || error.status > 500) { if(error.data=='No se encontró sesión activa, debes volver a ingresar.'){ urlService.cerrarSesion(); } else { if(!error.data) error.data = 'No fué posible realizar la operación !'; } } 127 else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); } 128 else { $rootScope.msgError = newMessage; $location.path('/infoPage'); } 129 urlService.updateTokenAuthorization(error); 130 return error; 131 132 } 133 }, 134 135 136 // consultar un registro de CCity 137 consultar : function ( key, usuarioData ){ 138 var url = urlHost + patronREST + 'ccity/consultar-service'; 139 var data = { 140 'usuario':usuarioData,
141 'objetoVO':{'cCityId':key} 142 } 143 var config = { headers : { 'Content-Type':'application/json;charset=utf-8;', 'X-Http-adClientIdStr':usuarioData.adClientId, 'X-Http-adOrgIdStr':usuarioData.adOrgId, 'X-Http-userNameStr':usuarioData.username } }; 144 $log.debug('ccity-services consultar DATA_ENVIADA: url{} ',url,' - data{Object} ',data,' - config{} ',config); 145 146 return $http.post(url, data, config).then(requestCompleted, requestFailed); 147 148 function requestCompleted(response) { 149 150 $log.debug('ccity-services consultar then: response{} ',response); 151 urlService.updateTokenAuthorization(response); 152 return response.data; 153 } 154 155 function requestFailed(error) { 156 157 $log.debug('ccity-services consultar requestFailed: error{} ',error); 158 var newMessage = ''; 159 if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } } 160 if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); } 161 else if (error.status === 400) { if(!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; } 162 else if (error.status === 404) { if(!error.data) error.data = 'El recurso requerido no está disponible !'; } 163 else if (error.status < 500 || error.status > 500) { if(error.data=='No se encontró sesión activa, debes volver a ingresar.'){ urlService.cerrarSesion(); } else { if(!error.data) error.data = 'No fué posible realizar la operación !'; } } 164 else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); } 165 else { $rootScope.msgError = newMessage; $location.path('/infoPage'); } 166 urlService.updateTokenAuthorization(error); 167 return error; 168 169 } 170 }, 171 172 173 // Listar CCity 174 listar : function ( cCityData, usuarioData ) { 175 var url = urlHost + patronREST + 'ccity/listar-service'; 176 var data = { 177 'usuario':usuarioData, 178 'objetoVO':cCityData 179 } 180 var config = { headers : { 'Content-Type':'application/json;charset=utf-8;', 'X-Http-adClientIdStr':usuarioData.adClientId, 'X-Http-adOrgIdStr':usuarioData.adOrgId, 'X-Http-userNameStr':usuarioData.username } }; 181 $log.debug('ccity-services listar DATA_ENVIADA: url{} ',url,' - data{Object} ',data,' - config{} ',config); 182 183 return $http.post(url, data, config).then(requestCompleted, requestFailed); 184 185 function requestCompleted(response) { 186 187 $log.debug('ccity-services listar then: response{} ',response); 188 urlService.updateTokenAuthorization(response); 189 return response.data; 190 } 191 192 function requestFailed(error) { 193 194 $log.debug('ccity-services listar requestFailed: error{} ',error); 195 var newMessage = ''; 196 if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } } 197 if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); } 198 else if (error.status === 400) { if(!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; } 199 else if (error.status === 404) { if(!error.data) error.data = 'El recurso requerido no está disponible !'; } 200 else if (error.status < 500 || error.status > 500) { if(error.data=='No se encontró sesión activa, debes volver a ingresar.'){ urlService.cerrarSesion(); } else { if(!error.data) error.data = 'No fué posible realizar la operación !'; } } 201 else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); } 202 else { $rootScope.msgError = newMessage; $location.path('/infoPage'); } 203 urlService.updateTokenAuthorization(error); 204 return error; 205 206 } 207 }, 208 209 /** FINAL METODOS COMUNES **/ 210 } 211 212 }]); 213 /*--------------------Final Services CCity --------------*/ 214 215})(); 216
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.