fix: 注释crontask无用任务函数
This commit is contained in:
@@ -250,139 +250,139 @@ func (t *TaskFunc) TaskCronUserLoginOMC(uri, params, body string) {
|
||||
func (t *TaskFunc) TaskDeleteExpiredRecord(uri, params, body string) {
|
||||
log.Debug("TaskDeleteExpiredRecord processing... ")
|
||||
|
||||
var response *resty.Response
|
||||
requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
log.Debug("requestURL: DELETE ", requestURL)
|
||||
client := resty.New()
|
||||
response, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
Delete(requestURL)
|
||||
if err != nil {
|
||||
log.Error("Failed to delete:", err)
|
||||
}
|
||||
// var response *resty.Response
|
||||
// requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
// requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
// log.Debug("requestURL: DELETE ", requestURL)
|
||||
// client := resty.New()
|
||||
// response, err := client.R().
|
||||
// EnableTrace().
|
||||
// SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
// Delete(requestURL)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to delete:", err)
|
||||
// }
|
||||
|
||||
log.Debug("StatusCode: ", response.StatusCode())
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
default:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
}
|
||||
// log.Debug("StatusCode: ", response.StatusCode())
|
||||
// switch response.StatusCode() {
|
||||
// case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// default:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// }
|
||||
}
|
||||
|
||||
func (t *TaskFunc) TaskUpdateTable(uri, params, body string) {
|
||||
log.Debug("TaskUpdateTable processing... ")
|
||||
|
||||
var response *resty.Response
|
||||
requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
// reqBody, err := json.Marshal(body)
|
||||
// var response *resty.Response
|
||||
// requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
// requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
// // reqBody, err := json.Marshal(body)
|
||||
// // if err != nil {
|
||||
// // log.Error("Failed to Marshal:", err)
|
||||
// // }
|
||||
// log.Debug("requestURL: Put ", requestURL)
|
||||
// log.Trace("body:", body)
|
||||
// client := resty.New()
|
||||
// response, err := client.R().
|
||||
// EnableTrace().
|
||||
// SetHeaders(map[string]string{"accessToken": t.Token}).
|
||||
// SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
// SetBody(body).
|
||||
// Put(requestURL)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to Marshal:", err)
|
||||
// log.Error("Failed to put:", err)
|
||||
// }
|
||||
log.Debug("requestURL: Put ", requestURL)
|
||||
log.Trace("body:", body)
|
||||
client := resty.New()
|
||||
response, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"accessToken": t.Token}).
|
||||
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
SetBody(body).
|
||||
Put(requestURL)
|
||||
if err != nil {
|
||||
log.Error("Failed to put:", err)
|
||||
}
|
||||
|
||||
log.Debug("StatusCode: ", response.StatusCode())
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
default:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
}
|
||||
// log.Debug("StatusCode: ", response.StatusCode())
|
||||
// switch response.StatusCode() {
|
||||
// case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// default:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// }
|
||||
}
|
||||
|
||||
func (t *TaskFunc) TaskRemoveExpiredFile(uri, params, body string) {
|
||||
log.Debug("TaskRemoveExpiredFile processing... ")
|
||||
|
||||
var response *resty.Response
|
||||
loginUri := "/login"
|
||||
loginBody := "{\"username\": \"cronuser\",\"password\": \"tcu@1000OMC!\",\"code\": \"\", \"uuid\": \"\"}"
|
||||
t.TaskCronUserLoginOMC(loginUri, "", loginBody)
|
||||
loginURI := fmt.Sprintf("%s?%s", loginUri, "")
|
||||
loginURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, loginURI)
|
||||
log.Debug("requestURL: Post ", loginURL)
|
||||
client := resty.New()
|
||||
loginResponse, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
SetBody(loginBody).
|
||||
Post(loginURL)
|
||||
if err != nil {
|
||||
log.Error("Failed to post:", err)
|
||||
return
|
||||
}
|
||||
// var response *resty.Response
|
||||
// loginUri := "/login"
|
||||
// loginBody := "{\"username\": \"cronuser\",\"password\": \"tcu@1000OMC!\",\"code\": \"\", \"uuid\": \"\"}"
|
||||
// t.TaskCronUserLoginOMC(loginUri, "", loginBody)
|
||||
// loginURI := fmt.Sprintf("%s?%s", loginUri, "")
|
||||
// loginURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, loginURI)
|
||||
// log.Debug("requestURL: Post ", loginURL)
|
||||
// client := resty.New()
|
||||
// loginResponse, err := client.R().
|
||||
// EnableTrace().
|
||||
// SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
// SetBody(loginBody).
|
||||
// Post(loginURL)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to post:", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
var accessToken string
|
||||
log.Debug("StatusCode: ", loginResponse.StatusCode())
|
||||
switch loginResponse.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
log.Debug("response body:", string(loginResponse.Body()))
|
||||
var loginResp LoginRespone
|
||||
err = json.Unmarshal(loginResponse.Body(), &loginResp)
|
||||
if err != nil {
|
||||
log.Error("Failed to unmarshal:", err)
|
||||
return
|
||||
}
|
||||
if loginResp.Code == 1 {
|
||||
accessToken = loginResp.Data.AccessToken
|
||||
} else {
|
||||
log.Error("Failed to login: %s", loginResp.Msg)
|
||||
return
|
||||
}
|
||||
default:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
return
|
||||
}
|
||||
// var accessToken string
|
||||
// log.Debug("StatusCode: ", loginResponse.StatusCode())
|
||||
// switch loginResponse.StatusCode() {
|
||||
// case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
// log.Debug("response body:", string(loginResponse.Body()))
|
||||
// var loginResp LoginRespone
|
||||
// err = json.Unmarshal(loginResponse.Body(), &loginResp)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to unmarshal:", err)
|
||||
// return
|
||||
// }
|
||||
// if loginResp.Code == 1 {
|
||||
// accessToken = loginResp.Data.AccessToken
|
||||
// } else {
|
||||
// log.Error("Failed to login: %s", loginResp.Msg)
|
||||
// return
|
||||
// }
|
||||
// default:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// return
|
||||
// }
|
||||
|
||||
requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
log.Debug("requestURL: DELETE ", requestURL)
|
||||
response, err = client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"Authorization": "Bearer " + accessToken}).
|
||||
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
Delete(requestURL)
|
||||
if err != nil {
|
||||
log.Error("Failed to delete:", err)
|
||||
return
|
||||
}
|
||||
// requestURI := fmt.Sprintf("%s?%s", uri, params)
|
||||
// requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
// log.Debug("requestURL: DELETE ", requestURL)
|
||||
// response, err = client.R().
|
||||
// EnableTrace().
|
||||
// SetHeaders(map[string]string{"Authorization": "Bearer " + accessToken}).
|
||||
// SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
// Delete(requestURL)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to delete:", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
log.Debug("StatusCode: ", response.StatusCode())
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
default:
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
}
|
||||
// log.Debug("StatusCode: ", response.StatusCode())
|
||||
// switch response.StatusCode() {
|
||||
// case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// default:
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// }
|
||||
}
|
||||
|
||||
func (t *TaskFunc) GetTableNameFromUri(uri string) string {
|
||||
@@ -397,39 +397,39 @@ func (t *TaskFunc) GetTableNameFromUri(uri string) string {
|
||||
func (t *TaskFunc) TaskDBBackupCSVGetBySQL(uri, params, body string) {
|
||||
log.Debug("TaskDBBackupCSVGetBySQL processing... ")
|
||||
|
||||
var response *resty.Response
|
||||
tableName := t.GetTableNameFromUri(uri)
|
||||
filePath := fmt.Sprintf("/tmp/%s-%s.csv", tableName, time.Now().Local().Format(global.DateData))
|
||||
pa := fmt.Sprintf(params, filePath)
|
||||
requestURI := fmt.Sprintf("%s?%s", uri, pa)
|
||||
requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
log.Debug("requestURL: Get ", requestURL)
|
||||
client := resty.New()
|
||||
response, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
Get(requestURL)
|
||||
if err != nil {
|
||||
log.Error("Failed to Get:", err)
|
||||
}
|
||||
// var response *resty.Response
|
||||
// tableName := t.GetTableNameFromUri(uri)
|
||||
// filePath := fmt.Sprintf("/tmp/%s-%s.csv", tableName, time.Now().Local().Format(global.DateData))
|
||||
// pa := fmt.Sprintf(params, filePath)
|
||||
// requestURI := fmt.Sprintf("%s?%s", uri, pa)
|
||||
// requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
|
||||
// log.Debug("requestURL: Get ", requestURL)
|
||||
// client := resty.New()
|
||||
// response, err := client.R().
|
||||
// EnableTrace().
|
||||
// SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
|
||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
// Get(requestURL)
|
||||
// if err != nil {
|
||||
// log.Error("Failed to Get:", err)
|
||||
// }
|
||||
|
||||
log.Debug("StatusCode: ", response.StatusCode())
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
cmd := exec.Command("cp", "-rf", filePath, GetYamlConfig().Database.Backup)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Errorf("Faile to exec:", err)
|
||||
return
|
||||
}
|
||||
log.Debug("response body:", string(response.Body()))
|
||||
body := new(map[string]interface{})
|
||||
_ = json.Unmarshal(response.Body(), &body)
|
||||
default:
|
||||
log.Error("response body:", string(response.Body()))
|
||||
}
|
||||
// log.Debug("StatusCode: ", response.StatusCode())
|
||||
// switch response.StatusCode() {
|
||||
// case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
// cmd := exec.Command("cp", "-rf", filePath, GetYamlConfig().Database.Backup)
|
||||
// out, err := cmd.CombinedOutput()
|
||||
// log.Tracef("Exec output: %v", string(out))
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to exec:", err)
|
||||
// return
|
||||
// }
|
||||
// log.Debug("response body:", string(response.Body()))
|
||||
// body := new(map[string]interface{})
|
||||
// _ = json.Unmarshal(response.Body(), &body)
|
||||
// default:
|
||||
// log.Error("response body:", string(response.Body()))
|
||||
// }
|
||||
}
|
||||
|
||||
func (t *TaskFunc) TaskRunShellCommand(uri, params, body string) {
|
||||
|
||||
Reference in New Issue
Block a user