.. _smev3_adapter_templates: Шаблоны ^^^^^^^ Пример шаблона XML ################## .. code-block:: xml {{ sql("legalEntities", "select * from LegalEntity le, LegalEntityAddress lea, LegalEntityCEO lec where le.OGRN=lea.OGRN and le.OGRN=lec.OGRN and lea.dateTo is null and lec.dateTo is null and le.name like ?", "%" + xpath("//*[local-name() = 'search']") + "%") }} {% for le in rows.legalEntities %} {{le.ogrn}} {{le.inn}} {{le.kpp}} {{le.name}} {{le.address}} {{le.fio}} {{ sql("ceos", "select * from LegalEntityCEO where OGRN=? and dateTo is not null", le.ogrn) }} {% for ceo in rows.ceos %} {% endfor %} {{ sql("addresses", "select * from LegalEntityAddress where OGRN=? and dateTo is not null", le.ogrn) }} {% for address in rows.addresses %}
{% endfor %} {% endfor %} Пример шаблона JSON ################### .. code-block:: javascript { "legalEntities": { "search": "{{ search }}", "requestId": "{{ requestId }}", "legalEntity": [ {{ sql("legalEntities", "select * from LegalEntity le, LegalEntityAddress lea, LegalEntityCEO lec where le.OGRN=lea.OGRN and le.OGRN=lec.OGRN and lea.dateTo is null and lec.dateTo is null and le.name like ?", "%" + search + "%") }} {% for le in rows.legalEntities %} { "ogrn": "{{le.ogrn}}", "inn": "{{le.inn}}", "kpp": "{{le.kpp}}", "name": "{{le.name}}", "legalAddress": "{{le.address}}", "ceo": "{{le.fio}}", "ceohistory": { "ceo": [ {{ sql("ceos", "select * from LegalEntityCEO where OGRN=? and dateTo is not null", le.ogrn) }} {% for ceo in rows.ceos %} { "from": "{{ceo.datefrom}}", "to": "{{ceo.dateto}}", "fio": "{{ceo.fio}}" } {% if not loop.last %} , {% endif %} {% endfor %} ]}, "addressHistory": { "address": [ {{ sql("addresses", "select * from LegalEntityAddress where OGRN=? and dateTo is not null", le.ogrn) }} {% for address in rows.addresses %} { "from": "{{address.datefrom}}", "to": "{{address.dateto}}", "address": "{{address.address}}" } {% if not loop.last %} , {% endif %} {% endfor %} ]} } {% if not loop.last %} , {% endif %} {% endfor %} ] } }