update
This commit is contained in:
parent
b304b41ab1
commit
077bdf3a45
@ -7,7 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testfb/config"
|
"testfb/config"
|
||||||
|
"testfb/models"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/storage/redis/v3"
|
"github.com/gofiber/storage/redis/v3"
|
||||||
)
|
)
|
||||||
@ -16,7 +16,14 @@ import (
|
|||||||
func GetUserInfo(redisClient *redis.Storage) fiber.Handler {
|
func GetUserInfo(redisClient *redis.Storage) fiber.Handler {
|
||||||
return func(c *fiber.Ctx) error {
|
return func(c *fiber.Ctx) error {
|
||||||
// 获取POST 请求参数
|
// 获取POST 请求参数
|
||||||
nationalId := c.FormValue("nationalId")
|
apiUser models.APIUser
|
||||||
|
if err := c.BodyParser(&apiUser); err != nil {
|
||||||
|
return c.Status(http.StatusUnauthorized).JSON(fiber.Map{
|
||||||
|
"message": "获取信息失败,参数错误",
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
nationalId := apiUser.NationalId
|
||||||
if nationalId == "" {
|
if nationalId == "" {
|
||||||
return c.Status(http.StatusUnauthorized).JSON(fiber.Map{
|
return c.Status(http.StatusUnauthorized).JSON(fiber.Map{
|
||||||
"message": "获取信息失败,身份证不能为空",
|
"message": "获取信息失败,身份证不能为空",
|
||||||
|
|||||||
@ -18,6 +18,14 @@ type User struct {
|
|||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReqApi struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
NationalId string `json:"nationalId"`
|
||||||
|
Phtone string `json:"phone"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) BeforeCreate(tx *gorm.DB) error {
|
func (u *User) BeforeCreate(tx *gorm.DB) error {
|
||||||
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(u.Password), bcrypt.DefaultCost)
|
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(u.Password), bcrypt.DefaultCost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user