|
|
@@ -4,6 +4,8 @@ import (
|
|
|
"fmt"
|
|
|
"fohow.com/apps/models/cent_model"
|
|
|
"fohow.com/apps/models/sys_config"
|
|
|
+ "io/ioutil"
|
|
|
+ "net/http"
|
|
|
"strconv"
|
|
|
|
|
|
// "strconv"
|
|
|
@@ -241,6 +243,9 @@ func (self *UserController) Get() {
|
|
|
WxUser *user_model.WxUser `json:"wx_user"`
|
|
|
MerchantUser *merchant_model.MerchantUserRelation `json:"merchant"`
|
|
|
}
|
|
|
+ if user.Employ {
|
|
|
+ go self.SetTodayCache(wxUser.Id)
|
|
|
+ }
|
|
|
|
|
|
// 商户信息, 如果不是商户,则返回 null
|
|
|
merchant_user_id := int64(0)
|
|
|
@@ -248,7 +253,7 @@ func (self *UserController) Get() {
|
|
|
merchant_user_id = user.Id
|
|
|
}
|
|
|
merchantUser := merchant_model.GetMerchantUserRelationByUserId(merchant_user_id, false) //一个商户对应多个用户
|
|
|
-
|
|
|
+ //set food cache
|
|
|
mergeUser := &Ret{User: user, WxUser: wxUser, MerchantUser: merchantUser}
|
|
|
self.Data["json"] = mergeUser
|
|
|
self.ServeJSON()
|
|
|
@@ -596,3 +601,31 @@ func (self *UserController) UpdateUserInfo() {
|
|
|
self.Data["json"] = wxUser
|
|
|
self.ServeJSON()
|
|
|
}
|
|
|
+
|
|
|
+func (self *UserController) SetTodayCache(wxUserId int64) {
|
|
|
+
|
|
|
+ // 定义 URL 和参数
|
|
|
+ baseURL := "http://127.0.0.1:8789/base/set-today-food"
|
|
|
+
|
|
|
+ // 构建带有参数的 URL
|
|
|
+ fullURL := fmt.Sprintf("%s?id=%d", baseURL, wxUserId)
|
|
|
+
|
|
|
+ // 发起 GET 请求
|
|
|
+ resp, err := http.Get(fullURL)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error making the request:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer resp.Body.Close()
|
|
|
+
|
|
|
+ // 读取响应内容
|
|
|
+ _, err = ioutil.ReadAll(resp.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error reading response body:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("Sucess:")
|
|
|
+ // 打印响应内容
|
|
|
+ //fmt.Println(string(body))
|
|
|
+}
|