huchanghua
2022-07-22 293b6d664512c30d2e6b2ce80487ba6fa16598c3
userApi.go
@@ -1,4 +1,4 @@
package dbapi
package bhomedbapi
import (
   "encoding/json"
@@ -9,16 +9,13 @@
}
func (api UserApi) Login(username string,password string) (bool,interface{}){
   url := DATA_URL_PREFIX + "/user/login"
   url := "/data/api-u/sys/login"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
      return false,nil
   }
   client := NewClient(WithNodes(netNode))
   paramBody :=make(map[string]interface{},0)
   paramBody["username"]=username
   paramBody["password"]=password
   respBody, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody,nil, nil)
   respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody,nil, nil)
   if err != nil {
      return false,nil
   }
@@ -30,11 +27,8 @@
}
func (api UserApi) FindAllUser(curUserId string) (bool,interface{}) {
   url := DATA_URL_PREFIX + "/user/findAllUser"
   url := "/data/api-u/users/findAllUser"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
      return false,nil
   }
   client := NewClient(WithNodes(netNode))
   query := map[string]string {
      "userId": curUserId,
@@ -52,11 +46,8 @@
}
func (api UserApi) FindById(userId string) (bool,interface{}) {
   url := DATA_URL_PREFIX + "/user/findById"
   url := "/data/api-u/users/findById"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
      return false,nil
   }
   client := NewClient(WithNodes(netNode))
   paramBody := map[string]interface{}{
      "userId": userId,
@@ -72,12 +63,27 @@
   return res.Success,res.Data
}
func (api UserApi) SaveAuth(paramBody map[string]interface{}) (bool,interface{}) {
   url := DATA_URL_PREFIX + "/user/saveAuth"
func (api UserApi) GetUserProfile(userId string) (bool,interface{}) {
   url := "/data/api-u/users/profile"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
   client := NewClient(WithNodes(netNode))
   header := map[string]string {
      "Login_user_id": userId,
   }
   respBody, err := client.DoGetRequest(url, nil, header)
   if err != nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      return false,nil
   }
   return res.Success,res.Data
}
func (api UserApi) SaveAuth(paramBody map[string]interface{}) (bool,interface{}) {
   url := "/data/api-u/users/saveAuth"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   respBody, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody,nil, nil)
   if err != nil {
@@ -91,11 +97,8 @@
}
func (api UserApi) UpdatePwd(userId string, oldPwd string, newPwd string) (bool,interface{}) {
   url := DATA_URL_PREFIX + "/user/updatePwd"
   url := "/data/api-u/users/updatePwd"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
      return false,nil
   }
   client := NewClient(WithNodes(netNode))
   paramBody := map[string]interface{}{
      "userId": userId,