package controller

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"iot_manager_service/app/user/model"
	"iot_manager_service/app/user/service"
	"iot_manager_service/util/common"
	"net/http"
)

var User = new(user)

type user struct{}

func (u *user) Login(c *gin.Context) {
	loginUser := model.LoginUser{}
	if err := c.ShouldBindJSON(&loginUser); err != nil {
		c.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
		return
	}
	info := service.UserService.Login(loginUser.Account, loginUser.PassWord)
	c.JSON(http.StatusOK, info)
}

func (u *user) GetPublicKey(c *gin.Context) {
	key := service.UserService.GetPublicKey()
	c.JSON(http.StatusOK, key)
}

func (u *user) GetUser(c *gin.Context) {
	fmt.Println("demo。。。")
}
