package controllers

import (
	"encoding/json"
	"oc-discovery/models"

	beego "github.com/beego/beego/v2/server/web"
)

// Operations about Identitys
type IdentityController struct {
	beego.Controller
}

// @Title CreateIdentity
// @Description create identitys
// @Param	body		body 	models.Identity	true		"body for identity content"
// @Success 200 {int} models.Identity.Id
// @Failure 403 body is empty
// @router / [post]
func (u *IdentityController) Post() {
	var identity models.Identity
	json.Unmarshal(u.Ctx.Input.RequestBody, &identity)
	id := models.UpdateIdentity(&identity)
	u.Data["json"] = id
	u.ServeJSON()
}

// @Title Get
// @Description get Identity
// @Success 200 {object} models.Identity
// @router / [get]
func (u *IdentityController) GetAll() {
	identity := models.GetIdentity()
	u.Data["json"] = identity
	u.ServeJSON()
}
