Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Ajuste tipos de dato para aprobacion #175

Merged
merged 3 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions controllers/cdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers

import (
"encoding/json"
"fmt"

"github.com/astaxie/beego"
cdphelper "github.com/udistrital/plan_cuentas_mid/helpers/cdpHelper"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (c *CdpController) SolicitarCdp() {
// @Failure 403 body is empty
// @router /aprobar_cdp [post]
func (c *CdpController) AprobarCdp() {
var v map[string]string
var v map[string]interface{}

defer func() {
if r := recover(); r != nil {
Expand All @@ -78,11 +79,26 @@ func (c *CdpController) AprobarCdp() {
}
}()

// logs.Debug("c.Ctx.Input.RequestBody: ", c.Ctx.Input.RequestBody)

if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err != nil {
responseformat.SetResponseFormat(&c.Controller, err, "E_0458", 500)
}

if response, err := cdphelper.AprobarCdp(v["_id"], v["vigencia"], v["area_funcional"]); err == nil {
// logs.Debug("v: ", v)

for i, value := range v {
switch value.(type) {
case float64:
v[i] = fmt.Sprintf("%.0f", value)
// logs.Debug("v[i]: ", v[i])
// logs.Debug("reflect.TypeOf(v[i]): ", reflect.TypeOf(v[i]))
default:
// logs.Debug("reflect.TypeOf(value)", reflect.TypeOf(value))
}
}

if response, err := cdphelper.AprobarCdp(v["_id"].(string), v["vigencia"].(string), v["area_funcional"].(string)); err == nil {
responseformat.SetResponseFormat(&c.Controller, response, "", 200)
} else {
responseformat.SetResponseFormat(&c.Controller, err, "E_0458", 500)
Expand Down