diff --git a/conf/app.conf b/conf/app.conf index 26ea4e4e..7d9a0da1 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -4,12 +4,14 @@ copyrequestbody = true EnableDocs = true httpport = ${ARKA_MID_HTTP_PORT||8080} runmode = ${RUN_MODE||prod} +nombreAplicacion = ${NOMBRE_APLICACION||arka_ii_main} actaRecibidoService = ${ACTA_RECIBIDO_CRUD} administrativaJbpmService = ${ADMINISTRATIVA_JBPM} administrativaService = ${ADMINISTRATIVA_SERVICE} autenticacionService = ${AUTENTICACION_MID_SERVICE} catalogoElementosService = ${CATALOGO_ELEMENTOS_SERVICE} +configuracionCrud = ${CONFIGURACION_CRUD} consecutivosService = ${CONSECUTIVOS_SERVICE} cuentasContablesService = ${CUENTAS_CONTABLES_SERVICE} movimientosArkaService = ${MOVIMIENTOS_ARKA_SERVICE} diff --git a/go.mod b/go.mod index af177e87..9410692b 100644 --- a/go.mod +++ b/go.mod @@ -4,17 +4,24 @@ go 1.14 require ( github.com/astaxie/beego v1.12.3 - github.com/mitchellh/mapstructure v1.4.1 github.com/smartystreets/goconvey v1.6.4 github.com/tealeg/xlsx v1.0.5 + github.com/udistrital/configuracion_api v0.0.0-20220225180608-8a66ca19fcc2 github.com/udistrital/utils_oas v0.0.0-20220415063412-5dae4bd58180 ) require ( github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/google/go-cmp v0.5.7 // indirect + github.com/lib/pq v1.10.5 // indirect github.com/prometheus/common v0.34.0 // indirect + github.com/stretchr/testify v1.7.1 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect golang.org/x/net v0.0.0-20220420153159-1850ba15e1be // indirect - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect + golang.org/x/sys v0.0.0-20220429121018-84afa8d3f7b3 // indirect + golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 2e00d2b6..b3626d1a 100644 --- a/go.sum +++ b/go.sum @@ -137,6 +137,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -184,8 +186,9 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -265,6 +268,8 @@ github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ= +github.com/lib/pq v1.10.5/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -272,6 +277,7 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -283,8 +289,6 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mndrix/golog v0.0.0-20170330170653-a28e2a269775/go.mod h1:Q4YHYl483MNk6wwg3g8YsINpKe5S2UzUJCRSRlFaSU0= github.com/mndrix/ps v0.0.0-20170330174427-18e65badd6ab/go.mod h1:dHgTaDInzkAqJv67VaX1IkK449M2UoBY68CZeI/bNCU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -333,6 +337,7 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -407,13 +412,18 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/udistrital/auditoria v0.0.0-20200115201815-9680ae9c2515/go.mod h1:2g8J932brTzbNOcSHob/vjt+/GFfMQuRreLZhvGiUro= +github.com/udistrital/configuracion_api v0.0.0-20220225180608-8a66ca19fcc2 h1:ZEG0q9mUUtDAtcz8oeqV+d56krakHOz7L0Gy7HXUnoY= +github.com/udistrital/configuracion_api v0.0.0-20220225180608-8a66ca19fcc2/go.mod h1:rJfjFZc6WbSsydWsSTdySnbKPtMwkz08o50Ix2OguRI= +github.com/udistrital/utils_oas v0.0.0-20211011160436-7fa8127363aa/go.mod h1:ctr3PgpZazF32ukxlLZP3AVjq8b2zaZ4beG4cqkx5ZA= github.com/udistrital/utils_oas v0.0.0-20220415063412-5dae4bd58180 h1:C4NRrY0b4TYIjbgANlP7gvNVEb7+LDBHcci5Lq/a9Ao= github.com/udistrital/utils_oas v0.0.0-20220415063412-5dae4bd58180/go.mod h1:jkSKIX5KYbf0/HxzGUs2leHo3KAwTC5n0oI1JDfoY78= github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= @@ -589,8 +599,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220429121018-84afa8d3f7b3 h1:kBsBifDikLCf5sUMbcD8p73OinDtAQWQp8+n7FiyzlA= +golang.org/x/sys v0.0.0-20220429121018-84afa8d3f7b3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -654,8 +664,9 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -745,8 +756,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -768,8 +780,9 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/helpers/configuracion/StructsParametros.go b/helpers/configuracion/StructsParametros.go new file mode 100644 index 00000000..9dc211b3 --- /dev/null +++ b/helpers/configuracion/StructsParametros.go @@ -0,0 +1,43 @@ +// Documentar en este archivo las estructuras de datos +// a almacenar en registros de configuracion_crud.parametro + +package configuracion + +// RolesArka es la estructura de los datos a almacenar en el +// campo Valor de un regitro de configuracion_api.parametro, +// cuyo nombre es el de la constante NombreParametroRoles. +// +// El objetivo es guardar los id de registros de +// configuracion_api.perfil asociados a cada rol necesario +// desde el modelo de negocios de Arka II +// +// Adicionalmente, esto es para permitir que los roles se puedan +// renombrar directamente desde el cliente de configuración +// sin afectar el funcionamiento del sistema +type RolesArka struct { + Administrador uint + Secretaria uint + AuxiliarUno uint + AuxiliarDos uint + Proveedor uint + Contabilidad uint +} + +// TiposContablesArka es la estructura a guardar en el campo +// Valor de un registro en configuracion_api.parametro cuyo +// Nombre es el de la constante NombreParametroTiposDeComprobante. +// +// Su objetivo es guardar los id de los comprobantes contables +// de cuentas_contables_crud.comprobante a ser especificados +// en el campo de etiquetas de cada transaccion contable +// enviada a movimientos_contables_mid +type TiposContablesArka struct { + Entrada string // P8 + Salida string // H21 + Traslado string // N39 (ajuste) + Baja string // H23 + Amortizacion string // H22 (cierre) + Depreciacion string // H22 (cierre) + Ajuste string // N39 + Avaluo string // N40 +} diff --git a/helpers/configuracion/configuracion.go b/helpers/configuracion/configuracion.go new file mode 100644 index 00000000..030d2d49 --- /dev/null +++ b/helpers/configuracion/configuracion.go @@ -0,0 +1,16 @@ +package configuracion + +const ( + NombreParametroRoles = "RolesRegistrados" + NombreParametroTiposDeComprobante = "ComprobantesKronos" +) + +var ( + roles RolesArka + comprobantes TiposContablesArka +) + +func init() { + ActualizaRolesArka() + ActualizaTiposDeComprobante() +} diff --git a/helpers/configuracion/lectura.go b/helpers/configuracion/lectura.go new file mode 100644 index 00000000..2754046c --- /dev/null +++ b/helpers/configuracion/lectura.go @@ -0,0 +1,66 @@ +package configuracion + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/astaxie/beego" + "github.com/astaxie/beego/logs" + + "github.com/udistrital/arka_mid/helpers/crud/configuracion" + "github.com/udistrital/arka_mid/helpers/utilsHelper" + modelsConfiguracion "github.com/udistrital/configuracion_api/models" + e "github.com/udistrital/utils_oas/errorctrl" +) + +// ActualizaRolesArka se puede llamar periodicamente. Un candidato podría ser +// el healthcheck +func ActualizaRolesArka() { + const funcion = "ActualizaRolesArka - " + defer e.ErrorControlFunction(funcion+"unhandled error", fmt.Sprint(http.StatusInternalServerError)) + + // parametro de roles registrados + getParametroArka(NombreParametroRoles, &roles) +} + +// ActualizaTiposDeComprobante carga los tipos de comprobante +func ActualizaTiposDeComprobante() { + const funcion = "ActualizaTiposDeComprobante - " + defer e.ErrorControlFunction(funcion+"unhandled error!", fmt.Sprint(http.StatusInternalServerError)) + + getParametroArka(NombreParametroTiposDeComprobante, &comprobantes) +} + +func getParametroArka(parametro string, out interface{}) { + const funcion = "parametroArka - " + defer e.ErrorControlFunction(funcion+"unhandled error!", fmt.Sprint(http.StatusInternalServerError)) + + var parametros []modelsConfiguracion.Parametro + query := utilsHelper.Query{ + Query: map[string]string{ + "Aplicacion__Nombre": beego.AppConfig.String("nombreAplicacion"), + "Nombre": parametro, + }, + Fields: []string{"Nombre", "Valor"}, + Limit: -1, + } + if err := configuracion.GetParametros(query, ¶metros); err != nil { + logs.Critical(err) + panic(err) + } + if len(parametros) != 1 { + cond := "" + if len(parametros) >= 10 { + cond = " (o más)" + } + err := fmt.Errorf("se esperaba encontrar un solo registro con Nombre:%s en configuracion_crud/parametros, hay: %d%s", + parametro, len(parametros), cond) + logs.Critical(err) + panic(err) + } + if err := json.Unmarshal([]byte(parametros[0].Valor), &out); err != nil { + logs.Critical(err) + panic(err) + } +} diff --git a/helpers/crud/configuracion/parametro.go b/helpers/crud/configuracion/parametro.go new file mode 100644 index 00000000..9464373d --- /dev/null +++ b/helpers/crud/configuracion/parametro.go @@ -0,0 +1,39 @@ +package configuracion + +import ( + "fmt" + "net/http" + + "github.com/astaxie/beego" + // "github.com/astaxie/beego/logs" + + "github.com/udistrital/arka_mid/helpers/utilsHelper" + modelsConfiguracion "github.com/udistrital/configuracion_api/models" + e "github.com/udistrital/utils_oas/errorctrl" + "github.com/udistrital/utils_oas/formatdata" + "github.com/udistrital/utils_oas/request" +) + +func GetParametros(query utilsHelper.Query, parametros *[]modelsConfiguracion.Parametro) (outputError map[string]interface{}) { + const funcion = "GetParametros - " + defer e.ErrorControlFunction(funcion+"unhandled error!", fmt.Sprint(http.StatusInternalServerError)) + + qString := query.Encode() + urlParametros := "http://" + beego.AppConfig.String("configuracionCrud") + "parametro?" + qString + // logs.Debug(urlParametros) + var respuestaApi interface{} + if resp, err := request.GetJsonTest(urlParametros, &respuestaApi); err != nil || resp.StatusCode != http.StatusOK { + const contexto = "request.GetJsonTest(urlParametros, &respuestaApi)" + if err == nil { + err = fmt.Errorf("undesired status code: %d", resp.StatusCode) + } + outputError = e.Error(funcion+contexto, err, fmt.Sprint(http.StatusBadGateway)) + return + } + // formatdata.JsonPrint(respuestaApi) + if err := formatdata.FillStruct(respuestaApi, ¶metros); err != nil { + const contexto = "formatdata.FillStruct(respuestaApi, ¶metros)" + outputError = e.Error(funcion+contexto, err, fmt.Sprint(http.StatusInternalServerError)) + } + return +} diff --git a/helpers/utilsHelper/bee.go b/helpers/utilsHelper/bee.go new file mode 100644 index 00000000..5e2644d5 --- /dev/null +++ b/helpers/utilsHelper/bee.go @@ -0,0 +1,89 @@ +package utilsHelper + +import ( + "fmt" + "net/url" + "strings" +) + +func EncodeUrl(query string, fields string, sortby string, order string, offset string, limit string) string { + params := url.Values{} + + if len(query) > 0 { + params.Add("query", query) + } + + if len(fields) > 0 { + params.Add("fields", fields) + } + + if len(sortby) > 0 { + params.Add("sortby", sortby) + + } + + if len(order) > 0 { + params.Add("order", order) + + } + + if len(offset) > 0 { + params.Add("offset", offset) + + } + + if len(limit) > 0 { + params.Add("limit", limit) + + } + + return params.Encode() +} + +type Sorting struct { + By string + Asc bool +} + +func (c *Sorting) OrderStr() string { + if c.Asc { + return "asc" + } + return "desc" +} + +type Query struct { + Query map[string]string + Limit int `default:"10"` + Offset int `default:"0"` + Fields []string + Sort []Sorting +} + +func (opts *Query) Encode() string { + + sortby := make([]string, 0) + order := make([]string, 0) + for _, v := range opts.Sort { + sortby = append(sortby, v.By) + order = append(order, v.OrderStr()) + } + + joinedQuery := "" + periods := len(opts.Query) + for k, v := range opts.Query { + joinedQuery += k + ":" + v + if periods > 1 { + joinedQuery += "," + periods-- + } + } + + return EncodeUrl(joinedQuery, + strings.Join(opts.Fields, ","), + strings.Join(sortby, ","), + strings.Join(order, ","), + fmt.Sprint(opts.Offset), + fmt.Sprint(opts.Limit), + ) +} diff --git a/helpers/utilsHelper/utils.go b/helpers/utilsHelper/utilidades.go similarity index 90% rename from helpers/utilsHelper/utils.go rename to helpers/utilsHelper/utilidades.go index eecbe052..56f97e11 100644 --- a/helpers/utilsHelper/utils.go +++ b/helpers/utilsHelper/utilidades.go @@ -3,7 +3,6 @@ package utilsHelper import ( "encoding/json" "fmt" - "net/url" "strings" "github.com/astaxie/beego/logs" @@ -188,37 +187,3 @@ func RemoveDuplicateIds(addrs []int) []int { } return result } - -func EncodeUrl(query string, fields string, sortby string, order string, offset string, limit string) string { - params := url.Values{} - - if len(query) > 0 { - params.Add("query", query) - } - - if len(fields) > 0 { - params.Add("fields", fields) - } - - if len(sortby) > 0 { - params.Add("sortby", sortby) - - } - - if len(order) > 0 { - params.Add("order", order) - - } - - if len(offset) > 0 { - params.Add("offset", offset) - - } - - if len(limit) > 0 { - params.Add("limit", limit) - - } - - return params.Encode() -} diff --git a/main.go b/main.go index cb46a77d..5051c77a 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "github.com/astaxie/beego" "github.com/astaxie/beego/plugins/cors" + _ "github.com/udistrital/arka_mid/helpers/configuracion" _ "github.com/udistrital/arka_mid/routers" apistatus "github.com/udistrital/utils_oas/apiStatusLib" "github.com/udistrital/utils_oas/auditoria" @@ -30,7 +31,7 @@ func main() { AllowCredentials: true, })) beego.ErrorController(&customerrorv2.CustomErrorController{}) - apistatus.Init() + apistatus.InitWithHandler(statusCheck) auditoria.InitMiddleware() beego.Run() } diff --git a/statusCheck.go b/statusCheck.go new file mode 100644 index 00000000..2ffdc2c0 --- /dev/null +++ b/statusCheck.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "net/http" + + "github.com/udistrital/arka_mid/helpers/configuracion" + e "github.com/udistrital/utils_oas/errorctrl" +) + +func statusCheck() interface{} { + const funcion = "statusCheck - " + defer e.ErrorControlFunction(funcion+"unhandled error!", fmt.Sprint(http.StatusInternalServerError)) + + configuracion.ActualizaRolesArka() + configuracion.ActualizaTiposDeComprobante() + return nil +}