35 lines
639 B
Go
35 lines
639 B
Go
package controller
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"hepa-calc-api/api/dao"
|
|
"hepa-calc-api/api/dto"
|
|
"hepa-calc-api/api/responses"
|
|
)
|
|
|
|
type User struct{}
|
|
|
|
// GetUser 获取用户数据-基本信息
|
|
func (r *User) GetUser(c *gin.Context) {
|
|
userId := c.GetInt64("UserId")
|
|
|
|
// 获取用户数据
|
|
userDao := dao.UserDao{}
|
|
user, err := userDao.GetUserById(userId)
|
|
if err != nil || user == nil {
|
|
responses.FailWithMessage("用户数据错误", c)
|
|
c.Abort()
|
|
return
|
|
}
|
|
|
|
if user.UserStatus == 2 {
|
|
responses.FailWithMessage("用户已禁用", c)
|
|
c.Abort()
|
|
return
|
|
}
|
|
|
|
g := dto.GetUserDto(user)
|
|
|
|
responses.OkWithData(g, c)
|
|
}
|