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