62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package service_meal
|
|
|
|
import (
|
|
"context"
|
|
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/fonchain_enterprise/fonchain-main/api/account"
|
|
meal_backend_account "github.com/fonchain_enterprise/fonchain-main/api/meal/backend/account"
|
|
appConfig "github.com/fonchain_enterprise/fonchain-main/pkg/config"
|
|
"github.com/fonchain_enterprise/fonchain-main/pkg/e"
|
|
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
|
|
"github.com/gin-gonic/gin"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func UserList(c *gin.Context) {
|
|
var pmInfoRequest meal_backend_account.UserListReq
|
|
if err := c.ShouldBind(&pmInfoRequest); err != nil {
|
|
logger.Errorf("UpdateAwProfile ShouldBind err", err)
|
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|
return
|
|
}
|
|
resp, err := service.GrpcMealAccountImpl.UserList(context.Background(), &pmInfoRequest)
|
|
if err != nil {
|
|
service.ResponseQuickMsg(c, e.Ok, err.Error(), nil)
|
|
return
|
|
}
|
|
service.ResponseQuickMsg(c, e.Ok, "", resp.Data)
|
|
}
|
|
|
|
func InfoPhone(c *gin.Context) {
|
|
body, err := ioutil.ReadAll(c.Request.Body)
|
|
if err != nil || len(body) == 0 {
|
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|
return
|
|
}
|
|
var mm map[string]interface{} = make(map[string]interface{})
|
|
_ = json.Unmarshal(body, &mm)
|
|
if mm == nil || len(mm) == 0 {
|
|
service.ResponseQuickMsg(c, e.Failed, "", nil)
|
|
return
|
|
}
|
|
if mm["phone"] == nil {
|
|
service.ResponseQuickMsg(c, e.Failed, "", nil)
|
|
return
|
|
}
|
|
req := account.UserByTelRequest{Domain: appConfig.Domain, Tel: fmt.Sprintf("%v", mm["phone"])}
|
|
fmt.Println("InfoPhonereq", &req)
|
|
resp, err := service.AccountProvider.UserByTel(context.Background(), &req)
|
|
if err != nil {
|
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|
return
|
|
}
|
|
if resp.IsExist {
|
|
service.ResponseQuickMsg(c, e.Ok, "", resp.Info)
|
|
} else {
|
|
service.ResponseQuickMsg(c, e.Failed, "", nil)
|
|
}
|
|
return
|
|
}
|