package controller

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"hongze/hongze_yb/controller/response"
	"hongze/hongze_yb/models/tables/wx_user"
)

func Test(c *gin.Context) {
	wxUserInfo, err := wx_user.GetByMobile("18170239278")
	if err != nil {
		response.Fail("获取失败", c)
		return
	}
	response.OkData("获取成功", wxUserInfo, c)
}

func Test2(c *gin.Context) {
	where := make(map[string]interface{})
	where["mobile like"] = "11817023927%"
	wxUserInfo, err := wx_user.GetByWhereMap(where)
	fmt.Println(wxUserInfo)
	if err != nil {
		if err == gorm.ErrRecordNotFound {
			response.Fail("获取失败,找不到该用户", c)
		} else {
			response.Fail("获取失败,"+err.Error(), c)
		}
		return
	}
	response.OkData("获取成功", wxUserInfo, c)
}
