|
@@ -79,7 +79,7 @@ func Login() (tokenId string, err error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -140,7 +140,7 @@ func Logout(tokenId string) (err error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -262,7 +262,7 @@ type UserData struct {
|
|
// @author: Roc
|
|
// @author: Roc
|
|
// @datetime 2024-01-18 13:30:38
|
|
// @datetime 2024-01-18 13:30:38
|
|
// @param tokenId string
|
|
// @param tokenId string
|
|
-// @return resp *BaseResponse
|
|
|
|
|
|
+// @return resp *SyncTaskUserResp
|
|
// @return err error
|
|
// @return err error
|
|
func SyncTask(tokenId string) (userResp *SyncTaskUserResp, err error) {
|
|
func SyncTask(tokenId string) (userResp *SyncTaskUserResp, err error) {
|
|
urlPath := `/IAM/XYGIntegrationService/syncTask/ProxyServices/syncTaskPS`
|
|
urlPath := `/IAM/XYGIntegrationService/syncTask/ProxyServices/syncTaskPS`
|
|
@@ -284,7 +284,7 @@ func SyncTask(tokenId string) (userResp *SyncTaskUserResp, err error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -334,7 +334,12 @@ type SyncFinishReq struct {
|
|
// @author: Roc
|
|
// @author: Roc
|
|
// @datetime 2024-01-18 13:30:38
|
|
// @datetime 2024-01-18 13:30:38
|
|
// @param tokenId string
|
|
// @param tokenId string
|
|
-// @return resp *BaseResponse
|
|
|
|
|
|
+// @param objectCode string
|
|
|
|
+// @param objectType string
|
|
|
|
+// @param id string
|
|
|
|
+// @param guid string
|
|
|
|
+// @param message string
|
|
|
|
+// @param success bool
|
|
// @return err error
|
|
// @return err error
|
|
func SyncFinish(tokenId, objectCode, objectType, id, guid, message string, success bool) (err error) {
|
|
func SyncFinish(tokenId, objectCode, objectType, id, guid, message string, success bool) (err error) {
|
|
urlPath := `/IAM/XYGIntegrationService/syncFinish/ProxyServices/syncFinishPS`
|
|
urlPath := `/IAM/XYGIntegrationService/syncFinish/ProxyServices/syncFinishPS`
|
|
@@ -364,7 +369,7 @@ func SyncFinish(tokenId, objectCode, objectType, id, guid, message string, succe
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -409,7 +414,7 @@ type PullTaskUserResp struct {
|
|
// @author: Roc
|
|
// @author: Roc
|
|
// @datetime 2024-01-16 14:04:47
|
|
// @datetime 2024-01-16 14:04:47
|
|
// @param tokenId string
|
|
// @param tokenId string
|
|
-// @return resp *BaseResponse
|
|
|
|
|
|
+// @return userResp *PullTaskUserResp
|
|
// @return err error
|
|
// @return err error
|
|
func PullTask(tokenId string) (userResp *PullTaskUserResp, err error) {
|
|
func PullTask(tokenId string) (userResp *PullTaskUserResp, err error) {
|
|
urlPath := `/IAM/XYGIntegrationService/pullTask/ProxyServices/pullTaskPS`
|
|
urlPath := `/IAM/XYGIntegrationService/pullTask/ProxyServices/pullTaskPS`
|
|
@@ -431,7 +436,7 @@ func PullTask(tokenId string) (userResp *PullTaskUserResp, err error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -479,9 +484,8 @@ type PullFinishReq struct {
|
|
// @param tokenId string
|
|
// @param tokenId string
|
|
// @param taskId string
|
|
// @param taskId string
|
|
// @param guid string
|
|
// @param guid string
|
|
-// @param success bool
|
|
|
|
// @param message string
|
|
// @param message string
|
|
-// @return resp *BaseResponse
|
|
|
|
|
|
+// @param success bool
|
|
// @return err error
|
|
// @return err error
|
|
func PullFinish(tokenId, taskId, guid, message string, success bool) (err error) {
|
|
func PullFinish(tokenId, taskId, guid, message string, success bool) (err error) {
|
|
urlPath := `/IAM/XYGIntegrationService/pullFinish/ProxyServices/pullFinishPS`
|
|
urlPath := `/IAM/XYGIntegrationService/pullFinish/ProxyServices/pullFinishPS`
|
|
@@ -507,7 +511,7 @@ func PullFinish(tokenId, taskId, guid, message string, success bool) (err error)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- result, err := HttpPost(urlPath, string(postData), "application/json")
|
|
|
|
|
|
+ result, err := HttpPost(urlPath, string(postData), map[string]string{"content-Type": "application/json"})
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -536,7 +540,7 @@ func getDocCode() string {
|
|
return fmt.Sprintf("%s-%s", time.Now().Format(utils.FormatDateTimeUnSpace), utils.GetRandStringNoSpecialChar(32))
|
|
return fmt.Sprintf("%s-%s", time.Now().Format(utils.FormatDateTimeUnSpace), utils.GetRandStringNoSpecialChar(32))
|
|
}
|
|
}
|
|
|
|
|
|
-func HttpPost(urlPath, postData string, params ...string) ([]byte, error) {
|
|
|
|
|
|
+func HttpPost(urlPath, postData string, headerMap map[string]string) ([]byte, error) {
|
|
if global.CONFIG.Xiangyu.UserSyncHost == `` {
|
|
if global.CONFIG.Xiangyu.UserSyncHost == `` {
|
|
return nil, errors.New("统一用户同步接口地址为空")
|
|
return nil, errors.New("统一用户同步接口地址为空")
|
|
}
|
|
}
|
|
@@ -550,11 +554,16 @@ func HttpPost(urlPath, postData string, params ...string) ([]byte, error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
- contentType := "application/x-www-form-urlencoded;charset=utf-8"
|
|
|
|
- if len(params) > 0 && params[0] != "" {
|
|
|
|
- contentType = params[0]
|
|
|
|
|
|
+
|
|
|
|
+ for headerKey, headerVal := range headerMap {
|
|
|
|
+ req.Header.Set(headerKey, headerVal)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果没有标记content-Type,那么就默认添加一个
|
|
|
|
+ if _, ok := headerMap["content-Type"]; !ok {
|
|
|
|
+ contentType := "application/x-www-form-urlencoded;charset=utf-8"
|
|
|
|
+ req.Header.Set("content-Type", contentType)
|
|
}
|
|
}
|
|
- req.Header.Set("content-Type", contentType)
|
|
|
|
req.SetBasicAuth(global.CONFIG.Xiangyu.UserSyncAuthUserName, global.CONFIG.Xiangyu.UserSyncAuthPwd)
|
|
req.SetBasicAuth(global.CONFIG.Xiangyu.UserSyncAuthUserName, global.CONFIG.Xiangyu.UserSyncAuthPwd)
|
|
resp, err := client.Do(req)
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
if err != nil {
|